Decompiled source of Custom Item Behaviour Library v1.2.4

BepInEx/plugins/CustomItemBehaviourLibrary/CustomItemBehaviourLibrary.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using CustomItemBehaviourLibrary.AbstractItems;
using CustomItemBehaviourLibrary.Compatibility;
using CustomItemBehaviourLibrary.Manager;
using CustomItemBehaviourLibrary.Misc;
using CustomItemBehaviourLibrary.NetcodePatcher;
using CustomItemBehaviourLibrary.Patches;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MoreShipUpgrades.Patches.Enemies;
using MoreShipUpgrades.UpgradeComponents.TierUpgrades.AttributeUpgrades;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;

[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)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
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 MoreShipUpgrades.Patches.Enemies
{
	[HarmonyPatch(typeof(BaboonBirdAI))]
	internal static class BaboonBirdAIPatcher
	{
		[HarmonyPatch("DoLOSCheck")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> DoLOSCheckTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> codes = new List<CodeInstruction>(instructions);
			int index = 0;
			PatchCheckItemInContainer(ref index, ref codes);
			return codes;
		}

		private static void PatchCheckItemInContainer(ref int index, ref List<CodeInstruction> codes)
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Expected O, but got Unknown
			MethodInfo method = typeof(ContainerBehaviour).GetMethod("CheckIfItemInContainer");
			while (index < codes.Count)
			{
				if (codes[index].opcode == OpCodes.Ldloc_S && codes[index].operand.ToString() == "GrabbableObject (18)" && !(codes[index + 1].opcode != OpCodes.Ldnull))
				{
					codes.Insert(index + 3, new CodeInstruction(OpCodes.And, (object)null));
					codes.Insert(index + 3, new CodeInstruction(OpCodes.Not, (object)null));
					codes.Insert(index + 3, new CodeInstruction(OpCodes.Call, (object)method));
					codes.Insert(index + 3, new CodeInstruction(OpCodes.Ldloc_S, codes[index].operand));
					break;
				}
				index++;
			}
			index++;
		}
	}
}
namespace CustomItemBehaviourLibrary
{
	[BepInPlugin("com.github.WhiteSpike.CustomItemBehaviourLibrary", "Custom Item Behaviour Library", "1.2.1")]
	public class Plugin : BaseUnityPlugin
	{
		internal static readonly Harmony harmony = new Harmony("com.github.WhiteSpike.CustomItemBehaviourLibrary");

		internal static readonly ManualLogSource mls = Logger.CreateLogSource("Custom Item Behaviour Library");

