Decompiled source of Horrible Company TEST v1.6.5

BeplnEx/plugins/AdvancedCompany.dll

Decompiled 2 years ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using AdvancedCompany.Boot;
using AdvancedCompany.Config;
using AdvancedCompany.Game;
using AdvancedCompany.IL;
using AdvancedCompany.Network;
using AdvancedCompany.Network.Messages;
using AdvancedCompany.Objects;
using AdvancedCompany.Objects.Interfaces;
using AdvancedCompany.Patches;
using AdvancedCompany.PostProcessing;
using AdvancedCompany.Terminal;
using AdvancedCompany.Terminal.Applications;
using AdvancedCompany.UI;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Coroner;
using Dissonance;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Steamworks;
using Steamworks.Data;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Audio;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AdvancedCompany
{
	public class AnimationClipOverrides : List<KeyValuePair<AnimationClip, AnimationClip>>
	{
		public AnimationClip this[string name]
		{
			get
			{
				return Find((KeyValuePair<AnimationClip, AnimationClip> x) => ((Object)x.Key).name.Equals(name)).Value;
			}
			set
			{
				int num = FindIndex((KeyValuePair<AnimationClip, AnimationClip> x) => ((Object)x.Key).name.Equals(name));
				if (num != -1)
				{
					base[num] = new KeyValuePair<AnimationClip, AnimationClip>(base[num].Key, value);
				}
			}
		}

		public AnimationClipOverrides(int capacity)
			: base(capacity)
		{
		}
	}
	[Bootable]
	public class Assets
	{
		public static AssetBundle AssetBundle;

		public static void Boot()
		{
			string text = Path.Combine(Path.GetDirectoryName(typeof(Assets).Assembly.Location), "advancedcompany/advancedcompanyassets");
			AssetBundle = AssetBundle.LoadFromFile(text);
			BootManager.AddTypeCallback(delegate(Type type)
			{
				if (type.GetCustomAttribute<LoadAssets>() != null)
				{
					MethodInfo method = type.GetMethod("LoadAssets", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
					if (method != null)
					{
						ParameterInfo[] parameters = method.GetParameters();
						if (parameters.Length == 1 && parameters[0].ParameterType == typeof(AssetBundle))
						{
							method.Invoke(null, new object[1] { AssetBundle });
						}
						else
						{
							Plugin.Log.LogError((object)("Method " + method.DeclaringType.FullName + "->" + method.Name + " has wrong parameters."));
						}
					}
					else
					{
						Plugin.Log.LogError((object)("Type " + type.FullName + " is missing static LoadAssets method."));
					}
				}
			});
		}
	}
	public static class GameAssets
	{
		public static Dictionary<string, Item> Scrap = new Dictionary<string, Item>();

		public static Dictionary<string, AudioClip> Audio = new Dictionary<string, AudioClip>();
	}
	[Bootable]
	public class HDRPChanges
	{
		public static void Boot()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			Plugin.Log.LogInfo((object)"Patching HDRP...");
			try
			{
				RenderPipelineAsset currentRenderPipeline = GraphicsSettings.currentRenderPipeline;
				HDRenderPipelineAsset val = (HDRenderPipelineAsset)(object)((currentRenderPipeline is HDRenderPipelineAsset) ? currentRenderPipeline : null);
				RenderPipelineSettings currentPlatformRenderPipelineSettings = val.currentPlatformRenderPipelineSettings;
				Type type = typeof(HDRenderPipelineAsset).Assembly.GetType("UnityEngine.Rendering.HighDefinition.HDRenderPipelineGlobalSettings");
				PropertyInfo property = type.GetProperty("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
				object value = property.GetValue(null);
				FieldInfo field = type.GetField("afterPostProcessCustomPostProcesses", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
				List<string> list = (List<string>)field.GetValue(value);
				list.Add(typeof(AdvancedCompany.PostProcessing.NightVision).AssemblyQualifiedName);
				currentPlatformRenderPipelineSettings.lightLoopSettings.cookieAtlasSize = (CookieAtlasResolution)2048;
				Plugin.Log.LogInfo((object)"Patched HDRP!");
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)"Error while patching HDRP!");
				Plugin.Log.LogError((object)ex);
			}
		}
	}
	public class LoadAssets : Attribute
	{
	}
	[Requires(typeof(ServerConfiguration))]
	[Bootable]
	public class Perks : NetworkBehaviour
	{
		internal static Perk SprintSpeedPerk;

		internal static Perk JumpHeightPerk;

		internal static Perk JumpStaminaPerk;

		internal static Perk SprintStaminaPerk;

		internal static Perk FallDamagePerk;

		internal static Perk DamagePerk;

		internal static Perk WeightPerk;

		internal static Perk InventorySlotsPerk;

		internal static Perk DealDamagePerk;

		internal static Perk ClimbingSpeedPerk;

		internal static Perk ScanDistancePerk;

		internal static Perk ExtraBatteryPerk;

		internal static Perk ExtendDeadlineDiscountPerk;

		internal static Perk LandingSpeedPerk;

		internal static Perk DeliverySpeedPerk;

		internal static Perk SaveLootPerk;

		internal static Perk TravelDiscountPerk;

		public static int ExtendDeadlinePrice
		{
			get
			{
				if ((Object)(object)TimeOfDay.Instance != (Object)null)
				{
					return (int)((float)TimeOfDay.Instance.profitQuota * GetMultiplier(ExtendDeadlineDiscountPerk));
				}
				return 0;
			}
		}

		public static void Boot()
		{
			SprintSpeedPerk = new Perk(Perk.Type.PLAYER, "SprintSpeed", "Sprint speed", "Increases your sprint speed by [change]% per level.", ServerConfiguration.Instance.PlayerPerks.SprintSpeed, (float baseValue, float change, int level) => baseValue + (float)level * change);
			JumpHeightPerk = new Perk(Perk.Type.PLAYER, "JumpHeight", "Jump height", "Increases your jump height by [change]% per level.", ServerConfiguration.Instance.PlayerPerks.JumpHeight, (float baseValue, float change, int level) => baseValue + (float)level * change);
			JumpStaminaPerk = new Perk(Perk.Type.PLAYER, "JumpStamina", "Jump endurance", "Reduces stamina usage of jumping by [change]% per level.", ServerConfiguration.Instance.PlayerPerks.JumpStamina, (float baseValue, float change, int level) => baseValue + (float)level * change);
			SprintStaminaPerk = new Perk(Perk.Type.PLAYER, "SprintStamina", "Sprint endurance", "Reduces stamina usage of sprinting by [change]% per level.", ServerConfiguration.Instance.PlayerPerks.SprintStamina, (float baseValue, float change, int level) => baseValue + (float)level * change);
			FallDamagePerk = new Perk(Perk.Type.PLAYER, "FallDamage", "Reinforced legs", "Increases the depth you can fall without damage by [change]% per level.", ServerConfiguration.Instance.PlayerPerks.FallDamage, (float baseValue, float change, int level) => baseValue + (float)level * change);
			DamagePerk = new Perk(Perk.Type.PLAYER, "Damage", "Protective skin", "Reduces damage from enemies by [change]% per level.", ServerConfiguration.Instance.PlayerPerks.Damage, (float baseValue, float change, int level) => baseValue - (float)level * change);
			WeightPerk = new Perk(Perk.Type.PLAYER, "Weight", "Weight reducer", "Reduces strain of weight by [change]% per level.", ServerConfiguration.Instance.PlayerPerks.Weight, (float baseValue, float change, int level) => baseValue - (float)level * change);
			InventorySlotsPerk = new Perk(Perk.Type.PLAYER, "InventorySlots", "Carry bags", "Increases inventory size by 1 per level.", ServerConfiguration.Instance.PlayerPerks.InventorySlots, (float baseValue, float change, int level) => baseValue + (float)level);
			DealDamagePerk = new Perk(Perk.Type.PLAYER, "DealDamage", "Strong arms", "Increases the chance for a critical strike by [change]%. Critical strikes will kill enemies with one hit.", ServerConfiguration.Instance.PlayerPerks.DealDamage, (float baseValue, float change, int level) => baseValue + (float)level * change);
			ClimbingSpeedPerk = new Perk(Perk.Type.PLAYER, "ClimbingSpeed", "Climbing speed", "Increases climbing speed by [change]% per level.", ServerConfiguration.Instance.PlayerPerks.ClimbingSpeed, (float baseValue, float change, int level) => baseValue + (float)level * change);
			ScanDistancePerk = new Perk(Perk.Type.SHIP, "ScanDistance", "Scanner distance", "Increases the distance of the scanner by [change]% per level.", ServerConfiguration.Instance.ShipPerks.ScanDistance, (float baseValue, float change, int level) => baseValue + (float)level * change);
			ExtraBatteryPerk = new Perk(Perk.Type.SHIP, "ExtraBattery", "Batterypack", "Increases battery capacity of items by [change]% per level.", ServerConfiguration.Instance.ShipPerks.ExtraBattery, (float baseValue, float change, int level) => baseValue + (float)level * change);
			ExtendDeadlineDiscountPerk = new Perk(Perk.Type.SHIP, "ExtendDeadlineDiscount", "Deadline discount", "Decreases the cost to extend the deadline by [change]% per level.", ServerConfiguration.Instance.ShipPerks.ExtendDeadlineDiscount, (float baseValue, float change, int level) => baseValue - (float)level * change);
			LandingSpeedPerk = new Perk(Perk.Type.SHIP, "LandingSpeed", "Landing speed", "Reduces the time to land and lift off by [change]% per level.", ServerConfiguration.Instance.ShipPerks.LandingSpeed, (float baseValue, float change, int level) => baseValue - (float)level * change);
			DeliverySpeedPerk = new Perk(Perk.Type.SHIP, "DeliverySpeed", "Express delivery", "Reduces the time for deliveries to arrive by [change]% per level.", ServerConfiguration.Instance.ShipPerks.DeliverySpeed, (float baseValue, float change, int level) => baseValue - (float)level * change);
			SaveLootPerk = new Perk(Perk.Type.SHIP, "SaveLoot", "Loot saver", "Increases the amount of saved loot by [change]% per level.", ServerConfiguration.Instance.ShipPerks.SaveLoot, (float baseValue, float change, int level) => baseValue + (float)level * change);
			TravelDiscountPerk = new Perk(Perk.Type.SHIP, "TravelDiscount", "Travel discount", "Decreases the price to travel to moons by [change]% per level.", ServerConfiguration.Instance.ShipPerks.TravelDiscount, (float baseValue, float change, int level) => baseValue - (float)level * change);
			AdvancedCompany.Network.Manager.AddListener<AdvancedCompany.Network.Messages.ExtendDeadline>(delegate
			{
				ExtendDeadline();
			});
			AdvancedCompany.Network.Manager.AddListener(delegate(ChangePerk message)
			{
				Perk perk = Perk.Perks[message.ID];
				Plugin.Log.LogMessage((object)("Received " + message.ID + ": " + message.Level));
				if (perk.PerkType == Perk.Type.PLAYER)
				{
					Player player3 = AdvancedCompany.Network.Manager.Lobby.Player(message.ClientID);
					player3.SetLevel(perk, message.Level);
					if (message.ClientID == GameNetworkManager.Instance.localPlayerController.playerClientId)
					{
						player3.SaveLocal();
					}
					if (!ServerConfiguration.Instance.General.SaveProgress && NetworkManager.Singleton.IsServer)
					{
						player3.SaveServer(GameNetworkManager.Instance.currentSaveFileName);
					}
				}
				else if (perk.PerkType == Perk.Type.SHIP)
				{
					Ship currentShip2 = AdvancedCompany.Network.Manager.Lobby.CurrentShip;
					Plugin.Log.LogMessage((object)"Ship");
					currentShip2.SetLevel(perk, message.Level);
					if (NetworkManager.Singleton.IsServer)
					{
						currentShip2.Save(GameNetworkManager.Instance.currentSaveFileName);
					}
				}
			});
			AdvancedCompany.Network.Manager.AddListener(delegate(Respec message)
			{
				if (message.Type == Perk.Type.PLAYER)
				{
					Player player2 = AdvancedCompany.Network.Manager.Lobby.Player(message.ClientID);
					player2.Reset(message.Reset);
					if (message.ClientID == GameNetworkManager.Instance.localPlayerController.playerClientId)
					{
						player2.SaveLocal();
					}
					if (!ServerConfiguration.Instance.General.SaveProgress && NetworkManager.Singleton.IsServer)
					{
						player2.SaveServer(GameNetworkManager.Instance.currentSaveFileName);
					}
				}
				else if (message.Type == Perk.Type.SHIP)
				{
					Ship currentShip = AdvancedCompany.Network.Manager.Lobby.CurrentShip;
					currentShip.Reset(message.Reset);
					if (NetworkManager.Singleton.IsServer)
					{
						currentShip.Save(GameNetworkManager.Instance.currentSaveFileName);
					}
				}
			});
			AdvancedCompany.Network.Manager.AddListener(delegate(GrantPlayerXP message)
			{
				if (message.All)
				{
					foreach (KeyValuePair<ulong, Player> connectedPlayer in AdvancedCompany.Network.Manager.Lobby.ConnectedPlayers)
					{
						connectedPlayer.Value.XP += message.XP;
						if (!ServerConfiguration.Instance.General.SaveProgress && NetworkManager.Singleton.IsServer)
						{
							connectedPlayer.Value.SaveServer(GameNetworkManager.Instance.currentSaveFileName);
						}
					}
				}
				else
				{
					Player player = AdvancedCompany.Network.Manager.Lobby.Player(message.ClientID);
					player.XP += message.XP;
					if (!ServerConfiguration.Instance.General.SaveProgress && NetworkManager.Singleton.IsServer)
					{
						player.SaveServer(GameNetworkManager.Instance.currentSaveFileName);
					}
				}
				if (message.All || message.ClientID == GameNetworkManager.Instance.localPlayerController.playerClientId)
				{
					AdvancedCompany.Network.Manager.Lobby.Player().SaveLocal();
				}
			});
			AdvancedCompany.Network.Manager.AddListener(delegate(GrantShipXP message)
			{
				Plugin.Log.LogMessage((object)("GrantShipXP Listener. " + message.XP));
				AdvancedCompany.Network.Manager.Lobby.CurrentShip.XP += message.XP;
				if (NetworkManager.Singleton.IsServer)
				{
					AdvancedCompany.Network.Manager.Lobby.CurrentShip.Save(GameNetworkManager.Instance.currentSaveFileName);
				}
			});
			AdvancedCompany.Network.Manager.AddListener(delegate(ChangeShip message)
			{
				AdvancedCompany.Network.Manager.Lobby.CurrentShip.TotalQuota = message.TotalQuota;
				AdvancedCompany.Network.Manager.Lobby.CurrentShip.ExtendedDeadline = message.ExtendedDeadline;
				if (NetworkManager.Singleton.IsServer)
				{
					AdvancedCompany.Network.Manager.Lobby.CurrentShip.Save(GameNetworkManager.Instance.currentSaveFileName);
				}
			});
		}

		public static void GameStarted()
		{
			AdvancedCompany.Patches.Terminal.UpdateMoonPrices();
			InventoryPatches.ArrangeHotbar(InventorySlotsOf(GameNetworkManager.Instance.localPlayerController));
		}

		public static void OnClientExtendDeadline(ulong clientId, FastBufferReader reader)
		{
			ExtendDeadline();
		}

		public static void OnDeadlineSync(ulong clientId, FastBufferReader reader)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			float timeUntilDeadline = default(float);
			((FastBufferReader)(ref reader)).ReadValue<float>(ref timeUntilDeadline, default(ForPrimitives));
			TimeOfDay.Instance.timeUntilDeadline = timeUntilDeadline;
			TimeOfDay.Instance.UpdateProfitQuotaCurrentTime();
		}

		public static void ExtendDeadline()
		{
			int extendDeadlinePrice = ExtendDeadlinePrice;
			if (extendDeadlinePrice <= AdvancedCompany.Patches.Terminal.Instance.groupCredits)
			{
				TimeOfDay instance = TimeOfDay.Instance;
				instance.timeUntilDeadline += TimeOfDay.Instance.totalTime;
				Terminal instance2 = AdvancedCompany.Patches.Terminal.Instance;
				instance2.groupCredits -= extendDeadlinePrice;
				if (NetworkManager.Singleton.IsServer)
				{
					AdvancedCompany.Patches.Terminal.Instance.SyncGroupCreditsServerRpc(AdvancedCompany.Patches.Terminal.Instance.groupCredits, AdvancedCompany.Patches.Terminal.Instance.numberOfItemsInDropship);
					AdvancedCompany.Network.Manager.SendToAll(new DeadlineChanged
					{
						NewDeadline = TimeOfDay.Instance.timeUntilDeadline
					});
					AdvancedCompany.Network.Manager.Send(new ChangeShip
					{
						TotalQuota = AdvancedCompany.Network.Manager.Lobby.CurrentShip.TotalQuota,
						ExtendedDeadline = true
					}, 0uL);
				}
				else
				{
					AdvancedCompany.Network.Manager.Send(new AdvancedCompany.Network.Messages.ExtendDeadline(), 0uL);
				}
			}
		}

		public static float GetMultiplier(Perk perk)
		{
			if (AdvancedCompany.Network.Manager.Lobby != null)
			{
				if (perk.PerkType == Perk.Type.PLAYER)
				{
					Player player = AdvancedCompany.Network.Manager.Lobby.Player();
					if (player != null)
					{
						return perk.GetMultiplier(player);
					}
				}
				else if (perk.PerkType == Perk.Type.SHIP)
				{
					Ship currentShip = AdvancedCompany.Network.Manager.Lobby.CurrentShip;
					if (currentShip != null)
					{
						return perk.GetMultiplier(currentShip);
					}
				}
			}
			return 1f;
		}

		public static float GetMultiplier(string perkName)
		{
			if (Perk.Perks.ContainsKey(perkName))
			{
				return GetMultiplier(Perk.Perks[perkName]);
			}
			return 1f;
		}

		public static float GetMultiplier(ulong clientID, string perkName)
		{
			if (Perk.Perks.ContainsKey(perkName) && AdvancedCompany.Network.Manager.Lobby != null)
			{
				Perk perk = Perk.Perks[perkName];
				if (perk.PerkType == Perk.Type.PLAYER)
				{
					Player player = AdvancedCompany.Network.Manager.Lobby.Player();
					if (player != null)
					{
						return Perk.Perks[perkName].GetMultiplier(player);
					}
				}
			}
			return 1f;
		}

		public static float GetMultiplier(PlayerControllerB controller, string perkName)
		{
			if ((Object)(object)controller != (Object)null)
			{
				return GetMultiplier(controller.playerClientId, perkName);
			}
			return 1f;
		}

		public static int InventorySlotsOf(PlayerControllerB controller)
		{
			if (Perk.Perks.ContainsKey("InventorySlots") && AdvancedCompany.Network.Manager.Lobby != null)
			{
				Player player = AdvancedCompany.Network.Manager.Lobby.Player(controller.playerClientId);
				if (player != null)
				{
					return (int)Math.Round(ServerConfiguration.Instance.PlayerPerks.InventorySlots.Base + (float)Perk.Perks["InventorySlots"].GetLevel(player));
				}
			}
			return 10;
		}
	}
	[LoadAssets]
	public class PlayerRocketBoots : MonoBehaviour
	{
		public GameObject LeftRocket;

		public GameObject RightRocket;

		private ParticleSystem LeftParticles;

		private ParticleSystem RightParticles;

		private bool Initialized = false;

		private static GameObject LeftRocketBootPrefab;

		private static GameObject RightRocketBootPrefab;

		public static void LoadAssets(AssetBundle assets)
		{
			LeftRocketBootPrefab = assets.LoadAsset<GameObject>("Assets/Prefabs/LeftRocketBoot.prefab");
			RightRocketBootPrefab = assets.LoadAsset<GameObject>("Assets/Prefabs/RightRocketBoot.prefab");
		}

		public void Awake()
		{
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			Transform val = ((Component)this).transform.Find("ScavengerModel").Find("metarig").Find("spine");
			Transform val2 = val.Find("thigh.L").Find("shin.L").Find("foot.L");
			Transform val3 = val.Find("thigh.R").Find("shin.R").Find("foot.R");
			if ((Object)(object)LeftRocket == (Object)null)
			{
				LeftRocket = Object.Instantiate<GameObject>(LeftRocketBootPrefab, val2);
				LeftRocket.transform.localPosition = new Vector3(-0.0786f, -0.0302f, 0.0056f);
				LeftRocket.transform.localEulerAngles = new Vector3(-54.256f, -170.885f, 169.978f);
				LeftRocket.transform.localScale = new Vector3(0.5319018f, 0.5319018f, 0.5319018f);
				LeftParticles = ((Component)LeftRocket.transform.Find("Particles")).GetComponent<ParticleSystem>();
			}
			if ((Object)(object)RightRocket == (Object)null)
			{
				RightRocket = Object.Instantiate<GameObject>(RightRocketBootPrefab, val3);
				RightRocket.transform.localPosition = new Vector3(0.0833f, -0.0401f, 0.0086f);
				RightRocket.transform.localEulerAngles = new Vector3(-124.165f, 0.07899f, -0.55297f);
				RightRocket.transform.localScale = new Vector3(0.5319018f, 0.5319018f, 0.5319018f);
				RightParticles = ((Component)RightRocket.transform.Find("Particles")).GetComponent<ParticleSystem>();
			}
		}

		public void PlayParticles()
		{
			LeftParticles.Play();
			RightParticles.Play();
		}
	}
	[BepInPlugin("com.potatoepet.AdvancedCompany", "AdvancedCompany", "1.0.10")]
	public class Plugin : BaseUnityPlugin
	{
		public const string Version = "1.0.10";

		private const string GUID = "com.potatoepet.AdvancedCompany";

		internal static ManualLogSource Log;

		internal static Plugin Instance;

		private void Awake()
		{
			try
			{
				Log = ((BaseUnityPlugin)this).Logger;
				AppDomain.CurrentDomain.AssemblyLoad += CurrentDomain_AssemblyLoad;
				Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
				Assembly[] array = assemblies;
				foreach (Assembly assembly in array)
				{
					CheckAssemblyPatches(assembly);
				}
				Instance = this;
				Log.LogInfo((object)"Booting");
				BootManager.Boot();
				Log.LogInfo((object)"Boot finished!");
				Log.LogInfo((object)"Patching with harmony...");
				Harmony.CreateAndPatchAll(typeof(AdvancedCompany.Network.Manager), "AdvancedCompany");
				Harmony.CreateAndPatchAll(typeof(BulletProofVest), "AdvancedCompany");
				Harmony.CreateAndPatchAll(typeof(LightningRod), "AdvancedCompany");
				Harmony.CreateAndPatchAll(typeof(AdvancedCompany.Objects.NightVision), "AdvancedCompany");
				Harmony.CreateAndPatchAll(typeof(SwimmingFins), "AdvancedCompany");
				Harmony.CreateAndPatchAll(typeof(AnimationPatches), "AdvancedCompany");
				Harmony.CreateAndPatchAll(typeof(BalancingPatches), "AdvancedCompany");
				Harmony.CreateAndPatchAll(typeof(DebugPatches), "AdvancedCompany");
				Harmony.CreateAndPatchAll(typeof(EnemyAICollisionDetect), "AdvancedCompany");
				Harmony.CreateAndPatchAll(typeof(Flavour), "AdvancedCompany");
				Harmony.CreateAndPatchAll(typeof(GameNetworkManager), "AdvancedCompany");
				Harmony.CreateAndPatchAll(typeof(GrabbableObject), "AdvancedCompany");
				Harmony.CreateAndPatchAll(typeof(HUDManager), "AdvancedCompany");
				Harmony.CreateAndPatchAll(typeof(InventoryPatches), "AdvancedCompany");
				Harmony.CreateAndPatchAll(typeof(ItemDataHandling), "AdvancedCompany");
				Harmony.CreateAndPatchAll(typeof(ItemDropship), "AdvancedCompany");
				Harmony.CreateAndPatchAll(typeof(Rocket), "AdvancedCompany");
				if (FileConfiguration.Instance.Lobby.Active.Value)
				{
					LobbySizePatches.MAX_PLAYERS = FileConfiguration.Instance.Lobby.MaxPlayers.Value;
					Harmony.CreateAndPatchAll(typeof(LobbySizePatches), "AdvancedCompany");
					LobbySizePatches.PatchAsync();
				}
				else
				{
					Harmony.CreateAndPatchAll(typeof(NoLobbyPatches), "AdvancedCompany");
				}
				Harmony.CreateAndPatchAll(typeof(PlayerControllerB), "AdvancedCompany");
				Harmony.CreateAndPatchAll(typeof(RoundManager), "AdvancedCompany");
				Harmony.CreateAndPatchAll(typeof(StartOfRound), "AdvancedCompany");
				Harmony.CreateAndPatchAll(typeof(AdvancedCompany.Patches.Terminal), "AdvancedCompany");
				Harmony.CreateAndPatchAll(typeof(TimeOfDay), "AdvancedCompany");
				Harmony.CreateAndPatchAll(typeof(Endscreen), "AdvancedCompany");
				Harmony.CreateAndPatchAll(typeof(Utils), "AdvancedCompany");
				Log.LogInfo((object)"Patching complete!");
			}
			catch (Exception ex)
			{
				Log.LogError((object)"Error while booting!");
				Log.LogError((object)ex);
			}
		}

		private void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
		{
			CheckAssemblyPatches(args.LoadedAssembly);
		}

		private static void CheckAssemblyPatches(Assembly assembly)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			if (!assembly.FullName.StartsWith("ReservedFlashlightSlot"))
			{
				return;
			}
			Harmony val = new Harmony("AdvancedCompany");
			Type[] types = assembly.GetTypes();
			for (int i = 0; i < types.Length; i++)
			{
				if (types[i].Name == "Keybinds")
				{
					MethodInfo method = types[i].GetMethod("OnActivateFlashlightPerformed", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
					HarmonyMethod val2 = new HarmonyMethod(typeof(Plugin).GetMethod("CheckFlashlight", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy));
					val.Patch((MethodBase)method, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					break;
				}
			}
		}

		private static bool CheckFlashlight()
		{
			if (ClientConfiguration.Instance.Keybinds.Flashlight != null && ClientConfiguration.Instance.Keybinds.Flashlight.Trim() != "")
			{
				return false;
			}
			return true;
		}

		public static bool ShouldSaveOutfits()
		{
			return (ServerConfiguration.Instance?.General?.SaveSuitsAfterDeath).GetValueOrDefault();
		}
	}
	public class Program
	{
		public static void Main(string[] args)
		{
			Console.WriteLine(AdvancedCompany.Terminal.Utils.WrapText("Ich bin ein Testtext der angezeigt werden soll, mal schauen, ob das auch wirklich funktioniert.", 30, "| ", " |"));
		}
	}
	[HarmonyPatch]
	public class Utils
	{
		private static List<GameObject> NetworkPrefabs = new List<GameObject>();

		private static bool NetworkManagerStarted = false;

		public static NetworkManager NetworkManager;

		public static void AddNetworkPrefab(GameObject go)
		{
			NetworkPrefabs.Add(go);
			if (NetworkManagerStarted)
			{
				NetworkManager.AddNetworkPrefab(go);
			}
		}

		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		[HarmonyPostfix]
		private static void Start(GameNetworkManager __instance)
		{
			NetworkManager = ((Component)__instance).GetComponent<NetworkManager>();
			for (int i = 0; i < NetworkPrefabs.Count; i++)
			{
				NetworkManager.AddNetworkPrefab(NetworkPrefabs[i]);
			}
			NetworkManagerStarted = true;
		}
	}
}
namespace AdvancedCompany.UI
{
	[LoadAssets]
	[HarmonyPatch]
	public class Endscreen
	{
		private static GameObject Container;

