Decompiled source of Liquid Labyrinth v0.0.10

BepInEx/plugins/com.github.visualerror.liquid_labyrinth.dll

Decompiled 10 months ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using LethalSettings.UI;
using LethalSettings.UI.Components;
using LiquidLabyrinth.Enums;
using LiquidLabyrinth.ItemData;
using LiquidLabyrinth.ItemHelpers;
using LiquidLabyrinth.Patches;
using LiquidLabyrinth.Properties;
using LiquidLabyrinth.Utilities;
using LiquidLabyrinth.Utilities.MonoBehaviours;
using Microsoft.CodeAnalysis;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("VisualError")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Crazy potions and the like!")]
[assembly: AssemblyFileVersion("0.0.10.0")]
[assembly: AssemblyInformationalVersion("0.0.10-dev.1+6d842bceebe3af1a1a880dfc5db3635f76615ae3")]
[assembly: AssemblyProduct("Liquid Labyrinth")]
[assembly: AssemblyTitle("com.github.visualerror.liquid_labyrinth")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/VisualError/LiquidLabyrinth")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
internal class <Module>
{
	static <Module>()
	{
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>();
		NetworkVariableSerializationTypes.InitializeSerializer_FixedString<FixedString32Bytes>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<FixedString32Bytes>();
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<Vector3>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<Vector3>();
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<float>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<float>();
		NetworkVariableSerializationTypes.InitializeSerializer_FixedString<FixedString128Bytes>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<FixedString128Bytes>();
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<Color>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<Color>();
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<BottleModes>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedValueEquals<BottleModes>();
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 LiquidLabyrinth
{
	[BepInPlugin("com.github.visualerror.liquid_labyrinth", "Liquid Labyrinth", "0.0.10")]
	[BepInDependency("evaisa.lethallib", "0.13.0")]
	[BepInDependency("com.willis.lc.lethalsettings", "1.3.0")]
	[BepInProcess("Lethal Company.exe")]
	internal class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		internal static Plugin Instance;

		internal ConfigEntry<bool> RevivePlayer;

		internal ConfigEntry<bool> NoGravityInOrbit;

		internal ConfigEntry<bool> IsGrabbableToEnemies;

		internal ConfigEntry<bool> UseCustomNameList;

		internal ConfigEntry<int> BottleRarity;

		internal ConfigEntry<bool> spawnRandomEnemy;

		internal ConfigEntry<string> customNameList;

		internal Dictionary<string, EnemyType> enemyTypes = new Dictionary<string, EnemyType>();

		internal Dictionary<Type, int> SaveableItemDict = new Dictionary<Type, int>();

		internal int SliderValue;

		private readonly Harmony Harmony = new Harmony("com.github.visualerror.liquid_labyrinth");

		private string nameList = "";

		private List<string> scientificNames = new List<string>(142)
		{
			"Quasarion Helium", "Neutronium Carbon", "Protonium Oxygen", "Electronium Nitrogen", "Photonium Phosphorus", "Gravitonium Sulfur", "Meteorium Chlorine", "Cosmonium Snezium", "Quantumium Red", "Subatomicium Blue",
			"Interstellarium Green", "Galacticium Purple", "Cosmicium Yellow", "Starlightium Pink", "Nebulonium Teal", "Cometium Brown", "Asteroidium Grey", "Planetium Black ", "Galaxyon White", "Universeon Silver",
			"Multiverseon Gold", "Parallelon Bronze", "Dimensionon Copper", "Timeon Zinc", "Spaceon Tin", "Realityon Lead", "Existenceon Nickel", "Infinityon Aluminum", "Eternityon Iron", "Immortalityon Steel",
			"Helium", "Neon", "Argon", "Krypton", "Xenon", "Radon", "Beryllium", "Magnesium", "Calcium", "Strontium",
			"Barium", "Hafnium", "Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinum", "Gold", "Silver",
			"Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Polonium", "Astatine", "Francium", "Radium", "Actinium",
			"Thorium", "Protactinium", "Uranium", "Neptunium", "Plutonium", "Americium", "Curium", "Berkelium", "Californium", "Einsteinium",
			"Fermium", "Mendelevium", "Nobelium", "Lawrencium", "Rutherfordium", "Dubnium", "Seaborgium", "Bohrium", "Hassium", "Meitnerium",
			"Ununnilium", "Unununium", "Ununvium", "Ununhexium", "Ununseptium", "Ununoctium", "Quantum Physics", "Relativity", "Newtonian Physics", "Schrodinger Equation",
			"Einstein", "Dark Matter", "Dark Energy", "Quantum Entanglement", "Higgs Boson", "Gravitational Wave", "Wormhole", "Tachyon", "Singularity", "Event Horizon",
			"Neutrino", "Muon", "Lepton", "Quark", "Gluon", "Atom", "Electron Shell", "Proton", "Electron", "Nuclear Fusion",
			"Nuclear Fission", "Atomic Bond", "Isotope", "Radioactive Decay", "Alpha Particle", "Beta Particle", "Gamma Ray", "Microwave", "Radio Wave", "X-Ray",
			"Ultraviolet Ray", "Visible Light", "Infrared Ray", "Cosmic Ray", "Hubble Constant", "Big Crunch", "Heat Death", "Black Hole", "Quasar", "Nebula",
			"Galaxy", "Star Cluster", "Exoplanet", "Solar Wind", "Solar Flare", "Nova", "Supernova", "Pulsar", "White Dwarf", "Red Giant",
			"Blue Giant", "Star System"
		};

		private void NetcodeWeaver()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			for (int i = 0; i < types.Length; i++)
			{
				MethodInfo[] methods = types[i].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);
					}
				}
			}
		}

		private void Awake()
		{
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Expected O, but got Unknown
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Expected O, but got Unknown
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Expected O, but got Unknown
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Expected O, but got Unknown
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Expected O, but got Unknown
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Expected O, but got Unknown
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Expected O, but got Unknown
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_0426: Unknown result type (might be due to invalid IL or missing references)
			//IL_0439: Expected O, but got Unknown
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Expected O, but got Unknown
			//IL_0451: Unknown result type (might be due to invalid IL or missing references)
			//IL_0456: Unknown result type (might be due to invalid IL or missing references)
			//IL_0461: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Unknown result type (might be due to invalid IL or missing references)
			//IL_0485: Expected O, but got Unknown
			//IL_0487: Unknown result type (might be due to invalid IL or missing references)
			//IL_048c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0497: Unknown result type (might be due to invalid IL or missing references)
			//IL_04aa: Expected O, but got Unknown
			//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Expected O, but got Unknown
			//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f0: Expected O, but got Unknown
			Instance = this;
			Logger = ((BaseUnityPlugin)this).Logger;
			NetcodeWeaver();
			Logger.LogInfo((object)"Plugin com.github.visualerror.liquid_labyrinth is loaded!");
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine();
			stringBuilder.AppendLine("           [-]  ");
			stringBuilder.AppendLine("         .-'-'-.");
			stringBuilder.AppendLine("         :-...-:");
			stringBuilder.AppendLine("         |;:   |");
			stringBuilder.AppendLine("         |;:.._|");
			stringBuilder.AppendLine("         `-...-'");
			stringBuilder.AppendLine(" Liquid Labyrinth Loaded!");
			Logger.LogWarning((object)stringBuilder.ToString());
			OtherUtils.GenerateLayerMap();
			Harmony.PatchAll(typeof(GameNetworkManagerPatch));
			Harmony.PatchAll(typeof(PlayerControllerBPatch));
			Harmony.PatchAll(typeof(StartOfRoundPatch));
			Harmony.PatchAll(typeof(GrabbableObjectPatch));
			Harmony.PatchAll(typeof(INoiseListenerWorkaround));
			RevivePlayer = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Toggle Bottle Revive", true, "Bottle revive functionality, for testing purposes");
			NoGravityInOrbit = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Toggle Bottle Gravity In Orbit", true, "If Bottle Gravity is enabled/disabled during orbit.");
			IsGrabbableToEnemies = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Toggle Enemy Pickups", false, "if enemies can pick up objects made by the mod");
			BottleRarity = ((BaseUnityPlugin)this).Config.Bind<int>("Scraps", "Bottle Rarity", 60, "Set bottle rarity [Needs game restart.]");
			spawnRandomEnemy = ((BaseUnityPlugin)this).Config.Bind<bool>("Fun", "Spawn random enemy on revive", false, "[alpha only] Allow all enemy types to be spawned when revive fail");
			UseCustomNameList = ((BaseUnityPlugin)this).Config.Bind<bool>("Fun", "Use Custom Name List", false, "Set to true if you wan't to use your custom name list for bottles.");
			customNameList = ((BaseUnityPlugin)this).Config.Bind<string>("Fun", "Custom Bottle Name List", "", "Custom name list of your bottles. use (\",\") as a seperator.");
			customNameList.Value = "";
			SliderValue = BottleRarity.Value;
			foreach (string scientificName in scientificNames)
			{
				MarkovChain.TrainMarkovChain(scientificName);
			}
			AssetLoader.LoadAssetBundles();
			try
			{
				ModSettingsConfig val = new ModSettingsConfig();
				val.Name = "Liquid Labyrinth";
				val.Id = "com.github.visualerror.liquid_labyrinth";
				val.Description = "Liquid Labyrinth: Mysterious liquids";
				MenuComponent[] obj = new MenuComponent[8]
				{
					(MenuComponent)new ToggleComponent
					{
						Value = RevivePlayer.Value,
						Text = ((ConfigEntryBase)RevivePlayer).Description.Description,
						OnValueChanged = delegate(ToggleComponent self, bool value)
						{
							RevivePlayer.Value = value;
						}
					},
					(MenuComponent)new ToggleComponent
					{
						Value = NoGravityInOrbit.Value,
						Text = ((ConfigEntryBase)NoGravityInOrbit).Description.Description,
						OnValueChanged = delegate(ToggleComponent self, bool value)
						{
							NoGravityInOrbit.Value = value;
						}
					},
					(MenuComponent)new ToggleComponent
					{
						Value = IsGrabbableToEnemies.Value,
						Text = ((ConfigEntryBase)IsGrabbableToEnemies).Description.Description,
						OnValueChanged = delegate(ToggleComponent self, bool value)
						{
							IsGrabbableToEnemies.Value = value;
						}
					},
					(MenuComponent)new ToggleComponent
					{
						Value = spawnRandomEnemy.Value,
						Text = ((ConfigEntryBase)spawnRandomEnemy).Description.Description,
						OnValueChanged = delegate(ToggleComponent self, bool value)
						{
							spawnRandomEnemy.Value = value;
						}
					},
					default(MenuComponent),
					default(MenuComponent),
					default(MenuComponent),
					default(MenuComponent)
				};
				HorizontalComponent val2 = new HorizontalComponent();
				val2.Children = (MenuComponent[])(object)new MenuComponent[1] { (MenuComponent)new SliderComponent
				{
					WholeNumbers = true,
					MaxValue = 1000f,
					MinValue = 0f,
					Text = ((ConfigEntryBase)BottleRarity).Description.Description,
					Value = BottleRarity.Value,
					ShowValue = true,
					OnValueChanged = delegate(SliderComponent self, float value)
					{
						BottleRarity.Value = (int)value;
					}
				} };
				obj[4] = (MenuComponent)val2;
				obj[5] = (MenuComponent)new ToggleComponent
				{
					Value = UseCustomNameList.Value,
					Text = ((ConfigEntryBase)UseCustomNameList).Description.Description,
					OnValueChanged = delegate(ToggleComponent self, bool value)
					{
						UseCustomNameList.Value = value;
					}
				};
				val2 = new HorizontalComponent();
				val2.ChildAlignment = (TextAnchor)4;
				val2.Children = (MenuComponent[])(object)new MenuComponent[2]
				{
					(MenuComponent)new InputComponent
					{
						Placeholder = "[currently doesn't work]",
						Value = customNameList.Value,
						OnValueChanged = delegate(InputComponent self, string value)
						{
							nameList = value;
						}
					},
					(MenuComponent)new ButtonComponent
					{
						Text = "Add Custom Name",
						OnClick = delegate
						{
							ConfigEntry<string> obj2 = customNameList;
							obj2.Value = obj2.Value + "," + nameList;
						}
					}
				};
				obj[6] = (MenuComponent)val2;
				VerticalComponent val3 = new VerticalComponent();
				val3.Children = (MenuComponent[])(object)new MenuComponent[1] { (MenuComponent)new LabelComponent
				{
					Text = string.Join("\n", customNameList.Value.Split(","))
				} };
				obj[7] = (MenuComponent)val3;
				val.MenuComponents = (MenuComponent[])(object)obj;
				ModMenu.RegisterMod(val);
			}
			catch (Exception ex)
			{
				Logger.LogWarning((object)"Couldn't load LethalSettings for Configs!");
				Logger.LogError((object)ex);
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.github.visualerror.liquid_labyrinth";

		public const string PLUGIN_NAME = "Liquid Labyrinth";

		public const string PLUGIN_VERSION = "0.0.10";
	}
}
namespace LiquidLabyrinth.Utilities
{
	internal class AssetLoader
	{
		internal static Dictionary<string, Object> assetsDictionary = new Dictionary<string, Object>();