		private void Awake()
		{
			IEnumerable<Type> enumerable;
			try
			{
				enumerable = Assembly.GetExecutingAssembly().GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				enumerable = ex.Types.Where((Type t) => t != null);
			}
			foreach (Type item in enumerable)
			{
				MethodInfo[] methods = item.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array = methods;
				foreach (MethodInfo methodInfo in array)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			PatchMainVersion();
			PatchBetaVersion();
			mls.LogInfo((object)"Custom Item Behaviour Library 1.2.1 has been loaded successfully.");
		}

		internal static void PatchMainVersion()
		{
			harmony.PatchAll(typeof(BaboonBirdAIPatcher));
			harmony.PatchAll(typeof(SpringManAIPatcher));
			harmony.PatchAll(typeof(HUDManagerPatcher));
			harmony.PatchAll(typeof(PlayerControllerBPatcher));
			mls.LogInfo((object)"Patched relevant components for correct item behaviours...");
		}

		internal static void PatchBetaVersion()
		{
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			for (int i = 0; i < assemblies.Length; i++)
			{
				if (assemblies[i].GetName().Name != "Assembly-CSharp")
				{
					continue;
				}
				Type[] types = assemblies[i].GetTypes();
				for (int j = 0; j < types.Length; j++)
				{
					if (types[j].Name == "BeltBagItem")
					{
						harmony.PatchAll(typeof(BeltBagItemPatcher));
						mls.LogInfo((object)"Patched belt bag for correct behaviour with containers.");
						break;
					}
				}
				break;
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "CustomItemBehaviourLibrary";

		public const string PLUGIN_NAME = "CustomItemBehaviourLibrary";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace CustomItemBehaviourLibrary.Util
{
	internal static class Constants
	{
	}
}
namespace CustomItemBehaviourLibrary.Patches
{
	[HarmonyPatch(typeof(BeltBagItem))]
	internal static class BeltBagItemPatcher
	{
		[HarmonyPrefix]
		[HarmonyPatch("PutObjectInBagLocalClient")]
		private static void GrabObjectClientRpcPostfix(GrabbableObject gObject)
		{
			PlayerControllerBPatcher.ContainerUnparenting(gObject);
		}

		[HarmonyTranspiler]
		[HarmonyPatch("ItemInteractLeftRight")]
		private static IEnumerable<CodeInstruction> ItemInteractLeftRightTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			FieldInfo field = typeof(GrabbableObject).GetField("isHeldByEnemy");
			MethodInfo method = typeof(BeltBagItemPatcher).GetMethod("IsContainer");
			List<CodeInstruction> codes = new List<CodeInstruction>(instructions);
			int index = 0;
			Tools.FindField(ref index, ref codes, field, method, skip: false, notInstruction: false, andInstruction: false, orInstruction: true, requireInstance: false, "Couldn't find the isHeldByEnemy field");
			codes.Insert(index, new CodeInstruction(OpCodes.Ldloc_1, (object)null));
			return codes;
		}

		public static bool IsContainer(GrabbableObject gObject)
		{
			return (Object)(object)((Component)gObject).GetComponent<ContainerBehaviour>() != (Object)null;
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal static class HUDManagerPatcher
	{
		[HarmonyPostfix]
		[HarmonyPatch("MeetsScanNodeRequirements")]
		private static void MeetsScanNodeRequirementsPostFix(ScanNodeProperties node, ref bool __result)
		{
			if (!((Object)(object)node == (Object)null) && !((Object)(object)((Component)node).transform.parent == (Object)null))
			{
				GrabbableObject component = ((Component)((Component)node).transform.parent).GetComponent<GrabbableObject>();
				if (!((Object)(object)component == (Object)null) && (Object)(object)((Component)component).gameObject.GetComponentInParent<ContainerBehaviour>() != (Object)null)
				{
					__result = false;
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal static class PlayerControllerBPatcher
	{
		[HarmonyPrefix]
		[HarmonyPatch("DropAllHeldItems")]
		private static bool DontDropItems(PlayerControllerB __instance)
		{
			if (!PortableTeleporterBehaviour.TPButtonPressed)
			{
				return true;
			}
			PortableTeleporterBehaviour.TPButtonPressed = false;
			__instance.isSinking = false;
			__instance.isUnderwater = false;
			__instance.sinkingValue = 0f;
			__instance.statusEffectAudio.Stop();
			return false;
		}

		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		private static void StartPostfix(PlayerControllerB __instance)
		{
			((Component)__instance).gameObject.AddComponent<PlayerManager>();
		}

		[HarmonyPostfix]
		[HarmonyPatch("KillPlayer")]
		private static void KillPlayerPostfix(PlayerControllerB __instance)
		{
			if ((Object)(object)__instance != (Object)(object)GameNetworkManager.Instance.localPlayerController || !PlayerManager.instance.holdingContainer)
			{
				return;
			}
			if (LategameCompatibility.Enabled)
			{
				GrabbableObject[] itemSlots = __instance.ItemSlots;
				foreach (GrabbableObject val in itemSlots)
				{
					ContainerBehaviour component = ((Component)val).GetComponent<ContainerBehaviour>();
					if (!((Object)(object)component == (Object)null))
					{
						component.UpdatePlayerAttributes(grabbing: false);
						break;
					}
				}
			}
			else
			{
				ContainerBehaviour component2 = ((Component)__instance.currentlyHeldObjectServer).GetComponent<ContainerBehaviour>();
				component2.UpdatePlayerAttributes(grabbing: false);
			}
		}

		[HarmonyTranspiler]
		[HarmonyPatch("SetPlayerSanityLevel")]
		private static IEnumerable<CodeInstruction> SetPlayerSanityLevelTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			MethodInfo method = typeof(PlayerManager).GetMethod("DecreaseSanityIncrease");
			int index = 0;
			List<CodeInstruction> codes = new List<CodeInstruction>(instructions);
			Tools.FindFloat(ref index, ref codes, 0.8f, method, skip: false, notInstruction: false, andInstruction: false, orInstruction: false, requireInstance: false, "Couldn't find first insanity multiplier");
			Tools.FindFloat(ref index, ref codes, 0.2f, method, skip: false, notInstruction: false, andInstruction: false, orInstruction: false, requireInstance: false, "Couldn't find first insanity multiplier");
			Tools.FindFloat(ref index, ref codes, -2f, method, skip: false, notInstruction: false, andInstruction: false, orInstruction: false, requireInstance: false, "Couldn't find first insanity multiplier");
			Tools.FindFloat(ref index, ref codes, 0.5f, method, skip: false, notInstruction: false, andInstruction: false, orInstruction: false, requireInstance: false, "Couldn't find first insanity multiplier");
			Tools.FindFloat(ref index, ref codes, 0.3f, method, skip: false, notInstruction: false, andInstruction: false, orInstruction: false, requireInstance: false, "Couldn't find first insanity multiplier");
			Tools.FindFloat(ref index, ref codes, -3f, method, skip: false, notInstruction: false, andInstruction: false, orInstruction: false, requireInstance: false, "Couldn't find first insanity multiplier");
			return codes;
		}

		[HarmonyTranspiler]
		[HarmonyPatch("Update")]
		private static IEnumerable<CodeInstruction> UpdateTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			MethodInfo method = typeof(ContainerBehaviour).GetMethod("CheckIfPlayerCarryingContainerMovement");
			FieldInfo field = typeof(PlayerControllerB).GetField("carryWeight");
			int index = 0;
			List<CodeInstruction> codes = new List<CodeInstruction>(instructions);
			Tools.FindField(ref index, ref codes, field, null, skip: true, notInstruction: false, andInstruction: false, orInstruction: false, requireInstance: false, "Couldn't find first carryWeight occurence");
			Tools.FindField(ref index, ref codes, field, method, skip: false, notInstruction: false, andInstruction: false, orInstruction: false, requireInstance: false, "Couldn't find second carryWeight occurence");
			Tools.FindField(ref index, ref codes, field, method, skip: false, notInstruction: false, andInstruction: false, orInstruction: false, requireInstance: false, "Couldn't find second carryWeight occurence");
			return codes;
		}

		[HarmonyPatch("PlayerLookInput")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> PlayerLookInputTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			MethodInfo method = typeof(ContainerBehaviour).GetMethod("CheckIfPlayerCarryingContainerLookSensitivity");
			List<CodeInstruction> codes = new List<CodeInstruction>(instructions);
			int index = 0;
			Tools.FindFloat(ref index, ref codes, 0.008f, method, skip: false, notInstruction: false, andInstruction: false, orInstruction: false, requireInstance: false, "Couldn't find look sensitivity value we wanted to influence");
			return codes;
		}

		[HarmonyPatch("Crouch_performed")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> CrouchPerformmedTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			MethodInfo method = typeof(ContainerBehaviour).GetMethod("CheckIfPlayerCarryingContainer");
			FieldInfo field = typeof(QuickMenuManager).GetField("isMenuOpen");
			List<CodeInstruction> codes = new List<CodeInstruction>(instructions);
			int index = 0;
			Tools.FindField(ref index, ref codes, field, method, skip: false, notInstruction: false, andInstruction: false, orInstruction: true, requireInstance: false, "Couldn't find isMenuOpen field");
			return codes;
		}

		[HarmonyPostfix]
		[HarmonyPatch("GrabObjectClientRpc")]
		private static void GrabObjectClientRpcPostfix(PlayerControllerB __instance)
		{
			ContainerUnparenting(__instance.currentlyHeldObjectServer);
		}

		internal static void ContainerUnparenting(GrabbableObject heldObject)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)heldObject == (Object)null))
			{
				ContainerBehaviour componentInParent = ((Component)heldObject).GetComponentInParent<ContainerBehaviour>();
				if (!((Object)(object)componentInParent == (Object)null) && !(heldObject is ContainerBehaviour))
				{
					((Component)heldObject).transform.SetParent(heldObject.parentObject);
					((Component)heldObject).transform.localScale = heldObject.originalScale;
					componentInParent.DecrementStoredItems();
				}
			}
		}
	}
	[HarmonyPatch(typeof(SpringManAI))]
	internal static class SpringManAIPatcher
	{
		[HarmonyPrefix]
		[HarmonyPatch("DoAIInterval")]
		private static void DoAllIntervalPrefix(ref SpringManAI __instance)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if (LookoutBehaviour.HasLineOfSightToPeepers(((Component)__instance).transform.position))
			{
				((EnemyAI)__instance).currentBehaviourStateIndex = 1;
			}
		}

		[HarmonyTranspiler]
		[HarmonyPatch("Update")]
		private static IEnumerable<CodeInstruction> Update_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected O, but got Unknown
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Expected O, but got Unknown
			MethodInfo method = typeof(LookoutBehaviour).GetMethod("HasLineOfSightToPeepers", BindingFlags.Static | BindingFlags.Public);
			MethodInfo method2 = typeof(SpringManAI).GetMethod("get_transform");
			MethodInfo method3 = typeof(Transform).GetMethod("get_position");
			bool flag = false;
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			for (int i = 1; i < list.Count; i++)
			{
				if (flag)
				{
					break;
				}
				if (!(list[i - 1].opcode != OpCodes.Ldc_I4_0) && !(list[i].opcode != OpCodes.Stloc_3))
				{
					list.Insert(i, new CodeInstruction(OpCodes.Or, (object)null));
					list.Insert(i, new CodeInstruction(OpCodes.Call, (object)method));
					list.Insert(i, new CodeInstruction(OpCodes.Callvirt, (object)method3));
					list.Insert(i, new CodeInstruction(OpCodes.Call, (object)method2));
					list.Insert(i, new CodeInstruction(OpCodes.Ldarg_0, (object)null));
					flag = true;
				}
			}
			return list;
		}
	}
}
namespace CustomItemBehaviourLibrary.Misc
{
	public static class AssetBundleHandler
	{
		public static AudioClip[] GetAudioClipList(this AssetBundle bundle, string name, int length)
		{
			AudioClip[] array = (AudioClip[])(object)new AudioClip[length];
			for (int i = 0; i < length; i++)
			{
				array[i] = bundle.TryLoadAudioClipAsset($"{name} {i}");
			}
			return array;
		}

		public static AudioClip TryLoadAudioClipAsset(this AssetBundle bundle, string path)
		{
			return bundle.LoadAsset<AudioClip>(path);
		}
	}
	internal static class Metadata
	{
		public const string GUID = "com.github.WhiteSpike.CustomItemBehaviourLibrary";

		public const string NAME = "Custom Item Behaviour Library";