		public static Endscreen Instance;

		private static GameObject PerformanceReportPrefab;

		private static GameObject DeadContainerPrefab;

		private static GameObject MissingContainerPrefab;

		private static GameObject NoteContainerPrefab;

		private static Transform AllDead;

		private static Transform PlayerNoteContainer;

		private static Transform DeadNoteContainer;

		private static Transform MissingTitle;

		private static Transform MissingScrollBox;

		private static Transform MissingNoteContainer;

		private static Transform CollectedLabel;

		private static Transform CollectedLine;

		private static TextMeshProUGUI CollectedText;

		private static TextMeshProUGUI TotalText;

		private static Transform ScrapLost;

		private static TextMeshProUGUI ScrapLostText;

		private static TextMeshProUGUI GradeText;

		private static int CollectedScrap;

		private static int TotalScrap;

		private static string Grade;

		private static bool AreAllDead;

		private static MethodInfo OpenEndgameMenuMethod = typeof(Endscreen).GetMethod("Open", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);

		public static void LoadAssets(AssetBundle assets)
		{
			PerformanceReportPrefab = assets.LoadAsset<GameObject>("Assets/UI/PerformanceReport.prefab");
			DeadContainerPrefab = assets.LoadAsset<GameObject>("Assets/UI/DeadContainer.prefab");
			MissingContainerPrefab = assets.LoadAsset<GameObject>("Assets/UI/MissingContainer.prefab");
			NoteContainerPrefab = assets.LoadAsset<GameObject>("Assets/UI/NoteContainer.prefab");
		}

		private static string GetDeathReason(PlayerControllerB controller)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected I4, but got Unknown
			if (Chainloader.PluginInfos.ContainsKey("com.elitemastereric.coroner"))
			{
				try
				{
					return CoronerDeathReason(controller);
				}
				catch (Exception)
				{
				}
			}
			CauseOfDeath causeOfDeath = controller.causeOfDeath;
			CauseOfDeath val = causeOfDeath;
			return (int)val switch
			{
				0 => "Uncertain circumstances", 
				9 => "Drowned", 
				4 => "Strangulated", 
				5 => "Suffocation", 
				6 => "Mauling", 
				3 => "Blast", 
				8 => "Crushed", 
				11 => "Electrocuted", 
				2 => "Gravity", 
				7 => "Gunshots", 
				12 => "Kicked", 
				_ => "Uncertain circumstances", 
			};
		}

		private static string CoronerDeathReason(PlayerControllerB controller)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return AdvancedDeathTracker.StringifyCauseOfDeath((AdvancedCauseOfDeath?)AdvancedDeathTracker.GetCauseOfDeath(controller));
		}

		public static void Open()
		{
			try
			{
				bool active = false;
				int childCount = PlayerNoteContainer.childCount;
				for (int num = childCount - 1; num >= 0; num--)
				{
					Object.Destroy((Object)(object)((Component)PlayerNoteContainer.GetChild(num)).gameObject);
				}
				childCount = DeadNoteContainer.childCount;
				for (int num2 = childCount - 1; num2 >= 0; num2--)
				{
					Object.Destroy((Object)(object)((Component)DeadNoteContainer.GetChild(num2)).gameObject);
				}
				childCount = MissingNoteContainer.childCount;
				for (int num3 = childCount - 1; num3 >= 0; num3--)
				{
					Object.Destroy((Object)(object)((Component)MissingNoteContainer.GetChild(num3)).gameObject);
				}
				for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
				{
					PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[i];
					string text = ((TMP_Text)HUDManager.Instance.statsUIElements.playerNamesText[i]).text;
					Texture2D avatar = PlayerControllerB.GetAvatar(val);
					string text2 = ((TMP_Text)HUDManager.Instance.statsUIElements.playerNotesText[i]).text;
					if (text2.StartsWith("Notes:"))
					{
						text2 = text2.Substring(6);
					}
					if (Chainloader.PluginInfos.ContainsKey("com.elitemastereric.coroner"))
					{
						int num4 = text2.IndexOf("Cause of Death");
						if (num4 > -1)
						{
							text2 = text2.Substring(0, num4);
						}
					}
					text2 = text2.Trim();
					string deathReason = GetDeathReason(val);
					if (text2 != "")
					{
						AddPlayerNote(avatar, text, text2);
					}
					if ((Object)(object)HUDManager.Instance.statsUIElements.playerStates[i].sprite == (Object)(object)HUDManager.Instance.statsUIElements.deceasedIcon)
					{
						AddDeceasedNote(avatar, text, deathReason);
					}
					if ((Object)(object)HUDManager.Instance.statsUIElements.playerStates[i].sprite == (Object)(object)HUDManager.Instance.statsUIElements.missingIcon)
					{
						active = true;
						AddMissingNote(avatar, text);
					}
				}
				((Component)MissingTitle).gameObject.SetActive(active);
				((Component)MissingScrollBox).gameObject.SetActive(active);
				CollectedScrap = RoundManager.Instance.scrapCollectedInLevel;
				TotalScrap = (int)RoundManager.Instance.totalScrapValueInLevel;
				AreAllDead = ((Behaviour)HUDManager.Instance.statsUIElements.allPlayersDeadOverlay).enabled;
				((Component)AllDead).gameObject.SetActive(AreAllDead);
				((TMP_Text)CollectedText).text = "";
				((TMP_Text)TotalText).text = "";
				((Component)CollectedText).gameObject.SetActive(true);
				((Component)TotalText).gameObject.SetActive(true);
				((Component)CollectedLine).gameObject.SetActive(true);
				((Component)CollectedLabel).gameObject.SetActive(true);
				((Component)ScrapLost).gameObject.SetActive(false);
				Grade = ((TMP_Text)HUDManager.Instance.statsUIElements.gradeLetter).text;
				((TMP_Text)GradeText).text = "";
				Container.SetActive(true);
				LayoutRebuilder.ForceRebuildLayoutImmediate(Container.GetComponent<RectTransform>());
				((MonoBehaviour)HUDManager.Instance).StartCoroutine(AnimateMenu());
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)"Error occured while opening end screen!");
				Plugin.Log.LogError((object)ex);
			}
		}

		private static IEnumerator AnimateMenu()
		{
			Cursor.lockState = (CursorLockMode)2;
			Cursor.visible = true;
			yield return (object)new WaitForSeconds(1f);
			float p = 0f;
			((TMP_Text)TotalText).text = TotalScrap.ToString() ?? "";
			while (p < 1f)
			{
				((TMP_Text)CollectedText).text = CollectedScrap.ToString() ?? "";
				p += 0.05f;
				yield return (object)new WaitForEndOfFrame();
			}
			if (AreAllDead)
			{
				yield return (object)new WaitForSeconds(1f);
				((Component)CollectedText).gameObject.SetActive(false);
				((Component)TotalText).gameObject.SetActive(false);
				((Component)CollectedLine).gameObject.SetActive(false);
				((Component)CollectedLabel).gameObject.SetActive(false);
				((TMP_Text)ScrapLostText).text = "Lost " + Mathf.Round((1f - Perks.GetMultiplier("SaveLoot")) * 1000f) / 10f + "% scrap";
				((Component)ScrapLost).gameObject.SetActive(true);
			}
			yield return (object)new WaitForSeconds(1f);
			((TMP_Text)GradeText).text = Grade;
			yield return (object)new WaitForSeconds(6f - (AreAllDead ? 1f : 0f));
			Container.SetActive(false);
			Cursor.lockState = (CursorLockMode)1;
			Cursor.visible = false;
		}

		public static Texture2D GetTextureFromImage(Image? image)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			if (image.HasValue)
			{
				Texture2D val = new Texture2D((int)image.Value.Width, (int)image.Value.Height);
				for (int i = 0; i < image.Value.Width; i++)
				{
					for (int j = 0; j < image.Value.Height; j++)
					{
						Image value = image.Value;
						Color pixel = ((Image)(ref value)).GetPixel(i, j);
						val.SetPixel(i, (int)image.Value.Height - j, new Color((float)(int)pixel.r / 255f, (float)(int)pixel.g / 255f, (float)(int)pixel.b / 255f, (float)(int)pixel.a / 255f));
					}
				}
				val.Apply();
				return val;
			}
			return null;
		}

		private static void AddPlayerNote(Texture2D image, string username, string notes)
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(NoteContainerPrefab, PlayerNoteContainer);
			Transform child = val.transform.GetChild(0);
			Transform child2 = child.GetChild(0);
			if ((Object)(object)image != (Object)null)
			{
				((Component)child2).GetComponent<RawImage>().texture = (Texture)(object)image;
			}
			else
			{
				((Component)child2).gameObject.SetActive(false);
			}
			((TMP_Text)((Component)child.GetChild(1)).GetComponent<TextMeshProUGUI>()).text = username;
			((TMP_Text)((Component)val.transform.GetChild(1)).GetComponent<TextMeshProUGUI>()).text = notes;
			val.transform.parent = PlayerNoteContainer;
			val.transform.localScale = new Vector3(1f, 1f, 1f);
		}

		private static void AddDeceasedNote(Texture2D image, string username, string deathReason)
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(DeadContainerPrefab, PlayerNoteContainer);
			Transform child = val.transform.GetChild(0);
			Transform child2 = child.GetChild(0);
			if ((Object)(object)image != (Object)null)
			{
				((Component)child2).GetComponent<RawImage>().texture = (Texture)(object)image;
			}
			else
			{
				((Component)child2).gameObject.SetActive(false);
			}
			((TMP_Text)((Component)child.GetChild(1)).GetComponent<TextMeshProUGUI>()).text = username;
			((TMP_Text)((Component)val.transform.GetChild(1)).GetComponent<TextMeshProUGUI>()).text = deathReason;
			val.transform.parent = DeadNoteContainer;
			val.transform.localScale = new Vector3(1f, 1f, 1f);
		}

		private static void AddMissingNote(Texture2D image, string username)
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(MissingContainerPrefab, PlayerNoteContainer);
			Transform child = val.transform.GetChild(0);
			Transform child2 = child.GetChild(0);
			if ((Object)(object)image != (Object)null)
			{
				((Component)child2).GetComponent<RawImage>().texture = (Texture)(object)image;
			}
			else
			{
				((Component)child2).gameObject.SetActive(false);
			}
			((TMP_Text)((Component)child.GetChild(1)).GetComponent<TextMeshProUGUI>()).text = username;
			val.transform.parent = MissingNoteContainer;
			val.transform.localScale = new Vector3(1f, 1f, 1f);
		}

		[HarmonyPatch(typeof(HUDManager), "Start")]
		[HarmonyPostfix]
		public static void Attach(HUDManager __instance)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			Container = Object.Instantiate<GameObject>(PerformanceReportPrefab, ((Component)__instance.endgameStatsAnimator).transform.parent);
			Container.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
			Container.GetComponent<RectTransform>().sizeDelta = new Vector2(823f, 717f);
			Transform child = Container.transform.GetChild(1);
			Transform child2 = child.GetChild(0);
			Transform child3 = child.GetChild(1);
			Transform child4 = Container.transform.GetChild(2);
			AllDead = child2.GetChild(1);
			PlayerNoteContainer = child2.GetChild(2).GetChild(0).GetChild(0);
			DeadNoteContainer = child3.GetChild(1).GetChild(0).GetChild(0);
			MissingTitle = child3.GetChild(2);
			MissingScrollBox = child3.GetChild(3);
			MissingNoteContainer = MissingScrollBox.GetChild(0).GetChild(0);
			Transform child5 = child4.GetChild(0);
			CollectedLabel = child5.GetChild(0);
			CollectedText = ((Component)child5.GetChild(1)).GetComponent<TextMeshProUGUI>();
			CollectedLine = child5.GetChild(2);
			TotalText = ((Component)child5.GetChild(3)).GetComponent<TextMeshProUGUI>();
			ScrapLost = child5.GetChild(4);
			ScrapLostText = ((Component)ScrapLost.GetChild(0)).GetComponent<TextMeshProUGUI>();
			GradeText = ((Component)child4.GetChild(1).GetChild(1)).GetComponent<TextMeshProUGUI>();
			Container.SetActive(false);
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> PatchHUDManagerEndOfGame(IEnumerable<CodeInstruction> instructions)
		{
			Plugin.Log.LogMessage((object)"Patching StartOfRound->EndOfGame...");
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Ldstr && list[i].operand.ToString() == "displayStats")
				{
					list[i + 1].opcode = OpCodes.Call;
					list[i + 1].operand = OpenEndgameMenuMethod;
					list.RemoveAt(i - 2);
					list.RemoveAt(i - 2);
					list.RemoveAt(i - 2);
				}
			}
			Plugin.Log.LogMessage((object)"Patched StartOfRound->EndOfGame!");
			return list.AsEnumerable();
		}
	}
}
namespace AdvancedCompany.Terminal
{
	public class BoxedScreen : IScreen, ITextElement
	{
		public string Title;

		public List<ITextElement> Content;

		public virtual string GetText(int availableWidth)
		{
			int num = availableWidth - Title.Length - 2;
			string text = "┌" + new string('─', availableWidth - 2) + "┐\n│" + new string(' ', (int)Math.Ceiling((float)num / 2f)) + Title + new string(' ', (int)Math.Ceiling((float)num / 2f) - ((num % 2 != 0) ? 1 : 0)) + "│\n├" + new string('─', availableWidth - 2) + "┤\n";
			foreach (ITextElement item in Content)
			{
				text += Utils.WrapText(item.GetText(availableWidth - 4), availableWidth, "│ ", " │");
			}
			return text + "└" + new string('─', availableWidth - 2) + "┘\n";
		}
	}
	public class Command
	{
		public string CommandText;

		public string Description;

		public bool IsActive = true;

		public bool IsCheat = false;

		public bool ServerOnly = false;

		public Action<string[]> Action;

		internal static List<Command> Commands = new List<Command>();

		public Command()
		{
			Commands.Add(this);
		}

		public static Command FindCommand(string commandText, bool isServer)
		{
			for (int i = 0; i < Commands.Count; i++)
			{
				if (Commands[i].IsActive && Commands[i].CommandText.Equals(commandText, StringComparison.OrdinalIgnoreCase) && (!Commands[i].ServerOnly || isServer))
				{
					return Commands[i];
				}
			}
			return null;
		}

		public void Execute(string[] @params)
		{
			Action(@params);
		}
	}
	public class CursorElement : ITextElement
	{
		public string Name;

		public string Description;

		public Action Action;

		public virtual string GetText(int availableWidth)
		{
			string text = Name;
			if (Description != null && Description != "")
			{
				text = text + "\n" + Utils.WrapText(Description, availableWidth, "  ");
			}
			return text;
		}
	}
	public class CursorMenu : IScrollable, ITextElement
	{
		private int _SelectedElement;

		public List<CursorElement> Elements;

		private int _ScrollPosStart = 0;

		private int _ScrollPosEnd = 0;

		private int _LastScrollPos = 0;

		public int SelectedElement
		{
			get
			{
				return _SelectedElement;
			}
			set
			{
				if (value >= Elements.Count)
				{
					_SelectedElement = 0;
				}
				else if (value < 0)
				{
					_SelectedElement = Elements.Count - 1;
				}
				else
				{
					_SelectedElement = value;
				}
			}
		}

		public void Execute()
		{
			Elements[SelectedElement].Action();
		}

		public virtual string GetText(int availableWidth)
		{
			string text = "";
			int num = 0;
			for (int i = 0; i < Elements.Count; i++)
			{
				if (_SelectedElement == i)
				{
					_ScrollPosStart = num;
				}
				string text2 = " " + ((_SelectedElement == i) ? ">" : " ") + " " + Utils.WrapText(Elements[i].GetText(availableWidth - 3), availableWidth, "   ", "", padLeftFirst: false);
				num += text2.Count((char c) => c.Equals('\n'));
				text += text2;
				if (_SelectedElement == i)
				{
					_ScrollPosEnd = num;
				}
			}
			return text;
		}

		public int GetScroll(int maxHeight)
		{
			int lastScrollPos = _LastScrollPos;
			int num = _LastScrollPos + maxHeight;
			int num2 = _LastScrollPos;
			if (_ScrollPosEnd > num)
			{
				num2 = _ScrollPosEnd - maxHeight;
			}
			if (_ScrollPosStart < lastScrollPos)
			{
				num2 = _ScrollPosStart;
			}
			_LastScrollPos = num2;
			return num2;
		}
	}
	public class Help
	{
		public static void Show()
		{
			List<string> list = new List<string>();
			TerminalKeyword[] allKeywords = AdvancedCompany.Patches.Terminal.Instance.terminalNodes.allKeywords;
			foreach (TerminalKeyword val in allKeywords)
			{
				if (val.word == "help")
				{
					list.AddRange(val.specialKeywordResult.displayText.Split('\n'));
				}
				if (val.word == "other")
				{
					list.AddRange(val.specialKeywordResult.displayText.Split('\n'));
				}
			}
			string text = "";
			string text2 = "";
			List<(string, string)> list2 = new List<(string, string)>();
			for (int j = 0; j < list.Count; j++)
			{
				string text3 = list[j];
				if (text3.StartsWith(">"))
				{
					if (text != "")
					{
						if (!text.Equals("other", StringComparison.OrdinalIgnoreCase))
						{
							list2.Add((text, text2));
							text2 = "";
						}
						else
						{
							text2 = "";
						}
					}
					text = text3.Substring(1);
				}
				else if (text3.Trim() != "")
				{
					text2 = text2 + text3 + "\n";
				}
			}
			if (text != "")
			{
				list2.Add((text, text2));
			}
			string text4 = "";
			foreach (var item in list2)
			{
				text4 = text4 + "> " + item.Item1 + "\n" + Utils.WrapText(item.Item2, 51, "  ");
			}
			foreach (Command command in Command.Commands)
			{
				if (command.IsActive && !command.IsCheat && (!command.ServerOnly || NetworkManager.Singleton.IsServer))
				{
					text4 = text4 + "> " + command.CommandText.ToUpperInvariant() + "\n" + Utils.WrapText(command.Description, 51, "  ") + "\n";
				}
			}
			AdvancedCompany.Patches.Terminal.SetText(text4);
		}
	}
	internal interface IScreen : ITextElement
	{
	}
	public interface IScrollable : ITextElement
	{
		int GetScroll(int maxHeight);
	}
	public interface ITextElement
	{
		string GetText(int availableWidth);
	}
	public class PerkCursorElement : CursorElement
	{
		private Perk Perk;

		public PerkCursorElement(Perk perk)
		{
			Perk = perk;
		}

		public override string GetText(int availableWidth)
		{
			int num = 25;
			int num2 = 11;
			string text = ((Perk.Name.Length > num) ? Perk.Name.Substring(0, num) : (Perk.Name + new string(' ', num - Perk.Name.Length)));
			int num3 = 0;
			int num4 = 0;
			if (Perk.PerkType == Perk.Type.PLAYER)
			{
				num3 = AdvancedCompany.Network.Manager.Lobby.Player().GetLevel(Perk);
				num4 = Perk.GetNextPrice(AdvancedCompany.Network.Manager.Lobby.Player());
			}
			if (Perk.PerkType == Perk.Type.SHIP)
			{
				num3 = AdvancedCompany.Network.Manager.Lobby.CurrentShip.GetLevel(Perk);
				num4 = Perk.GetNextPrice(AdvancedCompany.Network.Manager.Lobby.CurrentShip);
			}
			string text2 = new string('◼', num3) + new string('□', Perk.Levels - num3) + new string(' ', num2 - Perk.Levels);
			string text3 = "";
			if (num4 > 0)
			{
				text3 = " " + num4 + "XP";
			}
			return text + text2 + text3;
		}
	}
	public class ScrollBox : ITextElement
	{
		public IScrollable Content;

		public int MaxHeight = 0;

		public int ScrollPos = 0;

		public ScrollBox(int maxHeight)
		{
			MaxHeight = maxHeight;
		}

		public string GetText(int availableWidth)
		{
			string text = Content.GetText(availableWidth);
			int num = text.Count((char c) => c.Equals('\n')) - 1;
			if (num > MaxHeight)
			{
				text = Content.GetText(availableWidth - 2);
				int scroll = Content.GetScroll(MaxHeight);
				Plugin.Log.LogMessage((object)("Scroll: " + scroll));
				string[] array = text.Split('\n');
				string text2 = "";
				int num2 = (int)Math.Floor((float)MaxHeight * ((float)MaxHeight / (float)array.Length));
				int num3 = (int)Math.Round((float)scroll / (float)(array.Length - MaxHeight) * (float)(MaxHeight - num2));
				for (int i = scroll; i < scroll + MaxHeight && i < array.Length; i++)
				{
					bool flag = i - scroll >= num3 && i - scroll <= num3 + num2;
					string text3 = array[i];
					text2 = text2 + text3 + " " + (flag ? "█" : "░") + "\n";
				}
				return text2;
			}
			return text;
		}
	}
	public class TextElement : ITextElement
	{
		public string Text;

		public string GetText(int availableWidth)
		{
			return Utils.WrapText(Text, availableWidth);
		}

		public static explicit operator TextElement(string text)
		{
			return new TextElement
			{
				Text = text
			};
		}
	}
	public class Utils
	{
		public static string WrapText(string text, int lineLength, string padLeft = "", string padRight = "", bool padLeftFirst = true)
		{
			bool flag = true;
			int num = lineLength - padLeft.Length - padRight.Length;
			string text2 = "";
			int num2 = 0;
			while (num2 < text.Length)
			{
				int num3 = ((num2 + num >= text.Length) ? (text.Length - 1) : (num2 + num));
				int num4 = text.LastIndexOf(' ', num3);
				int num5 = text.IndexOf('\n', num2);
				if (num5 != -1 && num5 <= num3)
				{
					num4 = num5;
				}
				if (num3 == text.Length - 1)
				{
					num4 = text.Length;
				}
				if (num4 < num2)
				{
					num4 = -1;
				}
				int num6 = ((num4 != -1) ? (num4 - num2) : ((text.Length - num2 < num) ? (text.Length - num2) : num));
				if (num6 > num)
				{
					num6 = num;
				}
				string text3 = text.Substring(num2, num6);
				string text4 = ((!padLeftFirst && flag) ? "" : padLeft) + text3 + ((text3.Length < num) ? new string(' ', num - text3.Length) : "") + padRight + "\n";
				text2 += text4;
				flag = false;
				num2 = num2 + num6 + ((num4 != -1) ? 1 : 0);
			}
			return text2;
		}
	}
}
namespace AdvancedCompany.Terminal.Applications
{
	public class ExtendDeadline
	{
		public static void Open()
		{
			string text = "";
			bool flag = false;
			int extendDeadlinePrice = AdvancedCompany.Perks.ExtendDeadlinePrice;
			if (AdvancedCompany.Network.Manager.Lobby.CurrentShip.ExtendedDeadline)
			{
				text = "The deadline was already extended during this quota.";
			}
			else if (extendDeadlinePrice > AdvancedCompany.Patches.Terminal.Instance.groupCredits)
			{
				text = "Insufficient funds.";
			}
			else
			{
				flag = true;
				text = "Do you really want to extend the deadline?";
			}
			List<CursorElement> list = new List<CursorElement>();
			if (flag)
			{
				list.Add(new CursorElement
				{
					Name = "CONFIRM",
					Action = delegate
					{
						AdvancedCompany.Perks.ExtendDeadline();
						AdvancedCompany.Patches.Terminal.ActiveScreen = null;
						AdvancedCompany.Patches.Terminal.ActiveCursorMenu = null;
						AdvancedCompany.Patches.Terminal.SetText("[ Deadline was extended by one day ]\n\n\n");
					}
				});
				list.Add(new CursorElement
				{
					Name = "DENY",
					Action = delegate
					{
						Close();
					}
				});
			}
			else
			{
				list.Add(new CursorElement
				{
					Name = "BACK",
					Action = delegate
					{
						Close();
					}
				});
			}
			CursorMenu cursorMenu = new CursorMenu
			{
				Elements = list
			};
			BoxedScreen box = new BoxedScreen
			{
				Title = "EXTEND DEADLINE",
				Content = new List<ITextElement>
				{
					new TextElement
					{
						Text = $"To extend the deadline you need {extendDeadlinePrice} credits."
					},
					new TextElement
					{
						Text = " "
					},
					new TextElement
					{
						Text = text
					},
					cursorMenu
				}
			};
			SwitchTo(box, cursorMenu, back: false);
		}