		internal static List<Item> items = new List<Item>();

		internal static void LoadAssetBundles()
		{
			AssetBundle val = AssetBundle.LoadFromMemory(Resources.liquidlabyrinth);
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Logger.LogWarning((object)"Assetbundle could not be loaded!");
				return;
			}
			string[] allAssetNames = val.GetAllAssetNames();
			NetworkObject val4 = default(NetworkObject);
			foreach (string text in allAssetNames)
			{
				if (!Path.GetExtension(text).Contains("asset"))
				{
					continue;
				}
				Object val2 = val.LoadAsset<Object>(text);
				if (val2 == (Object)null)
				{
					Plugin.Logger.LogWarning((object)("Asset " + text + " could not be loaded because it is not an Object!"));
					continue;
				}
				assetsDictionary.Add(text, val2);
				Item val3 = (Item)(object)((val2 is Item) ? val2 : null);
				if (val3 != null)
				{
					int num = ((((object)val3.spawnPrefab.GetComponent<GrabbableObject>()).GetType() != typeof(PotionBottle)) ? 20 : Plugin.Instance.BottleRarity.Value);
					Items.RegisterScrap(val3, num, (LevelTypes)(-1));
					Plugin.Logger.LogWarning((object)("Added Scrap Item: " + text));
					if (val3.spawnPrefab.TryGetComponent<NetworkObject>(ref val4) && (Object)(object)val4 != (Object)null)
					{
						NetworkPrefabs.RegisterNetworkPrefab(val3.spawnPrefab);
						Plugin.Logger.LogWarning((object)$"NetworkPrefab for {text} loaded! Rarity: {num}");
					}
					if (!items.Contains(val3))
					{
						items.Add(val3);
					}
				}
			}
		}
	}
	public static class AudioExt
	{
		internal static AudioClip MakeSubclip(this AudioClip clip, float start, float stop)
		{
			int frequency = clip.frequency;
			float num = stop - start;
			int num2 = (int)((float)frequency * num);
			AudioClip obj = AudioClip.Create(((Object)clip).name + "-sub", num2, 1, frequency, false);
			float[] array = new float[num2];
			clip.GetData(array, (int)((float)frequency * start));
			obj.SetData(array, 0);
			return obj;
		}

		public static IEnumerator FadeOut(this AudioSource audioSource, float fadeTime)
		{
			float startVolume = audioSource.volume;
			while (audioSource.volume > 0f)
			{
				audioSource.volume -= startVolume * Time.deltaTime / fadeTime;
				yield return null;
			}
			audioSource.Stop();
			audioSource.volume = audioSource.maxDistance - audioSource.minDistance;
		}
	}
	internal class MarkovChain
	{
		private static Dictionary<char, Dictionary<char, Dictionary<char, int>>> markovChain = new Dictionary<char, Dictionary<char, Dictionary<char, int>>>();

		internal static void TrainMarkovChain(string text)
		{
			for (int i = 0; i < text.Length - 2; i++)
			{
				char key = text[i];
				char key2 = text[i + 1];
				char key3 = text[i + 2];
				if (!markovChain.ContainsKey(key))
				{
					markovChain[key] = new Dictionary<char, Dictionary<char, int>>();
				}
				if (!markovChain[key].ContainsKey(key2))
				{
					markovChain[key][key2] = new Dictionary<char, int>();
				}
				if (!markovChain[key][key2].ContainsKey(key3))
				{
					markovChain[key][key2][key3] = 0;
				}
				markovChain[key][key2][key3]++;
			}
		}

		private static bool IsSpecialCharacter(char character)
		{
			if (!char.IsPunctuation(character))
			{
				return char.IsSymbol(character);
			}
			return true;
		}

		internal static string GenerateText(int length, int max)
		{
			StringBuilder stringBuilder = new StringBuilder();
			char c;
			do
			{
				c = char.ToUpper(markovChain.Keys.ElementAt(Random.Range(0, markovChain.Count)));
			}
			while (IsSpecialCharacter(c));
			if (!markovChain.ContainsKey(c))
			{
				c = char.ToLower(c);
			}
			stringBuilder.Append(c);
			int num = 0;
			for (int i = 0; i < length - 1; i++)
			{
				Dictionary<char, Dictionary<char, int>> dictionary = markovChain[c];
				int count = dictionary.Count;
				int num2 = Random.Range(0, count);
				foreach (KeyValuePair<char, Dictionary<char, int>> item in dictionary)
				{
					int count2 = item.Value.Count;
					if (num2 < count2)
					{
						c = item.Key;
						break;
					}
					num2 -= count2;
				}
				num++;
				if ((i >= length - 2 || c == ' ') && num <= 2)
				{
					Plugin.Logger.Log((LogLevel)63, (object)"Word ended too small, adding additional characters.");
					i -= 4;
					if (c == ' ')
					{
						continue;
					}
				}
				if (c == ' ')
				{
					num = 0;
				}
				stringBuilder.Append(c);
			}
			if (stringBuilder.Length > max)
			{
				Plugin.Logger.Log((LogLevel)63, (object)$"Generated word was bigger than {max} characters, recreating..");
				return GenerateText(length, max);
			}
			return stringBuilder.ToString();
		}
	}
	internal class OtherUtils
	{
		private static Dictionary<int, int> _masksByLayer;

		private static List<string> ConvertToMixedCase(List<string> inputList)
		{
			List<string> list = new List<string>();
			foreach (string input in inputList)
			{
				list.Add(ToMixedCase(input));
			}
			return list;
		}

		private static string ToMixedCase(string input)
		{
			return new CultureInfo("en-US", useUserOverride: false).TextInfo.ToTitleCase(input);
		}

		internal static bool TryDestroyRigidBody(GameObject gameObject)
		{
			Rigidbody val = default(Rigidbody);
			if (gameObject.TryGetComponent<Rigidbody>(ref val))
			{
				Plugin.Logger.LogWarning((object)"destroying rigid");
				Object.Destroy((Object)(object)val);
				return true;
			}
			return false;
		}

		internal static void GenerateLayerMap()
		{
			_masksByLayer = new Dictionary<int, int>();
			for (int i = 0; i < 32; i++)
			{
				int num = 0;
				for (int j = 0; j < 32; j++)
				{
					if (!Physics.GetIgnoreLayerCollision(i, j))
					{
						num |= 1 << j;
					}
				}
				_masksByLayer.Add(i, num);
			}
		}

		internal static void SetTagRecursively(GameObject obj, string tag)
		{
			//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)
			if ((Object)(object)obj == (Object)null)
			{
				return;
			}
			foreach (Transform item in obj.transform)
			{
				((Component)item).gameObject.tag = tag;
				SetTagRecursively(((Component)item).gameObject, tag);
			}
		}

		internal static float mapValue(float mainValue, float inValueMin, float inValueMax, float outValueMin, float outValueMax)
		{
			return (mainValue - inValueMin) * (outValueMax - outValueMin) / (inValueMax - inValueMin) + outValueMin;
		}

		internal static int MaskForLayer(int layer)
		{
			return _masksByLayer[layer];
		}
	}
	internal class PlayerUtils
	{
		internal static void RotateToObject(PlayerControllerB player, GameObject targetObject)
		{
			CoroutineHandler.Instance.NewCoroutine(typeof(PlayerUtils), RotateToObjectCoroutine(player, targetObject), stopWhenRunning: true);
		}

		internal static IEnumerator RotateToObjectCoroutine(PlayerControllerB player, GameObject targetObject)
		{
			float turnStartTime = Time.time;
			while (!((Object)(object)player == (Object)null) && !((Object)(object)((Component)player).transform == (Object)null) && !((Object)(object)targetObject == (Object)null) && !((Object)(object)targetObject.transform == (Object)null))
			{
				Vector3 val = targetObject.transform.position - ((Component)player).transform.position;
				((Vector3)(ref val))..ctor(val.x, 0f, val.z);
				Quaternion val2 = Quaternion.LookRotation(val);
				Quaternion rotation = ((Component)player).transform.rotation;
				float num = 1f;
				float num2 = (Time.time - turnStartTime) / num;
				((Component)player).transform.rotation = Quaternion.Slerp(rotation, val2, num2);
				float num3 = Quaternion.Angle(rotation, val2);
				player.SyncFullRotWithClients();
				if (num3 < 0.01f)
				{
					break;
				}
				yield return null;
			}
		}

		internal static void RevivePlayer(PlayerControllerB player, DeadBodyInfo bodyInfo, Vector3 spawnPosition)
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			if (!player.isPlayerDead)
			{
				return;
			}
			if (((NetworkBehaviour)player).IsOwner || ((NetworkBehaviour)player).IsServer || ((NetworkBehaviour)player).IsHost)
			{
				bodyInfo.DeactivateBody(false);
			}
			player.ResetPlayerBloodObjects(player.isPlayerDead);
			player.isClimbingLadder = false;
			player.ResetZAndXRotation();
			((Collider)player.thisController).enabled = true;
			player.health = 100;
			player.disableLookInput = false;
			player.isPlayerDead = false;
			player.isPlayerControlled = true;
			player.isInElevator = true;
			player.isInHangarShipRoom = true;
			player.isInsideFactory = false;
			player.wasInElevatorLastFrame = false;
			StartOfRound.Instance.SetPlayerObjectExtrapolate(false);
			player.TeleportPlayer(spawnPosition, false, 0f, false, true);
			player.setPositionOfDeadPlayer = false;
			player.DisablePlayerModel(StartOfRound.Instance.allPlayerObjects[player.playerClientId], true, true);
			((Behaviour)player.helmetLight).enabled = false;
			player.Crouch(false);
			player.criticallyInjured = false;
			if ((Object)(object)player.playerBodyAnimator != (Object)null)
			{
				player.playerBodyAnimator.SetBool("Limp", false);
			}
			player.bleedingHeavily = false;
			player.activatingItem = false;
			player.twoHanded = false;
			player.inSpecialInteractAnimation = false;
			player.disableSyncInAnimation = false;
			player.inAnimationWithEnemy = null;
			player.holdingWalkieTalkie = false;
			player.speakingToWalkieTalkie = false;
			player.isSinking = false;
			player.isUnderwater = false;
			player.sinkingValue = 0f;
			player.statusEffectAudio.Stop();
			player.DisableJetpackControlsLocally();
			player.health = 100;
			player.mapRadarDotAnimator.SetBool("dead", false);
			if (((NetworkBehaviour)player).IsOwner)
			{
				HUDManager.Instance.gasHelmetAnimator.SetBool("gasEmitting", false);
				player.hasBegunSpectating = false;
				HUDManager.Instance.RemoveSpectateUI();
				HUDManager.Instance.gameOverAnimator.SetTrigger("revive");
				HUDManager.Instance.HideHUD(false);
				player.hinderedMultiplier = 1f;
				player.isMovementHindered = 0;
				player.sourcesCausingSinking = 0;
				player.reverbPreset = StartOfRound.Instance.shipReverb;
			}
			StartOfRound instance = StartOfRound.Instance;
			instance.livingPlayers++;
			SoundManager.Instance.earsRingingTimer = 0f;
			player.voiceMuffledByEnemy = false;
			SoundManager.Instance.playerVoicePitchTargets[player.playerClientId] = 1f;
			SoundManager.Instance.SetPlayerPitch(1f, (int)player.playerClientId);
			if ((Object)(object)player.currentVoiceChatIngameSettings == (Object)null)
			{
				StartOfRound.Instance.RefreshPlayerVoicePlaybackObjects();
			}
			if ((Object)(object)player.currentVoiceChatIngameSettings != (Object)null)
			{
				if ((Object)(object)player.currentVoiceChatIngameSettings.voiceAudio == (Object)null)
				{
					player.currentVoiceChatIngameSettings.InitializeComponents();
				}
				if (!((Object)(object)player.currentVoiceChatIngameSettings.voiceAudio == (Object)null))
				{
					((Component)player.currentVoiceChatIngameSettings.voiceAudio).GetComponent<OccludeAudio>().overridingLowPass = false;
				}
			}
		}
	}
	internal class SaveUtils
	{
		private static Dictionary<object, Queue<Dictionary<int, string>>> saveQueues = new Dictionary<object, Queue<Dictionary<int, string>>>();

		private static Dictionary<object, float> lastAddedTimes = new Dictionary<object, float>();

		internal static void AddToQueue<T>(T itemType, Dictionary<int, string> data, string saveName) where T : Type
		{
			if ((Type?)itemType == (Type?)null)
			{
				return;
			}
			if (!saveQueues.ContainsKey(itemType))
			{
				saveQueues[itemType] = new Queue<Dictionary<int, string>>();
			}
			_ = saveQueues[itemType].Count;
			foreach (KeyValuePair<int, string> datum in data)
			{
				int key = datum.Key;
				saveQueues[itemType].Enqueue(new Dictionary<int, string> { { key, datum.Value } });
			}
			lastAddedTimes[itemType] = Time.time;
			CoroutineHandler.Instance.NewCoroutine(itemType, ProcessQueueAfterDelay(itemType, 0.65f, saveName), stopWhenRunning: true);
		}

		internal static void ProcessAllQueuedItems<T>(T itemType, string saveName) where T : Type
		{
			if ((Type?)itemType == (Type?)null || !saveQueues.ContainsKey(itemType) || saveQueues[itemType].Count <= 0)
			{
				return;
			}
			Dictionary<int, string> dictionary = new Dictionary<int, string>();
			while (saveQueues[itemType].Count > 0)
			{
				foreach (KeyValuePair<int, string> item in saveQueues[itemType].Dequeue())
				{
					dictionary[item.Key] = item.Value;
				}
			}
			if (dictionary.Count == 0)
			{
				ES3.DeleteKey(saveName, GameNetworkManager.Instance.currentSaveFileName);
			}
			ES3.Save<Dictionary<int, string>>(saveName, dictionary, GameNetworkManager.Instance.currentSaveFileName);
			Plugin.Logger.LogWarning((object)("SAVED: " + string.Join("\n", dictionary)));
		}

		internal static IEnumerator ProcessQueueAfterDelay<T>(T itemType, float delay, string saveName) where T : Type
		{
			T itemType2 = itemType;
			if (!((Type?)itemType2 == (Type?)null))
			{
				yield return (object)new WaitUntil((Func<bool>)(() => Time.time - lastAddedTimes[itemType2] >= delay));
				ProcessAllQueuedItems(itemType2, saveName);
			}
		}
	}
}
namespace LiquidLabyrinth.Utilities.MonoBehaviours
{
	internal class CoroutineHandler : MonoBehaviour
	{
		private static CoroutineHandler instance;