		public const string VERSION = "1.2.1";
	}
	internal static class Tools
	{
		public static void FindCodeInstruction(ref int index, ref List<CodeInstruction> codes, object findValue, MethodInfo addCode, bool skip = false, bool requireInstance = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, string errorMessage = "Not found")
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			bool flag = false;
			while (index < codes.Count)
			{
				if (CheckCodeInstruction(codes[index], findValue))
				{
					flag = true;
					if (!skip)
					{
						if (andInstruction)
						{
							codes.Insert(index + 1, new CodeInstruction(OpCodes.And, (object)null));
						}
						if (!andInstruction && orInstruction)
						{
							codes.Insert(index + 1, new CodeInstruction(OpCodes.Or, (object)null));
						}
						if (notInstruction)
						{
							codes.Insert(index + 1, new CodeInstruction(OpCodes.Not, (object)null));
						}
						codes.Insert(index + 1, new CodeInstruction(OpCodes.Call, (object)addCode));
						if (requireInstance)
						{
							codes.Insert(index + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null));
						}
					}
					break;
				}
				index++;
			}
			if (!flag)
			{
				Plugin.mls.LogError((object)errorMessage);
			}
			index++;
		}

		public static void FindLocalField(ref int index, ref List<CodeInstruction> codes, int localIndex, object addCode = null, bool skip = false, bool store = false, bool requireInstance = false, string errorMessage = "Not found")
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			bool flag = false;
			while (index < codes.Count)
			{
				if (CheckCodeInstruction(codes[index], localIndex, store))
				{
					flag = true;
					if (!skip)
					{
						codes.Insert(index + 1, new CodeInstruction(OpCodes.Call, addCode));
						if (requireInstance)
						{
							codes.Insert(index + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null));
						}
					}
					break;
				}
				index++;
			}
			if (!flag)
			{
				Plugin.mls.LogError((object)errorMessage);
			}
			index++;
		}

		public static void FindString(ref int index, ref List<CodeInstruction> codes, string findValue, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found")
		{
			FindCodeInstruction(ref index, ref codes, findValue, addCode, skip, requireInstance, notInstruction, andInstruction, orInstruction, errorMessage);
		}

		public static void FindField(ref int index, ref List<CodeInstruction> codes, FieldInfo findField, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found")
		{
			FindCodeInstruction(ref index, ref codes, findField, addCode, skip, requireInstance, notInstruction, andInstruction, orInstruction, errorMessage);
		}

		public static void FindMethod(ref int index, ref List<CodeInstruction> codes, MethodInfo findMethod, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found")
		{
			FindCodeInstruction(ref index, ref codes, findMethod, addCode, skip, requireInstance, notInstruction, andInstruction, orInstruction, errorMessage);
		}

		public static void FindFloat(ref int index, ref List<CodeInstruction> codes, float findValue, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found")
		{
			FindCodeInstruction(ref index, ref codes, findValue, addCode, skip, requireInstance, notInstruction, andInstruction, orInstruction, errorMessage);
		}

		public static void FindInteger(ref int index, ref List<CodeInstruction> codes, sbyte findValue, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found")
		{
			FindCodeInstruction(ref index, ref codes, findValue, addCode, skip, requireInstance, notInstruction, andInstruction, orInstruction, errorMessage);
		}

		public static void FindSub(ref int index, ref List<CodeInstruction> codes, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found")
		{
			object findValue = OpCodes.Sub;
			bool notInstruction2 = notInstruction;
			bool andInstruction2 = andInstruction;
			bool orInstruction2 = orInstruction;
			FindCodeInstruction(ref index, ref codes, findValue, addCode, skip, requireInstance, notInstruction2, andInstruction2, orInstruction2, errorMessage);
		}

		public static void FindDiv(ref int index, ref List<CodeInstruction> codes, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found")
		{
			object findValue = OpCodes.Div;
			bool notInstruction2 = notInstruction;
			bool andInstruction2 = andInstruction;
			bool orInstruction2 = orInstruction;
			FindCodeInstruction(ref index, ref codes, findValue, addCode, skip, requireInstance, notInstruction2, andInstruction2, orInstruction2, errorMessage);
		}

		public static void FindAdd(ref int index, ref List<CodeInstruction> codes, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found")
		{
			object findValue = OpCodes.Add;
			bool notInstruction2 = notInstruction;
			bool andInstruction2 = andInstruction;
			bool orInstruction2 = orInstruction;
			FindCodeInstruction(ref index, ref codes, findValue, addCode, skip, requireInstance, notInstruction2, andInstruction2, orInstruction2, errorMessage);
		}

		public static void FindMul(ref int index, ref List<CodeInstruction> codes, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found")
		{
			object findValue = OpCodes.Mul;
			bool notInstruction2 = notInstruction;
			bool andInstruction2 = andInstruction;
			bool orInstruction2 = orInstruction;
			FindCodeInstruction(ref index, ref codes, findValue, addCode, skip, requireInstance, notInstruction2, andInstruction2, orInstruction2, errorMessage);
		}

		private static bool CheckCodeInstruction(CodeInstruction code, int localIndex, bool store = false)
		{
			if (!store)
			{
				return localIndex switch
				{
					0 => code.opcode == OpCodes.Ldloc_0, 
					1 => code.opcode == OpCodes.Ldloc_1, 
					2 => code.opcode == OpCodes.Ldloc_2, 
					3 => code.opcode == OpCodes.Ldloc_3, 
					_ => code.opcode == OpCodes.Ldloc && (int)code.operand == localIndex, 
				};
			}
			return localIndex switch
			{
				0 => code.opcode == OpCodes.Stloc_0, 
				1 => code.opcode == OpCodes.Stloc_1, 
				2 => code.opcode == OpCodes.Stloc_2, 
				3 => code.opcode == OpCodes.Stloc_3, 
				_ => code.opcode == OpCodes.Stloc && (int)code.operand == localIndex, 
			};
		}

		private static bool CheckCodeInstruction(CodeInstruction code, object findValue)
		{
			if (findValue is sbyte)
			{
				return CheckIntegerCodeInstruction(code, findValue);
			}
			if (findValue is float)
			{
				return code.opcode == OpCodes.Ldc_R4 && code.operand.Equals(findValue);
			}
			if (findValue is string)
			{
				return code.opcode == OpCodes.Ldstr && code.operand.Equals(findValue);
			}
			if (findValue is MethodInfo)
			{
				return (code.opcode == OpCodes.Call || code.opcode == OpCodes.Callvirt) && code.operand == findValue;
			}
			if (findValue is FieldInfo)
			{
				return (code.opcode == OpCodes.Ldfld || code.opcode == OpCodes.Stfld) && code.operand == findValue;
			}
			if (findValue is OpCode)
			{
				return code.opcode == (OpCode)findValue;
			}
			return false;
		}

		private static bool CheckIntegerCodeInstruction(CodeInstruction code, object findValue)
		{
			return (sbyte)findValue switch
			{
				0 => code.opcode == OpCodes.Ldc_I4_0, 
				1 => code.opcode == OpCodes.Ldc_I4_1, 
				2 => code.opcode == OpCodes.Ldc_I4_2, 
				3 => code.opcode == OpCodes.Ldc_I4_3, 
				4 => code.opcode == OpCodes.Ldc_I4_4, 
				5 => code.opcode == OpCodes.Ldc_I4_5, 
				6 => code.opcode == OpCodes.Ldc_I4_6, 
				7 => code.opcode == OpCodes.Ldc_I4_7, 
				8 => code.opcode == OpCodes.Ldc_I4_8, 
				_ => code.opcode == OpCodes.Ldc_I4_S && code.operand.Equals(findValue), 
			};
		}

		public static void ShuffleList<T>(List<T> list)
		{
			if (list == null)
			{
				throw new ArgumentNullException("list");
			}
			Random random = new Random();
			int num = list.Count;
			while (num > 1)
			{
				num--;
				int index = random.Next(num + 1);
				T value = list[index];
				list[index] = list[num];
				list[num] = value;
			}
		}

		public static bool SpawnMob(string mob, Vector3 position, int numToSpawn)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < RoundManager.Instance.currentLevel.Enemies.Count; i++)
			{
				if (RoundManager.Instance.currentLevel.Enemies[i].enemyType.enemyName == mob)
				{
					for (int j = 0; j < numToSpawn; j++)
					{
						RoundManager.Instance.SpawnEnemyOnServer(position, 0f, i);
					}
					return true;
				}
			}
			return false;
		}

		internal static string GenerateInfoForUpgrade(string infoFormat, int initialPrice, int[] incrementalPrices, Func<int, float> infoFunction, bool skipFirst = false)
		{
			string text = (skipFirst ? "" : string.Format(infoFormat, 1, initialPrice, infoFunction(0)));
			for (int i = 0; i < incrementalPrices.Length; i++)
			{
				float num = infoFunction(i + 1);
				text = ((num % 1f != 0f) ? (text + string.Format(infoFormat, i + 2, incrementalPrices[i], num)) : (text + string.Format(infoFormat, i + 2, incrementalPrices[i], Mathf.RoundToInt(num))));
			}
			return text;
		}

		public static Color ConvertValueToColor(string hex, Color defaultValue)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_0036: 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)
			Color result = default(Color);
			if (hex == null || !ColorUtility.TryParseHtmlString("#" + hex.Trim('#', ' '), ref result))
			{
				return defaultValue;
			}
			return result;
		}

		internal static string WrapText(string text, int availableLength, string leftPadding = "", string rightPadding = "", bool padLeftFirst = true)
		{
			int num = availableLength - leftPadding.Length - rightPadding.Length;
			string text2 = "";
			string text3 = "";
			int num2 = 0;
			int num3 = -1;
			bool flag = true;
			bool flag2 = false;
			for (int i = 0; i < text.Length; i++)
			{
				char c = text[i];
				if (c == '<')
				{
					flag2 = true;
				}
				if (c == ' ' && !flag2)
				{
					num3 = text3.Length;
				}
				if (c != '\n')
				{
					text3 += c;
					if (!flag2)
					{
						num2++;
					}
				}
				if (c == '>' && flag2)
				{
					flag2 = false;
				}
				if (num2 < num && c != '\n')
				{
					continue;
				}
				if (c != '\n' && c != ' ')
				{
					if (num3 != -1)
					{
						string text4 = ((padLeftFirst || !flag) ? leftPadding : "") + text3.Substring(0, num3) + new string(' ', Mathf.Max(0, num - num3)) + rightPadding;
						text2 = text2 + text4 + "\n";
						text3 = text3.Substring(num3 + 1);
					}
					else
					{
						string text5 = ((padLeftFirst || !flag) ? leftPadding : "") + text3 + rightPadding;
						text2 = text2 + text5 + "\n";
						text3 = "";
					}
				}
				else
				{
					if (text3 != "")
					{
						text2 = text2 + ((padLeftFirst || !flag) ? leftPadding : "") + text3 + new string(' ', Mathf.Max(0, num - num2)) + rightPadding + "\n";
					}
					text3 = "";
				}
				num3 = -1;
				flag = false;
				num2 = text3.Length;
			}
			if (text3 != "")
			{
				text2 = text2 + ((padLeftFirst || !flag) ? leftPadding : "") + text3 + new string(' ', Mathf.Max(0, num - num2)) + rightPadding + "\n";
			}
			return text2;
		}

		internal static void SpawnExplosion(Vector3 explosionPosition, bool spawnExplosionEffect = false, float killRange = 1f, float damageRange = 1f, int nonLethalDamage = 50, float physicsForce = 0f, GameObject overridePrefab = null, bool goThroughCar = false)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			Landmine.SpawnExplosion(explosionPosition, spawnExplosionEffect, killRange, damageRange, nonLethalDamage, physicsForce, overridePrefab, goThroughCar);
		}
	}
}
namespace CustomItemBehaviourLibrary.Manager
{
	internal class PlayerManager : MonoBehaviour
	{
		internal const float DEFAULT_MULTIPLIER = 1f;

		internal float sensitivityMultiplier = 1f;

		internal float sloppyMultiplier = 1f;

		internal bool holdingContainer = false;

		internal float sanityOvertimeTimer;

		internal float sanityOvertimeReplenish;

		internal static PlayerManager instance;

		private void Start()
		{
			instance = this;
			sanityOvertimeReplenish = 0f;
			sanityOvertimeTimer = 0f;
		}

		private void Update()
		{
			DepleteSanityOvertime();
		}

		internal void DepleteSanityOvertime()
		{
			if (!(sanityOvertimeReplenish <= 0f))
			{
				sanityOvertimeTimer -= Time.deltaTime;
				if (sanityOvertimeTimer <= 0f)
				{
					sanityOvertimeReplenish = 0f;
				}
			}
		}

		internal void AddSanityOvertimeTimer(float sanityOvertimeTimer)
		{
			this.sanityOvertimeTimer += sanityOvertimeTimer;
		}

		internal void SetSanityOvertimeReplenish(float sanityOvertimeReplenish)
		{
			this.sanityOvertimeReplenish = sanityOvertimeReplenish;
		}

		internal static float GetSanityOvertimeReplenish()
		{
			return instance.sanityOvertimeReplenish;
		}

		public static float DecreaseSanityIncrease(float defaultValue)
		{
			return defaultValue - instance.sanityOvertimeReplenish;
		}

		internal void SetSensitivityMultiplier(float sensitivityMultiplier)
		{
			this.sensitivityMultiplier = sensitivityMultiplier;
		}

		internal void SetSloppyMultiplier(float sloppyMultiplier)
		{
			this.sloppyMultiplier = sloppyMultiplier;
		}

		internal void SetHoldingContainer(bool holdingContainer)
		{
			this.holdingContainer = holdingContainer;
		}

		internal void ResetSensitivityMultiplier()
		{
			sensitivityMultiplier = 1f;
		}

		internal void ResetSloppyMultiplier()
		{
			sloppyMultiplier = 1f;
		}

		public float GetSensitivityMultiplier()
		{
			return sensitivityMultiplier;
		}

		public float GetSloppyMultiplier()
		{
			return sloppyMultiplier;
		}

		public bool GetHoldingContainer()
		{
			return holdingContainer;
		}
	}
}
namespace CustomItemBehaviourLibrary.Compatibility
{
	internal static class LategameCompatibility
	{
		public static bool Enabled => Chainloader.PluginInfos.ContainsKey("com.malco.lethalcompany.moreshipupgrades");

		internal static void AddWeight(ContainerBehaviour containerBehaviour)
		{
			PlayerControllerB playerHeldBy = ((GrabbableObject)containerBehaviour).playerHeldBy;
			playerHeldBy.carryWeight -= Mathf.Clamp(BackMuscles.DecreasePossibleWeight(((GrabbableObject)containerBehaviour).itemProperties.weight - 1f), 0f, 10f);
			PlayerControllerB playerHeldBy2 = ((GrabbableObject)containerBehaviour).playerHeldBy;
			playerHeldBy2.carryWeight += Mathf.Clamp(BackMuscles.DecreasePossibleWeight(containerBehaviour.totalWeight - 1f), 0f, 10f);
		}

		internal static void AddTotalWeight(ContainerBehaviour containerBehaviour)
		{
			PlayerControllerB playerHeldBy = ((GrabbableObject)containerBehaviour).playerHeldBy;
			playerHeldBy.carryWeight += Mathf.Clamp(BackMuscles.DecreasePossibleWeight(containerBehaviour.totalWeight - 1f), 0f, 10f);
		}

		internal static void RemoveTotalWeight(ContainerBehaviour containerBehaviour)
		{
			PlayerControllerB playerHeldBy = ((GrabbableObject)containerBehaviour).playerHeldBy;
			playerHeldBy.carryWeight -= Mathf.Clamp(BackMuscles.DecreasePossibleWeight(containerBehaviour.totalWeight - 1f), 0f, 10f);
		}

		internal static void RemoveWeight(ContainerBehaviour containerBehaviour)
		{
			PlayerControllerB playerHeldBy = ((GrabbableObject)containerBehaviour).playerHeldBy;
			playerHeldBy.carryWeight += Mathf.Clamp(BackMuscles.DecreasePossibleWeight(((GrabbableObject)containerBehaviour).itemProperties.weight - 1f), 0f, 10f);
			PlayerControllerB playerHeldBy2 = ((GrabbableObject)containerBehaviour).playerHeldBy;
			playerHeldBy2.carryWeight -= Mathf.Clamp(BackMuscles.DecreasePossibleWeight(containerBehaviour.totalWeight - 1f), 0f, 10f);
		}
	}
}
namespace CustomItemBehaviourLibrary.AbstractItems
{
	public abstract class ContainerBehaviour : GrabbableObject
	{
		public enum Restrictions
		{
			None,
			TotalWeight,
			ItemCount,
			All
		}

		internal const float VELOCITY_APPLY_EFFECT_THRESHOLD = 5f;

		protected Restrictions restriction;

		private Random randomNoise;

		private AudioSource wheelsNoise;

		protected AudioClip[] wheelsClip;

		protected float noiseRange;

		private float soundCounter;

		protected int maximumAmountItems;

		protected float maximumWeightAllowed;

		private int currentAmountItems;

		internal float totalWeight;

		protected float weightReduceMultiplier;

		protected float defaultWeight;

		protected float sloppiness;

		protected float lookSensitivityDrawback;

		protected bool makeItemsInvisible;

		private BoxCollider container;

		protected InteractTrigger[] triggers;

		protected BoxCollider[] triggerColliders;

		protected bool playSounds;

		private Dictionary<Restrictions, Func<bool>> checkMethods;

		private const string NO_ITEMS_TEXT = "No items to deposit...";

		private const string FULL_TEXT = "Too many items in the container";

		private const string TOO_MUCH_WEIGHT_TEXT = "Too much weight in the container...";

		private const string ALL_FULL_TEXT = "Cannot insert any more items in the container...";

		private const string WHEELBARROWCEPTION_TEXT = "You're not allowed to do that...";

		private const string ENEMY_DEPOSIT_TEXT = "You shouldn't put alive things in here...";

		private const string DEPOSIT_TEXT = "Depositing item...";

		private const string START_DEPOSIT_TEXT = "Deposit item: [LMB]";

		private const string WITHDRAW_ITEM_TEXT = "Withdraw item: [LMB]";

		public override void Start()
		{
			((GrabbableObject)this).Start();
			randomNoise = new Random(StartOfRound.Instance.randomMapSeed + 80);
			defaultWeight = base.itemProperties.weight;
			totalWeight = defaultWeight;
			soundCounter = 0f;
			wheelsNoise = ((Component)this).GetComponent<AudioSource>();
			triggers = ((Component)this).GetComponentsInChildren<InteractTrigger>();
			triggerColliders = (BoxCollider[])(object)new BoxCollider[triggers.Length];
			BoxCollider[] componentsInChildren = ((Component)this).GetComponentsInChildren<BoxCollider>();
			foreach (BoxCollider val in componentsInChildren)
			{
				if (!(((Object)val).name != "PlaceableBounds"))
				{
					container = val;
					break;
				}
			}
			for (int j = 0; j < triggers.Length; j++)
			{
				InteractTrigger val2 = triggers[j];
				((UnityEvent<PlayerControllerB>)(object)val2.onInteract).AddListener((UnityAction<PlayerControllerB>)InteractContainer);
				((Component)val2).tag = "InteractTrigger";
				val2.interactCooldown = false;
				val2.cooldownTime = 0f;
				triggerColliders[j] = ((Component)val2).GetComponent<BoxCollider>();
			}
			checkMethods = new Dictionary<Restrictions, Func<bool>>
			{
				[Restrictions.ItemCount] = CheckContainerItemCountRestriction,
				[Restrictions.TotalWeight] = CheckContainerWeightRestriction,
				[Restrictions.All] = CheckContainerAllRestrictions
			};
			SetupItemAttributes();
		}

		public float GetSloppiness()
		{
			return sloppiness;
		}

		public float GetLookSensitivityDrawback()
		{
			return lookSensitivityDrawback;
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			UpdateContainerSounds();
			UpdateInteractTriggers();
			bool enabled = ShowDepositPrompts();
			for (int i = 0; i < triggerColliders.Length; i++)
			{
				BoxCollider val = triggerColliders[i];
				((Collider)val).enabled = enabled;
			}
		}

		public void UpdateContainerDrop()
		{
			if (base.isHeld && !((Object)(object)base.playerHeldBy != (Object)(object)GameNetworkManager.Instance.localPlayerController) && currentAmountItems > 0)
			{
				DropAllItemsInContainerServerRpc();
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void DropAllItemsInContainerServerRpc()
		{
			//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(76295531u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 76295531u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					DropAllItemsInContainerClientRpc();
				}
			}
		}

		[ClientRpc]
		private void DropAllItemsInContainerClientRpc()
		{
			//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(3995238815u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3995238815u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			GrabbableObject[] componentsInChildren = ((Component)this).GetComponentsInChildren<GrabbableObject>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				if (!((Object)(object)componentsInChildren[i] == (Object)(object)this))
				{
					DropItem(ref componentsInChildren[i]);
				}
			}
			UpdateContainerWeightServerRpc();
		}

		protected void DropItem(ref GrabbableObject grabbableObject)
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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)
			grabbableObject.parentObject = null;
			grabbableObject.heldByPlayerOnServer = false;
			if (base.isInElevator)
			{
				((Component)grabbableObject).transform.SetParent(base.playerHeldBy.playersManager.elevatorTransform, true);
			}
			else
			{
				((Component)grabbableObject).transform.SetParent(base.playerHeldBy.playersManager.propsContainer, true);
			}
			base.playerHeldBy.SetItemInElevator(base.playerHeldBy.isInHangarShipRoom, base.isInElevator, grabbableObject);
			grabbableObject.EnablePhysics(true);
			grabbableObject.EnableItemMeshes(true);
			((Component)grabbableObject).transform.localScale = grabbableObject.originalScale;
			grabbableObject.isHeld = false;
			grabbableObject.isPocketed = false;
			grabbableObject.startFallingPosition = ((Component)grabbableObject).transform.parent.InverseTransformPoint(((Component)grabbableObject).transform.position);
			grabbableObject.FallToGround(true);
			grabbableObject.fallTime = Random.Range(-0.3f, 0.05f);
			grabbableObject.hasHitGround = false;
			if (!grabbableObject.itemProperties.syncDiscardFunction)
			{
				grabbableObject.playerHeldBy = null;
			}
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			GrabbableObject[] componentsInChildren = ((Component)this).GetComponentsInChildren<GrabbableObject>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				if (!((Object)(object)componentsInChildren[i] == (Object)(object)this))
				{
					componentsInChildren[i].EnableItemMeshes(!makeItemsInvisible);
				}
			}
		}

		private void UpdateContainerSounds()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			soundCounter += Time.deltaTime;
			if (!base.isHeld || (Object)(object)wheelsNoise == (Object)null)
			{
				return;
			}
			Vector3 velocity = base.playerHeldBy.thisController.velocity;
			if (((Vector3)(ref velocity)).magnitude == 0f)
			{
				wheelsNoise.Stop();
			}
			else if (!(soundCounter < 2f))
			{
				soundCounter = 0f;
				int num = randomNoise.Next(0, wheelsClip.Length);
				if (playSounds)
				{
					wheelsNoise.PlayOneShot(wheelsClip[num], 0.2f);
				}
				if (playSounds)
				{
					WalkieTalkie.TransmitOneShotAudio(wheelsNoise, wheelsClip[num], 0.2f);
				}
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, noiseRange, 0.8f, 0, base.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
			}
		}

		private void UpdateInteractTriggers()
		{
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if ((Object)(object)localPlayerController == (Object)null)
			{
				SetInteractTriggers(interactable: false, "No items to deposit...");
				return;
			}
			if (!localPlayerController.isHoldingObject)
			{
				SetInteractTriggers(interactable: false, "No items to deposit...");
				return;
			}
			GrabbableObject currentlyHeldObjectServer = localPlayerController.currentlyHeldObjectServer;
			if ((Object)(object)((Component)currentlyHeldObjectServer).GetComponent<ContainerBehaviour>() != (Object)null)
			{
				SetInteractTriggers(interactable: false, "You're not allowed to do that...");
				return;
			}
			EnemyAI component = ((Component)currentlyHeldObjectServer).GetComponent<EnemyAI>();
			if ((Object)(object)component != (Object)null && !component.isEnemyDead)
			{
				SetInteractTriggers(interactable: false, "You shouldn't put alive things in here...");
			}
			else if (!CheckContainerRestrictions())
			{
				SetInteractTriggers(interactable: true);
			}
		}

		private void SetInteractTriggers(bool interactable = false, string hoverTip = "Deposit item: [LMB]")
		{
			InteractTrigger[] array = triggers;
			foreach (InteractTrigger val in array)
			{
				val.interactable = interactable;
				if (interactable)
				{
					val.hoverTip = hoverTip;
				}
				else
				{
					val.disabledHoverTip = hoverTip;
				}
			}
		}

		private void EnableInteractTriggers(bool enabled)
		{
			InteractTrigger[] array = triggers;
			foreach (InteractTrigger val in array)
			{
				((Component)val).gameObject.SetActive(enabled);
			}
		}

		private bool CheckContainerRestrictions()
		{
			if (restriction == Restrictions.None)
			{
				return false;
			}
			return checkMethods[restriction]();
		}

		private bool CheckContainerAllRestrictions()
		{
			bool flag = totalWeight > 1f + maximumWeightAllowed / 100f;
			bool flag2 = currentAmountItems >= maximumAmountItems;
			if (flag || flag2)
			{
				SetInteractTriggers(interactable: false, "Cannot insert any more items in the container...");
				return true;
			}
			return false;
		}

		private bool CheckContainerWeightRestriction()
		{
			if (totalWeight > 1f + maximumWeightAllowed / 100f)
			{
				SetInteractTriggers(interactable: false, "Too much weight in the container...");
				return true;
			}
			return false;
		}

		private bool CheckContainerItemCountRestriction()
		{
			if (currentAmountItems >= maximumAmountItems)
			{
				SetInteractTriggers(interactable: false, "Too many items in the container");
				return true;
			}
			return false;
		}

		internal void UpdatePlayerAttributes(bool grabbing)
		{
			if (grabbing)
			{
				if (LategameCompatibility.Enabled)
				{
					LategameCompatibility.AddWeight(this);
				}
				else
				{
					PlayerControllerB playerHeldBy = base.playerHeldBy;
					playerHeldBy.carryWeight -= Mathf.Clamp(base.itemProperties.weight - 1f, 0f, 10f);
					PlayerControllerB playerHeldBy2 = base.playerHeldBy;
					playerHeldBy2.carryWeight += Mathf.Clamp(totalWeight - 1f, 0f, 10f);
				}
				PlayerManager.instance.SetSensitivityMultiplier(lookSensitivityDrawback);
				PlayerManager.instance.SetSloppyMultiplier(sloppiness);
				PlayerManager.instance.SetHoldingContainer(holdingContainer: true);
			}
			else
			{
				if (LategameCompatibility.Enabled)
				{
					LategameCompatibility.RemoveWeight(this);
				}
				else
				{
					PlayerControllerB playerHeldBy3 = base.playerHeldBy;
					playerHeldBy3.carryWeight += Mathf.Clamp(base.itemProperties.weight - 1f, 0f, 10f);
					PlayerControllerB playerHeldBy4 = base.playerHeldBy;
					playerHeldBy4.carryWeight -= Mathf.Clamp(totalWeight - 1f, 0f, 10f);
				}
				PlayerManager.instance.ResetSensitivityMultiplier();
				PlayerManager.instance.ResetSloppyMultiplier();
				PlayerManager.instance.SetHoldingContainer(holdingContainer: false);
			}
		}

		public override void DiscardItem()
		{
			wheelsNoise.Stop();
			if (Object.op_Implicit((Object)(object)base.playerHeldBy) && (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)base.playerHeldBy)
			{
				UpdatePlayerAttributes(grabbing: false);
				EnableInteractTriggers(enabled: true);
			}
			GrabbableObject[] componentsInChildren = ((Component)this).GetComponentsInChildren<GrabbableObject>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				if (!(componentsInChildren[i] is ContainerBehaviour))
				{
					base.playerHeldBy.SetItemInElevator(base.playerHeldBy.isInHangarShipRoom, base.playerHeldBy.isInElevator, componentsInChildren[i]);
					componentsInChildren[i].EnableItemMeshes(!makeItemsInvisible);
				}
			}
			((GrabbableObject)this).DiscardItem();
		}

		public override void GrabItem()
		{
			((GrabbableObject)this).GrabItem();
			if (Object.op_Implicit((Object)(object)base.playerHeldBy) && (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)base.playerHeldBy)
			{
				UpdatePlayerAttributes(grabbing: true);
				EnableInteractTriggers(enabled: false);
				if (base.playerHeldBy.isCrouching)
				{
					base.playerHeldBy.Crouch(!base.playerHeldBy.isCrouching);
				}
			}
		}

		private void SetupItemAttributes()
		{
			base.grabbable = true;
			base.grabbableToEnemies = true;
			base.itemProperties.toolTips = SetupContainerTooltips();
			SetupScanNodeProperties();
		}

		protected abstract string[] SetupContainerTooltips();

		protected abstract void SetupScanNodeProperties();

		public void DecrementStoredItems()
		{
			UpdateContainerWeightServerRpc();
		}

		[ServerRpc(RequireOwnership = false)]
		private void UpdateContainerWeightServerRpc()
		{
			//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(368202541u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 368202541u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					UpdateContainerWeightClientRpc();
				}
			}
		}

		[ClientRpc]
		private void UpdateContainerWeightClientRpc()
		{
			//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(871837224u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 871837224u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			GrabbableObject[] componentsInChildren = ((Component)this).GetComponentsInChildren<GrabbableObject>();
			if (base.isHeld && (Object)(object)base.playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				if (LategameCompatibility.Enabled)
				{
					LategameCompatibility.RemoveTotalWeight(this);
				}
				else
				{
					PlayerControllerB playerHeldBy = base.playerHeldBy;
					playerHeldBy.carryWeight -= Mathf.Clamp(totalWeight - 1f, 0f, 10f);
				}
			}
			totalWeight = defaultWeight;
			currentAmountItems = 0;
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				if (!((Object)(object)((Component)componentsInChildren[i]).GetComponent<ContainerBehaviour>() != (Object)null))
				{
					currentAmountItems++;
					GrabbableObject val3 = componentsInChildren[i];
					totalWeight += (val3.itemProperties.weight - 1f) * weightReduceMultiplier;
				}
			}
			if (base.isHeld && (Object)(object)base.playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				if (LategameCompatibility.Enabled)
				{
					LategameCompatibility.AddTotalWeight(this);
					return;
				}
				PlayerControllerB playerHeldBy2 = base.playerHeldBy;
				playerHeldBy2.carryWeight += Mathf.Clamp(totalWeight - 1f, 0f, 10f);
			}
		}

		private void InteractContainer(PlayerControllerB playerInteractor)
		{
			if (playerInteractor.isHoldingObject)
			{
				StoreItemInContainer(ref playerInteractor);
			}
		}

		private void StoreItemInContainer(ref PlayerControllerB playerInteractor)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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)
			Collider val = (Collider)(object)container;
			Vector3 val2 = RoundManager.RandomPointInBounds(val.bounds);
			Bounds bounds = val.bounds;
			val2.y = ((Bounds)(ref bounds)).max.y;
			val2.y += playerInteractor.currentlyHeldObjectServer.itemProperties.verticalOffset;
			val2 = ((Component)((Component)this).GetComponent<NetworkObject>()).transform.InverseTransformPoint(val2);
			GrabbableObject currentlyHeldObjectServer = playerInteractor.currentlyHeldObjectServer;
			playerInteractor.DiscardHeldObject(true, ((Component)this).GetComponent<NetworkObject>(), val2, false);
			currentlyHeldObjectServer.EnableItemMeshes(!makeItemsInvisible);
			UpdateContainerWeightServerRpc();
		}

		public static float CheckIfPlayerCarryingContainerLookSensitivity(float defaultValue)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if ((Object)(object)localPlayerController == (Object)null || (Object)(object)localPlayerController.thisController == (Object)null)
			{
				return defaultValue;
			}
			Vector3 velocity = localPlayerController.thisController.velocity;
			if (((Vector3)(ref velocity)).magnitude <= 5f)
			{
				return defaultValue;
			}
			return defaultValue * PlayerManager.instance.GetSensitivityMultiplier();
		}

		public static float CheckIfPlayerCarryingContainerMovement(float defaultValue)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if ((Object)(object)localPlayerController == (Object)null || (Object)(object)localPlayerController.thisController == (Object)null)
			{
				return defaultValue;
			}
			Vector3 velocity = localPlayerController.thisController.velocity;
			if (((Vector3)(ref velocity)).magnitude <= 5f)
			{
				return defaultValue;
			}
			return defaultValue * PlayerManager.instance.GetSloppyMultiplier();
		}

		public static bool CheckIfPlayerCarryingContainer()
		{
			return PlayerManager.instance.GetHoldingContainer();
		}

		public static bool CheckIfItemInContainer(GrabbableObject item)
		{
			if ((Object)(object)item == (Object)null)
			{
				return false;
			}
			return (Object)(object)((Component)item).GetComponentInParent<ContainerBehaviour>() != (Object)null;
		}

		protected virtual bool ShowDepositPrompts()
		{
			return true;
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_ContainerBehaviour()
		{
			//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
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(76295531u, new RpcReceiveHandler(__rpc_handler_76295531));
			NetworkManager.__rpc_func_table.Add(3995238815u, new RpcReceiveHandler(__rpc_handler_3995238815));
			NetworkManager.__rpc_func_table.Add(368202541u, new RpcReceiveHandler(__rpc_handler_368202541));
			NetworkManager.__rpc_func_table.Add(871837224u, new RpcReceiveHandler(__rpc_handler_871837224));
		}

		private static void __rpc_handler_76295531(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;
				((ContainerBehaviour)(object)target).DropAllItemsInContainerServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3995238815(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;
				((ContainerBehaviour)(object)target).DropAllItemsInContainerClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_368202541(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;
				((ContainerBehaviour)(object)target).UpdateContainerWeightServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_871837224(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;
				((ContainerBehaviour)(object)target).UpdateContainerWeightClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "ContainerBehaviour";
		}
	}
	public abstract class LookoutBehaviour : GrabbableObject
	{
		private static List<LookoutBehaviour> coilHeadItems = new List<LookoutBehaviour>();

		private bool Active;

		protected int maximumRange;

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

		public override void Update()
		{
			((GrabbableObject)this).Update();
			SetActive(!base.isHeld && !base.isHeldByEnemy);
		}

		protected virtual void SetActive(bool enable)
		{
			Active = enable;
		}

		protected virtual bool HasLineOfSightToPosition(Vector3 pos)
		{
			//IL_0018: 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)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (!Active)
			{
				return false;
			}
			float num = Vector3.Distance(((Component)this).transform.position, pos);
			return num < (float)maximumRange && !Physics.Linecast(((Component)this).transform.position, pos, StartOfRound.Instance.collidersRoomDefaultAndFoliage, (QueryTriggerInteraction)1);
		}

		public static bool HasLineOfSightToPeepers(Vector3 springPosition)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			foreach (LookoutBehaviour item in coilHeadItems.ToList())
			{
				if ((Object)(object)item == (Object)null)
				{
					coilHeadItems.Remove(item);
				}
				else if (item.HasLineOfSightToPosition(springPosition))
				{
					return true;
				}
			}
			return false;
		}

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

		protected internal override string __getTypeName()
		{
			return "LookoutBehaviour";
		}
	}
	public abstract class PortableTeleporterBehaviour : GrabbableObject
	{
		internal static bool TPButtonPressed;

		protected bool keepItems;

		private ShipTeleporter shipTeleporter;

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			if (CanUsePortableTeleporter())
			{
				int playerRadarIndex = SearchForPlayerInRadar();
				ShipTeleporter teleporter = GetShipTeleporter();
				TeleportPlayer(playerRadarIndex, ref teleporter);
			}
		}

		protected virtual void TeleportPlayer(int playerRadarIndex, ref ShipTeleporter teleporter)
		{
			if (playerRadarIndex == -1)
			{
				StartOfRound.Instance.mapScreen.targetedPlayer = base.playerHeldBy;
				TPButtonPressed = true;
				teleporter.PressTeleportButtonOnLocalClient();
			}
			else
			{
				StartOfRound.Instance.mapScreen.SwitchRadarTargetAndSync(playerRadarIndex);
				((MonoBehaviour)this).StartCoroutine(WaitToTP(teleporter));
			}
		}

		private int SearchForPlayerInRadar()
		{
			int result = -1;
			for (int i = 0; i < StartOfRound.Instance.mapScreen.radarTargets.Count; i++)
			{
				if (!((Object)(object)((Component)StartOfRound.Instance.mapScreen.radarTargets[i].transform).gameObject.GetComponent<PlayerControllerB>() != (Object)(object)base.playerHeldBy))
				{
					result = i;
					break;
				}
			}
			return result;
		}

		protected virtual bool CanUsePortableTeleporter()
		{
			if (base.itemUsedUp)
			{
				return false;
			}
			ShipTeleporter val = GetShipTeleporter();
			if ((Object)(object)val == (Object)null || !val.buttonTrigger.interactable)
			{
				return false;
			}
			return true;
		}

		private ShipTeleporter GetShipTeleporter()
		{
			if ((Object)(object)shipTeleporter != (Object)null)
			{
				return shipTeleporter;
			}
			ShipTeleporter[] array = Object.FindObjectsOfType<ShipTeleporter>();
			ShipTeleporter val = null;
			ShipTeleporter[] array2 = array;
			foreach (ShipTeleporter val2 in array2)
			{
				if (!val2.isInverseTeleporter)
				{
					val = val2;
					break;
				}
			}
			shipTeleporter = val;
			return shipTeleporter;
		}

		protected virtual IEnumerator WaitToTP(ShipTeleporter tele)
		{
			yield return (object)new WaitForSeconds(0.15f);
			if (keepItems)
			{
				ReqUpdateTpDropStatusServerRpc();
			}
			tele.PressTeleportButtonOnLocalClient();
		}

		[ServerRpc(RequireOwnership = false)]
		public void ReqUpdateTpDropStatusServerRpc()
		{
			//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(1894825709u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1894825709u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ChangeTPButtonPressedClientRpc();
				}
			}
		}

		[ClientRpc]
		private void ChangeTPButtonPressedClientRpc()
		{
			//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(2168290007u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2168290007u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					TPButtonPressed = true;
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_PortableTeleporterBehaviour()
		{
			//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(1894825709u, new RpcReceiveHandler(__rpc_handler_1894825709));
			NetworkManager.__rpc_func_table.Add(2168290007u, new RpcReceiveHandler(__rpc_handler_2168290007));
		}

		private static void __rpc_handler_1894825709(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;
				((PortableTeleporterBehaviour)(object)target).ReqUpdateTpDropStatusServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2168290007(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;
				((PortableTeleporterBehaviour)(object)target).ChangeTPButtonPressedClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "PortableTeleporterBehaviour";
		}
	}
	public abstract class ReplenishBatteryBehaviour : GrabbableObject
	{
		protected float rechargePercentage = 1f;

		protected float rechargeUsages = 1f;

		protected bool canOvercharge = false;

		protected bool destroyUponOutOfUsages = false;

		protected abstract bool CanRechargeItems();

		protected abstract GrabbableObject GrabItemToRecharge();

		protected abstract bool CanRechargeItem(GrabbableObject grabbableObject);

		[ServerRpc(RequireOwnership = false)]
		private void RechargeItemServerRpc(NetworkBehaviourReference grabbableObject)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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_007d: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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(170802947u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref grabbableObject, default(ForNetworkSerializable));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 170802947u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					RechargeItemClientRpc(grabbableObject);
				}
			}
		}

		[ClientRpc]
		private void RechargeItemClientRpc(NetworkBehaviourReference grabbableObject)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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_007d: 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_0097: 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(3304978283u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref grabbableObject, default(ForNetworkSerializable));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3304978283u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					GrabbableObject grabbableObject2 = default(GrabbableObject);
					((NetworkBehaviourReference)(ref grabbableObject)).TryGet<GrabbableObject>(ref grabbableObject2, (NetworkManager)null);
					RechargeItem(grabbableObject2);
				}
			}
		}

		protected virtual void RechargeItem(GrabbableObject grabbableObject)
		{
			grabbableObject.insertedBattery.charge = Mathf.Clamp(grabbableObject.insertedBattery.charge + rechargePercentage, 0f, canOvercharge ? float.MaxValue : 1f);
			grabbableObject.insertedBattery.empty = false;
			rechargeUsages -= 1f;
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (!CanRechargeItems())
			{
				if (destroyUponOutOfUsages)
				{
					((GrabbableObject)this).DestroyObjectInHand(base.playerHeldBy);
				}
				return;
			}
			GrabbableObject val = GrabItemToRecharge();
			if (!((Object)(object)val == (Object)null) && CanRechargeItem(val))
			{
				if (((NetworkBehaviour)this).IsServer)
				{
					RechargeItemClientRpc(new NetworkBehaviourReference((NetworkBehaviour)(object)val));
				}
				else
				{
					RechargeItemServerRpc(new NetworkBehaviourReference((NetworkBehaviour)(object)val));
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_ReplenishBatteryBehaviour()
		{
			//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(170802947u, new RpcReceiveHandler(__rpc_handler_170802947));
			NetworkManager.__rpc_func_table.Add(3304978283u, new RpcReceiveHandler(__rpc_handler_3304978283));
		}

		private static void __rpc_handler_170802947(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference grabbableObject = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref grabbableObject, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ReplenishBatteryBehaviour)(object)target).RechargeItemServerRpc(grabbableObject);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3304978283(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference grabbableObject = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref grabbableObject, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ReplenishBatteryBehaviour)(object)target).RechargeItemClientRpc(grabbableObject);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "ReplenishBatteryBehaviour";
		}
	}
	public abstract class ReplenishSanityBehaviour : GrabbableObject
	{
		protected float sanityReplenish;

		protected float sanityOvertime;

		protected float sanityOvertimeReplenish;

		protected int rechargeUsages;

		protected bool destroyUponExaustion;

		protected virtual bool CanRestoreSanity(PlayerControllerB player)
		{
			return rechargeUsages > 0;
		}

		protected virtual void RestoreSanity(ref PlayerControllerB player)
		{
			player.insanityLevel = Mathf.Clamp(player.insanityLevel - sanityReplenish * player.maxInsanityLevel, 0f, player.maxInsanityLevel);
			if (sanityOvertime > 0f)
			{
				PlayerManager.instance.SetSanityOvertimeReplenish(sanityOvertimeReplenish);
				PlayerManager.instance.AddSanityOvertimeTimer(sanityOvertime);
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			RestoreSanityServerRpc(new NetworkBehaviourReference((NetworkBehaviour)(object)base.playerHeldBy));
		}

		[ServerRpc(RequireOwnership = false)]
		private void RestoreSanityServerRpc(NetworkBehaviourReference player)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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_007d: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: 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(153343895u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref player, default(ForNetworkSerializable));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 153343895u, val, (RpcDelivery)0);
				}
				PlayerControllerB player2 = default(PlayerControllerB);
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && ((NetworkBehaviourReference)(ref player)).TryGet<PlayerControllerB>(ref player2, (NetworkManager)null) && CanRestoreSanity(player2))
				{
					RestoreSanityClientRpc(player);
				}
			}
		}

		[ClientRpc]
		private void RestoreSanityClientRpc(NetworkBehaviourReference player)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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_007d: 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_0097: 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(2732675176u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref player, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2732675176u, val, (RpcDelivery)0);
			}
			PlayerControllerB player2 = default(PlayerControllerB);
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost) || !((NetworkBehaviourReference)(ref player)).TryGet<PlayerControllerB>(ref player2, (NetworkManager)null))
			{
				return;
			}
			rechargeUsages--;
			if ((Object)(object)player2 == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				RestoreSanity(ref player2);
				if (rechargeUsages <= 0 && destroyUponExaustion)
				{
					((GrabbableObject)this).DestroyObjectInHand(base.playerHeldBy);
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_ReplenishSanityBehaviour()
		{
			//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(153343895u, new RpcReceiveHandler(__rpc_handler_153343895));
			NetworkManager.__rpc_func_table.Add(2732675176u, new RpcReceiveHandler(__rpc_handler_2732675176));
		}

		private static void __rpc_handler_153343895(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference player = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref player, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ReplenishSanityBehaviour)(object)target).RestoreSanityServerRpc(player);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2732675176(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference player = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref player, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ReplenishSanityBehaviour)(object)target).RestoreSanityClientRpc(player);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "ReplenishSanityBehaviour";
		}
	}
	public abstract class UnderwaterBreatherBehaviour : GrabbableObject
	{
		private StartOfRound roundInstance;

		public override void Start()
		{
			((GrabbableObject)this).Start();
			roundInstance = StartOfRound.Instance;
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			if (CanRetainOxygen())
			{
				roundInstance.drowningTimer = 1f;
			}
		}

		public virtual bool CanRetainOxygen()
		{
			return base.isHeld && (Object)(object)base.playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController;
		}

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

		protected internal override string __getTypeName()
		{
			return "UnderwaterBreatherBehaviour";
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace CustomItemBehaviourLibrary.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}