		public static void SwitchTo(BoxedScreen box, CursorMenu menu, bool back = true)
		{
			if ((Object)(object)AdvancedCompany.Patches.Terminal.Instance != (Object)null)
			{
				AdvancedCompany.Patches.Terminal.ActiveScreen = box;
				AdvancedCompany.Patches.Terminal.ActiveCursorMenu = menu;
				if (!back)
				{
					menu.SelectedElement = 0;
				}
			}
		}

		public static void Close()
		{
			if ((Object)(object)AdvancedCompany.Patches.Terminal.Instance != (Object)null)
			{
				AdvancedCompany.Patches.Terminal.ActiveCursorMenu = null;
				AdvancedCompany.Patches.Terminal.ActiveScreen = null;
				AdvancedCompany.Patches.Terminal.ClosingScreen = true;
			}
		}
	}
	public class Perks
	{
		private static BoxedScreen MainMenu;

		private static BoxedScreen RespecMenu;

		private static BoxedScreen PlayerPerksMenu;

		private static BoxedScreen ShipPerksMenu;

		private static BoxedScreen BuyPerkMenu;

		private static CursorMenu MainMenuCursorMenu;

		private static CursorMenu RespecCursorMenu;

		private static CursorMenu PlayerPerksCursorMenu;

		private static CursorMenu ShipPerksCursorMenu;

		private static CursorMenu BuyPerkCursorMenu;

		public static void Update()
		{
			MainMenuCursorMenu = new CursorMenu
			{
				Elements = new List<CursorElement>
				{
					new CursorElement
					{
						Name = "PLAYER",
						Description = "Upgrade your character.",
						Action = delegate
						{
							SwitchTo(PlayerPerksMenu, PlayerPerksCursorMenu, back: false);
						}
					},
					new CursorElement
					{
						Name = "SHIP",
						Description = "Upgrade your ship.",
						Action = delegate
						{
							SwitchTo(ShipPerksMenu, ShipPerksCursorMenu, back: false);
						}
					},
					new CursorElement
					{
						Name = "RESPEC",
						Description = "Reset your points.",
						Action = delegate
						{
							SwitchTo(RespecMenu, RespecCursorMenu, back: false);
						}
					},
					new CursorElement
					{
						Name = "CLOSE",
						Description = null,
						Action = delegate
						{
							Close();
						}
					}
				}
			};
			MainMenu = new BoxedScreen
			{
				Title = "PERKS",
				Content = new List<ITextElement>
				{
					new TextElement
					{
						Text = "Please select an action:"
					},
					new TextElement
					{
						Text = " "
					},
					new ScrollBox(13)
					{
						Content = MainMenuCursorMenu
					}
				}
			};
			List<CursorElement> list = new List<CursorElement>();
			foreach (Perk p2 in Perk.PerksByType(Perk.Type.PLAYER))
			{
				if (!p2.IsActive)
				{
					continue;
				}
				list.Add(new PerkCursorElement(p2)
				{
					Action = delegate
					{
						BuyPerk(p2, delegate
						{
							SwitchTo(PlayerPerksMenu, PlayerPerksCursorMenu);
						});
					}
				});
			}
			list.Add(new CursorElement
			{
				Name = "BACK",
				Action = delegate
				{
					SwitchTo(MainMenu, MainMenuCursorMenu);
				}
			});
			PlayerPerksCursorMenu = new CursorMenu
			{
				Elements = list
			};
			PlayerPerksMenu = new BoxedScreen
			{
				Title = "PLAYER PERKS",
				Content = new List<ITextElement>
				{
					new TextElement
					{
						Text = "Please select a perk to level:"
					},
					new TextElement
					{
						Text = " "
					},
					new ScrollBox(13)
					{
						Content = PlayerPerksCursorMenu
					}
				}
			};
			List<CursorElement> list2 = new List<CursorElement>();
			foreach (Perk p in Perk.PerksByType(Perk.Type.SHIP))
			{
				if (!p.IsActive)
				{
					continue;
				}
				list2.Add(new PerkCursorElement(p)
				{
					Action = delegate
					{
						BuyPerk(p, delegate
						{
							SwitchTo(ShipPerksMenu, ShipPerksCursorMenu);
						});
					}
				});
			}
			list2.Add(new CursorElement
			{
				Name = "BACK",
				Action = delegate
				{
					SwitchTo(MainMenu, MainMenuCursorMenu);
				}
			});
			ShipPerksCursorMenu = new CursorMenu
			{
				Elements = list2
			};
			ShipPerksMenu = new BoxedScreen
			{
				Title = "SHIP PERKS",
				Content = new List<ITextElement>
				{
					new TextElement
					{
						Text = "Please select a perk to level:"
					},
					new TextElement
					{
						Text = " "
					},
					new ScrollBox(13)
					{
						Content = ShipPerksCursorMenu
					}
				}
			};
			List<CursorElement> list3 = new List<CursorElement>();
			list3.Add(new CursorElement
			{
				Name = "RESPEC PLAYER",
				Description = "Respec your player.",
				Action = delegate
				{
					Confirm("RESPEC PLAYER", "Do you really want to respec your player?", delegate
					{
						AdvancedCompany.Network.Manager.Send(new Respec
						{
							ClientID = GameNetworkManager.Instance.localPlayerController.playerClientId,
							Type = Perk.Type.PLAYER,
							Reset = false
						}, 0uL);
						SwitchTo(RespecMenu, RespecCursorMenu);
						AdvancedCompany.Patches.Terminal.UpdateTerminalValues();
					}, delegate
					{
						SwitchTo(RespecMenu, RespecCursorMenu);
					});
				}
			});
			list3.Add(new CursorElement
			{
				Name = "RESET PLAYER",
				Description = "Reset the progress of your player.",
				Action = delegate
				{
					Confirm("RESET PLAYER", "Do you really want to RESET your player?", delegate
					{
						AdvancedCompany.Network.Manager.Send(new Respec
						{
							ClientID = GameNetworkManager.Instance.localPlayerController.playerClientId,
							Type = Perk.Type.PLAYER,
							Reset = true
						}, 0uL);
						SwitchTo(RespecMenu, RespecCursorMenu);
						AdvancedCompany.Patches.Terminal.UpdateTerminalValues();
					}, delegate
					{
						SwitchTo(RespecMenu, RespecCursorMenu);
					});
				}
			});
			if (NetworkManager.Singleton.IsServer)
			{
				list3.Add(new CursorElement
				{
					Name = "RESPEC SHIP",
					Description = "Respec your ship.",
					Action = delegate
					{
						Confirm("RESPEC SHIP", "Do you really want to respec your ship?", delegate
						{
							AdvancedCompany.Network.Manager.Send(new Respec
							{
								ClientID = GameNetworkManager.Instance.localPlayerController.playerClientId,
								Type = Perk.Type.SHIP,
								Reset = false
							}, 0uL);
							SwitchTo(RespecMenu, RespecCursorMenu);
							AdvancedCompany.Patches.Terminal.UpdateTerminalValues();
							AdvancedCompany.Patches.Terminal.UpdateMoonPrices();
						}, delegate
						{
							SwitchTo(RespecMenu, RespecCursorMenu);
						});
					}
				});
				list3.Add(new CursorElement
				{
					Name = "RESET SHIP",
					Description = "Reset the progress of your ship.",
					Action = delegate
					{
						Confirm("RESET SHIP", "Do you really want to RESET your ship?", delegate
						{
							AdvancedCompany.Network.Manager.Send(new Respec
							{
								ClientID = GameNetworkManager.Instance.localPlayerController.playerClientId,
								Type = Perk.Type.SHIP,
								Reset = true
							}, 0uL);
							SwitchTo(RespecMenu, RespecCursorMenu);
							AdvancedCompany.Patches.Terminal.UpdateTerminalValues();
							AdvancedCompany.Patches.Terminal.UpdateMoonPrices();
						}, delegate
						{
							SwitchTo(RespecMenu, RespecCursorMenu);
						});
					}
				});
			}
			list3.Add(new CursorElement
			{
				Name = "BACK",
				Description = null,
				Action = delegate
				{
					SwitchTo(MainMenu, MainMenuCursorMenu);
				}
			});
			RespecCursorMenu = new CursorMenu
			{
				Elements = list3
			};
			RespecMenu = new BoxedScreen
			{
				Title = "RESPEC",
				Content = new List<ITextElement>
				{
					new TextElement
					{
						Text = "Please select an action:"
					},
					new TextElement
					{
						Text = " "
					},
					new ScrollBox(13)
					{
						Content = RespecCursorMenu
					}
				}
			};
		}

		public static void Confirm(string title, string text, Action confirmAction, Action declineAction)
		{
			CursorMenu cursorMenu = new CursorMenu
			{
				Elements = new List<CursorElement>
				{
					new CursorElement
					{
						Name = "CONFIRM",
						Action = delegate
						{
							confirmAction();
						}
					},
					new CursorElement
					{
						Name = "DECLINE",
						Action = delegate
						{
							declineAction();
						}
					}
				}
			};
			BoxedScreen box = new BoxedScreen
			{
				Title = title,
				Content = new List<ITextElement>
				{
					new TextElement
					{
						Text = text
					},
					new TextElement
					{
						Text = " "
					},
					new ScrollBox(13)
					{
						Content = cursorMenu
					}
				}
			};
			SwitchTo(box, cursorMenu, back: false);
		}

		public static void BuyPerk(Perk perk, Action backAction)
		{
			int num = 0;
			string title = "";
			bool flag = false;
			bool flag2 = false;
			int level = 0;
			if (perk.PerkType == Perk.Type.PLAYER)
			{
				title = "PLAYER PERKS";
				Player player = AdvancedCompany.Network.Manager.Lobby.Player();
				level = perk.GetLevel(player);
				if (level < perk.Levels)
				{
					level++;
					num = perk.GetNextPrice(player);
					flag2 = player.RemainingXP >= num;
				}
				else
				{
					flag = true;
				}
			}
			if (perk.PerkType == Perk.Type.SHIP)
			{
				title = "SHIP PERKS";
				Ship currentShip = AdvancedCompany.Network.Manager.Lobby.CurrentShip;
				level = perk.GetLevel(currentShip);
				if (level < perk.Levels)
				{
					level++;
					num = perk.GetNextPrice(currentShip);
					flag2 = currentShip.RemainingXP >= num;
				}
				else
				{
					flag = true;
				}
			}
			if (flag)
			{
				CursorMenu cursorMenu = new CursorMenu
				{
					Elements = new List<CursorElement>
					{
						new CursorElement
						{
							Name = "BACK",
							Action = delegate
							{
								backAction();
							}
						}
					}
				};
				BoxedScreen box = new BoxedScreen
				{
					Title = title,
					Content = new List<ITextElement>
					{
						new TextElement
						{
							Text = perk.DisplayDescription
						},
						new TextElement
						{
							Text = " "
						},
						new TextElement
						{
							Text = "This perk is already maxed out!"
						},
						new TextElement
						{
							Text = " "
						},
						new ScrollBox(13)
						{
							Content = cursorMenu
						}
					}
				};
				SwitchTo(box, cursorMenu, back: false);
				return;
			}
			if (!flag2)
			{
				CursorMenu cursorMenu2 = new CursorMenu
				{
					Elements = new List<CursorElement>
					{
						new CursorElement
						{
							Name = "BACK",
							Action = delegate
							{
								backAction();
							}
						}
					}
				};
				BoxedScreen box2 = new BoxedScreen
				{
					Title = title,
					Content = new List<ITextElement>
					{
						new TextElement
						{
							Text = perk.DisplayDescription
						},
						new TextElement
						{
							Text = " "
						},
						new TextElement
						{
							Text = "You can't afford this perk. You need " + num + "XP!"
						},
						new TextElement
						{
							Text = " "
						},
						new ScrollBox(13)
						{
							Content = cursorMenu2
						}
					}
				};
				SwitchTo(box2, cursorMenu2, back: false);
				return;
			}
			CursorMenu cursorMenu3 = new CursorMenu
			{
				Elements = new List<CursorElement>
				{
					new CursorElement
					{
						Name = "CONFIRM",
						Action = delegate
						{
							AdvancedCompany.Network.Manager.Send(new ChangePerk
							{
								ClientID = GameNetworkManager.Instance.localPlayerController.playerClientId,
								ID = perk.ID,
								Level = level
							}, 0uL);
							AdvancedCompany.Patches.Terminal.UpdateTerminalValues();
							AdvancedCompany.Patches.Terminal.UpdateMoonPrices();
							backAction();
						}
					},
					new CursorElement
					{
						Name = "DECLINE",
						Action = delegate
						{
							backAction();
						}
					}
				}
			};
			BoxedScreen box3 = new BoxedScreen
			{
				Title = title,
				Content = new List<ITextElement>
				{
					new TextElement
					{
						Text = perk.DisplayDescription
					},
					new TextElement
					{
						Text = " "
					},
					new TextElement
					{
						Text = "Do you want to buy this perk for " + num + "XP?"
					},
					new TextElement
					{
						Text = " "
					},
					new ScrollBox(13)
					{
						Content = cursorMenu3
					}
				}
			};
			SwitchTo(box3, cursorMenu3, back: false);
		}

		public static void SwitchTo(BoxedScreen box, CursorMenu menu, bool back = true)
		{
			if ((Object)(object)AdvancedCompany.Patches.Terminal.Instance != (Object)null)
			{
				AdvancedCompany.Patches.Terminal.ActiveScreen = box;
				AdvancedCompany.Patches.Terminal.ActiveCursorMenu = menu;
				if (!back)
				{
					menu.SelectedElement = 0;
				}
			}
		}

		public static void Open()
		{
			Update();
			SwitchTo(MainMenu, MainMenuCursorMenu, back: false);
			AdvancedCompany.Patches.Terminal._playerXP.SetActive(true);
			AdvancedCompany.Patches.Terminal._shipXP.SetActive(true);
			AdvancedCompany.Patches.Terminal.UpdateTerminalValues();
		}

		public static void Close()
		{
			if ((Object)(object)AdvancedCompany.Patches.Terminal.Instance != (Object)null)
			{
				AdvancedCompany.Patches.Terminal.ActiveCursorMenu = null;
				AdvancedCompany.Patches.Terminal.ActiveScreen = null;
				AdvancedCompany.Patches.Terminal.ClosingScreen = true;
			}
		}
	}
}
namespace AdvancedCompany.PostProcessing
{
	[Serializable]
	[LoadAssets]
	[VolumeComponentMenu("Post-processing/Custom/NightVision")]
	public sealed class NightVision : CustomPostProcessVolumeComponent, IPostProcessComponent
	{
		[Tooltip("Controls the intensity of the effect.")]
		public ClampedFloatParameter intensity = new ClampedFloatParameter(0f, 0f, 1f, false);

		private static Material Material;

		private Material m_Material;

		public override CustomPostProcessInjectionPoint injectionPoint => (CustomPostProcessInjectionPoint)2;

		public bool IsActive()
		{
			return (Object)(object)m_Material != (Object)null && ((VolumeParameter<float>)(object)intensity).value > 0f;
		}

		public static void LoadAssets(AssetBundle assets)
		{
			Material = assets.LoadAsset<Material>("Assets/Shaders/NightVision.mat");
		}

		public override void Setup()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			m_Material = new Material(Material);
		}

		public override void Render(CommandBuffer cmd, HDCamera camera, RTHandle source, RTHandle destination)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)m_Material == (Object)null))
			{
				m_Material.SetFloat("_Intensity", ((VolumeParameter<float>)(object)intensity).value);
				m_Material.SetTexture("_MainTex", RTHandle.op_Implicit(source));
				cmd.Blit(RTHandle.op_Implicit(source), RTHandle.op_Implicit(destination), m_Material, 0);
			}
		}

		public override void Cleanup()
		{
			CoreUtils.Destroy((Object)(object)m_Material);
		}
	}
	public sealed class NightVisionEffect
	{
		private static GameObject LightAndFog;

		private static bool Active;

		private static float Phase;

		private static NightVision Instance;

		public static void Initialize()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Expected O, but got Unknown
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Expected O, but got Unknown
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("NightVisionRenderVolume");
			Volume val2 = val.AddComponent<Volume>();
			val2.isGlobal = true;
			val2.priority = 1000f;
			VolumeProfile val3 = ScriptableObject.CreateInstance<VolumeProfile>();
			((Object)val3).name = "NightVisionProfile";
			Instance = val3.Add<NightVision>(true);
			((Object)Instance).name = "NightVision";
			((VolumeComponent)Instance).active = true;
			val2.sharedProfile = val3;
			Player player = Player.GetPlayer(GameNetworkManager.Instance.localPlayerController);
			LightAndFog = new GameObject("NightVisionLight");
			LightAndFog.transform.parent = player.GetBone(Player.Bone.METARIG);
			LightAndFog.transform.localPosition = new Vector3(0f, 0f, 0.5f);
			LightAndFog.transform.localRotation = Quaternion.identity;
			LocalVolumetricFog val4 = LightAndFog.AddComponent<LocalVolumetricFog>();
			val4.parameters.size = new Vector3(50f, 50f, 50f);
			val4.parameters.falloffMode = (LocalVolumetricFogFalloffMode)1;
			val4.parameters.blendingMode = (LocalVolumetricFogBlendingMode)0;
			val4.parameters.anisotropy = 25f;
			val4.parameters.meanFreePath = 25f;
			GameObject val5 = new GameObject("Light1");
			val5.transform.parent = LightAndFog.transform;
			val5.transform.localPosition = new Vector3(8f, 9.1f, -1.5f);
			val5.transform.localRotation = Quaternion.Euler(50f, -61f, -68f);
			Light val6 = val5.AddComponent<Light>();
			val6.color = new Color(0f, 1f, 0f);
			val6.type = (LightType)0;
			val6.shape = (LightShape)2;
			val6.cullingMask = 2147483519;
			HDAdditionalLightData val7 = val5.AddComponent<HDAdditionalLightData>();
			val7.SetBoxSpotSize(new Vector2(500f, 500f));
			val7.SetIntensity(100f, (LightUnit)2);
			val7.spotLightShape = (SpotLightShape)2;
			val7.affectsVolumetric = true;
			val7.volumetricDimmer = 0.1f;
			val7.range = 1000f;
			val7.lightDimmer = 1f;
			val7.SetCullingMask(2147483519);
			GameObject val8 = new GameObject("Light2");
			val8.transform.parent = LightAndFog.transform;
			val8.transform.localPosition = new Vector3(8f, 6.5f, 8f);
			val8.transform.localRotation = Quaternion.Euler(56f, 114f, 110f);
			Light val9 = val8.AddComponent<Light>();
			val9.color = new Color(0f, 1f, 0f);
			val9.type = (LightType)0;
			val9.shape = (LightShape)2;
			val9.cullingMask = 2147483519;
			HDAdditionalLightData val10 = val8.AddComponent<HDAdditionalLightData>();
			val10.SetBoxSpotSize(new Vector2(500f, 500f));
			val10.SetIntensity(100f, (LightUnit)2);
			val10.spotLightShape = (SpotLightShape)2;
			val10.SetCullingMask(2147483519);
			val10.affectsVolumetric = true;
			val10.volumetricDimmer = 0.1f;
			val10.range = 1000f;
			val10.lightDimmer = 1f;
			LightAndFog.SetActive(false);
		}

		public static void Activate()
		{
			Active = true;
		}

		public static void Deactivate()
		{
			Active = false;
		}

		public static void Update()
		{
			if (Active)
			{
				Phase = Mathf.Clamp01(Phase + Time.deltaTime * 2f);
			}
			else
			{
				Phase = Mathf.Clamp01(Phase - Time.deltaTime * 5f);
			}
			if ((Object)(object)Instance != (Object)null)
			{
				if (((VolumeParameter<float>)(object)Instance.intensity).value != Phase)
				{
					((VolumeParameter<float>)(object)Instance.intensity).value = Phase;
				}
				if (Phase > 0f && !LightAndFog.activeSelf)
				{
					MeshRenderer component = ((Component)GameNetworkManager.Instance.localPlayerController.localVisor.GetChild(0)).GetComponent<MeshRenderer>();
					((Renderer)component).materials[2].SetFloat("_Metallic", 1f);
					((Renderer)component).materials[2].SetFloat("_Smoothness", 0f);
					LightAndFog.SetActive(true);
				}
				if (Phase <= 0f && LightAndFog.activeSelf)
				{
					MeshRenderer component2 = ((Component)GameNetworkManager.Instance.localPlayerController.localVisor.GetChild(0)).GetComponent<MeshRenderer>();
					((Renderer)component2).materials[2].SetFloat("_Metallic", 0.69f);
					((Renderer)component2).materials[2].SetFloat("_Smoothness", 0.5f);
					LightAndFog.SetActive(false);
				}
			}
		}
	}
}
namespace AdvancedCompany.Patches
{
	[LoadAssets]
	[HarmonyPatch]
	public class AnimationPatches
	{
		private static RuntimeAnimatorController PlayerAnimator;

		private static RuntimeAnimatorController OtherPlayerAnimator;

		public static void LoadAssets(AssetBundle assets)
		{
			PlayerAnimator = assets.LoadAsset<RuntimeAnimatorController>("Assets/Animators/metarig.controller");
			OtherPlayerAnimator = assets.LoadAsset<RuntimeAnimatorController>("Assets/Animators/metarigOtherPlayers.controller");
		}

		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		[HarmonyPrefix]
		private static void Initialize(StartOfRound __instance)
		{
			__instance.otherClientsAnimatorController = OtherPlayerAnimator;
			__instance.localClientAnimatorController = PlayerAnimator;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Awake")]
		[HarmonyPostfix]
		public static void Awake(PlayerControllerB __instance)
		{
			__instance.playerBodyAnimator.runtimeAnimatorController = OtherPlayerAnimator;
		}
	}
	[HarmonyPatch]
	internal class BalancingPatches
	{
		public static float BaseValueMultiplier = 0.4f;