		private Dictionary<object, Dictionary<Type, IEnumerator>> objectsRunningCoroutines = new Dictionary<object, Dictionary<Type, IEnumerator>>();

		private Dictionary<Type, IEnumerator> runningCoroutines = new Dictionary<Type, IEnumerator>();

		public static CoroutineHandler Instance
		{
			get
			{
				//IL_0012: 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_0027: Expected O, but got Unknown
				if ((Object)(object)instance == (Object)null)
				{
					GameObject val = new GameObject("CoroutineHandler");
					instance = val.AddComponent<CoroutineHandler>();
					Object.DontDestroyOnLoad((Object)val);
				}
				return instance;
			}
		}

		public IEnumerator NewCoroutine(object instance, IEnumerator coroutine, bool stopWhenRunning = false)
		{
			Type type = coroutine.GetType();
			if (objectsRunningCoroutines.ContainsKey(instance) && objectsRunningCoroutines[instance].ContainsKey(type))
			{
				if (!stopWhenRunning)
				{
					Plugin.Logger.LogWarning((object)$"Coroutine {type.Name} is already running for {instance}");
					return objectsRunningCoroutines[instance][type];
				}
				((MonoBehaviour)this).StopCoroutine(objectsRunningCoroutines[instance][type]);
				objectsRunningCoroutines[instance].Remove(type);
			}
			if (!objectsRunningCoroutines.ContainsKey(instance))
			{
				objectsRunningCoroutines[instance] = new Dictionary<Type, IEnumerator>();
			}
			Plugin.Logger.LogWarning((object)$"Starting coroutine {type.Name} for {instance}");
			objectsRunningCoroutines[instance][type] = coroutine;
			((MonoBehaviour)this).StartCoroutine(ExecuteCoroutine(instance, coroutine));
			return objectsRunningCoroutines[instance][type];
		}

		private IEnumerator ExecuteCoroutine(object instance, IEnumerator coroutine)
		{
			yield return ((MonoBehaviour)this).StartCoroutine(coroutine);
			if (objectsRunningCoroutines.TryGetValue(instance, out Dictionary<Type, IEnumerator> value))
			{
				value?.Remove(coroutine.GetType());
			}
		}

		public void StopAllCoroutines()
		{
			((MonoBehaviour)this).StopAllCoroutines();
			runningCoroutines.Clear();
		}
	}
}
namespace LiquidLabyrinth.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					resourceMan = new ResourceManager("LiquidLabyrinth.Properties.Resources", typeof(Resources).Assembly);
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static byte[] liquidlabyrinth => (byte[])ResourceManager.GetObject("liquidlabyrinth", resourceCulture);

		internal Resources()
		{
		}
	}
}
namespace LiquidLabyrinth.Patches
{
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal class GameNetworkManagerPatch
	{
		[HarmonyPatch("SaveItemsInShip")]
		private static void Postfix()
		{
			GrabbableObject[] array = Object.FindObjectsByType<GrabbableObject>((FindObjectsInactive)0, (FindObjectsSortMode)0);
			if (array == null || array.Length == 0)
			{
				return;
			}
			GrabbableObject[] array2 = array;
			foreach (GrabbableObject val in array2)
			{
				if (val.itemProperties.saveItemVariable)
				{
					((object)val).GetType().Equals(typeof(PotionBottle));
				}
			}
		}
	}
	[HarmonyPatch(typeof(GrabbableObject))]
	internal class GrabbableObjectPatch
	{
		[HarmonyPatch("FallToGround")]
		[HarmonyPrefix]
		private static bool FallToGroundPatch(GrabbableObject __instance)
		{
			return ((object)__instance).GetType().BaseType.BaseType != typeof(GrabbableRigidbody);
		}

		[HarmonyPatch("EnablePhysics")]
		[HarmonyPrefix]
		private static bool EnablePhysics(GrabbableObject __instance, bool enable)
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			if (((object)__instance).GetType().BaseType.BaseType == typeof(GrabbableRigidbody) && __instance is GrabbableRigidbody grabbableRigidbody && (Object)(object)grabbableRigidbody != (Object)null)
			{
				Plugin.Logger.LogWarning((object)$"replaced physics called: {enable} ({Assembly.GetCallingAssembly().GetName().Name})");
				grabbableRigidbody.EnableColliders(enable);
				if (((GrabbableObject)grabbableRigidbody).isHeldByEnemy && !enable)
				{
					Plugin.Logger.LogWarning((object)"Was held by enemy. Trying to fix values");
					((GrabbableObject)grabbableRigidbody).fallTime = 1f;
					((GrabbableObject)grabbableRigidbody).startFallingPosition = ((Component)grabbableRigidbody).transform.position;
					((GrabbableObject)grabbableRigidbody).targetFloorPosition = ((Component)grabbableRigidbody).transform.position;
					((GrabbableObject)grabbableRigidbody).floorYRot = (int)((Component)grabbableRigidbody).transform.localEulerAngles.y;
				}
				grabbableRigidbody.rb.isKinematic = !enable;
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class INoiseListenerWorkaround
	{
		[HarmonyPatch("PlayAudibleNoise")]
		[HarmonyPostfix]
		private static void PlayAudibleNoisePatch(RoundManager __instance, Vector3 noisePosition, ref float noiseRange, float noiseLoudness, int timesPlayedInSameSpot, bool noiseIsInsideClosedShip, int noiseID)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			if (noiseIsInsideClosedShip)
			{
				noiseRange /= 2f;
			}
			int num = Physics.OverlapSphereNonAlloc(noisePosition, noiseRange, __instance.tempColliderResults, 64);
			INoiseListener val = default(INoiseListener);
			for (int i = 0; i < num; i++)
			{
				if (!((Component)((Component)__instance.tempColliderResults[i]).transform).TryGetComponent<INoiseListener>(ref val))
				{
					continue;
				}
				if (noiseIsInsideClosedShip)
				{
					GrabbableObject component = ((Component)__instance.tempColliderResults[i]).gameObject.GetComponent<GrabbableObject>();
					if (((Object)(object)component == (Object)null || !component.isInShipRoom) && noiseLoudness < 0.9f)
					{
						break;
					}
				}
				val.DetectNoise(noisePosition, noiseLoudness, timesPlayedInSameSpot, noiseID);
			}
		}
	}
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch(typeof(DeadBodyInfo), "Start")]
		[HarmonyPostfix]
		private static void DeadBodyInfo_AwakePatch(DeadBodyInfo __instance)
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: 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)
			if (!__instance.detachedHead || !((Object)(object)__instance.detachedHeadObject != (Object)null))
			{
				return;
			}
			((Component)__instance.detachedHeadObject).gameObject.SetActive(false);
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				Object obj = AssetLoader.assetsDictionary["assets/liquid labyrinth/headitem.asset"];
				Item val = (Item)(object)((obj is Item) ? obj : null);
				if (!((Object)(object)val == (Object)null))
				{
					GameObject obj2 = Object.Instantiate<GameObject>(val.spawnPrefab, ((Component)__instance).transform);
					obj2.transform.position = __instance.detachedHeadObject.position;
					obj2.transform.rotation = __instance.detachedHeadObject.rotation;
					obj2.transform.Rotate(val.rotationOffset);
					obj2.GetComponent<NetworkObject>().Spawn(false);
				}
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "PlaceGrabbableObject")]
		[HarmonyPostfix]
		private static void PlaceGrabbableObjectPostfix(PlayerControllerB __instance, ref GrabbableObject placeObject)
		{
			if (placeObject is GrabbableRigidbody grabbableRigidbody && (Object)(object)grabbableRigidbody != (Object)null && ((NetworkBehaviour)__instance).IsOwner)
			{
				((GrabbableObject)grabbableRigidbody).PlayDropSFX();
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "PlaceGrabbableObject")]
		[HarmonyPrefix]
		private static void PlaceGrabbableObjectPrefix(PlayerControllerB __instance, ref GrabbableObject placeObject)
		{
			if (placeObject is GrabbableRigidbody grabbableRigidbody && (Object)(object)grabbableRigidbody != (Object)null && ((NetworkBehaviour)__instance).IsOwner)
			{
				grabbableRigidbody.net_Placed.Value = true;
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void AwakePostfix()
		{
			Plugin.Logger.LogWarning((object)"awake");
			EnemyType[] array = Resources.FindObjectsOfTypeAll<EnemyType>();
			foreach (EnemyType val in array)
			{
				if (!Plugin.Instance.enemyTypes.ContainsKey(val.enemyName))
				{
					Plugin.Instance.enemyTypes.Add(val.enemyName, val);
					Plugin.Logger.LogWarning((object)("Added enemy to list: " + val.enemyName));
				}
			}
		}

		[HarmonyPatch("Awake")]
		[HarmonyPrefix]
		private static bool AwakePrefix()
		{
			Plugin.Instance.SaveableItemDict.Clear();
			return true;
		}
	}
}
namespace LiquidLabyrinth.Labyrinth
{
	public class Liquids
	{
		public class LiquidConfiguration
		{
			public string Name { get; set; }