		[HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")]
		[HarmonyPrefix]
		public static void ChangeMaxScrapValue(RoundManager __instance)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Invalid comparison between Unknown and I4
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Invalid comparison between Unknown and I4
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Invalid comparison between Unknown and I4
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Invalid comparison between Unknown and I4
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Invalid comparison between Unknown and I4
			if (!ServerConfiguration.Instance.Moons.DeactivateWeatherMultipliers)
			{
				if ((int)__instance.currentLevel.currentWeather == 1)
				{
					__instance.scrapAmountMultiplier = ServerConfiguration.Instance.Moons.RainyScrapAmountMultiplier;
					__instance.scrapValueMultiplier = ServerConfiguration.Instance.Moons.RainyScrapValueMultiplier * BaseValueMultiplier;
				}
				else if ((int)__instance.currentLevel.currentWeather == 3)
				{
					__instance.scrapAmountMultiplier = ServerConfiguration.Instance.Moons.FoggyScrapAmountMultiplier;
					__instance.scrapValueMultiplier = ServerConfiguration.Instance.Moons.FoggyScrapValueMultiplier * BaseValueMultiplier;
				}
				else if ((int)__instance.currentLevel.currentWeather == 4)
				{
					__instance.scrapAmountMultiplier = ServerConfiguration.Instance.Moons.FloodedScrapAmountMultiplier;
					__instance.scrapValueMultiplier = ServerConfiguration.Instance.Moons.FloodedScrapValueMultiplier * BaseValueMultiplier;
				}
				else if ((int)__instance.currentLevel.currentWeather == 2)
				{
					__instance.scrapAmountMultiplier = ServerConfiguration.Instance.Moons.StormyScrapAmountMultiplier;
					__instance.scrapValueMultiplier = ServerConfiguration.Instance.Moons.StormyScrapValueMultiplier * BaseValueMultiplier;
				}
				else if ((int)__instance.currentLevel.currentWeather == 5)
				{
					__instance.scrapAmountMultiplier = ServerConfiguration.Instance.Moons.EclipsedScrapAmountMultiplier;
					__instance.scrapValueMultiplier = ServerConfiguration.Instance.Moons.EclipsedScrapValueMultiplier * BaseValueMultiplier;
				}
				else
				{
					__instance.scrapAmountMultiplier = ServerConfiguration.Instance.Moons.ClearScrapAmountMultiplier;
					__instance.scrapValueMultiplier = ServerConfiguration.Instance.Moons.ClearScrapValueMultiplier * BaseValueMultiplier;
				}
			}
		}
	}
	[HarmonyPatch]
	public class DebugPatches
	{
	}
	[HarmonyPatch]
	internal class EnemyAICollisionDetect
	{
		[HarmonyPatch(typeof(EnemyAICollisionDetect), "IHittable.Hit")]
		[HarmonyPrefix]
		private static void Hit(ref int force, Vector3 hitDirection, PlayerControllerB playerWhoHit, bool playHitSFX)
		{
			if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)playerWhoHit && Random.value < Perks.GetMultiplier("DealDamage"))
			{
				force += 100;
			}
		}
	}
	[HarmonyPatch]
	[LoadAssets]
	public class Flavour
	{
		private static Sprite Logo;

		private static Image HeaderImage;

		private static Image LoadImage;

		[HarmonyPatch(typeof(MenuManager), "Update")]
		[HarmonyPostfix]
		public static void Update()
		{
			if ((Object)(object)HeaderImage == (Object)null)
			{
				GameObject obj = GameObject.Find("HeaderImage");
				HeaderImage = ((obj != null) ? obj.GetComponent<Image>() : null) ?? null;
			}
			if ((Object)(object)LoadImage == (Object)null)
			{
				GameObject val = GameObject.Find("MenuContainer");
				for (int i = 0; i < val.transform.childCount; i++)
				{
					Transform child = val.transform.GetChild(i);
					if (!(((Object)child).name == "LoadingScreen"))
					{
						continue;
					}
					for (int j = 0; j < ((Component)child).transform.childCount; j++)
					{
						Transform child2 = ((Component)child).transform.GetChild(j);
						if (((Object)child2).name == "Image")
						{
							LoadImage = ((Component)child2).GetComponent<Image>();
						}
					}
					break;
				}
			}
			if ((Object)(object)HeaderImage != (Object)null && (Object)(object)HeaderImage.sprite != (Object)(object)Logo)
			{
				HeaderImage.sprite = Logo;
			}
			if ((Object)(object)LoadImage != (Object)null && (Object)(object)LoadImage.sprite != (Object)(object)Logo)
			{
				LoadImage.sprite = Logo;
			}
		}

		public static void LoadAssets(AssetBundle assets)
		{
			Logo = assets.LoadAsset<Sprite>("Assets/Icons/Logo.png");
		}
	}
	[HarmonyPatch]
	internal class GameNetworkManager
	{
		public static string KickReason;

		[HarmonyPatch(typeof(GameNetworkManager), "Singleton_OnClientConnectedCallback")]
		[HarmonyPrefix]
		private static void Singleton_OnClientConnectedCallback(GameNetworkManager __instance, ulong clientId)
		{
			AdvancedCompany.Network.Manager.NetworkManager_OnClientConnectedCallback(clientId);
		}

		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		[HarmonyPostfix]
		private static void Start(GameNetworkManager __instance)
		{
			AdvancedCompany.Network.Manager.Initialize();
			AdvancedCompany.Network.Manager.OnKicked = (AdvancedCompany.Network.Manager.Kicked)Delegate.Combine(AdvancedCompany.Network.Manager.OnKicked, (AdvancedCompany.Network.Manager.Kicked)delegate(string reason)
			{
				KickReason = reason;
			});
			AdvancedCompany.Network.Manager.OnLobbyCreated = (AdvancedCompany.Network.Manager.LobbyCreated)Delegate.Combine(AdvancedCompany.Network.Manager.OnLobbyCreated, (AdvancedCompany.Network.Manager.LobbyCreated)delegate
			{
				Player player2 = Player.GetPlayer(GameNetworkManager.Instance.localPlayerController);
				player2.LoadLocal();
				ServerConfiguration.Instance.LoadFromPreset(FileConfiguration.Instance);
				Lobby lobby = (AdvancedCompany.Network.Manager.Lobby = new Lobby
				{
					CurrentShip = Ship.Load(GameNetworkManager.Instance.currentSaveFileName),
					ConnectedPlayers = new Dictionary<ulong, Player> { { 0uL, player2 } }
				});
				ApplyConfiguration();
				Handshake handshake2 = new Handshake
				{
					ModVersion = "1.0.10",
					Player = player2
				};
				lobby.PlayerConnected(handshake2);
			});
			AdvancedCompany.Network.Manager.OnConnected = (AdvancedCompany.Network.Manager.Connected)Delegate.Combine(AdvancedCompany.Network.Manager.OnConnected, (AdvancedCompany.Network.Manager.Connected)delegate
			{
				Player player = Player.GetPlayer(GameNetworkManager.Instance.localPlayerController);
				player.LoadLocal();
				Handshake handshake = new Handshake
				{
					Player = player
				};
				Plugin.Log.LogMessage((object)("Sending handshake (" + player.ClientID + "):"));
				AdvancedCompany.Network.Manager.SendHandshake(handshake);
			});
			AdvancedCompany.Network.Manager.OnReceivedLobby = (AdvancedCompany.Network.Manager.ReceivedLobby)Delegate.Combine(AdvancedCompany.Network.Manager.OnReceivedLobby, (AdvancedCompany.Network.Manager.ReceivedLobby)delegate
			{
				ApplyConfiguration();
			});
		}

		public static void ApplyConfiguration()
		{
			Player player = Player.GetPlayer(GameNetworkManager.Instance.localPlayerController);
			bool flag = player.RemainingXP < 0;
			if (!flag)
			{
				foreach (Perk item in Perk.PerksByType(Perk.Type.PLAYER))
				{
					if (player.Levels.ContainsKey(item.ID) && player.Levels[item.ID] > 0 && (!item.IsActive || player.Levels[item.ID] > item.Levels))
					{
						flag = true;
					}
				}
			}
			if (flag)
			{
				AdvancedCompany.Network.Manager.Send(new Respec
				{
					ClientID = player.ClientID,
					Reset = false,
					Type = Perk.Type.PLAYER
				}, 0uL);
			}
			InventoryPatches.ArrangeHotbar(Perks.InventorySlotsOf(GameNetworkManager.Instance.localPlayerController));
			Perks.GameStarted();
		}

		[HarmonyPatch(typeof(GameNetworkManager), "SaveItemsInShip")]
		[HarmonyPostfix]
		public static void SaveItemsInShip(GameNetworkManager __instance)
		{
		}

		[HarmonyPatch(typeof(GameNetworkManager), "Disconnect")]
		[HarmonyPostfix]
		private static void Disconnect(GameNetworkManager __instance)
		{
		}

		[HarmonyPatch(typeof(GameNetworkManager), "SaveGame")]
		[HarmonyPrefix]
		private static void Save(GameNetworkManager __instance)
		{
			try
			{
				AdvancedCompany.Network.Manager.Lobby.Player().SaveLocal();
				if (NetworkManager.Singleton.IsServer)
				{
					AdvancedCompany.Network.Manager.Lobby.CurrentShip.Save(__instance.currentSaveFileName);
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)ex);
			}
		}

		[HarmonyPatch(typeof(GameNetworkManager), "ResetUnlockablesListValues")]
		[HarmonyPrefix]
		private static bool ResetClone(GameNetworkManager __instance)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)StartOfRound.Instance != (Object)null))
			{
				return true;
			}
			List<UnlockableItem> unlockables = StartOfRound.Instance.unlockablesList.unlockables;
			for (int i = 0; i < unlockables.Count; i++)
			{
				if (unlockables[i].unlockableType != 0)
				{
					unlockables[i].hasBeenUnlockedByPlayer = false;
				}
				if (unlockables[i].unlockableType == 1)
				{
					unlockables[i].placedPosition = Vector3.zero;
					unlockables[i].placedRotation = Vector3.zero;
					unlockables[i].hasBeenMoved = false;
					unlockables[i].inStorage = false;
				}
			}
			return false;
		}
	}
	[HarmonyPatch]
	internal class GrabbableObject
	{
		private static IEnumerable<CodeInstruction> PatchUpdate(IEnumerable<CodeInstruction> instructions)
		{
			Plugin.Log.LogMessage((object)"Patching GrabbableObject->Update...");
			PropertyInfo property = typeof(Perks).GetProperty("ExtraBatteryMultiplier", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Ldfld && list[i].operand.ToString() == "System.Single batteryUsage")
				{
					AdvancedCompany.IL.Patches.AddMultiplierInstruction("ExtraBattery", list, i + 1);
					break;
				}
			}
			return list.AsEnumerable();
		}

		[HarmonyPatch(typeof(GrabbableObject), "Update")]
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator, MethodBase method)
		{
			if (method.Name == "Update")
			{
				return PatchUpdate(instructions);
			}
			return instructions;
		}
	}
	[HarmonyPatch]
	internal class HUDManager
	{
		[HarmonyPatch(typeof(HUDManager), "MeetsScanNodeRequirements")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> PatchMeetsScanNodeRequirements(IEnumerable<CodeInstruction> instructions)
		{
			Plugin.Log.LogMessage((object)"Patching HUDManager->MeetsScanNodeRequirements...");
			PropertyInfo property = typeof(Perks).GetProperty("ScanDistanceMultiplier", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Ldfld && list[i].operand.ToString() == "System.Int32 maxRange")
				{
					AdvancedCompany.IL.Patches.AddMultiplierInstruction("ScanDistance", list, i + 2);
					break;
				}
			}
			return list.AsEnumerable();
		}
	}
	[HarmonyPatch]
	[LoadAssets]
	[Requires(typeof(ClientConfiguration))]
	[Bootable]
	public class InventoryPatches
	{
		public enum InventoryType
		{
			INVENTORY,
			HELMET,
			BODY,
			SHOES
		}

		private static InputAction InventorySlot1Action;

		private static InputAction InventorySlot2Action;

		private static InputAction InventorySlot3Action;

		private static InputAction InventorySlot4Action;

		private static InputAction InventorySlot5Action;

		private static InputAction InventorySlot6Action;

		private static InputAction InventorySlot7Action;

		private static InputAction InventorySlot8Action;

		private static InputAction InventorySlot9Action;

		private static InputAction InventorySlot10Action;

		private static InputAction FlashlightAction;

		private static InputAction NightVisionAction;

		public const int MAX_INVENTORY = 10;

		public static Image HelmetImage;

		public static Image BodyImage;

		public static Image ShoesImage;

		private static FieldInfo IsSendingItemRPCField = typeof(GrabbableObject).GetField("isSendingItemRPC", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);

		private static MethodInfo ActivateItemServerRpcMethod = typeof(GrabbableObject).GetMethod("ActivateItemServerRpc", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);

		private static FieldInfo FlashlightPreviousPlayerHeldBy = typeof(FlashlightItem).GetField("previousPlayerHeldBy", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);

		private static int OwnItemSlotResult;

		public static FieldInfo TimeSinceSwitchingSlotsField = AccessTools.Field(typeof(PlayerControllerB), "timeSinceSwitchingSlots");

		public static FieldInfo ThrowingObjectField = AccessTools.Field(typeof(PlayerControllerB), "throwingObject");

		public static MethodInfo NextItemMethod = AccessTools.Method(typeof(PlayerControllerB), "NextItemSlot", (Type[])null, (Type[])null);

		public static MethodInfo SwitchToItemSlotMethod = AccessTools.Method(typeof(PlayerControllerB), "SwitchToItemSlot", (Type[])null, (Type[])null);

		private static GameObject EnergyPrefab;

		private static AnimationClip EquipmentFrameAnimation;

		private static AnimationClip EquipmentFrameEnlargeAnimation;

		private static Sprite HelmetIcon;

		private static Sprite BodyIcon;

		private static Sprite ShoesIcon;

		private static GameObject[] EnergyBars = (GameObject[])(object)new GameObject[10];

		private static RectTransform[] EnergyInnerBars = (RectTransform[])(object)new RectTransform[10];

		private static GameObject ScaleCompensator;

		private static Transform Inventory;

		private static float PreviousAnchorMax = 0f;

		private static float PreviousWidth = 0f;

		private static bool UpdateNextFrame = false;

		private static FieldInfo CurrentlyGrabbingObjectField = typeof(PlayerControllerB).GetField("currentlyGrabbingObject", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);

		private static GrabbableObject HoveringObject;

		public static bool EquipmentSlotsAvailable => ServerConfiguration.Instance.Items.RocketBoots.Active || ServerConfiguration.Instance.Items.BulletProofVest.Active || ServerConfiguration.Instance.Items.NightVision.Active || ServerConfiguration.Instance.Items.SwimmingFins.Active;

		public static void Boot()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Expected O, but got Unknown
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Expected O, but got Unknown
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Expected O, but got Unknown
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Expected O, but got Unknown
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Expected O, but got Unknown
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Expected O, but got Unknown
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Expected O, but got Unknown
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Expected O, but got Unknown
			//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Expected O, but got Unknown
			InventorySlot1Action = new InputAction("InventorySlot1", (InputActionType)1, ClientConfiguration.Instance.Keybinds.InventorySlot1, (string)null, (string)null, (string)null);
			InventorySlot1Action.performed += delegate
			{
				ChangeToInventorySlot(0);
			};
			InventorySlot1Action.Enable();
			InventorySlot2Action = new InputAction("InventorySlot2", (InputActionType)1, ClientConfiguration.Instance.Keybinds.InventorySlot2, (string)null, (string)null, (string)null);
			InventorySlot2Action.performed += delegate
			{
				ChangeToInventorySlot(1);
			};
			InventorySlot2Action.Enable();
			InventorySlot3Action = new InputAction("InventorySlot3", (InputActionType)1, ClientConfiguration.Instance.Keybinds.InventorySlot3, (string)null, (string)null, (string)null);
			InventorySlot3Action.performed += delegate
			{
				ChangeToInventorySlot(2);
			};
			InventorySlot3Action.Enable();
			InventorySlot4Action = new InputAction("InventorySlot4", (InputActionType)1, ClientConfiguration.Instance.Keybinds.InventorySlot4, (string)null, (string)null, (string)null);
			InventorySlot4Action.performed += delegate
			{
				ChangeToInventorySlot(3);
			};
			InventorySlot4Action.Enable();
			InventorySlot5Action = new InputAction("InventorySlot5", (InputActionType)1, ClientConfiguration.Instance.Keybinds.InventorySlot5, (string)null, (string)null, (string)null);
			InventorySlot5Action.performed += delegate
			{
				ChangeToInventorySlot(4);
			};
			InventorySlot5Action.Enable();
			InventorySlot6Action = new InputAction("InventorySlot6", (InputActionType)1, ClientConfiguration.Instance.Keybinds.InventorySlot6, (string)null, (string)null, (string)null);
			InventorySlot6Action.performed += delegate
			{
				ChangeToInventorySlot(5);
			};
			InventorySlot6Action.Enable();
			InventorySlot7Action = new InputAction("InventorySlot7", (InputActionType)1, ClientConfiguration.Instance.Keybinds.InventorySlot7, (string)null, (string)null, (string)null);
			InventorySlot7Action.performed += delegate
			{
				ChangeToInventorySlot(6);
			};
			InventorySlot7Action.Enable();
			InventorySlot8Action = new InputAction("InventorySlot8", (InputActionType)1, ClientConfiguration.Instance.Keybinds.InventorySlot8, (string)null, (string)null, (string)null);
			InventorySlot8Action.performed += delegate
			{
				ChangeToInventorySlot(7);
			};
			InventorySlot8Action.Enable();
			InventorySlot9Action = new InputAction("InventorySlot9", (InputActionType)1, ClientConfiguration.Instance.Keybinds.InventorySlot9, (string)null, (string)null, (string)null);
			InventorySlot9Action.performed += delegate
			{
				ChangeToInventorySlot(8);
			};
			InventorySlot9Action.Enable();
			InventorySlot10Action = new InputAction("InventorySlot10", (InputActionType)1, ClientConfiguration.Instance.Keybinds.InventorySlot10, (string)null, (string)null, (string)null);
			InventorySlot10Action.performed += delegate
			{
				ChangeToInventorySlot(9);
			};
			InventorySlot10Action.Enable();
			FlashlightAction = new InputAction("Flashlight", (InputActionType)1, ClientConfiguration.Instance.Keybinds.Flashlight, (string)null, (string)null, (string)null);
			if (ClientConfiguration.Instance.Keybinds.Flashlight != ClientConfiguration.Instance.Keybinds.NightVision)
			{
				NightVisionAction = new InputAction("NightVision", (InputActionType)1, ClientConfiguration.Instance.Keybinds.NightVision, (string)null, (string)null, (string)null);
				NightVisionAction.performed += delegate
				{
					ToggleNightVision();
				};
				NightVisionAction.Enable();
				FlashlightAction.performed += delegate
				{
					ToggleFlashlight(ignoreHead: true);
				};
			}
			else
			{
				FlashlightAction.performed += delegate
				{
					ToggleFlashlight();
				};
			}
			FlashlightAction.Enable();
			AdvancedCompany.Network.Manager.AddListener(delegate(SwitchItem msg)
			{
				try
				{
					PlayerControllerB[] allPlayerScripts2 = StartOfRound.Instance.allPlayerScripts;
					foreach (PlayerControllerB val7 in allPlayerScripts2)
					{
						if (val7.playerClientId == msg.ClientID)
						{
							Plugin.Log.LogMessage((object)("Found client, switch to item " + msg.Slot));
							SwitchToItemSlotMethod.Invoke(val7, new object[2] { msg.Slot, null });
							break;
						}
					}
				}
				catch (Exception ex2)
				{
					Plugin.Log.LogError((object)ex2);
				}
			});
			AdvancedCompany.Network.Manager.AddListener(delegate(ChangeItemSlot msg)
			{
				try
				{
					PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
					foreach (PlayerControllerB val4 in allPlayerScripts)
					{
						if ((val4.isPlayerControlled || val4.isHostPlayerObject) && val4.playerClientId == msg.ClientID)
						{
							if ((Object)(object)val4.ItemSlots[msg.FromSlot] != (Object)null)
							{
								GrabbableObject val5 = val4.ItemSlots[msg.FromSlot];
								GrabbableObject val6 = val4.ItemSlots[msg.ToSlot];
								if ((Object)(object)val4 == (Object)(object)GameNetworkManager.Instance.localPlayerController)
								{
									Sprite sprite = HUDManager.Instance.itemSlotIcons[msg.ToSlot].sprite;
									bool enabled = ((Behaviour)HUDManager.Instance.itemSlotIcons[msg.ToSlot]).enabled;
									HUDManager.Instance.itemSlotIcons[msg.ToSlot].sprite = HUDManager.Instance.itemSlotIcons[msg.FromSlot].sprite;
									((Behaviour)HUDManager.Instance.itemSlotIcons[msg.ToSlot]).enabled = ((Behaviour)HUDManager.Instance.itemSlotIcons[msg.FromSlot]).enabled;
									HUDManager.Instance.itemSlotIcons[msg.FromSlot].sprite = sprite;
									((Behaviour)HUDManager.Instance.itemSlotIcons[msg.FromSlot]).enabled = enabled;
								}
								val4.ItemSlots[msg.FromSlot] = val6;
								val4.ItemSlots[msg.ToSlot] = val5;
								SwitchToItemSlotMethod.Invoke(val4, new object[2] { val4.currentItemSlot, null });
							}
							break;
						}
					}
				}
				catch (Exception ex)
				{
					Plugin.Log.LogError((object)ex);
				}
			});
			AdvancedCompany.Network.Manager.AddListener(delegate(UseFlashlight msg)
			{
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				Player playerByClientID = Player.GetPlayerByClientID(msg.ClientID);
				if (playerByClientID != null)
				{
					Plugin.Log.LogMessage((object)"Flashlight: Found player");
					GrabbableObject val = playerByClientID.Controller.ItemSlots[msg.Slot];
					if ((Object)(object)val != (Object)null)
					{
						FlashlightItem val2 = (FlashlightItem)(object)((val is FlashlightItem) ? val : null);
						if (val2 != null)
						{
							Plugin.Log.LogMessage((object)("Flashlight: Found flashlight on slot " + msg.Slot));
							val2.flashlightAudio.PlayOneShot(val2.flashlightClips[Random.Range(0, val2.flashlightClips.Length)]);
							RoundManager.Instance.PlayAudibleNoise(((Component)val2).transform.position, 7f, 0.4f, 0, ((GrabbableObject)val2).isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
							if (val2.flashlightInterferenceLevel < 2)
							{
								Plugin.Log.LogMessage((object)"Flashlight: Turning flashlight");
								if (!((GrabbableObject)val2).isBeingUsed)
								{
									for (int i = 0; i < playerByClientID.Controller.ItemSlots.Length; i++)
									{
										if (i != msg.Slot && (Object)(object)playerByClientID.Controller.ItemSlots[i] != (Object)null)
										{
											GrabbableObject obj2 = playerByClientID.Controller.ItemSlots[i];
											FlashlightItem val3 = (FlashlightItem)(object)((obj2 is FlashlightItem) ? obj2 : null);
											if (val3 != null)
											{
												if (((NetworkBehaviour)val3).IsOwner)
												{
													Plugin.Log.LogMessage((object)("Flashlight: Deactivating flashlight helmet light on " + i));
													if ((Object)(object)((GrabbableObject)val3).playerHeldBy != (Object)null)
													{
														((GrabbableObject)val3).playerHeldBy.ChangeHelmetLight(val3.flashlightTypeID, false);
													}
												}
												if (((GrabbableObject)val3).isBeingUsed)
												{
													Plugin.Log.LogMessage((object)("Flashlight: Deactivating flashlight on slot " + i));
													((GrabbableObject)val3).isBeingUsed = false;
													((Behaviour)val3.flashlightBulb).enabled = false;
													((Behaviour)val3.flashlightBulbGlow).enabled = false;
													if (val3.usingPlayerHelmetLight && (Object)(object)((GrabbableObject)val3).playerHeldBy != (Object)null)
													{
														((Behaviour)((GrabbableObject)val3).playerHeldBy.helmetLight).enabled = false;
													}
													if (val3.changeMaterial)
													{
														Material[] sharedMaterials = ((Renderer)val3.flashlightMesh).sharedMaterials;
														sharedMaterials[1] = val3.bulbDark;
														((Renderer)val3.flashlightMesh).sharedMaterials = sharedMaterials;
													}
												}
											}
										}
									}
								}
								if (!((GrabbableObject)val2).isBeingUsed && ((GrabbableObject)val2).insertedBattery != null && ((GrabbableObject)val2).insertedBattery.charge > 0f)
								{
									((GrabbableObject)val2).isBeingUsed = true;
								}
								else
								{
									((GrabbableObject)val2).isBeingUsed = false;
								}
								if (playerByClientID.Controller.currentItemSlot == msg.Slot)
								{
									Plugin.Log.LogMessage((object)"Flashlight: Flashlight is held");
									FlashlightPreviousPlayerHeldBy.SetValue(val2, ((GrabbableObject)val2).playerHeldBy);
									((GrabbableObject)val2).playerHeldBy.ChangeHelmetLight(val2.flashlightTypeID, true);
									((Behaviour)((GrabbableObject)val2).playerHeldBy.helmetLight).enabled = false;
									val2.usingPlayerHelmetLight = false;
									if (!((NetworkBehaviour)val2).IsOwner)
									{
										((GrabbableObject)val2).playerHeldBy.ChangeHelmetLight(val2.flashlightTypeID, ((GrabbableObject)val2).isBeingUsed);
										((Behaviour)val2.flashlightBulb).enabled = false;
										((Behaviour)val2.flashlightBulbGlow).enabled = false;
									}
									else
									{
										((Behaviour)val2.flashlightBulb).enabled = ((GrabbableObject)val2).isBeingUsed;
										((Behaviour)val2.flashlightBulbGlow).enabled = ((GrabbableObject)val2).isBeingUsed;
									}
									if (val2.changeMaterial)
									{
										Material[] sharedMaterials2 = ((Renderer)val2.flashlightMesh).sharedMaterials;
										if (((GrabbableObject)val2).isBeingUsed)
										{
											sharedMaterials2[1] = val2.bulbLight;
										}
										else
										{
											sharedMaterials2[1] = val2.bulbDark;
										}
										((Renderer)val2.flashlightMesh).sharedMaterials = sharedMaterials2;
									}
								}
								else
								{
									Plugin.Log.LogMessage((object)"Flashlight: Flashlight is pocketed");
									((Behaviour)val2.flashlightBulb).enabled = false;
									((Behaviour)val2.flashlightBulbGlow).enabled = false;
									((GrabbableObject)val2).playerHeldBy.ChangeHelmetLight(val2.flashlightTypeID, true);
									if (!((NetworkBehaviour)val2).IsOwn

BeplnEx/plugins/AdvancedCompany.Unity.dll

Decompiled 2 years ago
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
[CompilerGenerated]
[EditorBrowsable(EditorBrowsableState.Never)]
[GeneratedCode("Unity.MonoScriptGenerator.MonoScriptInfoGenerator", null)]
internal class UnitySourceGeneratedAssemblyMonoScriptTypes_v1
{
	private struct MonoScriptData
	{
		public byte[] FilePathsData;

		public byte[] TypesData;

		public int TotalTypes;

		public int TotalFiles;

		public bool IsEditorOnly;
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	private static MonoScriptData Get()
	{
		MonoScriptData result = default(MonoScriptData);
		result.FilePathsData = new byte[81]
		{
			0, 0, 0, 1, 0, 0, 0, 34, 92, 65,
			115, 115, 101, 116, 115, 92, 83, 99, 114, 105,
			112, 116, 115, 92, 83, 104, 97, 114, 101, 100,
			92, 73, 116, 101, 109, 68, 97, 116, 97, 46,
			99, 115, 0, 0, 0, 1, 0, 0, 0, 31,
			92, 65, 115, 115, 101, 116, 115, 92, 83, 99,
			114, 105, 112, 116, 115, 92, 83, 104, 97, 114,
			101, 100, 92, 77, 111, 111, 110, 115, 46, 99,
			115
		};
		result.TypesData = new byte[65]
		{
			0, 0, 0, 0, 29, 65, 100, 118, 97, 110,
			99, 101, 100, 67, 111, 109, 112, 97, 110, 121,
			46, 71, 97, 109, 101, 124, 73, 116, 101, 109,
			68, 97, 116, 97, 0, 0, 0, 0, 26, 65,
			100, 118, 97, 110, 99, 101, 100, 67, 111, 109,
			112, 97, 110, 121, 46, 71, 97, 109, 101, 124,
			77, 111, 111, 110, 115
		};
		result.TotalFiles = 2;
		result.TotalTypes = 2;
		result.IsEditorOnly = false;
		return result;
	}
}
namespace AdvancedCompany.Game;

public class ItemData : MonoBehaviour
{
	public int ID;

	public string ItemName;

	public Sprite ItemIcon;

	public float Weight;

	public bool IsConductive;

	public bool IsTwoHanded;

	public bool IsScrap;

	public int MinValue;

	public int MaxValue;

	public int Rarity = 100;

	public bool LimitPlanets;

	public int[] PlanetRarities = new int[9];

	public bool UsesBattery;

	public float BatteryUsage;

	public bool IsBuyable;

	public int Price;

	public int MaxDiscount;

	public AudioClip GrabSFX;

	public AudioClip DropSFX;

	public AudioClip PocketSFX;

	public string HoldAnimation;

	public bool HoldIsTwoHanded;

	public bool HasSaveData;

	public bool SyncUseFunction;

	public bool SyncInteractLRFunction;

	public bool SyncGrabFunction;

	public bool SyncDiscardFunction;

	public Vector3 EgoHeldPosition;

	public Vector3 EgoHeldRotation;

	public Vector3 HeldPosition;

	public Vector3 HeldRotation;

	public Vector3 GroundRestingRotation;

	public float GroundVerticalOffset;

	public Vector3 HolderRestingRotation;

	public Vector3 NoPosition;
}
public static class Moons
{
	public const int Count = 9;

	public const int COMPANY_BUILDING = 0;

	public const int EXPERIMENTATION = 1;

	public const int VOW = 2;

	public const int ASSURANCE = 3;

	public const int OFFENSE = 4;

	public const int MARCH = 5;

	public const int REND = 6;

	public const int DINE = 7;

	public const int TITAN = 8;
}

BeplnEx/plugins/LethalThings.dll

Decompiled 2 years ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using LethalLib.Extras;
using LethalLib.Modules;
using LethalThings.Extensions;
using LethalThings.MonoBehaviours;
using LethalThings.Patches;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
using On;
using On.GameNetcodeStuff;
using TMPro;
using Unity.Netcode;
using Unity.Netcode.Components;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LethalThings")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Mod for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+86ae65aa973bc30ae45609c9c37649bfb7da4c59")]
[assembly: AssemblyProduct("LethalThings")]
[assembly: AssemblyTitle("LethalThings")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
internal class <Module>
{
	static <Module>()
	{
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>();
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<Vector3>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<Vector3>();
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<float>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<float>();
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<HackingTool.HackState>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedValueEquals<HackingTool.HackState>();
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LethalLib.Modules
{
	public class SaveData
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_ResetSavedGameValues <0>__GameNetworkManager_ResetSavedGameValues;

			public static hook_SaveItemsInShip <1>__GameNetworkManager_SaveItemsInShip;

			public static hook_LoadShipGrabbableItems <2>__StartOfRound_LoadShipGrabbableItems;
		}

		public static List<string> saveKeys = new List<string>();

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			object obj = <>O.<0>__GameNetworkManager_ResetSavedGameValues;
			if (obj == null)
			{
				hook_ResetSavedGameValues val = GameNetworkManager_ResetSavedGameValues;
				<>O.<0>__GameNetworkManager_ResetSavedGameValues = val;
				obj = (object)val;
			}
			GameNetworkManager.ResetSavedGameValues += (hook_ResetSavedGameValues)obj;
			object obj2 = <>O.<1>__GameNetworkManager_SaveItemsInShip;
			if (obj2 == null)
			{
				hook_SaveItemsInShip val2 = GameNetworkManager_SaveItemsInShip;
				<>O.<1>__GameNetworkManager_SaveItemsInShip = val2;
				obj2 = (object)val2;
			}
			GameNetworkManager.SaveItemsInShip += (hook_SaveItemsInShip)obj2;
			object obj3 = <>O.<2>__StartOfRound_LoadShipGrabbableItems;
			if (obj3 == null)
			{
				hook_LoadShipGrabbableItems val3 = StartOfRound_LoadShipGrabbableItems;
				<>O.<2>__StartOfRound_LoadShipGrabbableItems = val3;
				obj3 = (object)val3;
			}
			StartOfRound.LoadShipGrabbableItems += (hook_LoadShipGrabbableItems)obj3;
		}

		private static void StartOfRound_LoadShipGrabbableItems(orig_LoadShipGrabbableItems orig, StartOfRound self)
		{
			orig.Invoke(self);
			SaveableObject[] array = Object.FindObjectsOfType<SaveableObject>();
			SaveableNetworkBehaviour[] array2 = Object.FindObjectsOfType<SaveableNetworkBehaviour>();
			SaveableObject[] array3 = array;
			for (int i = 0; i < array3.Length; i++)
			{
				array3[i].LoadObjectData();
			}
			SaveableNetworkBehaviour[] array4 = array2;
			for (int i = 0; i < array4.Length; i++)
			{
				array4[i].LoadObjectData();
			}
			if (ES3.KeyExists("LethalLibItemSaveKeys", GameNetworkManager.Instance.currentSaveFileName))
			{
				saveKeys = ES3.Load<List<string>>("LethalLibItemSaveKeys", GameNetworkManager.Instance.currentSaveFileName);
			}
		}

		private static void GameNetworkManager_SaveItemsInShip(orig_SaveItemsInShip orig, GameNetworkManager self)
		{
			orig.Invoke(self);
			SaveableObject[] array = Object.FindObjectsOfType<SaveableObject>();
			SaveableNetworkBehaviour[] array2 = Object.FindObjectsOfType<SaveableNetworkBehaviour>();
			SaveableObject[] array3 = array;
			for (int i = 0; i < array3.Length; i++)
			{
				array3[i].SaveObjectData();
			}
			SaveableNetworkBehaviour[] array4 = array2;
			for (int i = 0; i < array4.Length; i++)
			{
				array4[i].SaveObjectData();
			}
			ES3.Save<List<string>>("LethalLibItemSaveKeys", saveKeys, GameNetworkManager.Instance.currentSaveFileName);
		}

		private static void GameNetworkManager_ResetSavedGameValues(orig_ResetSavedGameValues orig, GameNetworkManager self)
		{
			orig.Invoke(self);
			foreach (string saveKey in saveKeys)
			{
				ES3.DeleteKey(saveKey, GameNetworkManager.Instance.currentSaveFileName);
			}
			saveKeys.Clear();
		}

		public static void SaveObjectData<T>(string key, T data, int objectId)
		{
			List<T> list = new List<T>();
			if (ES3.KeyExists("LethalThingsSave_" + key, GameNetworkManager.Instance.currentSaveFileName))
			{
				list = ES3.Load<List<T>>("LethalThingsSave_" + key, GameNetworkManager.Instance.currentSaveFileName);
			}
			List<int> list2 = new List<int>();
			if (ES3.KeyExists("LethalThingsSave_objectIds_" + key, GameNetworkManager.Instance.currentSaveFileName))
			{
				list2 = ES3.Load<List<int>>("LethalThingsSave_objectIds_" + key, GameNetworkManager.Instance.currentSaveFileName);
			}
			list.Add(data);
			list2.Add(objectId);
			if (!saveKeys.Contains("LethalThingsSave_" + key))
			{
				saveKeys.Add("LethalThingsSave_" + key);
			}
			if (!saveKeys.Contains("LethalThingsSave_objectIds_" + key))
			{
				saveKeys.Add("LethalThingsSave_objectIds_" + key);
			}
			ES3.Save<List<T>>("LethalThingsSave_" + key, list, GameNetworkManager.Instance.currentSaveFileName);
			ES3.Save<List<int>>("LethalThingsSave_objectIds_" + key, list2, GameNetworkManager.Instance.currentSaveFileName);
		}

		public static T LoadObjectData<T>(string key, int objectId)
		{
			List<T> list = new List<T>();
			if (ES3.KeyExists("LethalThingsSave_" + key, GameNetworkManager.Instance.currentSaveFileName))
			{
				list = ES3.Load<List<T>>("LethalThingsSave_" + key, GameNetworkManager.Instance.currentSaveFileName);
			}
			List<int> list2 = new List<int>();
			if (ES3.KeyExists("LethalThingsSave_objectIds_" + key, GameNetworkManager.Instance.currentSaveFileName))
			{
				list2 = ES3.Load<List<int>>("LethalThingsSave_objectIds_" + key, GameNetworkManager.Instance.currentSaveFileName);
			}
			if (!saveKeys.Contains("LethalThingsSave_" + key))
			{
				saveKeys.Add("LethalThingsSave_" + key);
			}
			if (!saveKeys.Contains("LethalThingsSave_objectIds_" + key))
			{
				saveKeys.Add("LethalThingsSave_objectIds_" + key);
			}
			if (list2.Contains(objectId))
			{
				int index = list2.IndexOf(objectId);
				return list[index];
			}
			return default(T);
		}
	}
}
namespace LethalThings
{
	public class Config
	{
		public static ConfigEntry<int> arsonSpawnWeight;

		public static ConfigEntry<int> dirtyArsonSpawnWeight;

		public static ConfigEntry<int> toimariSpawnWeight;

		public static ConfigEntry<int> hamisSpawnWeight;

		public static ConfigEntry<int> cookieSpawnWeight;

		public static ConfigEntry<int> maxwellSpawnWeight;

		public static ConfigEntry<float> evilMaxwellChance;

		public static ConfigEntry<bool> maxwellPlayMusicDefault;

		public static ConfigEntry<int> glizzySpawnChance;

		public static ConfigEntry<int> revolverSpawnChance;

		public static ConfigEntry<int> gremlinSodaSpawnChance;

		public static ConfigEntry<bool> toyHammerEnabled;

		public static ConfigEntry<int> toyHammerPrice;

		public static ConfigEntry<bool> pouchyBeltEnabled;

		public static ConfigEntry<int> pouchyBeltPrice;

		public static ConfigEntry<bool> remoteRadarEnabled;

		public static ConfigEntry<int> remoteRadarPrice;

		public static ConfigEntry<bool> rocketLauncherEnabled;

		public static ConfigEntry<int> rocketLauncherPrice;

		public static ConfigEntry<bool> hackingToolEnabled;

		public static ConfigEntry<int> hackingToolPrice;

		public static ConfigEntry<bool> flareGunEnabled;

		public static ConfigEntry<int> flareGunPrice;

		public static ConfigEntry<int> flareGunAmmoPrice;

		public static ConfigEntry<int> boombaSpawnWeight;

		public static ConfigEntry<bool> rugsEnabled;

		public static ConfigEntry<int> smallRugPrice;

		public static ConfigEntry<int> largeRugPrice;

		public static ConfigEntry<bool> fatalitiesSignEnabled;

		public static ConfigEntry<int> fatalitiesSignPrice;

		public static ConfigEntry<bool> dartBoardEnabled;

		public static ConfigEntry<int> dartBoardPrice;

		public static ConfigEntry<bool> teleporterTrapsEnabled;

		public static ConfigEntry<bool> enableItemChargerElectrocution;

		public static ConfigEntry<int> itemChargerElectrocutionDamage;

		public static ConfigEntry<bool> disableOverlappingModContent;

		public static ConfigFile VolumeConfig;

		public static ConfigEntry<string> version;

		public static void Load()
		{
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b8: Expected O, but got Unknown
			arsonSpawnWeight = Plugin.config.Bind<int>("Scrap", "Arson", 5, "How much does Arson spawn, higher = more common");
			dirtyArsonSpawnWeight = Plugin.config.Bind<int>("Scrap", "DirtyArson", 5, "How much does Arson (Dirty) spawn, higher = more common");
			toimariSpawnWeight = Plugin.config.Bind<int>("Scrap", "Toimari", 10, "How much does Toimari spawn, higher = more common");
			hamisSpawnWeight = Plugin.config.Bind<int>("Scrap", "Hamis", 10, "How much does Hamis spawn, higher = more common");
			cookieSpawnWeight = Plugin.config.Bind<int>("Scrap", "Cookie", 10, "How much does Cookie spawn, higher = more common");
			maxwellSpawnWeight = Plugin.config.Bind<int>("Scrap", "Maxwell", 3, "How much does Maxwell spawn, higher = more common");
			evilMaxwellChance = Plugin.config.Bind<float>("Scrap", "MaxwellEvilChance", 10f, "Chance for maxwell to be evil, percentage.");
			maxwellPlayMusicDefault = Plugin.config.Bind<bool>("Scrap", "MaxwellPlayMusicDefault", true, "Does Maxwell play music by default?");
			glizzySpawnChance = Plugin.config.Bind<int>("Scrap", "GlizzySpawnChance", 5, "How much do glizzies spawn, higher = more common");
			revolverSpawnChance = Plugin.config.Bind<int>("Scrap", "Revolver", 10, "How much do revolvers spawn, higher = more common");
			gremlinSodaSpawnChance = Plugin.config.Bind<int>("Scrap", "GremlinEnergyDrink", 10, "How much does Gremlin Energy Drink spawn, higher = more common");
			toyHammerEnabled = Plugin.config.Bind<bool>("Items", "ToyHammer", true, "Is Toy Hammer enabled?");
			toyHammerPrice = Plugin.config.Bind<int>("Items", "ToyHammerPrice", 15, "How much does Toy Hammer cost?");
			pouchyBeltEnabled = Plugin.config.Bind<bool>("Items", "PouchyBelt", true, "Is Pouchy Belt enabled?");
			pouchyBeltPrice = Plugin.config.Bind<int>("Items", "PouchyBeltPrice", 290, "How much does Pouchy Belt cost?");
			remoteRadarEnabled = Plugin.config.Bind<bool>("Items", "RemoteRadar", true, "Is Remote Radar enabled?");
			remoteRadarPrice = Plugin.config.Bind<int>("Items", "RemoteRadarPrice", 150, "How much does Remote Radar cost?");
			rocketLauncherEnabled = Plugin.config.Bind<bool>("Items", "RocketLauncher", true, "Is Rocket Launcher enabled?");
			rocketLauncherPrice = Plugin.config.Bind<int>("Items", "RocketLauncherPrice", 300, "How much does Rocket Launcher cost?");
			hackingToolEnabled = Plugin.config.Bind<bool>("Items", "HackingTool", true, "Is Hacking Tool enabled?");
			hackingToolPrice = Plugin.config.Bind<int>("Items", "HackingToolPrice", 120, "How much does Hacking Tool cost?");
			flareGunEnabled = Plugin.config.Bind<bool>("Items", "FlareGun", true, "Is Flare Gun enabled?");
			flareGunPrice = Plugin.config.Bind<int>("Items", "FlareGunPrice", 100, "How much does Flare Gun cost?");
			flareGunAmmoPrice = Plugin.config.Bind<int>("Items", "FlareGunAmmoPrice", 20, "How much does Flare Gun ammo cost?");
			boombaSpawnWeight = Plugin.config.Bind<int>("Enemies", "Boomba", 20, "How much does Boomba spawn, higher = more common");
			rugsEnabled = Plugin.config.Bind<bool>("Decor", "Rugs", true, "Are rugs enabled?");
			smallRugPrice = Plugin.config.Bind<int>("Decor", "SmallRugPrice", 80, "How much does a small rug cost?");
			largeRugPrice = Plugin.config.Bind<int>("Decor", "LargeRugPrice", 110, "How much does a large rug cost?");
			fatalitiesSignEnabled = Plugin.config.Bind<bool>("Decor", "FatalitiesSign", true, "Is Fatalities Sign enabled?");
			fatalitiesSignPrice = Plugin.config.Bind<int>("Decor", "FatalitiesSignPrice", 100, "How much does Fatalities Sign cost?");
			dartBoardEnabled = Plugin.config.Bind<bool>("Decor", "DartBoard", true, "Is Dart Board enabled?");
			dartBoardPrice = Plugin.config.Bind<int>("Decor", "DartBoardPrice", 120, "How much does Dart Board cost?");
			teleporterTrapsEnabled = Plugin.config.Bind<bool>("Traps", "TeleporterTraps", true, "Are teleporter traps enabled?");
			enableItemChargerElectrocution = Plugin.config.Bind<bool>("Misc", "EnableItemChargerElectrocution", true, "Do players get electrocuted when stuffing conductive objects in the item charger.");
			itemChargerElectrocutionDamage = Plugin.config.Bind<int>("Misc", "ItemChargerElectrocutionDamage", 20, "How much damage does the item charger electrocution do.");
			disableOverlappingModContent = Plugin.config.Bind<bool>("Misc", "DisableOverlappingModContent", true, "Disable content from other mods which exists in this one (e.g. maxwell).");
			version = Plugin.config.Bind<string>("Misc", "Version", "1.0.0", "Version of the mod config.");
			VolumeConfig = new ConfigFile(Paths.ConfigPath + "\\LethalThings.AudioVolume.cfg", true);
		}
	}
	public class Content
	{
		public class CustomItem
		{
			public string name = "";

			public string itemPath = "";

			public string infoPath = "";

			public Action<Item> itemAction = delegate
			{
			};

			public bool enabled = true;

			public CustomItem(string name, string itemPath, string infoPath, Action<Item> action = null)
			{
				this.name = name;
				this.itemPath = itemPath;
				this.infoPath = infoPath;
				if (action != null)
				{
					itemAction = action;
				}
			}

			public static CustomItem Add(string name, string itemPath, string infoPath = null, Action<Item> action = null)
			{
				return new CustomItem(name, itemPath, infoPath, action);
			}
		}

		public class CustomUnlockable
		{
			public string name = "";

			public string unlockablePath = "";

			public string infoPath = "";

			public Action<UnlockableItem> unlockableAction = delegate
			{
			};

			public bool enabled = true;

			public int unlockCost = -1;

			public CustomUnlockable(string name, string unlockablePath, string infoPath, Action<UnlockableItem> action = null, int unlockCost = -1)
			{
				this.name = name;
				this.unlockablePath = unlockablePath;
				this.infoPath = infoPath;
				if (action != null)
				{
					unlockableAction = action;
				}
				this.unlockCost = unlockCost;
			}

			public static CustomUnlockable Add(string name, string unlockablePath, string infoPath = null, Action<UnlockableItem> action = null, int unlockCost = -1, bool enabled = true)
			{
				return new CustomUnlockable(name, unlockablePath, infoPath, action, unlockCost)
				{
					enabled = enabled
				};
			}
		}

		public class CustomShopItem : CustomItem
		{
			public int itemPrice;

			public CustomShopItem(string name, string itemPath, string infoPath = null, int itemPrice = 0, Action<Item> action = null)
				: base(name, itemPath, infoPath, action)
			{
				this.itemPrice = itemPrice;
			}

			public static CustomShopItem Add(string name, string itemPath, string infoPath = null, int itemPrice = 0, Action<Item> action = null, bool enabled = true)
			{
				return new CustomShopItem(name, itemPath, infoPath, itemPrice, action)
				{
					enabled = enabled
				};
			}
		}

		public class CustomScrap : CustomItem
		{
			public LevelTypes levelType = (LevelTypes)510;

			public int rarity;

			public CustomScrap(string name, string itemPath, LevelTypes levelType, int rarity, Action<Item> action = null)
				: base(name, itemPath, null, action)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				this.levelType = levelType;
				this.rarity = rarity;
			}

			public static CustomScrap Add(string name, string itemPath, LevelTypes levelType, int rarity, Action<Item> action = null)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				return new CustomScrap(name, itemPath, levelType, rarity, action);
			}
		}

		public class CustomPlainItem : CustomItem
		{
			public CustomPlainItem(string name, string itemPath, Action<Item> action = null)
				: base(name, itemPath, null, action)
			{
			}

			public static CustomPlainItem Add(string name, string itemPath, Action<Item> action = null)
			{
				return new CustomPlainItem(name, itemPath, action);
			}
		}

		public class CustomEnemy
		{
			public string name;

			public string enemyPath;

			public int rarity;

			public LevelTypes levelFlags;

			public SpawnType spawnType;

			public string infoKeyword;

			public string infoNode;

			public bool enabled = true;

			public CustomEnemy(string name, string enemyPath, int rarity, LevelTypes levelFlags, SpawnType spawnType, string infoKeyword, string infoNode)
			{
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				this.name = name;
				this.enemyPath = enemyPath;
				this.rarity = rarity;
				this.levelFlags = levelFlags;
				this.spawnType = spawnType;
				this.infoKeyword = infoKeyword;
				this.infoNode = infoNode;
			}

			public static CustomEnemy Add(string name, string enemyPath, int rarity, LevelTypes levelFlags, SpawnType spawnType, string infoKeyword, string infoNode, bool enabled = true)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0004: Unknown result type (might be due to invalid IL or missing references)
				return new CustomEnemy(name, enemyPath, rarity, levelFlags, spawnType, infoKeyword, infoNode)
				{
					enabled = enabled
				};
			}
		}

		public class CustomMapObject
		{
			public string name;

			public string objectPath;

			public LevelTypes levelFlags;

			public Func<SelectableLevel, AnimationCurve> spawnRateFunction;

			public bool enabled = true;

			public CustomMapObject(string name, string objectPath, LevelTypes levelFlags, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null, bool enabled = false)
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				this.name = name;
				this.objectPath = objectPath;
				this.levelFlags = levelFlags;
				this.spawnRateFunction = spawnRateFunction;
				this.enabled = enabled;
			}

			public static CustomMapObject Add(string name, string objectPath, LevelTypes levelFlags, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null, bool enabled = false)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				return new CustomMapObject(name, objectPath, levelFlags, spawnRateFunction, enabled);
			}
		}

		public static AssetBundle MainAssets;

		public static Dictionary<string, GameObject> Prefabs = new Dictionary<string, GameObject>();

		public static GameObject devMenuPrefab;

		public static List<CustomUnlockable> customUnlockables;

		public static List<CustomItem> customItems;

		public static List<CustomEnemy> customEnemies;

		public static List<CustomMapObject> customMapObjects;

		public static GameObject ConfigManagerPrefab;

		public static void TryLoadAssets()
		{
			if ((Object)(object)MainAssets == (Object)null)
			{
				MainAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "lethalthings"));
				Plugin.logger.LogInfo((object)"Loaded asset bundle");
			}
		}

		public static void Load()
		{
			//IL_0583: Unknown result type (might be due to invalid IL or missing references)
			//IL_070f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0716: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a5: Unknown result type (might be due to invalid IL or missing references)
			TryLoadAssets();
			customItems = new List<CustomItem>
			{
				CustomScrap.Add("Arson", "Assets/Custom/LethalThings/Scrap/Arson/ArsonPlush.asset", (LevelTypes)510, Config.arsonSpawnWeight.Value),
				CustomScrap.Add("Cookie", "Assets/Custom/LethalThings/Scrap/Cookie/CookieFumo.asset", (LevelTypes)510, Config.cookieSpawnWeight.Value),
				CustomScrap.Add("Bilka", "Assets/Custom/LethalThings/Scrap/Toimari/ToimariPlush.asset", (LevelTypes)510, Config.toimariSpawnWeight.Value),
				CustomScrap.Add("Hamis", "Assets/Custom/LethalThings/Scrap/Hamis/HamisPlush.asset", (LevelTypes)510, Config.hamisSpawnWeight.Value),
				CustomScrap.Add("ArsonDirty", "Assets/Custom/LethalThings/Scrap/Arson/ArsonPlushDirty.asset", (LevelTypes)510, Config.dirtyArsonSpawnWeight.Value),
				CustomScrap.Add("Maxwell", "Assets/Custom/LethalThings/Scrap/Maxwell/Dingus.asset", (LevelTypes)510, Config.maxwellSpawnWeight.Value),
				CustomScrap.Add("Glizzy", "Assets/Custom/LethalThings/Scrap/glizzy/glizzy.asset", (LevelTypes)510, Config.glizzySpawnChance.Value),
				CustomScrap.Add("Revolver", "Assets/Custom/LethalThings/Scrap/Flaggun/Toygun.asset", (LevelTypes)510, Config.revolverSpawnChance.Value),
				CustomShopItem.Add("RocketLauncher", "Assets/Custom/LethalThings/Items/RocketLauncher/RocketLauncher.asset", "Assets/Custom/LethalThings/Items/RocketLauncher/RocketLauncherInfo.asset", Config.rocketLauncherPrice.Value, delegate(Item item)
				{
					NetworkPrefabs.RegisterNetworkPrefab(item.spawnPrefab.GetComponent<RocketLauncher>().missilePrefab);
				}, Config.rocketLauncherEnabled.Value),
				CustomShopItem.Add("Flaregun", "Assets/Custom/LethalThings/Items/Flaregun/Flaregun.asset", "Assets/Custom/LethalThings/Items/Flaregun/FlaregunInfo.asset", Config.flareGunPrice.Value, delegate(Item item)
				{
					NetworkPrefabs.RegisterNetworkPrefab(item.spawnPrefab.GetComponent<ProjectileWeapon>().projectilePrefab);
				}, Config.flareGunEnabled.Value),
				CustomShopItem.Add("FlaregunAmmo", "Assets/Custom/LethalThings/Items/Flaregun/FlaregunAmmo.asset", "Assets/Custom/LethalThings/Items/Flaregun/FlaregunAmmoInfo.asset", Config.flareGunAmmoPrice.Value, null, Config.flareGunEnabled.Value),
				CustomShopItem.Add("ToyHammer", "Assets/Custom/LethalThings/Items/ToyHammer/ToyHammer.asset", "Assets/Custom/LethalThings/Items/ToyHammer/ToyHammerInfo.asset", Config.toyHammerPrice.Value, null, Config.toyHammerEnabled.Value),
				CustomShopItem.Add("RemoteRadar", "Assets/Custom/LethalThings/Items/Radar/HandheldRadar.asset", "Assets/Custom/LethalThings/Items/Radar/HandheldRadarInfo.asset", Config.remoteRadarPrice.Value, null, Config.remoteRadarEnabled.Value),
				CustomShopItem.Add("PouchyBelt", "Assets/Custom/LethalThings/Items/Pouch/Pouch.asset", "Assets/Custom/LethalThings/Items/Pouch/PouchInfo.asset", Config.pouchyBeltPrice.Value, null, Config.pouchyBeltEnabled.Value),
				CustomShopItem.Add("HackingTool", "Assets/Custom/LethalThings/Items/HackingTool/HackingTool.asset", "Assets/Custom/LethalThings/Items/HackingTool/HackingToolInfo.asset", Config.hackingToolPrice.Value, null, Config.hackingToolEnabled.Value),
				CustomPlainItem.Add("Dart", "Assets/Custom/LethalThings/Unlockables/dartboard/Dart.asset"),
				CustomScrap.Add("GremlinEnergy", "Assets/Custom/LethalThings/Scrap/GremlinEnergy/GremlinEnergy.asset", (LevelTypes)510, Config.gremlinSodaSpawnChance.Value)
			};
			customEnemies = new List<CustomEnemy> { CustomEnemy.Add("Boomba", "Assets/Custom/LethalThings/Enemies/Roomba/Boomba.asset", Config.boombaSpawnWeight.Value, (LevelTypes)510, (SpawnType)0, null, "Assets/Custom/LethalThings/Enemies/Roomba/BoombaFile.asset") };
			customUnlockables = new List<CustomUnlockable>
			{
				CustomUnlockable.Add("SmallRug", "Assets/Custom/LethalThings/Unlockables/Rug/SmallRug.asset", "Assets/Custom/LethalThings/Unlockables/Rug/RugInfo.asset", null, Config.smallRugPrice.Value, Config.rugsEnabled.Value),
				CustomUnlockable.Add("LargeRug", "Assets/Custom/LethalThings/Unlockables/Rug/LargeRug.asset", "Assets/Custom/LethalThings/Unlockables/Rug/RugInfo.asset", null, Config.largeRugPrice.Value, Config.rugsEnabled.Value),
				CustomUnlockable.Add("FatalitiesSign", "Assets/Custom/LethalThings/Unlockables/Sign/Sign.asset", "Assets/Custom/LethalThings/Unlockables/Sign/SignInfo.asset", null, Config.fatalitiesSignPrice.Value, Config.fatalitiesSignEnabled.Value),
				CustomUnlockable.Add("Dartboard", "Assets/Custom/LethalThings/Unlockables/dartboard/Dartboard.asset", "Assets/Custom/LethalThings/Unlockables/dartboard/DartboardInfo.asset", null, Config.dartBoardPrice.Value, Config.dartBoardEnabled.Value)
			};
			customMapObjects = new List<CustomMapObject> { CustomMapObject.Add("TeleporterTrap", "Assets/Custom/LethalThings/hazards/TeleporterTrap/TeleporterTrap.asset", (LevelTypes)510, (SelectableLevel level) => new AnimationCurve((Keyframe[])(object)new Keyframe[2]
			{
				new Keyframe(0f, 0f),
				new Keyframe(1f, 4f)
			}), Config.teleporterTrapsEnabled.Value) };
			foreach (CustomItem customItem in customItems)
			{
				if (customItem.enabled)
				{
					Item val = MainAssets.LoadAsset<Item>(customItem.itemPath);
					if ((Object)(object)val.spawnPrefab.GetComponent<NetworkTransform>() == (Object)null && (Object)(object)val.spawnPrefab.GetComponent<CustomNetworkTransform>() == (Object)null)
					{
						NetworkTransform obj = val.spawnPrefab.AddComponent<NetworkTransform>();
						obj.SlerpPosition = false;
						obj.Interpolate = false;
						obj.SyncPositionX = false;
						obj.SyncPositionY = false;
						obj.SyncPositionZ = false;
						obj.SyncScaleX = false;
						obj.SyncScaleY = false;
						obj.SyncScaleZ = false;
						obj.UseHalfFloatPrecision = true;
					}
					Prefabs.Add(customItem.name, val.spawnPrefab);
					NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
					customItem.itemAction(val);
					if (customItem is CustomShopItem)
					{
						TerminalNode val2 = MainAssets.LoadAsset<TerminalNode>(customItem.infoPath);
						Plugin.logger.LogInfo((object)$"Registering shop item {customItem.name} with price {((CustomShopItem)customItem).itemPrice}");
						Items.RegisterShopItem(val, (TerminalNode)null, (TerminalNode)null, val2, ((CustomShopItem)customItem).itemPrice);
					}
					else if (customItem is CustomScrap)
					{
						Items.RegisterScrap(val, ((CustomScrap)customItem).rarity, ((CustomScrap)customItem).levelType);
					}
					else if (customItem is CustomPlainItem)
					{
						Items.RegisterItem(val);
					}
				}
			}
			foreach (CustomUnlockable customUnlockable in customUnlockables)
			{
				if (customUnlockable.enabled)
				{
					UnlockableItem unlockable = MainAssets.LoadAsset<UnlockableItemDef>(customUnlockable.unlockablePath).unlockable;
					if ((Object)(object)unlockable.prefabObject != (Object)null)
					{
						NetworkPrefabs.RegisterNetworkPrefab(unlockable.prefabObject);
					}
					Prefabs.Add(customUnlockable.name, unlockable.prefabObject);
					TerminalNode val3 = null;
					if (customUnlockable.infoPath != null)
					{
						val3 = MainAssets.LoadAsset<TerminalNode>(customUnlockable.infoPath);
					}
					Unlockables.RegisterUnlockable(unlockable, (StoreType)2, (TerminalNode)null, (TerminalNode)null, val3, customUnlockable.unlockCost);
				}
			}
			foreach (CustomEnemy customEnemy in customEnemies)
			{
				if (customEnemy.enabled)
				{
					EnemyType val4 = MainAssets.LoadAsset<EnemyType>(customEnemy.enemyPath);
					TerminalNode val5 = MainAssets.LoadAsset<TerminalNode>(customEnemy.infoNode);
					TerminalKeyword val6 = null;
					if (customEnemy.infoKeyword != null)
					{
						val6 = MainAssets.LoadAsset<TerminalKeyword>(customEnemy.infoKeyword);
					}
					NetworkPrefabs.RegisterNetworkPrefab(val4.enemyPrefab);
					Prefabs.Add(customEnemy.name, val4.enemyPrefab);
					Enemies.RegisterEnemy(val4, customEnemy.rarity, customEnemy.levelFlags, customEnemy.spawnType, val5, val6);
				}
			}
			foreach (CustomMapObject customMapObject in customMapObjects)
			{
				if (customMapObject.enabled)
				{
					SpawnableMapObjectDef val7 = MainAssets.LoadAsset<SpawnableMapObjectDef>(customMapObject.objectPath);
					NetworkPrefabs.RegisterNetworkPrefab(val7.spawnableMapObject.prefabToSpawn);
					Prefabs.Add(customMapObject.name, val7.spawnableMapObject.prefabToSpawn);
					MapObjects.RegisterMapObject(val7, customMapObject.levelFlags, customMapObject.spawnRateFunction);
				}
			}
			foreach (KeyValuePair<string, GameObject> prefab in Prefabs)
			{
				GameObject value = prefab.Value;
				string key = prefab.Key;
				AudioSource[] componentsInChildren = value.GetComponentsInChildren<AudioSource>();
				if (componentsInChildren.Length != 0)
				{
					ConfigEntry<float> val8 = Config.VolumeConfig.Bind<float>("Volume", key ?? "", 100f, "Audio volume for " + key + " (0 - 100)");
					AudioSource[] array = componentsInChildren;
					foreach (AudioSource obj2 in array)
					{
						obj2.volume *= val8.Value / 100f;
					}
				}
			}
			GameObject obj3 = MainAssets.LoadAsset<GameObject>("Assets/Custom/LethalThings/DevMenu.prefab");
			NetworkPrefabs.RegisterNetworkPrefab(obj3);
			devMenuPrefab = obj3;
			try
			{
				foreach (Type loadableType in Assembly.GetExecutingAssembly().GetLoadableTypes())
				{
					MethodInfo[] methods = loadableType.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
					foreach (MethodInfo methodInfo in methods)
					{
						if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
						{
							methodInfo.Invoke(null, null);
						}
					}
				}
			}
			catch (Exception)
			{
			}
			Plugin.logger.LogInfo((object)"Custom content loaded!");
		}
	}
	public static class InputCompat
	{
		public static InputActionAsset Asset;

		public static bool Enabled => Chainloader.PluginInfos.ContainsKey("com.rune580.LethalCompanyInputUtils");

		public static InputAction LTUtilityBeltQuick1 => Keybinds.Instance.LTUtilityBeltQuick1;

		public static InputAction LTUtilityBeltQuick2 => Keybinds.Instance.LTUtilityBeltQuick2;

		public static InputAction LTUtilityBeltQuick3 => Keybinds.Instance.LTUtilityBeltQuick3;

		public static InputAction LTUtilityBeltQuick4 => Keybinds.Instance.LTUtilityBeltQuick4;

		public static void Init()
		{
			Keybinds.Instance = new Keybinds();
			Asset = Keybinds.Instance.GetAsset();
		}
	}
	public class Keybinds : LcInputActions
	{
		public static Keybinds Instance;

		[InputAction("", Name = "[LT] Utility Belt Quick 1")]
		public InputAction LTUtilityBeltQuick1 { get; set; }

		[InputAction("", Name = "[LT] Utility Belt Quick 2")]
		public InputAction LTUtilityBeltQuick2 { get; set; }

		[InputAction("", Name = "[LT] Utility Belt Quick 3")]
		public InputAction LTUtilityBeltQuick3 { get; set; }

		[InputAction("", Name = "[LT] Utility Belt Quick 4")]
		public InputAction LTUtilityBeltQuick4 { get; set; }

		public InputActionAsset GetAsset()
		{
			return ((LcInputActions)this).Asset;
		}
	}
	public class Dingus : SaveableObject
	{
		public AudioSource noiseAudio;

		public AudioSource noiseAudioFar;

		public AudioSource musicAudio;

		public AudioSource musicAudioFar;

		[Space(3f)]
		public AudioClip[] noiseSFX;

		public AudioClip[] noiseSFXFar;

		public AudioClip evilNoise;

		[Space(3f)]
		public float noiseRange;

		public float maxLoudness;

		public float minLoudness;

		public float minPitch;

		public float maxPitch;

		private Random noisemakerRandom;

		public Animator triggerAnimator;

		private int timesPlayedWithoutTurningOff;

		private RoundManager roundManager;

		private float noiseInterval = 1f;

		public Animator danceAnimator;

		public bool wasLoadedFromSave;

		public bool exploding;

		private NetworkVariable<bool> isEvil = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public GameObject evilObject;

		public NetworkVariable<bool> isPlayingMusic = new NetworkVariable<bool>(Config.maxwellPlayMusicDefault.Value, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)1);

		public NetworkVariable<bool> isPipebomb = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public override void SaveObjectData()
		{
			SaveData.SaveObjectData("dingusBeEvil", isEvil.Value, uniqueId);
		}

		public override void LoadObjectData()
		{
			if (((NetworkBehaviour)this).IsHost)
			{
				bool flag = SaveData.LoadObjectData<bool>("dingusBeEvil", uniqueId);
				if (flag)
				{
					isEvil.Value = flag;
				}
			}
		}

		public override void Start()
		{
			((GrabbableObject)this).Start();
			roundManager = Object.FindObjectOfType<RoundManager>();
			noisemakerRandom = new Random(StartOfRound.Instance.randomMapSeed + 85);
			Debug.Log((object)"Making the dingus dance");
		}

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			if (((NetworkBehaviour)this).IsOwner)
			{
				isPlayingMusic.Value = Config.maxwellPlayMusicDefault.Value;
			}
			if (((NetworkBehaviour)this).IsHost)
			{
				isEvil.Value = Random.Range(0f, 100f) <= Config.evilMaxwellChance.Value;
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (!((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null))
			{
				int num = noisemakerRandom.Next(0, noiseSFX.Length);
				float num2 = (float)noisemakerRandom.Next((int)(minLoudness * 100f), (int)(maxLoudness * 100f)) / 100f;
				float pitch = (float)noisemakerRandom.Next((int)(minPitch * 100f), (int)(maxPitch * 100f)) / 100f;
				noiseAudio.pitch = pitch;
				noiseAudio.PlayOneShot(noiseSFX[num], num2);
				if ((Object)(object)noiseAudioFar != (Object)null)
				{
					noiseAudioFar.pitch = pitch;
					noiseAudioFar.PlayOneShot(noiseSFXFar[num], num2);
				}
				if ((Object)(object)triggerAnimator != (Object)null)
				{
					triggerAnimator.SetTrigger("playAnim");
				}
				WalkieTalkie.TransmitOneShotAudio(noiseAudio, noiseSFX[num], num2);
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, noiseRange, num2, 0, ((GrabbableObject)this).isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
			}
		}

		public override void DiscardItem()
		{
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				((GrabbableObject)this).playerHeldBy.equippedUsableItemQE = false;
			}
			((GrabbableObject)this).isBeingUsed = false;
			((GrabbableObject)this).DiscardItem();
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			((GrabbableObject)this).playerHeldBy.equippedUsableItemQE = true;
			danceAnimator.Play("dingusIdle");
			Debug.Log((object)"Making the dingus idle");
		}

		public override void ItemInteractLeftRight(bool right)
		{
			((GrabbableObject)this).ItemInteractLeftRight(right);
			if (!right && ((NetworkBehaviour)this).IsOwner)
			{
				isPlayingMusic.Value = !isPlayingMusic.Value;
			}
		}

		public override void InteractItem()
		{
			((GrabbableObject)this).InteractItem();
			if (isEvil.Value && !exploding && !isPipebomb.Value)
			{
				EvilMaxwellServerRpc();
			}
		}

		public void EvilMaxwellTruly()
		{
			danceAnimator.Play("dingusIdle");
			if (musicAudio.isPlaying)
			{
				musicAudio.Pause();
				musicAudioFar.Pause();
			}
			((MonoBehaviour)this).StartCoroutine(evilMaxwellMoment());
		}

		[ServerRpc(RequireOwnership = false)]
		public void EvilMaxwellServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(88404199u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 88404199u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					isPipebomb.Value = true;
					EvilMaxwellClientRpc();
				}
			}
		}

		[ClientRpc]
		public void EvilMaxwellClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1120322383u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1120322383u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				EvilMaxwellTruly();
				exploding = true;
				if (((NetworkBehaviour)this).IsOwner)
				{
					isPlayingMusic.Value = false;
				}
				timesPlayedWithoutTurningOff = 0;
				danceAnimator.Play("dingusIdle");
				if (musicAudio.isPlaying)
				{
					musicAudio.Pause();
					musicAudioFar.Pause();
				}
				Plugin.logger.LogInfo((object)"Evil maxwell moment");
			}
		}

		public IEnumerator evilMaxwellMoment()
		{
			yield return (object)new WaitForSeconds(1f);
			noiseAudio.PlayOneShot(evilNoise, 1f);
			evilObject.SetActive(true);
			((Renderer)((GrabbableObject)this).mainObjectRenderer).enabled = false;
			if ((Object)(object)noiseAudioFar != (Object)null)
			{
				noiseAudioFar.PlayOneShot(evilNoise, 1f);
			}
			if ((Object)(object)triggerAnimator != (Object)null)
			{
				triggerAnimator.SetTrigger("playAnim");
			}
			WalkieTalkie.TransmitOneShotAudio(noiseAudio, evilNoise, 1f);
			RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, noiseRange, 1f, 0, ((GrabbableObject)this).isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
			yield return (object)new WaitForSeconds(1.5f);
			Utilities.CreateExplosion(((Component)this).transform.position, spawnExplosionEffect: true, 100, 0f, 6.4f, 6, (CauseOfDeath)3);
			Rigidbody[] componentsInChildren = evilObject.GetComponentsInChildren<Rigidbody>();
			foreach (Rigidbody obj in componentsInChildren)
			{
				obj.isKinematic = false;
				obj.AddExplosionForce(1000f, evilObject.transform.position, 100f);
			}
			yield return (object)new WaitForSeconds(2f);
			if (((NetworkBehaviour)this).IsServer)
			{
				((Component)this).GetComponent<NetworkObject>().Despawn(true);
			}
		}

		public override void Update()
		{
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).Update();
			if (isEvil.Value)
			{
				((GrabbableObject)this).grabbable = false;
				((GrabbableObject)this).grabbableToEnemies = false;
			}
			if (isPlayingMusic.Value && !exploding)
			{
				if (!musicAudio.isPlaying)
				{
					musicAudio.Play();
					musicAudioFar.Play();
				}
				if (!((GrabbableObject)this).isHeld)
				{
					danceAnimator.Play("dingusDance");
				}
				else
				{
					danceAnimator.Play("dingusIdle");
				}
				if (noiseInterval <= 0f)
				{
					noiseInterval = 1f;
					timesPlayedWithoutTurningOff++;
					roundManager.PlayAudibleNoise(((Component)this).transform.position, 16f, 0.9f, timesPlayedWithoutTurningOff, false, 5);
				}
				else
				{
					noiseInterval -= Time.deltaTime;
				}
			}
			else
			{
				timesPlayedWithoutTurningOff = 0;
				danceAnimator.Play("dingusIdle");
				if (musicAudio.isPlaying)
				{
					musicAudio.Pause();
					musicAudioFar.Pause();
				}
			}
		}

		protected override void __initializeVariables()
		{
			if (isEvil == null)
			{
				throw new Exception("Dingus.isEvil cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)isEvil).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)isEvil, "isEvil");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)isEvil);
			if (isPlayingMusic == null)
			{
				throw new Exception("Dingus.isPlayingMusic cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)isPlayingMusic).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)isPlayingMusic, "isPlayingMusic");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)isPlayingMusic);
			if (isPipebomb == null)
			{
				throw new Exception("Dingus.isPipebomb cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)isPipebomb).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)isPipebomb, "isPipebomb");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)isPipebomb);
			base.__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_Dingus()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(88404199u, new RpcReceiveHandler(__rpc_handler_88404199));
			NetworkManager.__rpc_func_table.Add(1120322383u, new RpcReceiveHandler(__rpc_handler_1120322383));
		}

		private static void __rpc_handler_88404199(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Dingus)(object)target).EvilMaxwellServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1120322383(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((Dingus)(object)target).EvilMaxwellClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "Dingus";
		}
	}
	public class Missile : NetworkBehaviour
	{
		public int damage = 50;

		public float maxDistance = 10f;

		public float minDistance;

		public float gravity = 2.4f;

		public float flightDelay = 0.5f;

		public float flightForce = 150f;

		public float flightTime = 2f;

		public float autoDestroyTime = 3f;

		private float timeAlive;

		public float LobForce = 100f;

		public ParticleSystem particleSystem;

		private void OnCollisionEnter(Collision collision)
		{
			if (((NetworkBehaviour)this).IsHost)
			{
				Boom();
				BoomClientRpc();
			}
			else
			{
				BoomServerRpc();
			}
		}

		private void Start()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).GetComponent<Rigidbody>().useGravity = false;
			if (((NetworkBehaviour)this).IsHost)
			{
				((Component)this).GetComponent<Rigidbody>().AddForce(((Component)this).transform.forward * LobForce, (ForceMode)1);
			}
		}

		[ClientRpc]
		public void BoomClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3331368301u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3331368301u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					Boom();
				}
			}
		}

		[ServerRpc]
		public void BoomServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(452316787u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 452316787u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				Boom();
				BoomClientRpc();
			}
		}

		public void CreateExplosion()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB attacker = ((IEnumerable<PlayerControllerB>)StartOfRound.Instance.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB x) => ((NetworkBehaviour)x).OwnerClientId == ((NetworkBehaviour)this).OwnerClientId));
			Utilities.CreateExplosion(((Component)this).transform.position, spawnExplosionEffect: true, damage, minDistance, maxDistance, 10, (CauseOfDeath)3, attacker);
		}

		public void Boom()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)particleSystem == (Object)null)
			{
				Debug.LogError((object)"No particle system set on missile, destruction time!!");
				CreateExplosion();
				if (((NetworkBehaviour)this).IsHost)
				{
					Object.Destroy((Object)(object)((Component)this).gameObject);
				}
				return;
			}
			particleSystem.Stop(true, (ParticleSystemStopBehavior)1);
			((Component)particleSystem).transform.SetParent((Transform)null);
			((Component)particleSystem).transform.localScale = Vector3.one;
			GameObject gameObject = ((Component)particleSystem).gameObject;
			MainModule main = particleSystem.main;
			float duration = ((MainModule)(ref main)).duration;
			main = particleSystem.main;
			MinMaxCurve startLifetime = ((MainModule)(ref main)).startLifetime;
			Object.Destroy((Object)(object)gameObject, duration + ((MinMaxCurve)(ref startLifetime)).constant);
			CreateExplosion();
			if (((NetworkBehaviour)this).IsHost)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		private void FixedUpdate()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)this).IsHost)
			{
				return;
			}
			((Component)this).GetComponent<Rigidbody>().useGravity = false;
			((Component)this).GetComponent<Rigidbody>().AddForce(Vector3.down * gravity);
			if (timeAlive <= flightTime && timeAlive >= flightDelay)
			{
				((Component)this).GetComponent<Rigidbody>().AddForce(((Component)this).transform.forward * flightForce);
			}
			timeAlive += Time.fixedDeltaTime;
			if (timeAlive > autoDestroyTime)
			{
				if (((NetworkBehaviour)this).IsHost)
				{
					Boom();
					BoomClientRpc();
				}
				else
				{
					BoomServerRpc();
				}
			}
			else
			{
				Debug.Log((object)("Time alive: " + timeAlive + " / " + autoDestroyTime));
			}
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_Missile()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3331368301u, new RpcReceiveHandler(__rpc_handler_3331368301));
			NetworkManager.__rpc_func_table.Add(452316787u, new RpcReceiveHandler(__rpc_handler_452316787));
		}

		private static void __rpc_handler_3331368301(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((Missile)(object)target).BoomClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_452316787(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Missile)(object)target).BoomServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "Missile";
		}
	}
	public class PouchyBelt : GrabbableObject
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_SetHoverTipAndCurrentInteractTrigger <0>__PlayerControllerB_SetHoverTipAndCurrentInteractTrigger;

			public static hook_BeginGrabObject <1>__PlayerControllerB_BeginGrabObject;
		}

		public Transform beltCosmetic;

		public Vector3 beltCosmeticPositionOffset = new Vector3(0f, 0f, 0f);

		public Vector3 beltCosmeticRotationOffset = new Vector3(0f, 0f, 0f);

		public int beltCapacity = 3;

		private PlayerControllerB previousPlayerHeldBy;

		public List<int> slotIndexes = new List<int>();

		public static void Initialize()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			object obj = <>O.<0>__PlayerControllerB_SetHoverTipAndCurrentInteractTrigger;
			if (obj == null)
			{
				hook_SetHoverTipAndCurrentInteractTrigger val = PlayerControllerB_SetHoverTipAndCurrentInteractTrigger;
				<>O.<0>__PlayerControllerB_SetHoverTipAndCurrentInteractTrigger = val;
				obj = (object)val;
			}
			PlayerControllerB.SetHoverTipAndCurrentInteractTrigger += (hook_SetHoverTipAndCurrentInteractTrigger)obj;
			object obj2 = <>O.<1>__PlayerControllerB_BeginGrabObject;
			if (obj2 == null)
			{
				hook_BeginGrabObject val2 = PlayerControllerB_BeginGrabObject;
				<>O.<1>__PlayerControllerB_BeginGrabObject = val2;
				obj2 = (object)val2;
			}
			PlayerControllerB.BeginGrabObject += (hook_BeginGrabObject)obj2;
		}

		public void Awake()
		{
			if (InputCompat.Enabled)
			{
				InputCompat.LTUtilityBeltQuick1.started += InputReceived;
				InputCompat.LTUtilityBeltQuick2.started += InputReceived;
				InputCompat.LTUtilityBeltQuick3.started += InputReceived;
				InputCompat.LTUtilityBeltQuick4.started += InputReceived;
			}
		}

		private static void PlayerControllerB_BeginGrabObject(orig_BeginGrabObject orig, PlayerControllerB self)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			self.interactRay = new Ray(((Component)self.gameplayCamera).transform.position, ((Component)self.gameplayCamera).transform.forward);
			if (!Physics.Raycast(self.interactRay, ref self.hit, self.grabDistance, self.interactableObjectsMask) || ((Component)((RaycastHit)(ref self.hit)).collider).gameObject.layer == 8 || !(((Component)((RaycastHit)(ref self.hit)).collider).tag == "PhysicsProp") || self.twoHanded || self.sinkingValue > 0.73f)
			{
				return;
			}
			self.currentlyGrabbingObject = ((Component)((Component)((RaycastHit)(ref self.hit)).collider).transform).gameObject.GetComponent<GrabbableObject>();
			if ((!GameNetworkManager.Instance.gameHasStarted && !self.currentlyGrabbingObject.itemProperties.canBeGrabbedBeforeGameStart && ((Object)(object)StartOfRound.Instance.testRoom == (Object)null || !StartOfRound.Instance.testRoom.activeSelf)) || (Object)(object)self.currentlyGrabbingObject == (Object)null || self.inSpecialInteractAnimation || self.currentlyGrabbingObject.isHeld || self.currentlyGrabbingObject.isPocketed)
			{
				return;
			}
			NetworkObject networkObject = ((NetworkBehaviour)self.currentlyGrabbingObject).NetworkObject;
			if (!((Object)(object)networkObject == (Object)null) && networkObject.IsSpawned)
			{
				if (self.currentlyGrabbingObject is PouchyBelt && self.ItemSlots.Any((GrabbableObject x) => (Object)(object)x != (Object)null && x is PouchyBelt))
				{
					self.currentlyGrabbingObject.grabbable = false;
				}
				orig.Invoke(self);
				if (self.currentlyGrabbingObject is PouchyBelt)
				{
					self.currentlyGrabbingObject.grabbable = true;
				}
			}
		}

		private static void PlayerControllerB_SetHoverTipAndCurrentInteractTrigger(orig_SetHoverTipAndCurrentInteractTrigger orig, PlayerControllerB self)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			if (!Physics.Raycast(self.interactRay, ref self.hit, self.grabDistance, self.interactableObjectsMask) || ((Component)((RaycastHit)(ref self.hit)).collider).gameObject.layer == 8 || !(((Component)((RaycastHit)(ref self.hit)).collider).tag == "PhysicsProp"))
			{
				return;
			}
			if (self.FirstEmptyItemSlot() == -1)
			{
				((TMP_Text)self.cursorTip).text = "Inventory full!";
			}
			else if (((Component)((RaycastHit)(ref self.hit)).collider).gameObject.GetComponent<GrabbableObject>() is PouchyBelt)
			{
				if (self.ItemSlots.Any((GrabbableObject x) => (Object)(object)x != (Object)null && x is PouchyBelt))
				{
					((TMP_Text)self.cursorTip).text = "(Cannot hold more than 1 belt)";
				}
				else
				{
					((TMP_Text)self.cursorTip).text = "Pick up belt";
				}
			}
		}

		public void InputReceived(CallbackContext context)
		{
			if (((NetworkBehaviour)this).IsOwner && (Object)(object)base.playerHeldBy != (Object)null && ((CallbackContext)(ref context)).started)
			{
				int num = -1;
				if (((CallbackContext)(ref context)).action == InputCompat.LTUtilityBeltQuick1)
				{
					num = 0;
				}
				else if (((CallbackContext)(ref context)).action == InputCompat.LTUtilityBeltQuick2)
				{
					num = 1;
				}
				else if (((CallbackContext)(ref context)).action == InputCompat.LTUtilityBeltQuick3)
				{
					num = 2;
				}
				else if (((CallbackContext)(ref context)).action == InputCompat.LTUtilityBeltQuick4)
				{
					num = 3;
				}
				if (num != -1 && num < slotIndexes.Count)
				{
					base.playerHeldBy.SwitchItemSlots(slotIndexes[num]);
					Plugin.logger.LogInfo((object)$"Switched to slot: {slotIndexes[num]}");
				}
			}
		}

		public override void LateUpdate()
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).LateUpdate();
			if ((Object)(object)previousPlayerHeldBy != (Object)null)
			{
				((Component)beltCosmetic).gameObject.SetActive(true);
				beltCosmetic.SetParent((Transform)null);
				((Renderer)((Component)beltCosmetic).GetComponent<MeshRenderer>()).enabled = true;
				if (((NetworkBehaviour)this).IsOwner)
				{
					((Renderer)((Component)beltCosmetic).GetComponent<MeshRenderer>()).enabled = false;
				}
				Transform parent = previousPlayerHeldBy.lowerSpine.parent;
				beltCosmetic.position = parent.position + beltCosmeticPositionOffset;
				Quaternion rotation = parent.rotation;
				Quaternion rotation2 = Quaternion.Euler(((Quaternion)(ref rotation)).eulerAngles + beltCosmeticRotationOffset);
				beltCosmetic.rotation = rotation2;
				((Renderer)base.mainObjectRenderer).enabled = false;
				((Component)this).gameObject.SetActive(true);
			}
			else
			{
				((Component)beltCosmetic).gameObject.SetActive(false);
				((Renderer)base.mainObjectRenderer).enabled = true;
				beltCosmetic.SetParent(((Component)this).transform);
			}
		}

		public void UpdateHUD(bool add)
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			slotIndexes.Clear();
			HUDManager instance = HUDManager.Instance;
			if (add)
			{
				int num = 0;
				GrabbableObject[] itemSlots = GameNetworkManager.Instance.localPlayerController.ItemSlots;
				for (int i = 0; i < itemSlots.Length; i++)
				{
					if (itemSlots[i] is PouchyBelt)
					{
						num++;
					}
				}
				Image val = instance.itemSlotIconFrames[0];
				Image val2 = instance.itemSlotIcons[0];
				int num2 = instance.itemSlotIconFrames.Length;
				((Component)val).GetComponentInParent<CanvasScaler>();
				((Component)val).GetComponentInParent<AspectRatioFitter>();
				float x2 = ((Graphic)val).rectTransform.sizeDelta.x;
				float y = ((Graphic)val).rectTransform.sizeDelta.y;
				float num3 = ((Graphic)val).rectTransform.anchoredPosition.y + 1.125f * y * (float)num;
				Vector3 localEulerAngles = ((Transform)((Graphic)val).rectTransform).localEulerAngles;
				Vector3 localEulerAngles2 = ((Transform)((Graphic)val2).rectTransform).localEulerAngles;
				List<Image> list = instance.itemSlotIconFrames.ToList();
				List<Image> list2 = instance.itemSlotIcons.ToList();
				int num4 = list.FindLastIndex((Image x) => Regex.IsMatch(((Object)((Component)x).gameObject).name.ToLowerInvariant(), "\\bslot\\d\\b"));
				_ = beltCapacity;
				_ = beltCapacity;
				Debug.Log((object)$"Adding {beltCapacity} item slots! Surely this will go well..");
				Debug.Log((object)$"Adding after index: {num4}");
				for (int j = 0; j < beltCapacity; j++)
				{
					float num5 = 0f - ((Component)((Transform)((Graphic)val).rectTransform).parent).GetComponent<RectTransform>().sizeDelta.x / 2f - 3f + (float)j * x2 + (float)j * 15f;
					Image val3 = Object.Instantiate<Image>(list[0], ((Component)val).transform.parent);
					((Object)val3).name = $"Slot{num2 + j}[LethalThingsBelt]";
					((Graphic)val3).rectTransform.anchoredPosition = new Vector2(num5, num3);
					((Transform)((Graphic)val3).rectTransform).eulerAngles = localEulerAngles;
					Image component = ((Component)((Component)val3).transform.GetChild(0)).GetComponent<Image>();
					((Object)component).name = "icon";
					((Behaviour)component).enabled = false;
					((Transform)((Graphic)component).rectTransform).eulerAngles = localEulerAngles2;
					((Transform)((Graphic)component).rectTransform).Rotate(new Vector3(0f, 0f, -90f));
					int num6 = num4 + j + 1;
					list.Insert(num6, val3);
					list2.Insert(num6, component);
					slotIndexes.Add(num6);
					((Component)val3).transform.SetSiblingIndex(num6);
				}
				instance.itemSlotIconFrames = list.ToArray();
				instance.itemSlotIcons = list2.ToArray();
				Debug.Log((object)$"Added {beltCapacity} item slots!");
				return;
			}
			List<Image> list3 = instance.itemSlotIconFrames.ToList();
			List<Image> list4 = instance.itemSlotIcons.ToList();
			int count = list3.Count;
			int num7 = 0;
			for (int num8 = count - 1; num8 >= 0; num8--)
			{
				if (((Object)list3[num8]).name.Contains("[LethalThingsBelt]"))
				{
					num7++;
					Image obj = list3[num8];
					list3.RemoveAt(num8);
					list4.RemoveAt(num8);
					Object.Destroy((Object)(object)((Component)obj).gameObject);
					if (num7 >= beltCapacity)
					{
						break;
					}
				}
			}
			instance.itemSlotIconFrames = list3.ToArray();
			instance.itemSlotIcons = list4.ToArray();
			Debug.Log((object)$"Removed {beltCapacity} item slots!");
		}

		public void AddItemSlots()
		{
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				List<GrabbableObject> list = base.playerHeldBy.ItemSlots.ToList();
				base.playerHeldBy.ItemSlots = (GrabbableObject[])(object)new GrabbableObject[list.Count + beltCapacity];
				for (int i = 0; i < list.Count; i++)
				{
					base.playerHeldBy.ItemSlots[i] = list[i];
				}
				if ((Object)(object)base.playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
				{
					UpdateHUD(add: true);
				}
			}
		}

		public void RemoveItemSlots()
		{
			if (!((Object)(object)base.playerHeldBy != (Object)null))
			{
				return;
			}
			int num = base.playerHeldBy.ItemSlots.Length - beltCapacity;
			int currentItemSlot = base.playerHeldBy.currentItemSlot;
			for (int i = 0; i < beltCapacity; i++)
			{
				GrabbableObject val = base.playerHeldBy.ItemSlots[num + i];
				if ((Object)(object)val != (Object)null)
				{
					base.playerHeldBy.DropItem(val, num + i);
				}
			}
			int currentItemSlot2 = base.playerHeldBy.currentItemSlot;
			currentItemSlot2 = ((currentItemSlot < base.playerHeldBy.ItemSlots.Length) ? currentItemSlot : 0);
			List<GrabbableObject> list = base.playerHeldBy.ItemSlots.ToList();
			base.playerHeldBy.ItemSlots = (GrabbableObject[])(object)new GrabbableObject[list.Count - beltCapacity];
			for (int j = 0; j < base.playerHeldBy.ItemSlots.Length; j++)
			{
				base.playerHeldBy.ItemSlots[j] = list[j];
			}
			if ((Object)(object)base.playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				UpdateHUD(add: false);
			}
			base.playerHeldBy.SwitchItemSlots(currentItemSlot2);
		}

		public override void DiscardItem()
		{
			RemoveItemSlots();
			previousPlayerHeldBy = null;
			((GrabbableObject)this).DiscardItem();
		}

		public override void OnNetworkDespawn()
		{
			RemoveItemSlots();
			previousPlayerHeldBy = null;
			((NetworkBehaviour)this).OnNetworkDespawn();
		}

		public void GrabItemOnClient()
		{
			((GrabbableObject)this).GrabItemOnClient();
		}

		public override void OnDestroy()
		{
			if (InputCompat.Enabled)
			{
				InputCompat.LTUtilityBeltQuick1.started -= InputReceived;
				InputCompat.LTUtilityBeltQuick2.started -= InputReceived;
				InputCompat.LTUtilityBeltQuick3.started -= InputReceived;
				InputCompat.LTUtilityBeltQuick4.started -= InputReceived;
			}
			((NetworkBehaviour)this).OnDestroy();
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				if ((Object)(object)base.playerHeldBy != (Object)(object)previousPlayerHeldBy)
				{
					AddItemSlots();
				}
				previousPlayerHeldBy = base.playerHeldBy;
			}
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		protected internal override string __getTypeName()
		{
			return "PouchyBelt";
		}
	}
	public class PowerOutletStun : NetworkBehaviour
	{
		private Coroutine electrocutionCoroutine;

		public AudioSource strikeAudio;

		public ParticleSystem strikeParticle;

		private NetworkVariable<int> damage = new NetworkVariable<int>(20, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public void Electrocute(ItemCharger socket)
		{
			Debug.Log((object)"Attempting electrocution");
			if (electrocutionCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(electrocutionCoroutine);
			}
			electrocutionCoroutine = ((MonoBehaviour)this).StartCoroutine(electrocutionDelayed(socket));
		}

		public void Awake()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			StormyWeather val = Object.FindObjectOfType<StormyWeather>(true);
			GameObject gameObject = ((Component)val.targetedStrikeAudio).gameObject;
			strikeAudio = Object.Instantiate<GameObject>(gameObject, ((Component)this).transform).GetComponent<AudioSource>();
			((Component)strikeAudio).transform.localPosition = Vector3.zero;
			((Component)strikeAudio).gameObject.SetActive(true);
			strikeParticle = Object.Instantiate<GameObject>(((Component)val.explosionEffectParticle).gameObject, ((Component)this).transform).GetComponent<ParticleSystem>();
			((Component)strikeParticle).transform.localPosition = Vector3.zero;
			((Component)strikeParticle).gameObject.SetActive(true);
			if (((NetworkBehaviour)this).IsHost)
			{
				damage.Value = Config.itemChargerElectrocutionDamage.Value;
			}
		}

		private IEnumerator electrocutionDelayed(ItemCharger socket)
		{
			Debug.Log((object)"Electrocution started");
			socket.zapAudio.Play();
			yield return (object)new WaitForSeconds(0.75f);
			socket.chargeStationAnimator.SetTrigger("zap");
			Debug.Log((object)"Electrocution finished");
			if (((NetworkBehaviour)this).NetworkObject.IsOwner && !((NetworkBehaviour)this).NetworkObject.IsOwnedByServer)
			{
				Debug.Log((object)"Sending stun to server!!");
				ElectrocutedServerRpc(((Component)this).transform.position);
			}
			else if (((NetworkBehaviour)this).NetworkObject.IsOwner && ((NetworkBehaviour)this).NetworkObject.IsOwnedByServer)
			{
				Debug.Log((object)"Sending stun to clients!!");
				ElectrocutedClientRpc(((Component)this).transform.position);
				Electrocuted(((Component)this).transform.position);
			}
		}

		[ClientRpc]
		private void ElectrocutedClientRpc(Vector3 position)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(328188188u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 328188188u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					Debug.Log((object)"Stun received!!");
					Electrocuted(position);
				}
			}
		}

		private void Electrocuted(Vector3 position)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			StormyWeather obj = Object.FindObjectOfType<StormyWeather>(true);
			Utilities.CreateExplosion(position, spawnExplosionEffect: false, Config.itemChargerElectrocutionDamage.Value, 0f, 5f, 3, (CauseOfDeath)11);
			strikeParticle.Play();
			obj.PlayThunderEffects(position, strikeAudio);
		}

		[ServerRpc]
		private void ElectrocutedServerRpc(Vector3 position)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Invalid comparison between Unknown and I4
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2844681185u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2844681185u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ElectrocutedClientRpc(position);
			}
		}

		protected override void __initializeVariables()
		{
			if (damage == null)
			{
				throw new Exception("PowerOutletStun.damage cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)damage).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)damage, "damage");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)damage);
			((NetworkBehaviour)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_PowerOutletStun()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(328188188u, new RpcReceiveHandler(__rpc_handler_328188188));
			NetworkManager.__rpc_func_table.Add(2844681185u, new RpcReceiveHandler(__rpc_handler_2844681185));
		}

		private static void __rpc_handler_328188188(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PowerOutletStun)(object)target).ElectrocutedClientRpc(position);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2844681185(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PowerOutletStun)(object)target).ElectrocutedServerRpc(position);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "PowerOutletStun";
		}
	}
	public class ProjectileWeapon : SaveableObject
	{
		public AudioSource mainAudio;

		public AudioClip[] activateClips;

		public AudioClip[] noAmmoSounds;

		public AudioClip[] reloadSounds;

		public Transform aimDirection;

		public int maxAmmo = 4;

		private NetworkVariable<int> currentAmmo = new NetworkVariable<int>(4, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public GameObject projectilePrefab;

		public float LobForce = 100f;

		private float timeSinceLastShot;

		private PlayerControllerB previousPlayerHeldBy;

		public Animator Animator;

		public ParticleSystem particleSystem;

		public Item ammoItem;

		public int ammoSlotToUse = -1;

		public override void SaveObjectData()
		{
			SaveData.SaveObjectData("projectileWeaponAmmoData", currentAmmo.Value, uniqueId);
		}

		public override void LoadObjectData()
		{
			if (((NetworkBehaviour)this).IsHost)
			{
				currentAmmo.Value = SaveData.LoadObjectData<int>("projectileWeaponAmmoData", uniqueId);
			}
		}

		public static void Init()
		{
		}

		private static bool GrabbableObject_UseItemBatteries(orig_UseItemBatteries orig, GrabbableObject self)
		{
			if (self is ProjectileWeapon)
			{
				return true;
			}
			return orig.Invoke(self);
		}

		public override void Start()
		{
			((GrabbableObject)this).Start();
		}

		public override void OnDestroy()
		{
			((NetworkBehaviour)this).OnDestroy();
		}

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			if (((NetworkBehaviour)this).IsServer)
			{
				currentAmmo.Value = maxAmmo;
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (currentAmmo.Value > 0)
			{
				if (((NetworkBehaviour)this).IsHost)
				{
					NetworkVariable<int> obj = currentAmmo;
					int value = obj.Value;
					obj.Value = value - 1;
				}
				PlayRandomAudio(mainAudio, activateClips);
				Animator.Play("fire");
				particleSystem.Play();
				timeSinceLastShot = 0f;
				if (((NetworkBehaviour)this).IsOwner)
				{
					if (((NetworkBehaviour)this).IsHost)
					{
						ProjectileSpawner(aimDirection.position, aimDirection.rotation);
					}
					else
					{
						SpawnProjectileServerRpc(aimDirection.position, aimDirection.rotation);
					}
				}
			}
			else
			{
				PlayRandomAudio(mainAudio, noAmmoSounds);
			}
		}

		private bool ReloadedGun()
		{
			int num = FindAmmoInInventory();
			if (num == -1)
			{
				return false;
			}
			ammoSlotToUse = num;
			return true;
		}

		private int FindAmmoInInventory()
		{
			for (int i = 0; i < ((GrabbableObject)this).playerHeldBy.ItemSlots.Length; i++)
			{
				if (!((Object)(object)((GrabbableObject)this).playerHeldBy.ItemSlots[i] == (Object)null) && ((GrabbableObject)this).playerHeldBy.ItemSlots[i].itemProperties.itemId == ammoItem.itemId)
				{
					return i;
				}
			}
			return -1;
		}

		[ServerRpc]
		private void FixWeightServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(43845628u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 43845628u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				FixWeightClientRpc();
			}
		}

		[ClientRpc]
		private void FixWeightClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(948021082u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 948021082u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && (Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
				{
					PlayerControllerB playerHeldBy = ((GrabbableObject)this).playerHeldBy;
					playerHeldBy.carryWeight -= Mathf.Clamp(ammoItem.weight - 1f, 0f, 10f);
				}
			}
		}

		public override void ItemInteractLeftRight(bool right)
		{
			((GrabbableObject)this).ItemInteractLeftRight(right);
			if (right || !((NetworkBehaviour)this).IsOwner)
			{
				return;
			}
			if (ReloadedGun())
			{
				if (currentAmmo.Value > 0)
				{
					HUDManager.Instance.DisplayTip("Item already loaded.", "You can reload once you use up all the ammo.", false, false, "LC_Tip1");
					return;
				}
				ReloadAmmoServerRpc();
				DestroyItemInSlotAndSync(ammoSlotToUse);
				ammoSlotToUse = -1;
			}
			else
			{
				HUDManager.Instance.DisplayTip("No ammo found.", "Buy " + ammoItem.itemName + " from the Terminal to reload.", false, false, "LC_Tip1");
			}
		}

		[ServerRpc]
		private void ReloadAmmoServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1064596822u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1064596822u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				currentAmmo.Value = maxAmmo;
				ReloadAmmoSoundClientRpc();
			}
		}

		[ClientRpc]
		private void ReloadAmmoSoundClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3520251861u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3520251861u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					PlayRandomAudio(mainAudio, reloadSounds);
					Animator.Play("reload");
				}
			}
		}

		[ServerRpc]
		private void SpawnProjectileServerRpc(Vector3 aimPosition, Quaternion aimRotation)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Invalid comparison between Unknown and I4
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(681922146u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref aimPosition);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref aimRotation);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 681922146u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ProjectileSpawner(aimPosition, aimRotation);
			}
		}

		private void ProjectileSpawner(Vector3 aimPosition, Quaternion aimRotation)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = Object.Instantiate<GameObject>(projectilePrefab, aimPosition, aimRotation);
			obj.GetComponent<NetworkObject>().SpawnWithOwnership(((NetworkBehaviour)this).OwnerClientId, false);
			obj.GetComponent<Rigidbody>().AddForce(aimDirection.forward * LobForce, (ForceMode)1);
		}

		private void PlayRandomAudio(AudioSource audioSource, AudioClip[] audioClips)
		{
			if (audioClips.Length != 0)
			{
				audioSource.PlayOneShot(audioClips[Random.Range(0, audioClips.Length)]);
			}
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			timeSinceLastShot += Time.deltaTime;
		}

		private void OnEnable()
		{
		}

		private void OnDisable()
		{
		}

		public override void PocketItem()
		{
			((GrabbableObject)this).PocketItem();
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				((GrabbableObject)this).playerHeldBy.equippedUsableItemQE = false;
			}
		}

		public override void DiscardItem()
		{
			((GrabbableObject)this).DiscardItem();
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				((GrabbableObject)this).playerHeldBy.equippedUsableItemQE = false;
			}
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			((GrabbableObject)this).playerHeldBy.equippedUsableItemQE = true;
		}

		public void DestroyItemInSlotAndSync(int itemSlot)
		{
			if (((NetworkBehaviour)this).IsOwner)
			{
				if (itemSlot >= ((GrabbableObject)this).playerHeldBy.ItemSlots.Length || (Object)(object)((GrabbableObject)this).playerHeldBy.ItemSlots[itemSlot] == (Object)null)
				{
					Debug.LogError((object)$"Destroy item in slot called for a slot (slot {itemSlot}) which is empty or incorrect");
				}
				DestroyItemInSlotServerRpc(itemSlot);
			}
		}

		[ServerRpc]
		public void DestroyItemInSlotServerRpc(int itemSlot)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3656085789u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, itemSlot);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3656085789u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				DestroyItemInSlotClientRpc(itemSlot);
			}
		}

		[ClientRpc]
		public void DestroyItemInSlotClientRpc(int itemSlot)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(314723133u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, itemSlot);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 314723133u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					DestroyItemInSlot(itemSlot);
				}
			}
		}

		public void DestroyItemInSlot(int itemSlot)
		{
			if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null || (Object)(object)NetworkManager.Singleton == (Object)null || NetworkManager.Singleton.ShutdownInProgress)
			{
				return;
			}
			GrabbableObject val = ((GrabbableObject)this).playerHeldBy.ItemSlots[itemSlot];
			if ((Object)(object)val == (Object)null || (Object)(object)val.itemProperties == (Object)null)
			{
				Plugin.logger.LogError((object)"Item properties are null, cannot destroy item in slot");
				return;
			}
			PlayerControllerB playerHeldBy = ((GrabbableObject)this).playerHeldBy;
			playerHeldBy.carryWeight -= Mathf.Clamp(val.itemProperties.weight - 1f, 0f, 10f);
			if (((GrabbableObject)this).playerHeldBy.currentItemSlot == itemSlot)
			{
				((GrabbableObject)this).playerHeldBy.isHoldingObject = false;
				((GrabbableObject)this).playerHeldBy.twoHanded = false;
				if (((NetworkBehaviour)((GrabbableObject)this).playerHeldBy).IsOwner)
				{
					((GrabbableObject)this).playerHeldBy.playerBodyAnimator.SetBool("cancelHolding", true);
					((GrabbableObject)this).playerHeldBy.playerBod

BeplnEx/plugins/LetMeLookDown.dll

Decompiled 2 years ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LetMeLookDown")]
[assembly: AssemblyDescription("Mod made by flipf17")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LetMeLookDown")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a9c88d54-8f01-44a7-be0d-bd61d38aadcb")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LetMeLookDown
{
	[BepInPlugin("FlipMods.LetMeLookDown", "LetMeLookDown", "1.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony _harmony;

		private static Plugin instance;

		public static float maxAngle = 80f;

		private void Awake()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			_harmony = new Harmony("LetMeLookDown");
			_harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"LetMeLookDown mod loaded");
			instance = this;
		}

		public static void Log(string message)
		{
			((BaseUnityPlugin)instance).Logger.LogInfo((object)message);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "FlipMods.LetMeLookDown";

		public const string PLUGIN_NAME = "LetMeLookDown";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}
namespace LetMeLookDown.Patches
{
	[HarmonyPatch]
	internal class AdjustSmoothLookingPatcher
	{
		[HarmonyPatch(typeof(PlayerControllerB), "CalculateSmoothLookingInput")]
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Ldc_R4 && (float)list[i].operand == 60f)
				{
					list[i].operand = Plugin.maxAngle;
					break;
				}
			}
			return list.AsEnumerable();
		}
	}
	[HarmonyPatch]
	internal class AdjustNormalLookingPatcher
	{
		[HarmonyPatch(typeof(PlayerControllerB), "CalculateNormalLookingInput")]
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Ldc_R4 && (float)list[i].operand == 60f)
				{
					list[i].operand = Plugin.maxAngle;
					break;
				}
			}
			return list.AsEnumerable();
		}
	}
}