			internal string ModName { get; set; }

			public Color color { get; set; }

			public string Description { get; set; }

			public object[] CustomArguments { get; set; }
		}

		public static void RegisterLiquid(LiquidConfiguration liquid)
		{
			string name = Assembly.GetCallingAssembly().GetName().Name;
			liquid.ModName = name;
		}
	}
}
namespace LiquidLabyrinth.ItemHelpers
{
	[RequireComponent(typeof(Rigidbody))]
	internal class GrabbableRigidbody : SaveableItem
	{
		public EnemyAI? enemyCurrentlyHeld;

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

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

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

		public bool floatWhileOrbiting;

		public float gravity = 9.8f;

		internal Rigidbody rb;

		internal AudioSource itemAudio;

		public float itemMass = 1f;

		public float terminalVelocity;

		internal Vector3 oldEnemyPosition;

		public override void Start()
		{
			rb = ((Component)this).GetComponent<Rigidbody>();
			itemAudio = ((Component)this).GetComponent<AudioSource>();
			if (!((Object)(object)rb == (Object)null) && !((Object)(object)itemAudio == (Object)null))
			{
				rb.useGravity = false;
				rb.mass = itemMass;
				((GrabbableObject)this).itemProperties.itemSpawnsOnGround = false;
				terminalVelocity = MathF.Sqrt(2f * rb.mass * gravity);
				((GrabbableObject)this).Start();
			}
		}

		public override void Update()
		{
			((GrabbableObject)this).fallTime = 1f;
			((GrabbableObject)this).reachedFloorTarget = true;
			bool isHeld = ((GrabbableObject)this).isHeld;
			((GrabbableObject)this).isHeld = true;
			((GrabbableObject)this).Update();
			((GrabbableObject)this).isHeld = isHeld;
		}

		public void EnableColliders(bool enable)
		{
			for (int i = 0; i < ((GrabbableObject)this).propColliders.Length; i++)
			{
				if (!((Object)(object)((GrabbableObject)this).propColliders[i] == (Object)null) && !((Component)((GrabbableObject)this).propColliders[i]).gameObject.CompareTag("InteractTrigger") && !((Component)((GrabbableObject)this).propColliders[i]).gameObject.CompareTag("DoNotSet"))
				{
					((GrabbableObject)this).propColliders[i].enabled = enable;
				}
			}
		}

		public virtual void FixedUpdate()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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 (((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsServer)
			{
				if ((floatWhileOrbiting && StartOfRound.Instance.inShipPhase && !rb.isKinematic && Plugin.Instance.NoGravityInOrbit.Value) || net_isFloating.Value)
				{
					rb.AddForce(Vector3.zero, (ForceMode)2);
				}
				else if (!rb.isKinematic && !((GrabbableObject)this).isHeld)
				{
					rb.useGravity = false;
					rb.AddForce(Vector3.down * gravity, (ForceMode)5);
				}
				else
				{
					rb.AddForce(Vector3.zero, (ForceMode)2);
				}
			}
		}

		public override void LateUpdate()
		{
			//IL_00da: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_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)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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)
			//IL_0063: 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)
			if ((Object)(object)((GrabbableObject)this).parentObject != (Object)null && (((GrabbableObject)this).isHeld || ((GrabbableObject)this).isHeldByEnemy))
			{
				((Component)this).transform.rotation = ((GrabbableObject)this).parentObject.rotation;
				Vector3 val = ((GrabbableObject)this).itemProperties.rotationOffset;
				if (((GrabbableObject)this).isHeldByEnemy)
				{
					val += new Vector3(0f, 90f, 0f);
				}
				((Component)this).transform.Rotate(val);
				((Component)this).transform.position = ((GrabbableObject)this).parentObject.position;
				Vector3 positionOffset = ((GrabbableObject)this).itemProperties.positionOffset;
				positionOffset = ((GrabbableObject)this).parentObject.rotation * positionOffset;
				Transform transform = ((Component)this).transform;
				transform.position += positionOffset;
			}
			if ((Object)(object)((GrabbableObject)this).radarIcon != (Object)null)
			{
				((GrabbableObject)this).radarIcon.position = ((Component)this).transform.position;
			}
		}

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			if (((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsServer)
			{
				net_GrabbableToEnemies.Value = Plugin.Instance.IsGrabbableToEnemies.Value;
			}
			((GrabbableObject)this).grabbableToEnemies = net_GrabbableToEnemies.Value;
		}

		public virtual void OnCollisionEnter(Collision collision)
		{
			//IL_001a: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			Vector3 velocity;
			if (((NetworkBehaviour)this).IsClient)
			{
				string tag = collision.gameObject.tag;
				velocity = rb.velocity;
				OnCollision_ClientRpc(tag, ((Vector3)(ref velocity)).magnitude);
			}
			else if (((NetworkBehaviour)this).IsServer)
			{
				string tag2 = collision.gameObject.tag;
				velocity = rb.velocity;
				OnCollision_ServerRpc(tag2, ((Vector3)(ref velocity)).magnitude);
			}
		}

		[ServerRpc]
		public void OnCollision_ServerRpc(string objectTag, float rigidBodyMagnitude)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: 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 != 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(630190830u, val, (RpcDelivery)0);
				bool flag = objectTag != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(objectTag, false);
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref rigidBodyMagnitude, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 630190830u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				OnCollision_ClientRpc(objectTag, rigidBodyMagnitude);
			}
		}

		[ClientRpc]
		public void OnCollision_ClientRpc(string objectTag, float rigidBodyMagnitude)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: 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_0088: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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(1205909959u, val, (RpcDelivery)0);
				bool flag = objectTag != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(objectTag, false);
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref rigidBodyMagnitude, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1205909959u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((Object)(object)rb == (Object)null) && !rb.isKinematic)
			{
				if ((Object)(object)itemAudio == (Object)null)
				{
					Plugin.Logger.LogWarning((object)"ITEM AUDIO SOURCE DOESNT EXIST.");
				}
				else if (!(objectTag == "Player"))
				{
					float pitch = OtherUtils.mapValue(rigidBodyMagnitude, 0.8f, 10f, 0.8f, 1.5f);
					itemAudio.pitch = pitch;
					((GrabbableObject)this).PlayDropSFX();
				}
			}
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			itemAudio.pitch = 1f;
			((Component)this).transform.parent = null;
			((GrabbableObject)this).EnablePhysics(false);
			if (((NetworkBehaviour)this).IsOwner)
			{
				net_Placed.Value = false;
			}
		}

		public override void PocketItem()
		{
			((GrabbableObject)this).PocketItem();
			((GrabbableObject)this).EnablePhysics(false);
		}

		public override void GrabItemFromEnemy(EnemyAI enemy)
		{
			((GrabbableObject)this).GrabItemFromEnemy(enemy);
			((GrabbableObject)this).isHeldByEnemy = true;
			itemAudio.pitch = 1f;
			enemyCurrentlyHeld = enemy;
			((Component)this).transform.parent = null;
		}

		public override void DiscardItemFromEnemy()
		{
			((GrabbableObject)this).DiscardItemFromEnemy();
			Plugin.Logger.LogWarning((object)("drop called by enemy " + ((Object)enemyCurrentlyHeld).name));
			((GrabbableObject)this).isHeldByEnemy = false;
			enemyCurrentlyHeld = null;
		}

		public override void DiscardItem()
		{
			if (!net_Placed.Value)
			{
				((GrabbableObject)this).EnablePhysics(true);
			}
			((GrabbableObject)this).DiscardItem();
		}

		public override void InteractItem()
		{
			((GrabbableObject)this).InteractItem();
			itemAudio.pitch = 1f;
		}

		public override void OnPlaceObject()
		{
			((GrabbableObject)this).OnPlaceObject();
			EnableColliders(enable: true);
			rb.isKinematic = true;
		}

		public override void FallWithCurve()
		{
		}

		public void FallToGround(bool randomizePosition = false)
		{
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_GrabbableRigidbody()
		{
			//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(630190830u, new RpcReceiveHandler(__rpc_handler_630190830));
			NetworkManager.__rpc_func_table.Add(1205909959u, new RpcReceiveHandler(__rpc_handler_1205909959));
		}

		private static void __rpc_handler_630190830(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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			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!");
				}
				return;
			}
			bool flag = default(bool);
			((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
			string objectTag = null;
			if (flag)
			{
				((FastBufferReader)(ref reader)).ReadValueSafe(ref objectTag, false);
			}
			float rigidBodyMagnitude = default(float);
			((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref rigidBodyMagnitude, default(ForPrimitives));
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((GrabbableRigidbody)(object)target).OnCollision_ServerRpc(objectTag, rigidBodyMagnitude);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}

		private static void __rpc_handler_1205909959(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_0067: 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)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string objectTag = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref objectTag, false);
				}
				float rigidBodyMagnitude = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref rigidBodyMagnitude, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((GrabbableRigidbody)(object)target).OnCollision_ClientRpc(objectTag, rigidBodyMagnitude);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "GrabbableRigidbody";
		}
	}
	internal class HeadItem : Throwable, INoiseListener
	{
		private string? _localtooltip;

		private string? _localdescription;

		private bool Equiped;

		private NetworkVariable<FixedString32Bytes> net_tooltip = new NetworkVariable<FixedString32Bytes>(FixedString32Bytes.op_Implicit("Head."), (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private NetworkVariable<FixedString32Bytes> net_description = new NetworkVariable<FixedString32Bytes>(FixedString32Bytes.op_Implicit("Unknown."), (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private Vector3? lastNoisePosition;

		public override void OnNetworkSpawn()
		{
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			base.OnNetworkSpawn();
			Plugin.Logger.LogWarning((object)"network called");
			DeadBodyInfo componentInParent = ((Component)this).GetComponentInParent<DeadBodyInfo>(true);
			ScanNodeProperties componentInChildren = ((Component)this).GetComponentInChildren<ScanNodeProperties>();
			if (((NetworkBehaviour)this).IsServer || ((NetworkBehaviour)this).IsHost)
			{
				if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInChildren != (Object)null)
				{
					Plugin.Logger.LogWarning((object)"found player");
					net_tooltip.Value = FixedString32Bytes.op_Implicit(componentInParent.playerScript.playerUsername + "'s Head.");
					net_description.Value = FixedString32Bytes.op_Implicit(Enum.GetName(typeof(CauseOfDeath), componentInParent.causeOfDeath));
				}
				else
				{
					Plugin.Logger.LogWarning((object)"Couldn't find Player");
					if (Utility.IsNullOrWhiteSpace(_localtooltip) && Utility.IsNullOrWhiteSpace(_localdescription))
					{
						return;
					}
					net_tooltip.Value = FixedString32Bytes.op_Implicit(_localtooltip ?? "");
					net_description.Value = FixedString32Bytes.op_Implicit(_localdescription);
				}
			}
			((GrabbableObject)this).customGrabTooltip = $"{net_tooltip.Value} [E]";
			if (!((Object)(object)componentInChildren == (Object)null))
			{
				componentInChildren.headerText = $"{net_tooltip.Value}";
				componentInChildren.subText = $"{net_description.Value}";
			}
		}

		public override int GetItemDataToSave()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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)
			FixedString32Bytes value = net_tooltip.Value;
			string? tip = ((object)(FixedString32Bytes)(ref value)).ToString();
			value = net_description.Value;
			Data = new HeadItemData(tip, ((object)(FixedString32Bytes)(ref value)).ToString());
			return base.GetItemDataToSave();
		}

		public override void LoadItemSaveData(int saveData)
		{
			DataType = typeof(HeadItemData);
			base.LoadItemSaveData(saveData);
			if (NetworkManager.Singleton.IsHost && NetworkManager.Singleton.IsServer && Data is HeadItemData headItemData && headItemData != null)
			{
				_localtooltip = headItemData.tooltip;
				_localdescription = headItemData.description;
			}
		}

		public override void FixedUpdate()
		{
			//IL_0019: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			base.FixedUpdate();
			if (lastNoisePosition.HasValue)
			{
				Vector3 val = lastNoisePosition.Value - ((Component)this).transform.position;
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				rb.AddForce(normalized * 1.5f, (ForceMode)5);
			}
		}

		public override void Update()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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)
			base.Update();
			if (!((NetworkBehaviour)this).IsSpawned)
			{
				return;
			}
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if ((Object)(object)localPlayerController == (Object)null)
			{
				return;
			}
			float num = localPlayerController.insanityLevel + 1f / localPlayerController.maxInsanityLevel + 1f;
			float num2 = Vector3.Distance(((Component)localPlayerController.gameplayCamera).transform.position, ((Component)this).transform.position);
			if (num2 > 10f || ((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)(object)localPlayerController && !Equiped))
			{
				localPlayerController.isMovementHindered = (int)Mathf.MoveTowards((float)localPlayerController.isMovementHindered, 0f, Time.deltaTime);
			}
			if (!localPlayerController.HasLineOfSightToPosition(((Component)this).transform.position, 30f / (num2 / 5f), 60, -1f) || ((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)(object)localPlayerController && !Equiped))
			{
				return;
			}
			if (num2 < 10f)
			{
				localPlayerController.insanityLevel += 0.75f / num;
				localPlayerController.insanitySpeedMultiplier += 0.75f / num;
				localPlayerController.isMovementHindered = (int)(num - 1f);
				localPlayerController.JumpToFearLevel(localPlayerController.insanityLevel / localPlayerController.maxInsanityLevel, true);
				if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
				{
					HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
				}
			}
			else
			{
				localPlayerController.insanityLevel += 0.3f / num;
				localPlayerController.insanitySpeedMultiplier += 0.3f / num;
			}
		}

		public override void EquipItem()
		{
			base.EquipItem();
			Equiped = true;
		}

		public override void DiscardItem()
		{
			base.DiscardItem();
			Equiped = false;
		}

		public override void PocketItem()
		{
			base.PocketItem();
			Equiped = false;
		}

		public void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot, int noiseID)
		{
			//IL_0014: 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)
			if (noiseID != 75)
			{
				lastNoisePosition = null;
				return;
			}
			lastNoisePosition = noisePosition;
			Plugin.Logger.LogWarning((object)$"heard at {noisePosition}");
		}

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "HeadItem";
		}
	}
	internal class PotionBottle : Throwable, INoiseListener
	{
		private Renderer? rend;

		[Header("Wobble Settings")]
		private Vector3 lastPos;

		private Vector3 velocity;

		private Vector3 lastRot;

		private Vector3 angularVelocity;

		public float MaxWobble = 1f;

		public float WobbleSpeed = 1f;

		public float Recovery = 1f;

		private float _localFill = -1f;

		private float wobbleAmountX;

		private float wobbleAmountZ;

		private float wobbleAmountToAddX;

		private float wobbleAmountToAddZ;

		private float maxEmission = 10f;

		private float pulse;

		private float time = 0.5f;

		[Space(3f)]
		[Header("Bottle Properties")]
		public Animator itemAnimator;

		public AudioClip openCorkSFX;

		public AudioClip closeCorkSFX;

		public AudioClip changeModeSFX;

		public AudioClip glassBreakSFX;

		public AudioClip liquidShakeSFX;

		public GameObject Liquid;

		public List<string> BottleProperties;

		private string bottleType;

		[Space(3f)]
		[Header("Liquid Properties")]
		public bool BreakBottle;

		public bool IsShaking;

		private NetworkVariable<float> net_emission = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)1);

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

		private NetworkVariable<FixedString128Bytes> net_Name = new NetworkVariable<FixedString128Bytes>(FixedString128Bytes.op_Implicit("BottleType"), (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private NetworkVariable<float> net_Fill = new NetworkVariable<float>(-1f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)1);

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

		private NetworkVariable<Color> net_color = new NetworkVariable<Color>(Color.red, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private NetworkVariable<Color> net_lighterColor = new NetworkVariable<Color>(Color.blue, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private NetworkVariable<BottleModes> net_mode = new NetworkVariable<BottleModes>(BottleModes.Open, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)1);

		private int _BottleModesLength = Enum.GetValues(typeof(BottleModes)).Length;

		private Light light;

		private Coroutine ToastCoroutine;

		private static RaycastHit[] _potionBreakHits = (RaycastHit[])(object)new RaycastHit[20];

		private float elapsedTime;

		private float shakeTime;

		private Vector3 lastNoisePosition;

		public string GetModeString(BottleModes mode, bool isOpened)
		{
			if (mode == BottleModes.Open && isOpened)
			{
				return "Close";
			}
			return Enum.GetName(typeof(BottleModes), mode);
		}

		public override void EquipItem()
		{
			base.EquipItem();
			((GrabbableObject)this).playerHeldBy.equippedUsableItemQE = true;
			wobbleAmountToAddX += Random.Range(1f, 10f);
			wobbleAmountToAddZ += Random.Range(1f, 10f);
		}

		public override void DiscardItem()
		{
			base.DiscardItem();
		}

		public override void InteractItem()
		{
			base.InteractItem();
			Plugin.Logger.LogWarning((object)"Interacted!");
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			LMBToThrow = false;
			Plugin.Logger.LogWarning((object)$"{used} {buttonDown}");
			Holding = buttonDown;
			if ((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)null)
			{
				return;
			}
			((GrabbableObject)this).playerHeldBy.activatingItem = buttonDown;
			switch (net_mode.Value)
			{
			case BottleModes.Open:
				if (buttonDown)
				{
					itemAnimator.SetBool("CorkOpen", !net_isOpened.Value);
					if (!net_isOpened.Value)
					{
						itemAudio.PlayOneShot(openCorkSFX);
						RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 4f, 0.5f, 2, false, 0);
					}
					else
					{
						itemAudio.PlayOneShot(closeCorkSFX);
						RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 4f, 0.5f, 1, false, 0);
					}
					if (((NetworkBehaviour)this).IsOwner)
					{
						net_isOpened.Value = !net_isOpened.Value;
						((GrabbableObject)this).SetControlTipsForItem();
					}
				}
				break;
			case BottleModes.Drink:
				if (net_isOpened.Value)
				{
					((GrabbableObject)this).playerHeldBy.playerBodyAnimator.SetBool("useTZPItem", buttonDown);
				}
				break;
			case BottleModes.Throw:
				LMBToThrow = true;
				playerThrownBy = ((GrabbableObject)this).playerHeldBy;
				if (((NetworkBehaviour)this).IsOwner)
				{
					HUDManager.Instance.ClearControlTips();
				}
				if ((((NetworkBehaviour)this).IsServer || ((NetworkBehaviour)this).IsHost) && Random.Range(1, 100) <= 25)
				{
					BreakBottle = true;
				}
				break;
			case BottleModes.Toast:
				if (buttonDown && ((NetworkBehaviour)this).IsOwner && ToastCoroutine == null)
				{
					ToastCoroutine = ((MonoBehaviour)this).StartCoroutine(Toast());
				}
				break;
			case BottleModes.Shake:
				IsShaking = buttonDown;
				if (buttonDown)
				{
					CoroutineHandler.Instance.NewCoroutine(this, ShakeBottle());
				}
				break;
			}
			base.ItemActivate(used, buttonDown);
		}

		private IEnumerator ShakeBottle()
		{
			((GrabbableObject)this).playerHeldBy.playerBodyAnimator.SetTrigger("shakeItem");
			AnimatorStateInfo currentAnimatorStateInfo = ((GrabbableObject)this).playerHeldBy.playerBodyAnimator.GetCurrentAnimatorStateInfo(2);
			float length = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).length;
			float num = Random.Range(0f, liquidShakeSFX.length - length);
			float stop = Mathf.Min(num + length, liquidShakeSFX.length);
			AudioClip val = liquidShakeSFX.MakeSubclip(num, stop);
			itemAudio.PlayOneShot(val);
			RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 4f, 0.5f, 2, false, 0);
			CoroutineHandler.Instance.NewCoroutine(this, itemAudio.FadeOut(1f));
			while (Holding)
			{
				yield return (object)new WaitForSeconds(0.05f);
				currentAnimatorStateInfo = ((GrabbableObject)this).playerHeldBy.playerBodyAnimator.GetCurrentAnimatorStateInfo(2);
				if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("ShakeItem") && ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime > 0.76f)
				{
					((GrabbableObject)this).playerHeldBy.playerBodyAnimator.SetTrigger("shakeItem");
					length = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).length;
					num = Random.Range(0f, liquidShakeSFX.length - length);
					stop = Mathf.Min(num + length, liquidShakeSFX.length);
					val = liquidShakeSFX.MakeSubclip(num, stop);
					itemAudio.PlayOneShot(val);
					RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 4f, 0.5f, 2, false, 0);
					CoroutineHandler.Instance.NewCoroutine(this, itemAudio.FadeOut(1f));
				}
			}
		}

		private IEnumerator Toast()
		{
			RaycastHit[] source = Physics.SphereCastAll(new Ray(((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.position + ((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.forward * 20f, ((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.forward), 20f, 80f, LayerMask.GetMask(new string[1] { "Props" }));
			if (source.Count() > 0)
			{
				PotionBottle potionBottle = default(PotionBottle);
				RaycastHit val = ((IEnumerable<RaycastHit>)source).FirstOrDefault((Func<RaycastHit, bool>)((RaycastHit hit) => ((Component)((RaycastHit)(ref hit)).transform).TryGetComponent<PotionBottle>(ref potionBottle) && ((GrabbableObject)potionBottle).isHeld && (Object)(object)((GrabbableObject)potionBottle).playerHeldBy != (Object)(object)GameNetworkManager.Instance.localPlayerController));
				Plugin.Logger.LogWarning((object)((RaycastHit)(ref val)).transform);
				if ((Object)(object)((RaycastHit)(ref val)).transform != (Object)null && (Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
				{
					Plugin.Logger.LogWarning((object)"FOUND!");
					if (((NetworkBehaviour)this).IsOwner)
					{
						((GrabbableObject)this).playerHeldBy.UpdateSpecialAnimationValue(true, (short)0, ((GrabbableObject)this).playerHeldBy.targetYRot, true);
					}
					PlayerUtils.RotateToObject(((GrabbableObject)this).playerHeldBy, ((Component)((RaycastHit)(ref val)).transform).gameObject);
					((GrabbableObject)this).playerHeldBy.inSpecialInteractAnimation = true;
					((GrabbableObject)this).playerHeldBy.isClimbingLadder = false;
					((GrabbableObject)this).playerHeldBy.playerBodyAnimator.ResetTrigger("SA_ChargeItem");
					((GrabbableObject)this).playerHeldBy.playerBodyAnimator.SetTrigger("SA_ChargeItem");
					yield return (object)new WaitForSeconds(0.5f);
					((GrabbableObject)this).playerHeldBy.playerBodyAnimator.ResetTrigger("SA_ChargeItem");
					if (((NetworkBehaviour)this).IsOwner)
					{
						((GrabbableObject)this).playerHeldBy.UpdateSpecialAnimationValue(false, (short)0, 0f, false);
					}
					((GrabbableObject)this).playerHeldBy.activatingItem = false;
					((GrabbableObject)this).playerHeldBy.inSpecialInteractAnimation = false;
					((GrabbableObject)this).playerHeldBy.isClimbingLadder = false;
					Plugin.Logger.LogWarning((object)"DONE ANIMATION");
				}
			}
			ToastCoroutine = null;
		}

		public override void ItemInteractLeftRight(bool right)
		{
			base.ItemInteractLeftRight(right);
			if (((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null && ((GrabbableObject)this).playerHeldBy.activatingItem) || !((NetworkBehaviour)this).IsOwner)
			{
				return;
			}
			if (right)
			{
				NetworkVariable<BottleModes> obj = net_mode;
				obj.Value -= 1;
				if (net_mode.Value == (BottleModes)(-1))
				{
					net_mode.Value = (BottleModes)(_BottleModesLength - 1);
				}
			}
			else
			{
				NetworkVariable<BottleModes> obj2 = net_mode;
				obj2.Value += 1;
				if (net_mode.Value == (BottleModes)_BottleModesLength)
				{
					net_mode.Value = BottleModes.Open;
				}
			}
			itemAudio.PlayOneShot(changeModeSFX);
			((GrabbableObject)this).SetControlTipsForItem();
		}

		public override void OnNetworkSpawn()
		{
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			base.OnNetworkSpawn();
			light = ((Component)this).GetComponentInChildren<Light>();
			floatWhileOrbiting = true;
			ScanNodeProperties componentInChildren = ((Component)this).GetComponentInChildren<ScanNodeProperties>();
			if (((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsServer)
			{
				net_CanRevivePlayer.Value = Plugin.Instance.RevivePlayer.Value;
				if ((Object)(object)componentInChildren != (Object)null)
				{
					if (componentInChildren.headerText == "BottleType")
					{
						componentInChildren.headerText = MarkovChain.GenerateText(Random.Range(3, 14), 128);
						Plugin.Logger.LogWarning((object)"generating random name");
					}
					bottleType = componentInChildren.headerText;
					net_Name.Value = new FixedString128Bytes(componentInChildren.headerText);
				}
				int num = Math.Abs(componentInChildren.headerText.GetHashCode());
				float num2 = (float)(num * 16807 % 256) / 255f;
				float num3 = (float)(num * 48271 % 256) / 255f;
				float num4 = (float)(num * 69621 % 256) / 255f;
				float num5 = 1f;
				net_lighterColor.Value = new Color(Mathf.Clamp01(num2 + num5), Mathf.Clamp01(num3 + num5), Mathf.Clamp01(num4 + num5));
				net_color.Value = new Color(num2, num3, num4, 1f);
				if (_localFill != -1f)
				{
					net_Fill.Value = _localFill;
				}
				if (net_Fill.Value == -1f)
				{
					net_Fill.Value = Random.Range(0f, 1f);
					Plugin.Logger.LogWarning((object)"Bottle fill is -1, setting random value.");
				}
			}
			FixedString128Bytes value = net_Name.Value;
			componentInChildren.headerText = ((object)(FixedString128Bytes)(ref value)).ToString();
			itemAnimator.SetBool("CorkOpen", net_isOpened.Value);
			((Renderer)((Component)this).gameObject.GetComponent<MeshRenderer>()).material.color = new Color(net_color.Value.g, net_color.Value.r, net_color.Value.b);
			Liquid = ((Component)((Component)this).gameObject.transform.Find("Liquid")).gameObject;
			if ((Object)(object)Liquid != (Object)null)
			{
				rend = (Renderer?)(object)Liquid.GetComponent<MeshRenderer>();
				rend.material.SetFloat("_Emission", net_emission.Value);
				rend.material.SetColor("_LiquidColor", net_color.Value);
				rend.material.SetColor("_SurfaceColor", net_lighterColor.Value);
				rend.material.SetFloat("_Fill", net_Fill.Value);
			}
			light.color = net_color.Value;
			itemAnimator.SetBool("CorkOpen", net_isOpened.Value);
		}

		public override void LoadItemSaveData(int saveData)
		{
			DataType = typeof(BottleItemData);
			base.LoadItemSaveData(saveData);
			if (!NetworkManager.Singleton.IsHost || !NetworkManager.Singleton.IsServer)
			{
				return;
			}
			BottleItemData bottleItemData = Data as BottleItemData;
			if (bottleItemData != null)
			{
				if (bottleItemData == null)
				{
					bottleItemData = new BottleItemData("BottleType", 0f);
				}
				((Component)this).GetComponentInChildren<ScanNodeProperties>().headerText = bottleItemData.name;
				_localFill = bottleItemData.fill;
			}
			else
			{
				Plugin.Logger.LogWarning((object)$"Couldn't find save data for {((object)this).GetType().Name} ({saveData}). Please send this log to the mod developer.");
			}
		}

		public override int GetItemDataToSave()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			FixedString128Bytes value = net_Name.Value;
			Data = new BottleItemData(((object)(FixedString128Bytes)(ref value)).ToString(), net_Fill.Value);
			return base.GetItemDataToSave();
		}

		[ServerRpc]
		private void HitGround_ServerRpc()
		{
			//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(1700649u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1700649u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				Plugin.Logger.LogWarning((object)"It hit da ground");
				HitGround_ClientRpc();
				DoPotionEffect();
				Object.Destroy((Object)(object)((Component)this).gameObject, 0.5f);
			}
		}

		private void DoPotionEffect()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_002a: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			if (Physics.SphereCastNonAlloc(new Ray(((Component)this).gameObject.transform.position + ((Component)this).gameObject.transform.up * 2f, ((Component)this).gameObject.transform.forward), 10f, _potionBreakHits, 80f, 1048576) == 0)
			{
				return;
			}
			RaycastHit[] potionBreakHits = _potionBreakHits;
			DeadBodyInfo val2 = default(DeadBodyInfo);
			for (int i = 0; i < potionBreakHits.Length; i++)
			{
				RaycastHit val = potionBreakHits[i];
				if (net_CanRevivePlayer.Value && ((Component)((RaycastHit)(ref val)).transform).TryGetComponent<DeadBodyInfo>(ref val2))
				{
					PlayerControllerB playerScript = val2.playerScript;
					RevivePlayer(playerScript, ((RaycastHit)(ref val)).transform.position);
					break;
				}
			}
		}

		[ClientRpc]
		private void HitGround_ClientRpc()
		{
			//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)
			//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 != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2577803141u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2577803141u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((GrabbableObject)this).EnableItemMeshes(false);
					AudioSource component = ((Component)this).gameObject.GetComponent<AudioSource>();
					RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 10f, 1f, 0, false, 0);
					component.PlayOneShot(glassBreakSFX, 1f);
					component.PlayOneShot(((GrabbableObject)this).itemProperties.dropSFX, 1f);
				}
			}
		}

		private void RevivePlayer(PlayerControllerB player, Vector3 position)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_003a: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			if ((((NetworkBehaviour)this).IsServer || ((NetworkBehaviour)this).IsHost) && !((Object)(object)player.deadBody == (Object)null))
			{
				if (25 >= Random.Range(1, 100))
				{
					Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(position, default(NavMeshHit), 10f, -1);
					ReviveAsEnemy(player, navMeshPosition);
				}
				else
				{
					Revive_ClientRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)player), position);
				}
			}
		}

		private EnemyType SelectEnemyType()
		{
			if (!Plugin.Instance.spawnRandomEnemy.Value)
			{
				return Plugin.Instance.enemyTypes["Masked"];
			}
			return Plugin.Instance.enemyTypes.ElementAt(Random.Range(0, Plugin.Instance.enemyTypes.Count)).Value;
		}

		private void ReviveAsEnemy(PlayerControllerB player, Vector3 navMeshPosition)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_0022: 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)
			NetworkObjectReference val = RoundManager.Instance.SpawnEnemyGameObject(navMeshPosition, ((Component)player).transform.eulerAngles.y, -1, SelectEnemyType());
			NetworkObject val2 = default(NetworkObject);
			if (!((NetworkObjectReference)(ref val)).TryGet(ref val2, (NetworkManager)null))
			{
				Plugin.Logger.LogWarning((object)"Tried to spawn an enemy, but failed to get spawned enemy game object.");
				return;
			}
			DeactivateBody_ClientRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)player));
			EnemyAI component = ((Component)val2).GetComponent<EnemyAI>();
			if (!((Object)(object)component == (Object)null))
			{
				component.isOutside = !player.isInsideFactory;
				component.allAINodes = GameObject.FindGameObjectsWithTag(component.isOutside ? "OutsideAINode" : "AINode");
				player.redirectToEnemy = component;
			}
		}

		[ClientRpc]
		private void Revive_ClientRpc(NetworkBehaviourReference player, 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: 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(3604068451u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref player, default(ForNetworkSerializable));
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3604068451u, val, (RpcDelivery)0);
				}
				PlayerControllerB val3 = default(PlayerControllerB);
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && ((NetworkBehaviourReference)(ref player)).TryGet<PlayerControllerB>(ref val3, (NetworkManager)null) && !((Object)(object)val3.deadBody == (Object)null))
				{
					PlayerUtils.RevivePlayer(val3, val3.deadBody, position);
					val3.deadBody.DeactivateBody(false);
				}
			}
		}

		[ClientRpc]
		private void DeactivateBody_ClientRpc(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)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2817193289u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref player, default(ForNetworkSerializable));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2817193289u, val, (RpcDelivery)0);
				}
				PlayerControllerB val3 = default(PlayerControllerB);
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && ((NetworkBehaviourReference)(ref player)).TryGet<PlayerControllerB>(ref val3, (NetworkManager)null) && !((Object)(object)val3.deadBody == (Object)null))
				{
					val3.deadBody.DeactivateBody(false);
				}
			}
		}

		public override void OnCollisionEnter(Collision collision)
		{
			//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)
			LMBToThrow = false;
			if (rb.isKinematic)
			{
				return;
			}
			if ((Object)(object)collision.rigidbody != (Object)null)
			{
				Vector3 val = collision.rigidbody.velocity;
				if (((Vector3)(ref val)).magnitude > terminalVelocity)
				{
					BreakBottle = true;
					if (((NetworkBehaviour)this).IsServer || ((NetworkBehaviour)this).IsHost)
					{
						isThrown.Value = true;
					}
				}
			}
			if (isThrown.Value && BreakBottle && ((NetworkBehaviour)this).IsOwner)
			{
				HitGround_ServerRpc();
			}
			base.OnCollisionEnter(collision);
		}

		public override void SetControlTipsForItem()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			base.SetControlTipsForItem();
			string modeString = GetModeString(net_mode.Value, net_isOpened.Value);
			string[] array = new string[3]
			{
				$"Name: Bottle of {net_Name.Value}",
				"Mode: " + modeString,
				"Switch Mode [Q/E]"
			};
			if (((NetworkBehaviour)this).IsOwner)
			{
				HUDManager.Instance.ChangeControlTipMultiple(array, true, ((GrabbableObject)this).itemProperties);
			}
		}

		public override void Update()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			base.Update();
			if (Vector3.Distance(lastNoisePosition, ((Component)this).transform.position) > 4.2f && ((NetworkBehaviour)this).IsServer)
			{
				net_isFloating.Value = false;
			}
			float num = 0.2f * Time.deltaTime;
			if ((Object)(object)rend == (Object)null)
			{
				return;
			}
			rend.material.SetFloat("_Emission", net_emission.Value);
			rend.material.SetFloat("_Fill", net_Fill.Value);
			light.intensity = net_emission.Value;
			if (((GrabbableObject)this).itemUsedUp)
			{
				return;
			}
			if ((IsShaking || net_isFloating.Value) && ((NetworkBehaviour)this).IsOwner)
			{
				net_emission.Value = Mathf.Lerp(net_emission.Value, maxEmission, num);
				shakeTime += Time.deltaTime;
			}
			else if (net_emission.Value > 0.001f && ((NetworkBehaviour)this).IsOwner)
			{
				float num2 = elapsedTime / shakeTime;
				net_emission.Value = Mathf.Lerp(net_emission.Value, 0f, num2);
				elapsedTime += Time.deltaTime;
			}
			else if (((NetworkBehaviour)this).IsOwner)
			{
				net_emission.Value = 0f;
				elapsedTime = 0f;
				elapsedTime = 0f;
			}
			MaxWobble = net_Fill.Value * 0.2f;
			if (((NetworkBehaviour)this).IsOwner && (Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null && net_mode.Value == BottleModes.Drink && Holding && net_isOpened.Value)
			{
				AnimatorStateInfo currentAnimatorStateInfo = ((GrabbableObject)this).playerHeldBy.playerBodyAnimator.GetCurrentAnimatorStateInfo(2);
				if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime > 1f)
				{
					net_Fill.Value = Mathf.Lerp(net_Fill.Value, 0f, Time.deltaTime * 0.5f);
					Plugin.Logger.LogWarning((object)$"Started drinking! ({net_Fill.Value})");
				}
			}
			if ((double)net_Fill.Value <= 0.05)
			{
				if (((NetworkBehaviour)this).IsOwner)
				{
					net_Fill.Value = 0f;
					rend.material.SetFloat("_Fill", 0f);
				}
				((GrabbableObject)this).itemUsedUp = true;
			}
			else
			{
				Wobble();
			}
		}

		private void Wobble()
		{
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: 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)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or mis