BeplnEx/plugins/PossessedMask.dll

Decompiled 2 years ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using UnityEngine;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("PossessedMask")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PossessedMask")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4F62CD59-C324-4153-BDDC-B58865CC6A5A")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace PossessedMask
{
	[BepInPlugin("oe.tweaks.qol.possessedmask", "Possessed Mask", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("oe.tweaks.qol.possessedmask");

		private const string GUID = "oe.tweaks.qol.possessedmask";

		private const string NAME = "Possessed Mask";

		private const string VERSION = "1.0.0";

		internal static Plugin Instance;

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> enableMaskPossessionMechanic;

		internal static ConfigEntry<bool> enableMaskSwitchSlotMechanic;

		internal static ConfigEntry<int> enableChangeMaskSpawnChance;

		internal static ConfigEntry<int> numberOfSlotsFilledToEnableDroppingMask;

		internal static ConfigEntry<float> timeToStartSwitchingSlots;

		internal static ConfigEntry<float> timeToStartPossession;

		internal static ConfigEntry<bool> twoHandedItemBehaviour;

		internal static ConfigEntry<int> maskRarity;

		internal static ConfigEntry<bool> maskRarityScaling;

		internal static ConfigEntry<float> maskRarityScalingMultiplier;

		internal static ConfigEntry<int> minMaskItemBaseValue;

		internal static ConfigEntry<int> maxMaskItemBaseValue;

		internal static ConfigEntry<float> minTimeToSwitchSlots;

		internal static ConfigEntry<float> maxTimeToSwitchSlots;

		internal static ConfigEntry<float> deltaTimeToSwitchSlots;

		internal static ConfigEntry<float> minSwitchingSlotTime;

		internal static ConfigEntry<float> minTimeToPossess;

		internal static ConfigEntry<float> maxTimeToPossess;

		internal static ConfigEntry<float> deltaTimeToPossess;

		internal static ConfigEntry<float> minPossessingTime;

		internal static ConfigEntry<float> minTimeToPossessPlayer;

		internal static ConfigEntry<float> maxTimeToPossessPlayer;

		internal static ConfigEntry<float> deltaTimeToPossessPlayer;

		internal static ConfigEntry<float> maxPossessingPlayerTime;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"'Possessed Mask' is loading...");
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			enableMaskPossessionMechanic = ((BaseUnityPlugin)this).Config.Bind<bool>("Mechanics", "EnableMaskPossessionMechanic", true, "If true, mask possession mechanic will be enabled");
			enableMaskSwitchSlotMechanic = ((BaseUnityPlugin)this).Config.Bind<bool>("Mechanics", "EnableMaskSwitchSlotMechanic", true, "If true, mask switching to your active slot mechanic will be enabled");
			enableChangeMaskSpawnChance = ((BaseUnityPlugin)this).Config.Bind<int>("Mechanics", "EnableChangeMaskSpawnChance", 2, "If 0, will not override mask spawn chance, scrap value and available levels.\nIf 1, will override spawn chance, scrap value but not available levels.\nif 2 will override all of them.");
			numberOfSlotsFilledToEnableDroppingMask = ((BaseUnityPlugin)this).Config.Bind<int>("General", "NumberOfSlotsFilledToEnableDroppingMask", 3, "Number of inventory slots that need to be filled to enable dropping a mask");
			timeToStartSwitchingSlots = ((BaseUnityPlugin)this).Config.Bind<float>("General", "TimeToStartSwitchingSlots", 5f, "After this much time with mask in inventory start switching slots");
			timeToStartPossession = ((BaseUnityPlugin)this).Config.Bind<float>("General", "TimeToStartPossession", 10f, "After this much time with mask in inventory start possessions");
			twoHandedItemBehaviour = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "TwoHandedItemBehaviour", true, "If true, 2 handed items will be dropped when switching slots");
			maskRarity = ((BaseUnityPlugin)this).Config.Bind<int>("Mask Rarity", "MaskRarity", 35, "Rarity of mask item 0 - 100 (0 - doesn't spawn, 100 - spawns a lot)");
			maskRarityScaling = ((BaseUnityPlugin)this).Config.Bind<bool>("Mask Rarity", "MaskRarityScaling", true, "If true, mask rarity will be scaled up by moon rank");
			maskRarityScalingMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Mask Rarity", "MaskRarityScalingMultiplier", 0.5f, "Multiplier for mask rarity scaling");
			minMaskItemBaseValue = ((BaseUnityPlugin)this).Config.Bind<int>("Mask Item Base Value", "MinMaskItemBaseValue", 100, "Minimum base value of mask item (affected by multipliers >1)");
			maxMaskItemBaseValue = ((BaseUnityPlugin)this).Config.Bind<int>("Mask Item Base Value", "MaxMaskItemBaseValue", 150, "Maximum base value of mask item (affected by multipliers >1)");
			minTimeToSwitchSlots = ((BaseUnityPlugin)this).Config.Bind<float>("Time To Switch Slots", "MinTimeToSwitchSlots", 12f, "Minimum time between switching slots");
			maxTimeToSwitchSlots = ((BaseUnityPlugin)this).Config.Bind<float>("Time To Switch Slots", "MaxTimeToSwitchSlots", 20f, "Maximum time between switching slots");
			deltaTimeToSwitchSlots = ((BaseUnityPlugin)this).Config.Bind<float>("Time To Switch Slots", "DeltaTimeToSwitchSlots", 0.5f, "Time to subtract from min and max each time a switch happens");
			minSwitchingSlotTime = ((BaseUnityPlugin)this).Config.Bind<float>("Time To Switch Slots", "MinSwitchingSlotTime", 3f, "The number at which subtracting from min and max stops");
			minTimeToPossess = ((BaseUnityPlugin)this).Config.Bind<float>("Time To Possess", "MinTimeToPossess", 20f, "Minimum time between possessions");
			maxTimeToPossess = ((BaseUnityPlugin)this).Config.Bind<float>("Time To Possess", "MaxTimeToPossess", 30f, "Maximum time between possessions");
			deltaTimeToPossess = ((BaseUnityPlugin)this).Config.Bind<float>("Time To Possess", "DeltaTimeToPossess", 1f, "Time to subtract from min and max each time a possession happens");
			minPossessingTime = ((BaseUnityPlugin)this).Config.Bind<float>("Time To Possess", "MinPossessingTime", 10f, "The number at which subtracting from min and max stops");
			minTimeToPossessPlayer = ((BaseUnityPlugin)this).Config.Bind<float>("Item Activation Time", "MinTimeToPossessPlayer", 2f, "Minimum time of actual possession");
			maxTimeToPossessPlayer = ((BaseUnityPlugin)this).Config.Bind<float>("Item Activation Time", "MaxTimeToPossessPlayer", 4f, "Maximum time of actual possession");
			deltaTimeToPossessPlayer = ((BaseUnityPlugin)this).Config.Bind<float>("Item Activation Time", "DeltaTimeToPossessPlayer", 1f, "Time to add to min and max each time a possession happens");
			maxPossessingPlayerTime = ((BaseUnityPlugin)this).Config.Bind<float>("Item Activation Time", "MaxPossessingPlayerTime", 9f, "The number at which adding to min and max stops");
			harmony.PatchAll();
			Log.LogInfo((object)"'Possessed Mask' loaded!");
		}
	}
}
namespace PossessedMask.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	public class PlayerControllerBPatch
	{
		[HarmonyPatch("Discard_performed")]
		[HarmonyPrefix]
		private static bool PatchDiscard(PlayerControllerB __instance, CallbackContext context)
		{
			GrabbableObject val = __instance.ItemSlots[__instance.currentItemSlot];
			if ((Object)(object)val == (Object)null || ((object)val).GetType() != typeof(HauntedMaskItem))
			{
				return true;
			}
			if (__instance.ItemSlots.Count((GrabbableObject slot) => (Object)(object)slot != (Object)null) < Plugin.numberOfSlotsFilledToEnableDroppingMask.Value)
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch("ScrollMouse_performed")]
		[HarmonyPrefix]
		private static bool PatchScrollMouse_performed(PlayerControllerB __instance, CallbackContext context)
		{
			GrabbableObject val = __instance.ItemSlots[__instance.currentItemSlot];
			if ((Object)(object)val != (Object)null && ((object)val).GetType() == typeof(HauntedMaskItem) && __instance.activatingItem)
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch("KillPlayer")]
		[HarmonyPostfix]
		private static void PatchKillPlayer(PlayerControllerB __instance)
		{
			if (__instance.isPlayerDead)
			{
				IngamePlayerSettings.Instance.playerInput.actions.FindAction("ActivateItem", false).Enable();
				IngamePlayerSettings.Instance.playerInput.actions.FindAction("Interact", false).Enable();
				IngamePlayerSettings.Instance.playerInput.actions.FindAction("SwitchItem", false).Enable();
				IngamePlayerSettings.Instance.playerInput.actions.FindAction("Discard", false).Enable();
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	public class StartOfRoundPatch
	{
		private static PlayerControllerB localPlayer = null;

		private static float timeHeldByPlayer = 0f;

		private static float nextTimeToSwitchSlot = 0f;

		private static float timeUntilPossession = 0f;

		private static AudioClip[] possessionSounds = (AudioClip[])(object)new AudioClip[3];

		private static AudioClip[] slotSwitchSounds = (AudioClip[])(object)new AudioClip[2];

		private static float minTimeToSwitchSlots;

		private static float maxTimeToSwitchSlots;

		private static float deltaTimeToSwitchSlots;

		private static float minSwitchingSlotTime;

		private static float minTimeToPossess;

		private static float maxTimeToPossess;

		private static float deltaTimeToPossess;

		private static float minPossessingTime;

		private static float minTimeToPossessPlayer;

		private static float maxTimeToPossessPlayer;

		private static float deltaTimeToPossessPlayer;

		private static float maxPossessingPlayerTime;

		private static Terminal terminal = null;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void PatchLoadResources(StartOfRound __instance)
		{
			AssetBundle val = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetManifestResourceNames()[0]));
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogError((object)"Failed to load asset bundle");
				return;
			}
			Plugin.Log.LogInfo((object)"Asset bundle loaded");
			possessionSounds[0] = val.LoadAsset<AudioClip>("possession1");
			possessionSounds[1] = val.LoadAsset<AudioClip>("possession2");
			possessionSounds[2] = val.LoadAsset<AudioClip>("possession3");
			slotSwitchSounds[0] = val.LoadAsset<AudioClip>("slot1");
			slotSwitchSounds[1] = val.LoadAsset<AudioClip>("slot2");
			((MonoBehaviour)__instance).StartCoroutine(RegisterMasks());
			minTimeToSwitchSlots = Plugin.minTimeToSwitchSlots.Value;
			maxTimeToSwitchSlots = Plugin.maxTimeToSwitchSlots.Value;
			deltaTimeToSwitchSlots = Plugin.deltaTimeToSwitchSlots.Value;
			minSwitchingSlotTime = Plugin.minSwitchingSlotTime.Value;
			minTimeToPossess = Plugin.minTimeToPossess.Value;
			maxTimeToPossess = Plugin.maxTimeToPossess.Value;
			deltaTimeToPossess = Plugin.deltaTimeToPossess.Value;
			minPossessingTime = Plugin.minPossessingTime.Value;
			minTimeToPossessPlayer = Plugin.minTimeToPossessPlayer.Value;
			maxTimeToPossessPlayer = Plugin.maxTimeToPossessPlayer.Value;
			deltaTimeToPossessPlayer = Plugin.deltaTimeToPossessPlayer.Value;
			maxPossessingPlayerTime = Plugin.maxPossessingPlayerTime.Value;
		}

		private static IEnumerator RegisterMasks()
		{
			if (Plugin.enableChangeMaskSpawnChance.Value == 0)
			{
				yield break;
			}
			while (!Object.op_Implicit((Object)(object)terminal))
			{
				terminal = Object.FindObjectOfType<Terminal>();
				yield return (object)new WaitForSeconds(1f);
			}
			Item val = ((IEnumerable<Item>)StartOfRound.Instance.allItemsList.itemsList).FirstOrDefault((Func<Item, bool>)((Item item) => item.itemName == "Comedy"));
			if (!Object.op_Implicit((Object)(object)val))
			{
				Plugin.Log.LogError((object)"Comedy not found in allItemsList, skipping patching Comedy");
			}
			else
			{
				val.minValue = Plugin.minMaskItemBaseValue.Value;
				val.maxValue = Plugin.maxMaskItemBaseValue.Value;
			}
			Item val2 = ((IEnumerable<Item>)StartOfRound.Instance.allItemsList.itemsList).FirstOrDefault((Func<Item, bool>)((Item item) => item.itemName == "Tragedy"));
			if (!Object.op_Implicit((Object)(object)val2))
			{
				Plugin.Log.LogError((object)"Tragedy not found in allItemsList, skipping patching Tragedy");
			}
			else
			{
				val2.minValue = Plugin.minMaskItemBaseValue.Value;
				val2.maxValue = Plugin.maxMaskItemBaseValue.Value;
			}
			SelectableLevel[] moonsCatalogueList = terminal.moonsCatalogueList;
			float num = Plugin.maskRarityScalingMultiplier.Value;
			SelectableLevel[] array = moonsCatalogueList;
			foreach (SelectableLevel val3 in array)
			{
				int rarity = Mathf.Clamp(Mathf.RoundToInt((float)Plugin.maskRarity.Value * (1f + (Plugin.maskRarityScaling.Value ? num : 0f))), 0, 100);
				if (Object.op_Implicit((Object)(object)val))
				{
					SpawnableItemWithRarity val4 = new SpawnableItemWithRarity();
					val4.spawnableItem = val;
					val4.rarity = rarity;
					int num2 = val3.spawnableScrap.FindIndex((SpawnableItemWithRarity item) => item.spawnableItem.itemName == "Comedy");
					if (num2 == -1 && Plugin.enableChangeMaskSpawnChance.Value == 2)
					{
						val3.spawnableScrap.Add(val4);
					}
					else
					{
						val3.spawnableScrap[num2] = val4;
					}
				}
				if (Object.op_Implicit((Object)(object)val2))
				{
					SpawnableItemWithRarity val5 = new SpawnableItemWithRarity();
					val5.spawnableItem = val2;
					val5.rarity = rarity;
					int num3 = val3.spawnableScrap.FindIndex((SpawnableItemWithRarity item) => item.spawnableItem.itemName == "Tragedy");
					if (num3 == -1 && Plugin.enableChangeMaskSpawnChance.Value == 2)
					{
						val3.spawnableScrap.Add(val5);
					}
					else
					{
						val3.spawnableScrap[num3] = val5;
					}
				}
				if (Plugin.maskRarityScaling.Value)
				{
					num *= Plugin.maskRarityScalingMultiplier.Value;
				}
			}
		}

		[HarmonyPatch("openingDoorsSequence")]
		[HarmonyPostfix]
		private static void PatchOpeningDoorsSequence(StartOfRound __instance)
		{
			localPlayer = __instance.localPlayerController;
			timeUntilPossession = Plugin.timeToStartPossession.Value;
			timeHeldByPlayer = 0f;
			nextTimeToSwitchSlot = 0f;
			minTimeToSwitchSlots = Plugin.minTimeToSwitchSlots.Value;
			maxTimeToSwitchSlots = Plugin.maxTimeToSwitchSlots.Value;
			minTimeToPossess = Plugin.minTimeToPossess.Value;
			maxTimeToPossess = Plugin.maxTimeToPossess.Value;
			minTimeToPossessPlayer = Plugin.minTimeToPossessPlayer.Value;
			maxTimeToPossessPlayer = Plugin.maxTimeToPossessPlayer.Value;
			Plugin.Log.LogInfo((object)"Reset timers and reloaded config values");
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void PatchUpdate()
		{
			if ((Object)(object)localPlayer == (Object)null || localPlayer.isPlayerDead || StartOfRound.Instance.inShipPhase || StartOfRound.Instance.currentLevelID == 3)
			{
				return;
			}
			nextTimeToSwitchSlot -= Time.deltaTime;
			bool flag = false;
			for (int i = 0; i < localPlayer.ItemSlots.Length; i++)
			{
				GrabbableObject val = localPlayer.ItemSlots[i];
				if (!((Object)(object)val == (Object)null) && !(((object)val).GetType() != typeof(HauntedMaskItem)))
				{
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				return;
			}
			timeHeldByPlayer += Time.deltaTime;
			timeUntilPossession -= Time.deltaTime;
			GrabbableObject val2 = localPlayer.ItemSlots[localPlayer.currentItemSlot];
			if (Plugin.enableMaskPossessionMechanic.Value && (Object)(object)val2 != (Object)null && ((object)val2).GetType() == typeof(HauntedMaskItem))
			{
				if (timeUntilPossession < 0f)
				{
					float num = Random.Range(minTimeToPossessPlayer, maxTimeToPossessPlayer);
					minTimeToPossessPlayer += ((minTimeToPossessPlayer < maxPossessingPlayerTime) ? deltaTimeToPossessPlayer : 0f);
					maxTimeToPossessPlayer += ((maxTimeToPossessPlayer < maxPossessingPlayerTime) ? deltaTimeToPossessPlayer : 0f);
					Plugin.Log.LogInfo((object)$"Player has held mask for enough time, possessing for {num} seconds");
					timeUntilPossession = Random.Range(minTimeToPossess, maxTimeToPossess);
					minTimeToPossess -= ((minTimeToPossess > minPossessingTime) ? deltaTimeToPossess : 0f);
					maxTimeToPossess -= ((maxTimeToPossess > minPossessingTime) ? deltaTimeToPossess : 0f);
					PossessPlayer(num);
					nextTimeToSwitchSlot = num + 1f;
				}
			}
			else
			{
				if (!Plugin.enableMaskSwitchSlotMechanic.Value || !(timeHeldByPlayer > Plugin.timeToStartSwitchingSlots.Value) || !(nextTimeToSwitchSlot <= 0f))
				{
					return;
				}
				Plugin.Log.LogMessage((object)"Player is not holding a mask, switching to closest held mask");
				int num2 = localPlayer.ItemSlots.Length;
				GrabbableObject[] itemSlots = localPlayer.ItemSlots;
				int currentItemSlot = localPlayer.currentItemSlot;
				bool flag2 = false;
				bool forward = false;
				bool flag3 = false;
				for (int j = 1; j <= num2 / 2; j++)
				{
					int num3 = ((currentItemSlot + j) % num2 + num2) % num2;
					Plugin.Log.LogMessage((object)$"Checking slot: {num3}");
					GrabbableObject val3 = itemSlots[num3];
					if ((Object)(object)val3 != (Object)null && ((object)val3).GetType() == typeof(HauntedMaskItem))
					{
						Plugin.Log.LogMessage((object)"Success! (+1)");
						flag2 = true;
						forward = true;
						if (j == 1)
						{
							flag3 = true;
						}
						break;
					}
					num3 = ((currentItemSlot - j) % num2 + num2) % num2;
					Plugin.Log.LogMessage((object)$"Checking slot: {num3}");
					val3 = itemSlots[num3];
					if ((Object)(object)val3 != (Object)null && ((object)val3).GetType() == typeof(HauntedMaskItem))
					{
						Plugin.Log.LogMessage((object)"Success! (-1)");
						flag2 = true;
						forward = false;
						if (j == 1)
						{
							flag3 = true;
						}
						break;
					}
				}
				if (!flag2)
				{
					Plugin.Log.LogWarning((object)"No masks were found even though player has held a mask");
					return;
				}
				if ((Object)(object)val2 != (Object)null && val2.isBeingUsed)
				{
					val2.ItemActivate(false, false);
				}
				bool currentIsTwoHanded = (Object)(object)val2 != (Object)null && val2.itemProperties.twoHanded;
				if (flag3)
				{
					IngamePlayerSettings.Instance.playerInput.actions.FindAction("SwitchItem", false).Disable();
				}
				if (!((Object)(object)localPlayer.currentlyHeldObject != (Object)null) || !(((object)localPlayer.currentlyHeldObject).GetType() == typeof(HauntedMaskItem)))
				{
					((MonoBehaviour)localPlayer).StartCoroutine(SwitchSlot(forward, currentIsTwoHanded, flag3));
					nextTimeToSwitchSlot = Random.Range(minTimeToSwitchSlots, maxTimeToSwitchSlots);
					minTimeToSwitchSlots -= ((minTimeToSwitchSlots > minSwitchingSlotTime) ? deltaTimeToSwitchSlots : 0f);
					maxTimeToSwitchSlots -= ((maxTimeToSwitchSlots > minSwitchingSlotTime) ? deltaTimeToSwitchSlots : 0f);
					Plugin.Log.LogInfo((object)("Next switch in " + nextTimeToSwitchSlot + " seconds"));
				}
			}
		}

		private static void PossessPlayer(float time)
		{
			IngamePlayerSettings.Instance.playerInput.actions.FindAction("SwitchItem", false).Disable();
			IngamePlayerSettings.Instance.playerInput.actions.FindAction("Interact", false).Disable();
			IngamePlayerSettings.Instance.playerInput.actions.FindAction("Discard", false).Enable();
			if ((Object)(object)localPlayer.currentlyHeldObjectServer != (Object)null && ((object)localPlayer.currentlyHeldObjectServer).GetType() == typeof(HauntedMaskItem))
			{
				IngamePlayerSettings.Instance.playerInput.actions.FindAction("SwitchItem", false).Disable();
				IngamePlayerSettings.Instance.playerInput.actions.FindAction("ActivateItem", false).Disable();
				ShipBuildModeManager.Instance.CancelBuildMode(true);
				localPlayer.currentlyHeldObjectServer.UseItemOnClient(true);
				((Component)localPlayer.currentlyHeldObjectServer).GetComponent<AudioSource>().PlayOneShot(possessionSounds[Random.Range(0, possessionSounds.Length)], localPlayer.itemAudio.volume * 0.75f);
				((MonoBehaviour)localPlayer).StartCoroutine(DePossessPlayer(time));
			}
			else
			{
				nextTimeToSwitchSlot = 0f;
				IngamePlayerSettings.Instance.playerInput.actions.FindAction("SwitchItem", false).Enable();
				IngamePlayerSettings.Instance.playerInput.actions.FindAction("Interact", false).Enable();
				IngamePlayerSettings.Instance.playerInput.actions.FindAction("Discard", false).Enable();
			}
		}

		private static IEnumerator DePossessPlayer(float time)
		{
			yield return (object)new WaitForSeconds(time);
			ShipBuildModeManager.Instance.CancelBuildMode(true);
			if ((Object)(object)localPlayer.currentlyHeldObjectServer != (Object)null)
			{
				localPlayer.currentlyHeldObjectServer.UseItemOnClient(false);
			}
			yield return (object)new WaitForEndOfFrame();
			IngamePlayerSettings.Instance.playerInput.actions.FindAction("ActivateItem", false).Enable();
			IngamePlayerSettings.Instance.playerInput.actions.FindAction("Interact", false).Enable();
			IngamePlayerSettings.Instance.playerInput.actions.FindAction("SwitchItem", false).Enable();
			IngamePlayerSettings.Instance.playerInput.actions.FindAction("Discard", false).Enable();
		}

		private static IEnumerator SwitchSlot(bool forward, bool currentIsTwoHanded, bool oneAway)
		{
			if (currentIsTwoHanded)
			{
				if (Plugin.twoHandedItemBehaviour.Value)
				{
					GrabbableObject current = localPlayer.currentlyHeldObject;
					yield return ((MonoBehaviour)localPlayer).StartCoroutine(localPlayer.waitToEndOfFrameToDiscard());
					current.EnableItemMeshes(true);
					yield return (object)new WaitForEndOfFrame();
					if (Random.Range(0f, 1f) < 0.25f)
					{
						localPlayer.itemAudio.PlayOneShot(slotSwitchSounds[Random.Range(0, slotSwitchSounds.Length)], localPlayer.itemAudio.volume * 0.25f);
					}
					localPlayer.SwitchToItemSlot(localPlayer.NextItemSlot(forward), (GrabbableObject)null);
					localPlayer.SwitchItemSlotsServerRpc(forward);
				}
			}
			else
			{
				if (Random.Range(0f, 1f) < 0.25f)
				{
					localPlayer.itemAudio.PlayOneShot(slotSwitchSounds[Random.Range(0, slotSwitchSounds.Length)], localPlayer.itemAudio.volume * 0.25f);
				}
				yield return (object)new WaitForEndOfFrame();
				localPlayer.SwitchToItemSlot(localPlayer.NextItemSlot(forward), (GrabbableObject)null);
				localPlayer.SwitchItemSlotsServerRpc(forward);
			}
			if (oneAway)
			{
				yield return (object)new WaitForSeconds(0.5f);
				IngamePlayerSettings.Instance.playerInput.actions.FindAction("SwitchItem", false).Enable();
			}
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	public class TerminalPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void PatchStart(Terminal __instance)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			string name = "MaskedPlayerEnemy";
			SpawnableEnemyWithRarity val = new SpawnableEnemyWithRarity();
			val.rarity = 0;
			SelectableLevel[] moonsCatalogueList = __instance.moonsCatalogueList;
			for (int i = 0; i < moonsCatalogueList.Length; i++)
			{
				foreach (SpawnableEnemyWithRarity enemy in moonsCatalogueList[i].Enemies)
				{
					if (((Object)enemy.enemyType).name == name)
					{
						val.enemyType = enemy.enemyType;
						break;
					}
				}
				if ((Object)(object)val.enemyType != (Object)null)
				{
					break;
				}
			}
			if ((Object)(object)val.enemyType == (Object)null)
			{
				Plugin.Log.LogError((object)"Masked enemy isn't allowed to spawn on any level!");
				return;
			}
			Plugin.Log.LogMessage((object)("Masked enemy found: " + ((Object)val.enemyType).name + ", fixing AI on all levels..."));
			moonsCatalogueList = __instance.moonsCatalogueList;
			foreach (SelectableLevel val2 in moonsCatalogueList)
			{
				if (!val2.Enemies.Exists((SpawnableEnemyWithRarity enemy) => ((Object)enemy.enemyType).name == name))
				{
					Plugin.Log.LogMessage((object)("Masked enemy not found on " + val2.PlanetName + ", adding zero..."));
					val2.Enemies.Add(val);
				}
				else
				{
					Plugin.Log.LogMessage((object)("Masked enemy found on " + val2.PlanetName + "."));
				}
			}
		}
	}
}