Decompiled source of gofyb Modpack v1.2.0

pachers/BepInEx.MonoMod.HookGenPatcher/BepInEx.MonoMod.HookGenPatcher.dll

Decompiled 9 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using BepInEx.Configuration;
using BepInEx.Logging;
using Mono.Cecil;
using MonoMod;
using MonoMod.RuntimeDetour.HookGen;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Bepinex.Monomod.HookGenPatcher")]
[assembly: AssemblyDescription("Runtime HookGen for BepInEx")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HarbingerOfMe")]
[assembly: AssemblyProduct("Bepinex.Monomod.HookGenPatcher")]
[assembly: AssemblyCopyright("HarbingerOfMe-2022")]
[assembly: AssemblyTrademark("MIT")]
[assembly: ComVisible(false)]
[assembly: Guid("12032e45-9577-4195-8f4f-a729911b2f08")]
[assembly: AssemblyFileVersion("1.2.1.0")]
[assembly: NeutralResourcesLanguage("en")]
[assembly: AssemblyVersion("1.2.1.0")]
namespace BepInEx.MonoMod.HookGenPatcher;

public static class HookGenPatcher
{
	internal static ManualLogSource Logger = Logger.CreateLogSource("HookGenPatcher");

	private const string CONFIG_FILE_NAME = "HookGenPatcher.cfg";

	private static readonly ConfigFile Config = new ConfigFile(Path.Combine(Paths.ConfigPath, "HookGenPatcher.cfg"), true);

	private const char EntrySeparator = ',';

	private static readonly ConfigEntry<string> AssemblyNamesToHookGenPatch = Config.Bind<string>("General", "MMHOOKAssemblyNames", "Assembly-CSharp.dll", $"Assembly names to make mmhooks for, separate entries with : {','} ");

	private static readonly ConfigEntry<bool> preciseHash = Config.Bind<bool>("General", "Preciser filehashing", false, "Hash file using contents instead of size. Minor perfomance impact.");

	private static bool skipHashing => !preciseHash.Value;

	public static IEnumerable<string> TargetDLLs { get; } = new string[0];


	public static void Initialize()
	{
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Expected O, but got Unknown
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_023e: Expected O, but got Unknown
		//IL_0278: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: Expected O, but got Unknown
		//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ce: Expected O, but got Unknown
		string[] array = AssemblyNamesToHookGenPatch.Value.Split(new char[1] { ',' });
		string text = Path.Combine(Paths.PluginPath, "MMHOOK");
		string[] array2 = array;
		foreach (string text2 in array2)
		{
			string text3 = "MMHOOK_" + text2;
			string text4 = Path.Combine(Paths.ManagedPath, text2);
			string text5 = Path.Combine(text, text3);
			bool flag = true;
			string[] files = Directory.GetFiles(Paths.PluginPath, text3, SearchOption.AllDirectories);
			foreach (string text6 in files)
			{
				if (Path.GetFileName(text6).Equals(text3))
				{
					text5 = text6;
					Logger.LogInfo((object)"Previous MMHOOK location found. Using that location to save instead.");
					flag = false;
					break;
				}
			}
			if (flag)
			{
				Directory.CreateDirectory(text);
			}
			FileInfo fileInfo = new FileInfo(text4);
			long length = fileInfo.Length;
			long num = 0L;
			if (File.Exists(text5))
			{
				try
				{
					AssemblyDefinition val = AssemblyDefinition.ReadAssembly(text5);
					try
					{
						if (val.MainModule.GetType("BepHookGen.size" + length) != null)
						{
							if (skipHashing)
							{
								Logger.LogInfo((object)"Already ran for this version, reusing that file.");
								continue;
							}
							num = fileInfo.makeHash();
							if (val.MainModule.GetType("BepHookGen.content" + num) != null)
							{
								Logger.LogInfo((object)"Already ran for this version, reusing that file.");
								continue;
							}
						}
					}
					finally
					{
						((IDisposable)val)?.Dispose();
					}
				}
				catch (BadImageFormatException)
				{
					Logger.LogWarning((object)("Failed to read " + Path.GetFileName(text5) + ", probably corrupted, remaking one."));
				}
			}
			Environment.SetEnvironmentVariable("MONOMOD_HOOKGEN_PRIVATE", "1");
			Environment.SetEnvironmentVariable("MONOMOD_DEPENDENCY_MISSING_THROW", "0");
			MonoModder val2 = new MonoModder
			{
				InputPath = text4,
				OutputPath = text5,
				ReadingMode = (ReadingMode)2
			};
			try
			{
				IAssemblyResolver assemblyResolver = val2.AssemblyResolver;
				IAssemblyResolver obj = ((assemblyResolver is BaseAssemblyResolver) ? assemblyResolver : null);
				if (obj != null)
				{
					((BaseAssemblyResolver)obj).AddSearchDirectory(Paths.BepInExAssemblyDirectory);
				}
				val2.Read();
				val2.MapDependencies();
				if (File.Exists(text5))
				{
					Logger.LogDebug((object)("Clearing " + text5));
					File.Delete(text5);
				}
				Logger.LogInfo((object)"Starting HookGenerator");
				HookGenerator val3 = new HookGenerator(val2, Path.GetFileName(text5));
				ModuleDefinition outputModule = val3.OutputModule;
				try
				{
					val3.Generate();
					outputModule.Types.Add(new TypeDefinition("BepHookGen", "size" + length, (TypeAttributes)1, outputModule.TypeSystem.Object));
					if (!skipHashing)
					{
						outputModule.Types.Add(new TypeDefinition("BepHookGen", "content" + ((num == 0L) ? fileInfo.makeHash() : num), (TypeAttributes)1, outputModule.TypeSystem.Object));
					}
					outputModule.Write(text5);
				}
				finally
				{
					((IDisposable)outputModule)?.Dispose();
				}
				Logger.LogInfo((object)"Done.");
			}
			finally
			{
				((IDisposable)val2)?.Dispose();
			}
		}
	}

	public static void Patch(AssemblyDefinition _)
	{
	}

	private static long makeHash(this FileInfo fileInfo)
	{
		FileStream inputStream = fileInfo.OpenRead();
		byte[] value = null;
		using (MD5 mD = new MD5CryptoServiceProvider())
		{
			value = mD.ComputeHash(inputStream);
		}
		long num = BitConverter.ToInt64(value, 0);
		if (num == 0L)
		{
			return 1L;
		}
		return num;
	}
}

pachers/BepInEx.MonoMod.HookGenPatcher/MonoMod.dll

Decompiled 9 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Cecil.Mdb;
using Mono.Cecil.Pdb;
using Mono.Collections.Generic;
using MonoMod.Cil;
using MonoMod.InlineRT;
using MonoMod.Utils;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("0x0ade")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright 2021 0x0ade")]
[assembly: AssemblyDescription("General purpose .NET assembly modding \"basework\". This package contains the core IL patcher and relinker.")]
[assembly: AssemblyFileVersion("21.8.5.1")]
[assembly: AssemblyInformationalVersion("21.08.05.01")]
[assembly: AssemblyProduct("MonoMod")]
[assembly: AssemblyTitle("MonoMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("21.8.5.1")]
[module: UnverifiableCode]
internal static class MultiTargetShims
{
	private static readonly object[] _NoArgs = new object[0];

	public static TypeReference GetConstraintType(this TypeReference type)
	{
		return type;
	}
}
namespace MonoMod
{
	[MonoMod__SafeToCopy__]
	public class MonoModAdded : Attribute
	{
	}
	[MonoMod__SafeToCopy__]
	public class MonoModConstructor : Attribute
	{
	}
	[MonoMod__SafeToCopy__]
	public class MonoModCustomAttributeAttribute : Attribute
	{
		public MonoModCustomAttributeAttribute(string h)
		{
		}
	}
	[MonoMod__SafeToCopy__]
	public class MonoModCustomMethodAttributeAttribute : Attribute
	{
		public MonoModCustomMethodAttributeAttribute(string h)
		{
		}
	}
	[MonoMod__SafeToCopy__]
	public class MonoModEnumReplace : Attribute
	{
	}
	[MonoMod__SafeToCopy__]
	public class MonoModForceCall : Attribute
	{
	}
	[MonoMod__SafeToCopy__]
	public class MonoModForceCallvirt : Attribute
	{
	}
	[MonoMod__SafeToCopy__]
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
	[Obsolete("Use MonoModLinkFrom or RuntimeDetour / HookGen instead.")]
	public class MonoModHook : Attribute
	{
		public string FindableID;

		public Type Type;

		public MonoModHook(string findableID)
		{
			FindableID = findableID;
		}

		public MonoModHook(Type type)
		{
			Type = type;
			FindableID = type.FullName;
		}
	}
	[MonoMod__SafeToCopy__]
	public class MonoModIfFlag : Attribute
	{
		public MonoModIfFlag(string key)
		{
		}

		public MonoModIfFlag(string key, bool fallback)
		{
		}
	}
	[MonoMod__SafeToCopy__]
	public class MonoModIgnore : Attribute
	{
	}
	[MonoMod__SafeToCopy__]
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
	public class MonoModLinkFrom : Attribute
	{
		public string FindableID;

		public Type Type;

		public MonoModLinkFrom(string findableID)
		{
			FindableID = findableID;
		}

		public MonoModLinkFrom(Type type)
		{
			Type = type;
			FindableID = type.FullName;
		}
	}
	[MonoMod__SafeToCopy__]
	public class MonoModLinkTo : Attribute
	{
		public MonoModLinkTo(string t)
		{
		}

		public MonoModLinkTo(Type t)
		{
		}

		public MonoModLinkTo(string t, string n)
		{
		}

		public MonoModLinkTo(Type t, string n)
		{
		}
	}
	[MonoMod__SafeToCopy__]
	public class MonoModNoNew : Attribute
	{
	}
	[MonoMod__SafeToCopy__]
	public class MonoModOnPlatform : Attribute
	{
		public MonoModOnPlatform(params Platform[] p)
		{
		}
	}
	[MonoMod__SafeToCopy__]
	public class MonoModOriginal : Attribute
	{
	}
	[MonoMod__SafeToCopy__]
	public class MonoModOriginalName : Attribute
	{
		public MonoModOriginalName(string n)
		{
		}
	}
	[MonoMod__SafeToCopy__]
	public class MonoModPatch : Attribute
	{
		public MonoModPatch(string name)
		{
		}
	}
	[MonoMod__SafeToCopy__]
	public class MonoModPublic : Attribute
	{
	}
	[MonoMod__SafeToCopy__]
	public class MonoModRemove : Attribute
	{
	}
	[MonoMod__SafeToCopy__]
	public class MonoModReplace : Attribute
	{
	}
	[MonoMod__SafeToCopy__]
	public class MonoModTargetModule : Attribute
	{
		public MonoModTargetModule(string name)
		{
		}
	}
	[MonoMod__SafeToCopy__]
	internal class MonoMod__SafeToCopy__ : Attribute
	{
	}
	public delegate bool MethodParser(MonoModder modder, MethodBody body, Instruction instr, ref int instri);
	public delegate void MethodRewriter(MonoModder modder, MethodDefinition method);
	public delegate void MethodBodyRewriter(MonoModder modder, MethodBody body, Instruction instr, int instri);
	public delegate ModuleDefinition MissingDependencyResolver(MonoModder modder, ModuleDefinition main, string name, string fullName);
	public delegate void PostProcessor(MonoModder modder);
	public delegate void ModReadEventHandler(MonoModder modder, ModuleDefinition mod);
	public class RelinkMapEntry
	{
		public string Type;

		public string FindableID;

		public RelinkMapEntry()
		{
		}

		public RelinkMapEntry(string type, string findableID)
		{
			Type = type;
			FindableID = findableID;
		}
	}
	public enum DebugSymbolFormat
	{
		Auto,
		MDB,
		PDB
	}
	public class MonoModder : IDisposable
	{
		public static readonly bool IsMono = (object)Type.GetType("Mono.Runtime") != null;

		public static readonly Version Version = typeof(MonoModder).Assembly.GetName().Version;

		public Dictionary<string, object> SharedData = new Dictionary<string, object>();

		public Dictionary<string, object> RelinkMap = new Dictionary<string, object>();

		public Dictionary<string, ModuleDefinition> RelinkModuleMap = new Dictionary<string, ModuleDefinition>();

		public HashSet<string> SkipList = new HashSet<string>(EqualityComparer<string>.Default);

		public Dictionary<string, IMetadataTokenProvider> RelinkMapCache = new Dictionary<string, IMetadataTokenProvider>();

		public Dictionary<string, TypeReference> RelinkModuleMapCache = new Dictionary<string, TypeReference>();

		public Dictionary<string, OpCode> ForceCallMap = new Dictionary<string, OpCode>();

		public ModReadEventHandler OnReadMod;

		public PostProcessor PostProcessors;

		public Dictionary<string, Action<object, object[]>> CustomAttributeHandlers = new Dictionary<string, Action<object, object[]>> { 
		{
			"MonoMod.MonoModPublic",
			delegate
			{
			}
		} };

		public Dictionary<string, Action<object, object[]>> CustomMethodAttributeHandlers = new Dictionary<string, Action<object, object[]>>();

		public MissingDependencyResolver MissingDependencyResolver;

		public MethodParser MethodParser;

		public MethodRewriter MethodRewriter;

		public MethodBodyRewriter MethodBodyRewriter;

		public Stream Input;

		public string InputPath;

		public Stream Output;

		public string OutputPath;

		public List<string> DependencyDirs = new List<string>();

		public ModuleDefinition Module;

		public Dictionary<ModuleDefinition, List<ModuleDefinition>> DependencyMap = new Dictionary<ModuleDefinition, List<ModuleDefinition>>();

		public Dictionary<string, ModuleDefinition> DependencyCache = new Dictionary<string, ModuleDefinition>();

		public Func<ICustomAttributeProvider, TypeReference, bool> ShouldCleanupAttrib;

		public bool LogVerboseEnabled;

		public bool CleanupEnabled;

		public bool PublicEverything;

		public List<ModuleReference> Mods = new List<ModuleReference>();

		public bool Strict;

		public bool MissingDependencyThrow;

		public bool RemovePatchReferences;

		public bool PreventInline;

		public bool? UpgradeMSCORLIB;

		public ReadingMode ReadingMode = (ReadingMode)1;

		public DebugSymbolFormat DebugSymbolOutputFormat;

		public int CurrentRID;

		protected IAssemblyResolver _assemblyResolver;

		protected ReaderParameters _readerParameters;

		protected WriterParameters _writerParameters;

		public bool GACEnabled;

		private string[] _GACPathsNone = new string[0];

		protected string[] _GACPaths;

		protected MethodDefinition _mmOriginalCtor;

		protected MethodDefinition _mmOriginalNameCtor;

		protected MethodDefinition _mmAddedCtor;

		protected MethodDefinition _mmPatchCtor;

		public virtual IAssemblyResolver AssemblyResolver
		{
			get
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Expected O, but got Unknown
				if (_assemblyResolver == null)
				{
					DefaultAssemblyResolver val = new DefaultAssemblyResolver();
					foreach (string dependencyDir in DependencyDirs)
					{
						((BaseAssemblyResolver)val).AddSearchDirectory(dependencyDir);
					}
					_assemblyResolver = (IAssemblyResolver)(object)val;
				}
				return _assemblyResolver;
			}
			set
			{
				_assemblyResolver = value;
			}
		}

		public virtual ReaderParameters ReaderParameters
		{
			get
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: 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_002c: Expected O, but got Unknown
				if (_readerParameters == null)
				{
					_readerParameters = new ReaderParameters(ReadingMode)
					{
						AssemblyResolver = AssemblyResolver,
						ReadSymbols = true
					};
				}
				return _readerParameters;
			}
			set
			{
				_readerParameters = value;
			}
		}

		public virtual WriterParameters WriterParameters
		{
			get
			{
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: 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)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Invalid comparison between Unknown and I4
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Expected O, but got Unknown
				//IL_0067: Expected O, but got Unknown
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Expected O, but got Unknown
				if (_writerParameters == null)
				{
					bool flag = DebugSymbolOutputFormat == DebugSymbolFormat.PDB;
					bool flag2 = DebugSymbolOutputFormat == DebugSymbolFormat.MDB;
					if (DebugSymbolOutputFormat == DebugSymbolFormat.Auto)
					{
						if ((PlatformHelper.Current & 0x25) == 37)
						{
							flag = true;
						}
						else
						{
							flag2 = true;
						}
					}
					WriterParameters val = new WriterParameters
					{
						WriteSymbols = true
					};
					object symbolWriterProvider;
					if (!flag)
					{
						if (!flag2)
						{
							symbolWriterProvider = null;
						}
						else
						{
							ISymbolWriterProvider val2 = (ISymbolWriterProvider)new MdbWriterProvider();
							symbolWriterProvider = val2;
						}
					}
					else
					{
						ISymbolWriterProvider val2 = (ISymbolWriterProvider)new NativePdbWriterProvider();
						symbolWriterProvider = val2;
					}
					val.SymbolWriterProvider = (ISymbolWriterProvider)symbolWriterProvider;
					_writerParameters = val;
				}
				return _writerParameters;
			}
			set
			{
				_writerParameters = value;
			}
		}

		public string[] GACPaths
		{
			get
			{
				if (!GACEnabled)
				{
					return _GACPathsNone;
				}
				if (_GACPaths != null)
				{
					return _GACPaths;
				}
				if (!IsMono)
				{
					string environmentVariable = Environment.GetEnvironmentVariable("windir");
					if (string.IsNullOrEmpty(environmentVariable))
					{
						return _GACPaths = _GACPathsNone;
					}
					environmentVariable = Path.Combine(environmentVariable, "Microsoft.NET");
					environmentVariable = Path.Combine(environmentVariable, "assembly");
					_GACPaths = new string[3]
					{
						Path.Combine(environmentVariable, "GAC_32"),
						Path.Combine(environmentVariable, "GAC_64"),
						Path.Combine(environmentVariable, "GAC_MSIL")
					};
				}
				else
				{
					List<string> list = new List<string>();
					string text = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(typeof(object).Module.FullyQualifiedName)), "gac");
					if (Directory.Exists(text))
					{
						list.Add(text);
					}
					string environmentVariable2 = Environment.GetEnvironmentVariable("MONO_GAC_PREFIX");
					if (!string.IsNullOrEmpty(environmentVariable2))
					{
						string[] array = environmentVariable2.Split(new char[1] { Path.PathSeparator });
						foreach (string text2 in array)
						{
							if (!string.IsNullOrEmpty(text2))
							{
								string path = text2;
								path = Path.Combine(path, "lib");
								path = Path.Combine(path, "mono");
								path = Path.Combine(path, "gac");
								if (Directory.Exists(path) && !list.Contains(path))
								{
									list.Add(path);
								}
							}
						}
					}
					_GACPaths = list.ToArray();
				}
				return _GACPaths;
			}
			set
			{
				GACEnabled = true;
				_GACPaths = value;
			}
		}

		public MonoModder()
		{
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			MethodParser = DefaultParser;
			MissingDependencyResolver = DefaultMissingDependencyResolver;
			PostProcessors = (PostProcessor)Delegate.Combine(PostProcessors, new PostProcessor(DefaultPostProcessor));
			string environmentVariable = Environment.GetEnvironmentVariable("MONOMOD_DEPDIRS");
			if (!string.IsNullOrEmpty(environmentVariable))
			{
				foreach (string item in from dir in environmentVariable.Split(new char[1] { Path.PathSeparator })
					select dir.Trim())
				{
					IAssemblyResolver assemblyResolver = AssemblyResolver;
					IAssemblyResolver obj = ((assemblyResolver is BaseAssemblyResolver) ? assemblyResolver : null);
					if (obj != null)
					{
						((BaseAssemblyResolver)obj).AddSearchDirectory(item);
					}
					DependencyDirs.Add(item);
				}
			}
			LogVerboseEnabled = Environment.GetEnvironmentVariable("MONOMOD_LOG_VERBOSE") == "1";
			CleanupEnabled = Environment.GetEnvironmentVariable("MONOMOD_CLEANUP") != "0";
			PublicEverything = Environment.GetEnvironmentVariable("MONOMOD_PUBLIC_EVERYTHING") == "1";
			PreventInline = Environment.GetEnvironmentVariable("MONOMOD_PREVENTINLINE") == "1";
			Strict = Environment.GetEnvironmentVariable("MONOMOD_STRICT") == "1";
			MissingDependencyThrow = Environment.GetEnvironmentVariable("MONOMOD_DEPENDENCY_MISSING_THROW") != "0";
			RemovePatchReferences = Environment.GetEnvironmentVariable("MONOMOD_DEPENDENCY_REMOVE_PATCH") != "0";
			string environmentVariable2 = Environment.GetEnvironmentVariable("MONOMOD_DEBUG_FORMAT");
			if (environmentVariable2 != null)
			{
				environmentVariable2 = environmentVariable2.ToLowerInvariant();
				if (environmentVariable2 == "pdb")
				{
					DebugSymbolOutputFormat = DebugSymbolFormat.PDB;
				}
				else if (environmentVariable2 == "mdb")
				{
					DebugSymbolOutputFormat = DebugSymbolFormat.MDB;
				}
			}
			string environmentVariable3 = Environment.GetEnvironmentVariable("MONOMOD_MSCORLIB_UPGRADE");
			UpgradeMSCORLIB = (string.IsNullOrEmpty(environmentVariable3) ? null : new bool?(environmentVariable3 != "0"));
			GACEnabled = Environment.GetEnvironmentVariable("MONOMOD_GAC_ENABLED") != "0";
			MonoModRulesManager.Register(this);
		}

		public virtual void ClearCaches(bool all = false, bool shareable = false, bool moduleSpecific = false)
		{
			if (all || shareable)
			{
				foreach (KeyValuePair<string, ModuleDefinition> item in DependencyCache)
				{
					item.Value.Dispose();
				}
				DependencyCache.Clear();
			}
			if (all || moduleSpecific)
			{
				RelinkMapCache.Clear();
				RelinkModuleMapCache.Clear();
			}
		}

		public virtual void Dispose()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			ClearCaches(all: true);
			ModuleDefinition module = Module;
			if (module != null)
			{
				module.Dispose();
			}
			Module = null;
			((IDisposable)AssemblyResolver)?.Dispose();
			AssemblyResolver = null;
			foreach (ModuleDefinition mod in Mods)
			{
				if ((int)mod != 0)
				{
					mod.Dispose();
				}
			}
			foreach (List<ModuleDefinition> value in DependencyMap.Values)
			{
				foreach (ModuleDefinition item in value)
				{
					if (item != null)
					{
						item.Dispose();
					}
				}
			}
			DependencyMap.Clear();
			Input?.Dispose();
			Output?.Dispose();
		}

		public virtual void Log(object value)
		{
			Log(value.ToString());
		}

		public virtual void Log(string text)
		{
			Console.Write("[MonoMod] ");
			Console.WriteLine(text);
		}

		public virtual void LogVerbose(object value)
		{
			if (LogVerboseEnabled)
			{
				Log(value);
			}
		}

		public virtual void LogVerbose(string text)
		{
			if (LogVerboseEnabled)
			{
				Log(text);
			}
		}

		private static ModuleDefinition _ReadModule(Stream input, ReaderParameters args)
		{
			if (args.ReadSymbols)
			{
				try
				{
					return ModuleDefinition.ReadModule(input, args);
				}
				catch
				{
					args.ReadSymbols = false;
					input.Seek(0L, SeekOrigin.Begin);
				}
			}
			return ModuleDefinition.ReadModule(input, args);
		}

		private static ModuleDefinition _ReadModule(string input, ReaderParameters args)
		{
			if (args.ReadSymbols)
			{
				try
				{
					return ModuleDefinition.ReadModule(input, args);
				}
				catch
				{
					args.ReadSymbols = false;
				}
			}
			return ModuleDefinition.ReadModule(input, args);
		}

		public virtual void Read()
		{
			if (Module != null)
			{
				return;
			}
			if (Input != null)
			{
				Log("Reading input stream into module.");
				Module = _ReadModule(Input, GenReaderParameters(mainModule: true));
			}
			else if (InputPath != null)
			{
				Log("Reading input file into module.");
				IAssemblyResolver assemblyResolver = AssemblyResolver;
				IAssemblyResolver obj = ((assemblyResolver is BaseAssemblyResolver) ? assemblyResolver : null);
				if (obj != null)
				{
					((BaseAssemblyResolver)obj).AddSearchDirectory(Path.GetDirectoryName(InputPath));
				}
				DependencyDirs.Add(Path.GetDirectoryName(InputPath));
				Module = _ReadModule(InputPath, GenReaderParameters(mainModule: true, InputPath));
			}
			string environmentVariable = Environment.GetEnvironmentVariable("MONOMOD_MODS");
			if (string.IsNullOrEmpty(environmentVariable))
			{
				return;
			}
			foreach (string item in from path in environmentVariable.Split(new char[1] { Path.PathSeparator })
				select path.Trim())
			{
				ReadMod(item);
			}
		}

		public virtual void MapDependencies()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			foreach (ModuleDefinition mod in Mods)
			{
				ModuleDefinition main = mod;
				MapDependencies(main);
			}
			MapDependencies(Module);
		}

		public virtual void MapDependencies(ModuleDefinition main)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			if (DependencyMap.ContainsKey(main))
			{
				return;
			}
			DependencyMap[main] = new List<ModuleDefinition>();
			Enumerator<AssemblyNameReference> enumerator = main.AssemblyReferences.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					AssemblyNameReference current = enumerator.Current;
					MapDependency(main, current);
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
		}

		public virtual void MapDependency(ModuleDefinition main, AssemblyNameReference depRef)
		{
			MapDependency(main, depRef.Name, depRef.FullName, depRef);
		}

		public virtual void MapDependency(ModuleDefinition main, string name, string fullName = null, AssemblyNameReference depRef = null)
		{
			if (!DependencyMap.TryGetValue(main, out var value))
			{
				value = (DependencyMap[main] = new List<ModuleDefinition>());
			}
			if (fullName != null && (DependencyCache.TryGetValue(fullName, out var value2) || DependencyCache.TryGetValue(fullName + " [RT:" + main.RuntimeVersion + "]", out value2)))
			{
				LogVerbose("[MapDependency] " + ((ModuleReference)main).Name + " -> " + ((ModuleReference)value2).Name + " ((" + fullName + "), (" + name + ")) from cache");
				value.Add(value2);
				MapDependencies(value2);
				return;
			}
			if (DependencyCache.TryGetValue(name, out value2) || DependencyCache.TryGetValue(name + " [RT:" + main.RuntimeVersion + "]", out value2))
			{
				LogVerbose("[MapDependency] " + ((ModuleReference)main).Name + " -> " + ((ModuleReference)value2).Name + " (" + name + ") from cache");
				value.Add(value2);
				MapDependencies(value2);
				return;
			}
			string text = Path.GetExtension(name).ToLowerInvariant();
			bool flag = text == "pdb" || text == "mdb";
			string text2 = null;
			foreach (string dependencyDir in DependencyDirs)
			{
				text2 = Path.Combine(dependencyDir, name + ".dll");
				if (!File.Exists(text2))
				{
					text2 = Path.Combine(dependencyDir, name + ".exe");
				}
				if (!File.Exists(text2) && !flag)
				{
					text2 = Path.Combine(dependencyDir, name);
				}
				if (File.Exists(text2))
				{
					break;
				}
				text2 = null;
			}
			if (text2 == null && depRef != null)
			{
				try
				{
					AssemblyDefinition obj = AssemblyResolver.Resolve(depRef);
					value2 = ((obj != null) ? obj.MainModule : null);
				}
				catch
				{
				}
				if (value2 != null)
				{
					text2 = value2.FileName;
				}
			}
			if (text2 == null)
			{
				string[] gACPaths = GACPaths;
				for (int i = 0; i < gACPaths.Length; i++)
				{
					text2 = Path.Combine(gACPaths[i], name);
					if (Directory.Exists(text2))
					{
						string[] directories = Directory.GetDirectories(text2);
						int num = 0;
						int num2 = 0;
						for (int j = 0; j < directories.Length; j++)
						{
							string text3 = directories[j];
							if (text3.StartsWith(text2))
							{
								text3 = text3.Substring(text2.Length + 1);
							}
							Match match = Regex.Match(text3, "\\d+");
							if (match.Success)
							{
								int num3 = int.Parse(match.Value);
								if (num3 > num)
								{
									num = num3;
									num2 = j;
								}
							}
						}
						text2 = Path.Combine(directories[num2], name + ".dll");
						break;
					}
					text2 = null;
				}
			}
			if (text2 == null)
			{
				try
				{
					AssemblyDefinition obj3 = AssemblyResolver.Resolve(AssemblyNameReference.Parse(fullName ?? name));
					value2 = ((obj3 != null) ? obj3.MainModule : null);
				}
				catch
				{
				}
				if (value2 != null)
				{
					text2 = value2.FileName;
				}
			}
			if (value2 == null)
			{
				if (text2 != null && File.Exists(text2))
				{
					value2 = _ReadModule(text2, GenReaderParameters(mainModule: false, text2));
				}
				else if ((value2 = MissingDependencyResolver?.Invoke(this, main, name, fullName)) == null)
				{
					return;
				}
			}
			LogVerbose("[MapDependency] " + ((ModuleReference)main).Name + " -> " + ((ModuleReference)value2).Name + " ((" + fullName + "), (" + name + ")) loaded");
			value.Add(value2);
			if (fullName == null)
			{
				fullName = value2.Assembly.FullName;
			}
			DependencyCache[fullName] = value2;
			DependencyCache[name] = value2;
			MapDependencies(value2);
		}

		public virtual ModuleDefinition DefaultMissingDependencyResolver(MonoModder mod, ModuleDefinition main, string name, string fullName)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			if (MissingDependencyThrow && Environment.GetEnvironmentVariable("MONOMOD_DEPENDENCY_MISSING_THROW") == "0")
			{
				Log("[MissingDependencyResolver] [WARNING] Use MMILRT.Modder.MissingDependencyThrow instead of setting the env var MONOMOD_DEPENDENCY_MISSING_THROW");
				MissingDependencyThrow = false;
			}
			if (MissingDependencyThrow || Strict)
			{
				throw new RelinkTargetNotFoundException("MonoMod cannot map dependency " + ((ModuleReference)main).Name + " -> ((" + fullName + "), (" + name + ")) - not found", (IMetadataTokenProvider)(object)main, (IMetadataTokenProvider)null);
			}
			return null;
		}

		public virtual void Write(Stream output = null, string outputPath = null)
		{
			output = output ?? Output;
			outputPath = outputPath ?? OutputPath;
			PatchRefsInType(PatchWasHere());
			if (output != null)
			{
				Log("[Write] Writing modded module into output stream.");
				Module.Write(output, WriterParameters);
			}
			else
			{
				Log("[Write] Writing modded module into output file.");
				Module.Write(outputPath, WriterParameters);
			}
		}

		public virtual ReaderParameters GenReaderParameters(bool mainModule, string path = null)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			ReaderParameters readerParameters = ReaderParameters;
			ReaderParameters val = new ReaderParameters(readerParameters.ReadingMode);
			val.AssemblyResolver = readerParameters.AssemblyResolver;
			val.MetadataResolver = readerParameters.MetadataResolver;
			val.InMemory = readerParameters.InMemory;
			val.MetadataImporterProvider = readerParameters.MetadataImporterProvider;
			val.ReflectionImporterProvider = readerParameters.ReflectionImporterProvider;
			val.ThrowIfSymbolsAreNotMatching = readerParameters.ThrowIfSymbolsAreNotMatching;
			val.ApplyWindowsRuntimeProjections = readerParameters.ApplyWindowsRuntimeProjections;
			val.SymbolStream = readerParameters.SymbolStream;
			val.SymbolReaderProvider = readerParameters.SymbolReaderProvider;
			val.ReadSymbols = readerParameters.ReadSymbols;
			if (path != null && !File.Exists(path + ".mdb") && !File.Exists(Path.ChangeExtension(path, "pdb")))
			{
				val.ReadSymbols = false;
			}
			return val;
		}

		public virtual void ReadMod(string path)
		{
			if (Directory.Exists(path))
			{
				Log("[ReadMod] Loading mod dir: " + path);
				string text = ((ModuleReference)Module).Name.Substring(0, ((ModuleReference)Module).Name.Length - 3);
				string value = text.Replace(" ", "");
				if (!DependencyDirs.Contains(path))
				{
					IAssemblyResolver assemblyResolver = AssemblyResolver;
					IAssemblyResolver obj = ((assemblyResolver is BaseAssemblyResolver) ? assemblyResolver : null);
					if (obj != null)
					{
						((BaseAssemblyResolver)obj).AddSearchDirectory(path);
					}
					DependencyDirs.Add(path);
				}
				string[] files = Directory.GetFiles(path);
				foreach (string text2 in files)
				{
					if ((Path.GetFileName(text2).StartsWith(text) || Path.GetFileName(text2).StartsWith(value)) && text2.ToLower().EndsWith(".mm.dll"))
					{
						ReadMod(text2);
					}
				}
				return;
			}
			Log("[ReadMod] Loading mod: " + path);
			ModuleDefinition val = _ReadModule(path, GenReaderParameters(mainModule: false, path));
			string directoryName = Path.GetDirectoryName(path);
			if (!DependencyDirs.Contains(directoryName))
			{
				IAssemblyResolver assemblyResolver2 = AssemblyResolver;
				IAssemblyResolver obj2 = ((assemblyResolver2 is BaseAssemblyResolver) ? assemblyResolver2 : null);
				if (obj2 != null)
				{
					((BaseAssemblyResolver)obj2).AddSearchDirectory(directoryName);
				}
				DependencyDirs.Add(directoryName);
			}
			Mods.Add((ModuleReference)(object)val);
			OnReadMod?.Invoke(this, val);
		}

		public virtual void ReadMod(Stream stream)
		{
			Log($"[ReadMod] Loading mod: stream#{(uint)stream.GetHashCode()}");
			ModuleDefinition val = _ReadModule(stream, GenReaderParameters(mainModule: false));
			Mods.Add((ModuleReference)(object)val);
			OnReadMod?.Invoke(this, val);
		}

		public virtual void ParseRules(ModuleDefinition mod)
		{
			//IL_002c: 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)
			TypeDefinition type = mod.GetType("MonoMod.MonoModRules");
			Type rulesTypeMMILRT = null;
			if (type != null)
			{
				rulesTypeMMILRT = this.ExecuteRules(type);
				mod.Types.Remove(type);
			}
			Enumerator<TypeDefinition> enumerator = mod.Types.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					TypeDefinition current = enumerator.Current;
					ParseRulesInType(current, rulesTypeMMILRT);
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
		}

		public virtual void ParseRulesInType(TypeDefinition type, Type rulesTypeMMILRT = null)
		{
			//IL_0035: 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_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_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_0431: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			Extensions.GetPatchFullName((MemberReference)(object)type);
			if (!MatchingConditionals((ICustomAttributeProvider)(object)type, Module))
			{
				return;
			}
			CustomAttribute customAttribute = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModCustomAttributeAttribute");
			CustomAttributeArgument val;
			if (customAttribute != null)
			{
				val = customAttribute.ConstructorArguments[0];
				MethodInfo method2 = rulesTypeMMILRT.GetMethod((string)((CustomAttributeArgument)(ref val)).Value);
				CustomAttributeHandlers[((MemberReference)type).FullName] = delegate(object self, object[] args)
				{
					method2.Invoke(self, args);
				};
			}
			customAttribute = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModCustomMethodAttributeAttribute");
			if (customAttribute != null)
			{
				val = customAttribute.ConstructorArguments[0];
				MethodInfo method = rulesTypeMMILRT.GetMethod((string)((CustomAttributeArgument)(ref val)).Value);
				ParameterInfo[] parameters = method.GetParameters();
				if (parameters.Length == 2 && Extensions.IsCompatible(parameters[0].ParameterType, typeof(ILContext)))
				{
					CustomMethodAttributeHandlers[((MemberReference)type).FullName] = delegate(object self, object[] args)
					{
						//IL_0024: Unknown result type (might be due to invalid IL or missing references)
						//IL_002e: Expected O, but got Unknown
						//IL_0029: Unknown result type (might be due to invalid IL or missing references)
						//IL_0033: Expected O, but got Unknown
						//IL_0040: Unknown result type (might be due to invalid IL or missing references)
						//IL_004a: Expected O, but got Unknown
						ILContext il = new ILContext((MethodDefinition)args[0]);
						il.Invoke((Manipulator)delegate
						{
							method.Invoke(self, new object[2]
							{
								il,
								args[1]
							});
						});
						if (il.IsReadOnly)
						{
							il.Dispose();
						}
					};
				}
				else
				{
					CustomMethodAttributeHandlers[((MemberReference)type).FullName] = delegate(object self, object[] args)
					{
						method.Invoke(self, args);
					};
				}
			}
			for (CustomAttribute val2 = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModHook"); val2 != null; val2 = ((ICustomAttributeProvider)(object)type).GetNextCustomAttribute("MonoMod.MonoModHook"))
			{
				ParseLinkFrom((MemberReference)(object)type, val2);
			}
			for (CustomAttribute val2 = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModLinkFrom"); val2 != null; val2 = ((ICustomAttributeProvider)(object)type).GetNextCustomAttribute("MonoMod.MonoModLinkFrom"))
			{
				ParseLinkFrom((MemberReference)(object)type, val2);
			}
			for (CustomAttribute val2 = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModLinkTo"); val2 != null; val2 = ((ICustomAttributeProvider)(object)type).GetNextCustomAttribute("MonoMod.MonoModLinkTo"))
			{
				ParseLinkTo((MemberReference)(object)type, val2);
			}
			if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModIgnore"))
			{
				return;
			}
			Enumerator<MethodDefinition> enumerator = type.Methods.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					MethodDefinition current = enumerator.Current;
					if (MatchingConditionals((ICustomAttributeProvider)(object)current, Module))
					{
						for (CustomAttribute val2 = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)current, "MonoMod.MonoModHook"); val2 != null; val2 = ((ICustomAttributeProvider)(object)current).GetNextCustomAttribute("MonoMod.MonoModHook"))
						{
							ParseLinkFrom((MemberReference)(object)current, val2);
						}
						for (CustomAttribute val2 = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)current, "MonoMod.MonoModLinkFrom"); val2 != null; val2 = ((ICustomAttributeProvider)(object)current).GetNextCustomAttribute("MonoMod.MonoModLinkFrom"))
						{
							ParseLinkFrom((MemberReference)(object)current, val2);
						}
						for (CustomAttribute val2 = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)current, "MonoMod.MonoModLinkTo"); val2 != null; val2 = ((ICustomAttributeProvider)(object)current).GetNextCustomAttribute("MonoMod.MonoModLinkTo"))
						{
							ParseLinkTo((MemberReference)(object)current, val2);
						}
						if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)current, "MonoMod.MonoModForceCall"))
						{
							ForceCallMap[Extensions.GetID((MethodReference)(object)current, (string)null, (string)null, true, false)] = OpCodes.Call;
						}
						else if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)current, "MonoMod.MonoModForceCallvirt"))
						{
							ForceCallMap[Extensions.GetID((MethodReference)(object)current, (string)null, (string)null, true, false)] = OpCodes.Callvirt;
						}
					}
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			Enumerator<FieldDefinition> enumerator2 = type.Fields.GetEnumerator();
			try
			{
				while (enumerator2.MoveNext())
				{
					FieldDefinition current2 = enumerator2.Current;
					if (MatchingConditionals((ICustomAttributeProvider)(object)current2, Module))
					{
						for (CustomAttribute val2 = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)current2, "MonoMod.MonoModHook"); val2 != null; val2 = ((ICustomAttributeProvider)(object)current2).GetNextCustomAttribute("MonoMod.MonoModHook"))
						{
							ParseLinkFrom((MemberReference)(object)current2, val2);
						}
						for (CustomAttribute val2 = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)current2, "MonoMod.MonoModLinkFrom"); val2 != null; val2 = ((ICustomAttributeProvider)(object)current2).GetNextCustomAttribute("MonoMod.MonoModLinkFrom"))
						{
							ParseLinkFrom((MemberReference)(object)current2, val2);
						}
						for (CustomAttribute val2 = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)current2, "MonoMod.MonoModLinkTo"); val2 != null; val2 = ((ICustomAttributeProvider)(object)current2).GetNextCustomAttribute("MonoMod.MonoModLinkTo"))
						{
							ParseLinkTo((MemberReference)(object)current2, val2);
						}
					}
				}
			}
			finally
			{
				((IDisposable)enumerator2).Dispose();
			}
			Enumerator<PropertyDefinition> enumerator3 = type.Properties.GetEnumerator();
			try
			{
				while (enumerator3.MoveNext())
				{
					PropertyDefinition current3 = enumerator3.Current;
					if (MatchingConditionals((ICustomAttributeProvider)(object)current3, Module))
					{
						for (CustomAttribute val2 = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)current3, "MonoMod.MonoModHook"); val2 != null; val2 = ((ICustomAttributeProvider)(object)current3).GetNextCustomAttribute("MonoMod.MonoModHook"))
						{
							ParseLinkFrom((MemberReference)(object)current3, val2);
						}
						for (CustomAttribute val2 = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)current3, "MonoMod.MonoModLinkFrom"); val2 != null; val2 = ((ICustomAttributeProvider)(object)current3).GetNextCustomAttribute("MonoMod.MonoModLinkFrom"))
						{
							ParseLinkFrom((MemberReference)(object)current3, val2);
						}
						for (CustomAttribute val2 = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)current3, "MonoMod.MonoModLinkTo"); val2 != null; val2 = ((ICustomAttributeProvider)(object)current3).GetNextCustomAttribute("MonoMod.MonoModLinkTo"))
						{
							ParseLinkTo((MemberReference)(object)current3, val2);
						}
					}
				}
			}
			finally
			{
				((IDisposable)enumerator3).Dispose();
			}
			Enumerator<TypeDefinition> enumerator4 = type.NestedTypes.GetEnumerator();
			try
			{
				while (enumerator4.MoveNext())
				{
					TypeDefinition current4 = enumerator4.Current;
					ParseRulesInType(current4, rulesTypeMMILRT);
				}
			}
			finally
			{
				((IDisposable)enumerator4).Dispose();
			}
		}

		public virtual void ParseLinkFrom(MemberReference target, CustomAttribute hook)
		{
			//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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_003c: 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)
			//IL_005a: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			CustomAttributeArgument val = hook.ConstructorArguments[0];
			string key = (string)((CustomAttributeArgument)(ref val)).Value;
			object value;
			if (target is TypeReference)
			{
				value = Extensions.GetPatchFullName((MemberReference)(TypeReference)target);
			}
			else if (target is MethodReference)
			{
				value = new RelinkMapEntry(Extensions.GetPatchFullName((MemberReference)(object)((MemberReference)(MethodReference)target).DeclaringType), Extensions.GetID((MethodReference)target, (string)null, (string)null, false, false));
			}
			else if (target is FieldReference)
			{
				value = new RelinkMapEntry(Extensions.GetPatchFullName((MemberReference)(object)((MemberReference)(FieldReference)target).DeclaringType), ((MemberReference)(FieldReference)target).Name);
			}
			else
			{
				if (!(target is PropertyReference))
				{
					return;
				}
				value = new RelinkMapEntry(Extensions.GetPatchFullName((MemberReference)(object)((MemberReference)(PropertyReference)target).DeclaringType), ((MemberReference)(PropertyReference)target).Name);
			}
			RelinkMap[key] = value;
		}

		public virtual void ParseLinkTo(MemberReference from, CustomAttribute hook)
		{
			//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)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			MemberReference obj = ((from is MethodReference) ? from : null);
			string key = ((obj != null) ? Extensions.GetID((MethodReference)(object)obj, (string)null, (string)null, true, false) : null) ?? Extensions.GetPatchFullName(from);
			CustomAttributeArgument val;
			if (hook.ConstructorArguments.Count == 1)
			{
				Dictionary<string, object> relinkMap = RelinkMap;
				val = hook.ConstructorArguments[0];
				relinkMap[key] = (string)((CustomAttributeArgument)(ref val)).Value;
			}
			else
			{
				Dictionary<string, object> relinkMap2 = RelinkMap;
				val = hook.ConstructorArguments[0];
				string type = (string)((CustomAttributeArgument)(ref val)).Value;
				val = hook.ConstructorArguments[1];
				relinkMap2[key] = new RelinkMapEntry(type, (string)((CustomAttributeArgument)(ref val)).Value);
			}
		}

		public virtual void RunCustomAttributeHandlers(ICustomAttributeProvider cap)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			if (!cap.HasCustomAttributes)
			{
				return;
			}
			CustomAttribute[] array = cap.CustomAttributes.ToArray();
			foreach (CustomAttribute val in array)
			{
				if (CustomAttributeHandlers.TryGetValue(((MemberReference)val.AttributeType).FullName, out var value))
				{
					value?.Invoke(null, new object[2] { cap, val });
				}
				if (cap is MethodReference && CustomMethodAttributeHandlers.TryGetValue(((MemberReference)val.AttributeType).FullName, out value))
				{
					value?.Invoke(null, new object[2]
					{
						(object)(MethodDefinition)cap,
						val
					});
				}
			}
		}

		public virtual void AutoPatch()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			Log("[AutoPatch] Parsing rules in loaded mods");
			foreach (ModuleDefinition mod4 in Mods)
			{
				ModuleDefinition mod = mod4;
				ParseRules(mod);
			}
			Log("[AutoPatch] PrePatch pass");
			foreach (ModuleDefinition mod5 in Mods)
			{
				ModuleDefinition mod2 = mod5;
				PrePatchModule(mod2);
			}
			Log("[AutoPatch] Patch pass");
			foreach (ModuleDefinition mod6 in Mods)
			{
				ModuleDefinition mod3 = mod6;
				PatchModule(mod3);
			}
			Log("[AutoPatch] PatchRefs pass");
			PatchRefs();
			if (PostProcessors != null)
			{
				Delegate[] invocationList = PostProcessors.GetInvocationList();
				for (int i = 0; i < invocationList.Length; i++)
				{
					Log($"[PostProcessor] PostProcessor pass #{i + 1}");
					((PostProcessor)invocationList[i])?.Invoke(this);
				}
			}
		}

		public virtual IMetadataTokenProvider Relinker(IMetadataTokenProvider mtp, IGenericParameterProvider context)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				return PostRelinker(MainRelinker(mtp, context) ?? mtp, context) ?? throw new RelinkTargetNotFoundException(mtp, (IMetadataTokenProvider)(object)context);
			}
			catch (Exception ex)
			{
				throw new RelinkFailedException((string)null, ex, mtp, (IMetadataTokenProvider)(object)context);
			}
		}

		public virtual IMetadataTokenProvider MainRelinker(IMetadataTokenProvider mtp, IGenericParameterProvider context)
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			TypeReference val = (TypeReference)(object)((mtp is TypeReference) ? mtp : null);
			if (val != null)
			{
				if (((MemberReference)val).Module == Module)
				{
					return (IMetadataTokenProvider)(object)val;
				}
				if (((MemberReference)val).Module != null && !Mods.Contains((ModuleReference)(object)((MemberReference)val).Module))
				{
					return (IMetadataTokenProvider)(object)Module.ImportReference(val);
				}
				val = (TypeReference)(((object)Extensions.SafeResolve(val)) ?? ((object)val));
				TypeReference val2 = FindTypeDeep(Extensions.GetPatchFullName((MemberReference)(object)val));
				if (val2 == null)
				{
					if (RelinkMap.ContainsKey(((MemberReference)val).FullName))
					{
						return null;
					}
					throw new RelinkTargetNotFoundException(mtp, (IMetadataTokenProvider)(object)context);
				}
				return (IMetadataTokenProvider)(object)Module.ImportReference(val2);
			}
			if (mtp is FieldReference || mtp is MethodReference || mtp is PropertyReference || mtp is EventReference)
			{
				return Extensions.ImportReference(Module, mtp);
			}
			throw new InvalidOperationException($"MonoMod default relinker can't handle metadata token providers of the type {((object)mtp).GetType()}");
		}

		public virtual IMetadataTokenProvider PostRelinker(IMetadataTokenProvider mtp, IGenericParameterProvider context)
		{
			return ResolveRelinkTarget(mtp) ?? mtp;
		}

		public virtual IMetadataTokenProvider ResolveRelinkTarget(IMetadataTokenProvider mtp, bool relink = true, bool relinkModule = true)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Expected O, but got Unknown
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Expected O, but got Unknown
			//IL_023c: Expected O, but got Unknown
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Expected O, but got Unknown
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			string text = null;
			string text2;
			if (mtp is TypeReference)
			{
				text2 = ((MemberReference)(TypeReference)mtp).FullName;
			}
			else if (mtp is MethodReference)
			{
				text2 = Extensions.GetID((MethodReference)mtp, (string)null, (string)null, true, false);
				text = Extensions.GetID((MethodReference)mtp, (string)null, (string)null, true, true);
			}
			else if (mtp is FieldReference)
			{
				text2 = ((MemberReference)(FieldReference)mtp).FullName;
			}
			else
			{
				if (!(mtp is PropertyReference))
				{
					return null;
				}
				text2 = ((MemberReference)(PropertyReference)mtp).FullName;
			}
			if (RelinkMapCache.TryGetValue(text2, out var value))
			{
				return value;
			}
			if (relink && (RelinkMap.TryGetValue(text2, out var value2) || (text != null && RelinkMap.TryGetValue(text, out value2))))
			{
				if (value2 is IMetadataTokenProvider)
				{
					return RelinkMapCache[text2] = Extensions.ImportReference(Module, (IMetadataTokenProvider)value2);
				}
				if (value2 is RelinkMapEntry)
				{
					string type = ((RelinkMapEntry)value2).Type;
					string findableID = ((RelinkMapEntry)value2).FindableID;
					TypeReference obj = FindTypeDeep(type);
					TypeDefinition val2 = ((obj != null) ? Extensions.SafeResolve(obj) : null);
					if (val2 == null)
					{
						return RelinkMapCache[text2] = ResolveRelinkTarget(mtp, relink: false, relinkModule);
					}
					value2 = Extensions.FindMethod(val2, findableID, true) ?? ((object)Extensions.FindField(val2, findableID)) ?? ((object)(Extensions.FindProperty(val2, findableID) ?? null));
					if (value2 == null)
					{
						if (Strict)
						{
							throw new RelinkTargetNotFoundException(string.Format("{0} ({1}, {2}) (remap: {3})", "MonoMod relinker failed finding", type, findableID, mtp), mtp, (IMetadataTokenProvider)null);
						}
						return null;
					}
					return RelinkMapCache[text2] = Extensions.ImportReference(Module, (IMetadataTokenProvider)value2);
				}
				if (value2 is string && mtp is TypeReference)
				{
					IMetadataTokenProvider val5 = (IMetadataTokenProvider)(object)FindTypeDeep((string)value2);
					if (val5 == null)
					{
						if (Strict)
						{
							throw new RelinkTargetNotFoundException(string.Format("{0} {1} (remap: {2})", "MonoMod relinker failed finding", value2, mtp), mtp, (IMetadataTokenProvider)null);
						}
						return null;
					}
					value2 = Extensions.ImportReference(Module, ResolveRelinkTarget(val5, relink: false, relinkModule) ?? val5);
				}
				if (value2 is IMetadataTokenProvider)
				{
					Dictionary<string, IMetadataTokenProvider> relinkMapCache = RelinkMapCache;
					string key = text2;
					IMetadataTokenProvider val6 = (IMetadataTokenProvider)value2;
					IMetadataTokenProvider result = val6;
					relinkMapCache[key] = val6;
					return result;
				}
				throw new InvalidOperationException($"MonoMod doesn't support RelinkMap value of type {value2.GetType()} (remap: {mtp})");
			}
			if (relinkModule && mtp is TypeReference)
			{
				if (RelinkModuleMapCache.TryGetValue(text2, out var value3))
				{
					return (IMetadataTokenProvider)(object)value3;
				}
				value3 = (TypeReference)mtp;
				if (RelinkModuleMap.TryGetValue(value3.Scope.Name, out var value4))
				{
					TypeReference type2 = (TypeReference)(object)value4.GetType(((MemberReference)value3).FullName);
					if (type2 == null)
					{
						if (Strict)
						{
							throw new RelinkTargetNotFoundException(string.Format("{0} {1} (remap: {2})", "MonoMod relinker failed finding", ((MemberReference)value3).FullName, mtp), mtp, (IMetadataTokenProvider)null);
						}
						return null;
					}
					return (IMetadataTokenProvider)(object)(RelinkModuleMapCache[text2] = Module.ImportReference(type2));
				}
				return (IMetadataTokenProvider)(object)Module.ImportReference(value3);
			}
			return null;
		}

		public virtual bool DefaultParser(MonoModder mod, MethodBody body, Instruction instr, ref int instri)
		{
			return true;
		}

		public virtual TypeReference FindType(string name)
		{
			return FindType(Module, name, new Stack<ModuleDefinition>()) ?? Module.GetType(name, false);
		}

		public virtual TypeReference FindType(string name, bool runtimeName)
		{
			return FindType(Module, name, new Stack<ModuleDefinition>()) ?? Module.GetType(name, runtimeName);
		}

		protected virtual TypeReference FindType(ModuleDefinition main, string fullName, Stack<ModuleDefinition> crawled)
		{
			TypeReference type;
			if ((type = main.GetType(fullName, false)) != null)
			{
				return type;
			}
			if (fullName.StartsWith("<PrivateImplementationDetails>/"))
			{
				return null;
			}
			if (crawled.Contains(main))
			{
				return null;
			}
			crawled.Push(main);
			foreach (ModuleDefinition item in DependencyMap[main])
			{
				if ((!RemovePatchReferences || !((AssemblyNameReference)item.Assembly.Name).Name.EndsWith(".mm")) && (type = FindType(item, fullName, crawled)) != null)
				{
					return type;
				}
			}
			return null;
		}

		public virtual TypeReference FindTypeDeep(string name)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			TypeReference val = FindType(name, runtimeName: false);
			if (val != null)
			{
				return val;
			}
			Stack<ModuleDefinition> crawled = new Stack<ModuleDefinition>();
			val = null;
			foreach (ModuleDefinition mod in Mods)
			{
				ModuleDefinition key = mod;
				foreach (ModuleDefinition item in DependencyMap[key])
				{
					if ((val = FindType(item, name, crawled)) != null)
					{
						IMetadataScope scope = val.Scope;
						AssemblyNameReference dllRef = (AssemblyNameReference)(object)((scope is AssemblyNameReference) ? scope : null);
						if (dllRef != null && !((IEnumerable<AssemblyNameReference>)Module.AssemblyReferences).Any((AssemblyNameReference n) => n.Name == dllRef.Name))
						{
							Module.AssemblyReferences.Add(dllRef);
						}
						return Module.ImportReference(val);
					}
				}
			}
			return null;
		}

		public virtual void PrePatchModule(ModuleDefinition mod)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Expected O, but got Unknown
			Enumerator<TypeDefinition> enumerator = mod.Types.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					TypeDefinition current = enumerator.Current;
					PrePatchType(current);
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			Enumerator<ModuleReference> enumerator2 = mod.ModuleReferences.GetEnumerator();
			try
			{
				while (enumerator2.MoveNext())
				{
					ModuleReference current2 = enumerator2.Current;
					if (!Module.ModuleReferences.Contains(current2))
					{
						Module.ModuleReferences.Add(current2);
					}
				}
			}
			finally
			{
				((IDisposable)enumerator2).Dispose();
			}
			Enumerator<Resource> enumerator3 = mod.Resources.GetEnumerator();
			try
			{
				while (enumerator3.MoveNext())
				{
					Resource current3 = enumerator3.Current;
					if (current3 is EmbeddedResource)
					{
						Module.Resources.Add((Resource)new EmbeddedResource(current3.Name.StartsWith(((AssemblyNameReference)mod.Assembly.Name).Name) ? (((AssemblyNameReference)Module.Assembly.Name).Name + current3.Name.Substring(((AssemblyNameReference)mod.Assembly.Name).Name.Length)) : current3.Name, current3.Attributes, ((EmbeddedResource)current3).GetResourceData()));
					}
				}
			}
			finally
			{
				((IDisposable)enumerator3).Dispose();
			}
		}

		public virtual void PrePatchType(TypeDefinition type, bool forceAdd = false)
		{
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Expected O, but got Unknown
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Expected O, but got Unknown
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Expected O, but got Unknown
			string patchFullName = Extensions.GetPatchFullName((MemberReference)(object)type);
			if ((((TypeReference)type).Namespace != "MonoMod" && Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModIgnore")) || SkipList.Contains(patchFullName) || !MatchingConditionals((ICustomAttributeProvider)(object)type, Module) || (((MemberReference)type).FullName == "MonoMod.MonoModRules" && !forceAdd))
			{
				return;
			}
			TypeReference val = (forceAdd ? null : Module.GetType(patchFullName, false));
			TypeDefinition val2 = ((val != null) ? Extensions.SafeResolve(val) : null);
			if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModReplace") || Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModRemove"))
			{
				if (val2 != null)
				{
					if (val2.DeclaringType == null)
					{
						Module.Types.Remove(val2);
					}
					else
					{
						val2.DeclaringType.NestedTypes.Remove(val2);
					}
				}
				if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModRemove"))
				{
					return;
				}
			}
			else if (val != null)
			{
				PrePatchNested(type);
				return;
			}
			LogVerbose("[PrePatchType] Adding " + patchFullName + " to the target module.");
			TypeDefinition val3 = new TypeDefinition(((TypeReference)type).Namespace, ((MemberReference)type).Name, type.Attributes, type.BaseType);
			Enumerator<GenericParameter> enumerator = ((TypeReference)type).GenericParameters.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					GenericParameter current = enumerator.Current;
					((TypeReference)val3).GenericParameters.Add(Extensions.Clone(current));
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			Enumerator<InterfaceImplementation> enumerator2 = type.Interfaces.GetEnumerator();
			try
			{
				while (enumerator2.MoveNext())
				{
					InterfaceImplementation current2 = enumerator2.Current;
					val3.Interfaces.Add(current2);
				}
			}
			finally
			{
				((IDisposable)enumerator2).Dispose();
			}
			val3.ClassSize = type.ClassSize;
			if (type.DeclaringType != null)
			{
				val3.DeclaringType = Extensions.Relink((TypeReference)(object)type.DeclaringType, new Relinker(Relinker), (IGenericParameterProvider)(object)val3).Resolve();
				val3.DeclaringType.NestedTypes.Add(val3);
			}
			else
			{
				Module.Types.Add(val3);
			}
			val3.PackingSize = type.PackingSize;
			Extensions.AddRange<SecurityDeclaration>(val3.SecurityDeclarations, (IEnumerable<SecurityDeclaration>)type.SecurityDeclarations);
			val3.CustomAttributes.Add(new CustomAttribute(GetMonoModAddedCtor()));
			val = (TypeReference)(object)val3;
			PrePatchNested(type);
		}

		protected virtual void PrePatchNested(TypeDefinition type)
		{
			for (int i = 0; i < type.NestedTypes.Count; i++)
			{
				PrePatchType(type.NestedTypes[i]);
			}
		}

		public virtual void PatchModule(ModuleDefinition mod)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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)
			Enumerator<TypeDefinition> enumerator = mod.Types.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					TypeDefinition current = enumerator.Current;
					if ((((TypeReference)current).Namespace == "MonoMod" || ((TypeReference)current).Namespace.StartsWith("MonoMod.")) && ((MemberReference)current.BaseType).FullName == "System.Attribute")
					{
						PatchType(current);
					}
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			enumerator = mod.Types.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					TypeDefinition current2 = enumerator.Current;
					if ((!(((TypeReference)current2).Namespace == "MonoMod") && !((TypeReference)current2).Namespace.StartsWith("MonoMod.")) || !(((MemberReference)current2.BaseType).FullName == "System.Attribute"))
					{
						PatchType(current2);
					}
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
		}

		public virtual void PatchType(TypeDefinition type)
		{
			//IL_0078: 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_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: 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_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			string patchFullName = Extensions.GetPatchFullName((MemberReference)(object)type);
			TypeReference type2 = Module.GetType(patchFullName, false);
			if (type2 == null)
			{
				return;
			}
			TypeDefinition val = ((type2 != null) ? Extensions.SafeResolve(type2) : null);
			Enumerator<CustomAttribute> enumerator;
			if ((((TypeReference)type).Namespace != "MonoMod" && Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModIgnore")) || SkipList.Contains(patchFullName) || !MatchingConditionals((ICustomAttributeProvider)(object)type, Module))
			{
				if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModIgnore") && val != null)
				{
					enumerator = type.CustomAttributes.GetEnumerator();
					try
					{
						while (enumerator.MoveNext())
						{
							CustomAttribute current = enumerator.Current;
							if (CustomAttributeHandlers.ContainsKey(((MemberReference)current.AttributeType).FullName))
							{
								val.CustomAttributes.Add(Extensions.Clone(current));
							}
						}
					}
					finally
					{
						((IDisposable)enumerator).Dispose();
					}
				}
				PatchNested(type);
				return;
			}
			if (patchFullName == ((MemberReference)type).FullName)
			{
				LogVerbose("[PatchType] Patching type " + patchFullName);
			}
			else
			{
				LogVerbose("[PatchType] Patching type " + patchFullName + " (prefixed: " + ((MemberReference)type).FullName + ")");
			}
			enumerator = type.CustomAttributes.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					CustomAttribute current2 = enumerator.Current;
					if (!Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)val, ((MemberReference)current2.AttributeType).FullName))
					{
						val.CustomAttributes.Add(Extensions.Clone(current2));
					}
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			HashSet<MethodDefinition> hashSet = new HashSet<MethodDefinition>();
			Enumerator<PropertyDefinition> enumerator2 = type.Properties.GetEnumerator();
			try
			{
				while (enumerator2.MoveNext())
				{
					PropertyDefinition current3 = enumerator2.Current;
					PatchProperty(val, current3, hashSet);
				}
			}
			finally
			{
				((IDisposable)enumerator2).Dispose();
			}
			HashSet<MethodDefinition> hashSet2 = new HashSet<MethodDefinition>();
			Enumerator<EventDefinition> enumerator3 = type.Events.GetEnumerator();
			try
			{
				while (enumerator3.MoveNext())
				{
					EventDefinition current4 = enumerator3.Current;
					PatchEvent(val, current4, hashSet2);
				}
			}
			finally
			{
				((IDisposable)enumerator3).Dispose();
			}
			Enumerator<MethodDefinition> enumerator4 = type.Methods.GetEnumerator();
			try
			{
				while (enumerator4.MoveNext())
				{
					MethodDefinition current5 = enumerator4.Current;
					if (!hashSet.Contains(current5) && !hashSet2.Contains(current5))
					{
						PatchMethod(val, current5);
					}
				}
			}
			finally
			{
				((IDisposable)enumerator4).Dispose();
			}
			if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModEnumReplace"))
			{
				int num = 0;
				while (num < val.Fields.Count)
				{
					if (((MemberReference)val.Fields[num]).Name == "value__")
					{
						num++;
					}
					else
					{
						val.Fields.RemoveAt(num);
					}
				}
			}
			Enumerator<FieldDefinition> enumerator5 = type.Fields.GetEnumerator();
			try
			{
				while (enumerator5.MoveNext())
				{
					FieldDefinition current6 = enumerator5.Current;
					PatchField(val, current6);
				}
			}
			finally
			{
				((IDisposable)enumerator5).Dispose();
			}
			PatchNested(type);
		}

		protected virtual void PatchNested(TypeDefinition type)
		{
			for (int i = 0; i < type.NestedTypes.Count; i++)
			{
				PatchType(type.NestedTypes[i]);
			}
		}

		public virtual void PatchProperty(TypeDefinition targetType, PropertyDefinition prop, HashSet<MethodDefinition> propMethods = null)
		{
			//IL_006e: 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_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Expected O, but got Unknown
			//IL_022b: Expected O, but got Unknown
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Expected O, but got Unknown
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Expected O, but got Unknown
			//IL_02b5: Expected O, but got Unknown
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			if (!MatchingConditionals((ICustomAttributeProvider)(object)prop, Module))
			{
				return;
			}
			((MemberReference)prop).Name = Extensions.GetPatchName((MemberReference)(object)prop);
			PropertyDefinition val = Extensions.FindProperty(targetType, ((MemberReference)prop).Name);
			string text = "<" + ((MemberReference)prop).Name + ">__BackingField";
			FieldDefinition val2 = Extensions.FindField(prop.DeclaringType, text);
			FieldDefinition val3 = Extensions.FindField(targetType, text);
			Enumerator<CustomAttribute> enumerator;
			Enumerator<MethodDefinition> enumerator2;
			if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)prop, "MonoMod.MonoModIgnore"))
			{
				if (val != null)
				{
					enumerator = prop.CustomAttributes.GetEnumerator();
					try
					{
						while (enumerator.MoveNext())
						{
							CustomAttribute current = enumerator.Current;
							if (CustomAttributeHandlers.ContainsKey(((MemberReference)current.AttributeType).FullName))
							{
								val.CustomAttributes.Add(Extensions.Clone(current));
							}
						}
					}
					finally
					{
						((IDisposable)enumerator).Dispose();
					}
				}
				if (val2 != null)
				{
					val2.DeclaringType.Fields.Remove(val2);
				}
				if (prop.GetMethod != null)
				{
					propMethods?.Add(prop.GetMethod);
				}
				if (prop.SetMethod != null)
				{
					propMethods?.Add(prop.SetMethod);
				}
				enumerator2 = prop.OtherMethods.GetEnumerator();
				try
				{
					while (enumerator2.MoveNext())
					{
						MethodDefinition current2 = enumerator2.Current;
						propMethods?.Add(current2);
					}
					return;
				}
				finally
				{
					((IDisposable)enumerator2).Dispose();
				}
			}
			if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)prop, "MonoMod.MonoModRemove") || Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)prop, "MonoMod.MonoModReplace"))
			{
				if (val != null)
				{
					targetType.Properties.Remove(val);
					if (val3 != null)
					{
						targetType.Fields.Remove(val3);
					}
					if (val.GetMethod != null)
					{
						targetType.Methods.Remove(val.GetMethod);
					}
					if (val.SetMethod != null)
					{
						targetType.Methods.Remove(val.SetMethod);
					}
					enumerator2 = val.OtherMethods.GetEnumerator();
					try
					{
						while (enumerator2.MoveNext())
						{
							MethodDefinition current3 = enumerator2.Current;
							targetType.Methods.Remove(current3);
						}
					}
					finally
					{
						((IDisposable)enumerator2).Dispose();
					}
				}
				if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)prop, "MonoMod.MonoModRemove"))
				{
					return;
				}
			}
			if (val == null)
			{
				PropertyDefinition val4 = new PropertyDefinition(((MemberReference)prop).Name, prop.Attributes, ((PropertyReference)prop).PropertyType);
				val = val4;
				PropertyDefinition val5 = val4;
				val5.CustomAttributes.Add(new CustomAttribute(GetMonoModAddedCtor()));
				Enumerator<ParameterDefinition> enumerator3 = ((PropertyReference)prop).Parameters.GetEnumerator();
				try
				{
					while (enumerator3.MoveNext())
					{
						ParameterDefinition current4 = enumerator3.Current;
						((PropertyReference)val5).Parameters.Add(Extensions.Clone(current4));
					}
				}
				finally
				{
					((IDisposable)enumerator3).Dispose();
				}
				val5.DeclaringType = targetType;
				targetType.Properties.Add(val5);
				if (val2 != null)
				{
					FieldDefinition val6 = new FieldDefinition(text, val2.Attributes, ((FieldReference)val2).FieldType);
					val3 = val6;
					FieldDefinition val7 = val6;
					targetType.Fields.Add(val7);
				}
			}
			enumerator = prop.CustomAttributes.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					CustomAttribute current5 = enumerator.Current;
					val.CustomAttributes.Add(Extensions.Clone(current5));
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			MethodDefinition getMethod = prop.GetMethod;
			MethodDefinition getMethod2;
			if (getMethod != null && (getMethod2 = PatchMethod(targetType, getMethod)) != null)
			{
				val.GetMethod = getMethod2;
				propMethods?.Add(getMethod);
			}
			MethodDefinition setMethod = prop.SetMethod;
			if (setMethod != null && (getMethod2 = PatchMethod(targetType, setMethod)) != null)
			{
				val.SetMethod = getMethod2;
				propMethods?.Add(setMethod);
			}
			enumerator2 = prop.OtherMethods.GetEnumerator();
			try
			{
				while (enumerator2.MoveNext())
				{
					MethodDefinition current6 = enumerator2.Current;
					if ((getMethod2 = PatchMethod(targetType, current6)) != null)
					{
						val.OtherMethods.Add(getMethod2);
						propMethods?.Add(current6);
					}
				}
			}
			finally
			{
				((IDisposable)enumerator2).Dispose();
			}
		}

		public virtual void PatchEvent(TypeDefinition targetType, EventDefinition srcEvent, HashSet<MethodDefinition> propMethods = null)
		{
			//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_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Expected O, but got Unknown
			//IL_0252: Expected O, but got Unknown
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Expected O, but got Unknown
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Expected O, but got Unknown
			//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_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			((MemberReference)srcEvent).Name = Extensions.GetPatchName((MemberReference)(object)srcEvent);
			EventDefinition val = Extensions.FindEvent(targetType, ((MemberReference)srcEvent).Name);
			string text = "<" + ((MemberReference)srcEvent).Name + ">__BackingField";
			FieldDefinition val2 = Extensions.FindField(srcEvent.DeclaringType, text);
			FieldDefinition val3 = Extensions.FindField(targetType, text);
			Enumerator<CustomAttribute> enumerator;
			Enumerator<MethodDefinition> enumerator2;
			if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)srcEvent, "MonoMod.MonoModIgnore"))
			{
				if (val != null)
				{
					enumerator = srcEvent.CustomAttributes.GetEnumerator();
					try
					{
						while (enumerator.MoveNext())
						{
							CustomAttribute current = enumerator.Current;
							if (CustomAttributeHandlers.ContainsKey(((MemberReference)current.AttributeType).FullName))
							{
								val.CustomAttributes.Add(Extensions.Clone(current));
							}
						}
					}
					finally
					{
						((IDisposable)enumerator).Dispose();
					}
				}
				if (val2 != null)
				{
					val2.DeclaringType.Fields.Remove(val2);
				}
				if (srcEvent.AddMethod != null)
				{
					propMethods?.Add(srcEvent.AddMethod);
				}
				if (srcEvent.RemoveMethod != null)
				{
					propMethods?.Add(srcEvent.RemoveMethod);
				}
				if (srcEvent.InvokeMethod != null)
				{
					propMethods?.Add(srcEvent.InvokeMethod);
				}
				enumerator2 = srcEvent.OtherMethods.GetEnumerator();
				try
				{
					while (enumerator2.MoveNext())
					{
						MethodDefinition current2 = enumerator2.Current;
						propMethods?.Add(current2);
					}
					return;
				}
				finally
				{
					((IDisposable)enumerator2).Dispose();
				}
			}
			if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)srcEvent, "MonoMod.MonoModRemove") || Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)srcEvent, "MonoMod.MonoModReplace"))
			{
				if (val != null)
				{
					targetType.Events.Remove(val);
					if (val3 != null)
					{
						targetType.Fields.Remove(val3);
					}
					if (val.AddMethod != null)
					{
						targetType.Methods.Remove(val.AddMethod);
					}
					if (val.RemoveMethod != null)
					{
						targetType.Methods.Remove(val.RemoveMethod);
					}
					if (val.InvokeMethod != null)
					{
						targetType.Methods.Remove(val.InvokeMethod);
					}
					if (val.OtherMethods != null)
					{
						enumerator2 = val.OtherMethods.GetEnumerator();
						try
						{
							while (enumerator2.MoveNext())
							{
								MethodDefinition current3 = enumerator2.Current;
								targetType.Methods.Remove(current3);
							}
						}
						finally
						{
							((IDisposable)enumerator2).Dispose();
						}
					}
				}
				if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)srcEvent, "MonoMod.MonoModRemove"))
				{
					return;
				}
			}
			if (val == null)
			{
				EventDefinition val4 = new EventDefinition(((MemberReference)srcEvent).Name, srcEvent.Attributes, ((EventReference)srcEvent).EventType);
				val = val4;
				EventDefinition val5 = val4;
				val5.CustomAttributes.Add(new CustomAttribute(GetMonoModAddedCtor()));
				val5.DeclaringType = targetType;
				targetType.Events.Add(val5);
				if (val2 != null)
				{
					FieldDefinition val6 = new FieldDefinition(text, val2.Attributes, ((FieldReference)val2).FieldType);
					targetType.Fields.Add(val6);
				}
			}
			enumerator = srcEvent.CustomAttributes.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					CustomAttribute current4 = enumerator.Current;
					val.CustomAttributes.Add(Extensions.Clone(current4));
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			MethodDefinition addMethod = srcEvent.AddMethod;
			MethodDefinition addMethod2;
			if (addMethod != null && (addMethod2 = PatchMethod(targetType, addMethod)) != null)
			{
				val.AddMethod = addMethod2;
				propMethods?.Add(addMethod);
			}
			MethodDefinition removeMethod = srcEvent.RemoveMethod;
			if (removeMethod != null && (addMethod2 = PatchMethod(targetType, removeMethod)) != null)
			{
				val.RemoveMethod = addMethod2;
				propMethods?.Add(removeMethod);
			}
			MethodDefinition invokeMethod = srcEvent.InvokeMethod;
			if (invokeMethod != null && (addMethod2 = PatchMethod(targetType, invokeMethod)) != null)
			{
				val.InvokeMethod = addMethod2;
				propMethods?.Add(invokeMethod);
			}
			enumerator2 = srcEvent.OtherMethods.GetEnumerator();
			try
			{
				while (enumerator2.MoveNext())
				{
					MethodDefinition current5 = enumerator2.Current;
					if ((addMethod2 = PatchMethod(targetType, current5)) != null)
					{
						val.OtherMethods.Add(addMethod2);
						propMethods?.Add(current5);
					}
				}
			}
			finally
			{
				((IDisposable)enumerator2).Dispose();
			}
		}

		public virtual void PatchField(TypeDefinition targetType, FieldDefinition field)
		{
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: 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)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Expected O, but got Unknown
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			string patchFullName = Extensions.GetPatchFullName((MemberReference)(object)field.DeclaringType);
			if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)field, "MonoMod.MonoModNoNew") || SkipList.Contains(patchFullName + "::" + ((MemberReference)field).Name) || !MatchingConditionals((ICustomAttributeProvider)(object)field, Module))
			{
				return;
			}
			((MemberReference)field).Name = Extensions.GetPatchName((MemberReference)(object)field);
			if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)field, "MonoMod.MonoModRemove") || Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)field, "MonoMod.MonoModReplace"))
			{
				FieldDefinition val = Extensions.FindField(targetType, ((MemberReference)field).Name);
				if (val != null)
				{
					targetType.Fields.Remove(val);
				}
				if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)field, "MonoMod.MonoModRemove"))
				{
					return;
				}
			}
			FieldDefinition val2 = Extensions.FindField(targetType, ((MemberReference)field).Name);
			Enumerator<CustomAttribute> enumerator;
			if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)field, "MonoMod.MonoModIgnore") && val2 != null)
			{
				enumerator = field.CustomAttributes.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						CustomAttribute current = enumerator.Current;
						if (CustomAttributeHandlers.ContainsKey(((MemberReference)current.AttributeType).FullName))
						{
							val2.CustomAttributes.Add(Extensions.Clone(current));
						}
					}
					return;
				}
				finally
				{
					((IDisposable)enumerator).Dispose();
				}
			}
			if (val2 == null)
			{
				val2 = new FieldDefinition(((MemberReference)field).Name, field.Attributes, ((FieldReference)field).FieldType);
				val2.CustomAttributes.Add(new CustomAttribute(GetMonoModAddedCtor()));
				val2.InitialValue = field.InitialValue;
				if (field.HasConstant)
				{
					val2.Constant = field.Constant;
				}
				targetType.Fields.Add(val2);
			}
			enumerator = field.CustomAttributes.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					CustomAttribute current2 = enumerator.Current;
					val2.CustomAttributes.Add(Extensions.Clone(current2));
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
		}

		public virtual MethodDefinition PatchMethod(TypeDefinition targetType, MethodDefinition method)
		{
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_049f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bb: Expected O, but got Unknown
			//IL_04c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0504: Unknown result type (might be due to invalid IL or missing references)
			//IL_0511: Unknown result type (might be due to invalid IL or missing references)
			//IL_0564: Unknown result type (might be due to invalid IL or missing references)
			//IL_0569: Unknown result type (might be due to invalid IL or missing references)
			//IL_0453: Unknown result type (might be due to invalid IL or missing references)
			//IL_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Expected O, but got Unknown
			//IL_05a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_069a: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a1: Expected O, but got Unknown
			//IL_06be: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0630: Unknown result type (might be due to invalid IL or missing references)
			//IL_0635: Unknown result type (might be due to invalid IL or missing references)
			//IL_0676: Unknown result type (might be due to invalid IL or missing references)
			//IL_0680: Expected O, but got Unknown
			if (((MemberReference)method).Name.StartsWith("orig_") || Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)method, "MonoMod.MonoModOriginal"))
			{
				return null;
			}
			if (!AllowedSpecialName(method, targetType) || !MatchingConditionals((ICustomAttributeProvider)(object)method, Module))
			{
				return null;
			}
			string patchFullName = Extensions.GetPatchFullName((MemberReference)(object)targetType);
			if (SkipList.Contains(Extensions.GetID((MethodReference)(object)method, (string)null, patchFullName, true, false)))
			{
				return null;
			}
			((MemberReference)method).Name = Extensions.GetPatchName((MemberReference)(object)method);
			if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)method, "MonoMod.MonoModConstructor"))
			{
				if (!method.IsSpecialName && !Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)method, "MonoMod.MonoModOriginalName"))
				{
					CustomAttribute val = new CustomAttribute(GetMonoModOriginalNameCtor());
					val.ConstructorArguments.Add(new CustomAttributeArgument(Module.TypeSystem.String, (object)("orig_" + ((MemberReference)method).Name)));
					method.CustomAttributes.Add(val);
				}
				((MemberReference)method).Name = (method.IsStatic ? ".cctor" : ".ctor");
				method.IsSpecialName = true;
				method.IsRuntimeSpecialName = true;
			}
			MethodDefinition val2 = Extensions.FindMethod(targetType, Extensions.GetID((MethodReference)(object)method, (string)null, patchFullName, true, false), true);
			MethodDefinition obj = method;
			string text = patchFullName;
			MethodDefinition val3 = Extensions.FindMethod(targetType, Extensions.GetID((MethodReference)(object)obj, method.GetOriginalName(), text, true, false), true);
			if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)method, "MonoMod.MonoModIgnore"))
			{
				if (val2 != null)
				{
					Enumerator<CustomAttribute> enumerator = method.CustomAttributes.GetEnumerator();
					try
					{
						while (enumerator.MoveNext())
						{
							CustomAttribute current = enumerator.Current;
							if (CustomAttributeHandlers.ContainsKey(((MemberReference)current.AttributeType).FullName) || CustomMethodAttributeHandlers.ContainsKey(((MemberReference)current.AttributeType).FullName))
							{
								val2.CustomAttributes.Add(Extensions.Clone(current));
							}
						}
					}
					finally
					{
						((IDisposable)enumerator).Dispose();
					}
				}
				return null;
			}
			if (val2 == null && Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)method, "MonoMod.MonoModNoNew"))
			{
				return null;
			}
			if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)method, "MonoMod.MonoModRemove"))
			{
				if (val2 != null)
				{
					targetType.Methods.Remove(val2);
				}
				return null;
			}
			if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)method, "MonoMod.MonoModReplace"))
			{
				if (val2 != null)
				{
					val2.CustomAttributes.Clear();
					val2.Attributes = method.Attributes;
					val2.IsPInvokeImpl = method.IsPInvokeImpl;
					val2.ImplAttributes = method.ImplAttributes;
				}
			}
			else if (val2 != null && val3 == null)
			{
				val3 = Extensions.Clone(val2, (MethodDefinition)null);
				((MemberReference)val3).Name = method.GetOriginalName();
				val3.Attributes = (MethodAttributes)(val2.Attributes & 0xF7FF & 0xEFFF);
				((MemberReference)val3).MetadataToken = GetMetadataToken((TokenType)100663296);
				val3.IsVirtual = false;
				val3.Overrides.Clear();
				Enumerator<MethodReference> enumerator2 = method.Overrides.GetEnumerator();
				try
				{
					while (enumerator2.MoveNext())
					{
						MethodReference current2 = enumerator2.Current;
						val3.Overrides.Add(current2);
					}
				}
				finally
				{
					((IDisposable)enumerator2).Dispose();
				}
				val3.CustomAttributes.Add(new CustomAttribute(GetMonoModOriginalCtor()));
				MethodDefinition val4 = Extensions.FindMethod(method.DeclaringType, Extensions.GetID((MethodReference)(object)method, method.GetOriginalName(), (string)null, true, false), true);
				if (val4 != null)
				{
					Enumerator<CustomAttribute> enumerator = val4.CustomAttributes.GetEnumerator();
					try
					{
						while (enumerator.MoveNext())
						{
							CustomAttribute current3 = enumerator.Current;
							if (CustomAttributeHandlers.ContainsKey(((MemberReference)current3.AttributeType).FullName) || CustomMethodAttributeHandlers.ContainsKey(((MemberReference)current3.AttributeType).FullName))
							{
								val3.CustomAttributes.Add(Extensions.Clone(current3));
							}
						}
					}
					finally
					{
						((IDisposable)enumerator).Dispose();
					}
				}
				targetType.Methods.Add(val3);
			}
			if (val3 != null && method.IsConstructor && method.IsStatic && method.HasBody && !Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)method, "MonoMod.MonoModConstructor"))
			{
				Collection<Instruction> instructions = method.Body.Instructions;
				ILProcessor iLProcessor = method.Body.GetILProcessor();
				iLProcessor.InsertBefore(instructions[instructions.Count - 1], iLProcessor.Create(OpCodes.Call, (MethodReference)(object)val3));
			}
			if (val2 != null)
			{
				val2.Body = Extensions.Clone(method.Body, val2);
				val2.IsManaged = method.IsManaged;
				val2.IsIL = method.IsIL;
				val2.IsNative = method.IsNative;
				val2.PInvokeInfo = method.PInvokeInfo;
				val2.IsPreserveSig = method.IsPreserveSig;
				val2.IsInternalCall = method.IsInternalCall;
				val2.IsPInvokeImpl = method.IsPInvokeImpl;
				Enumerator<CustomAttribute> enumerator = method.CustomAttributes.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						CustomAttribute current4 = enumerator.Current;
						val2.CustomAttributes.Add(Extensions.Clone(current4));
					}
				}
				finally
				{
					((IDisposable)enumerator).Dispose();
				}
				method = val2;
			}
			else
			{
				MethodDefinition val5 = new MethodDefinition(((MemberReference)method).Name, method.Attributes, Module.TypeSystem.Void);
				((MemberReference)val5).MetadataToken = GetMetadataToken((TokenType)100663296);
				((MethodReference)val5).CallingConvention = ((MethodReference)method).CallingConvention;
				((MethodReference)val5).ExplicitThis = ((MethodReference)method).ExplicitThis;
				((MethodReference)val5).MethodReturnType = ((MethodReference)method).MethodReturnType;
				val5.Attributes = method.Attributes;
				val5.ImplAttributes = method.ImplAttributes;
				val5.SemanticsAttributes = method.SemanticsAttributes;
				val5.DeclaringType = targetType;
				((MethodReference)val5).ReturnType = ((MethodReference)method).ReturnType;
				val5.Body = Extensions.Clone(method.Body, val5);
				val5.PInvokeInfo = method.PInvokeInfo;
				val5.IsPInvokeImpl = method.IsPInvokeImpl;
				Enumerator<GenericParameter> enumerator3 = ((MethodReference)method).GenericParameters.GetEnumerator();
				try
				{
					while (enumerator3.MoveNext())
					{
						GenericParameter current5 = enumerator3.Current;
						((MethodReference)val5).GenericParameters.Add(Extensions.Clone(current5));
					}
				}
				finally
				{
					((IDisposable)enumerator3).Dispose();
				}
				Enumerator<ParameterDefinition> enumerator4 = ((MethodReference)method).Parameters.GetEnumerator();
				try
				{
					while (enumerator4.MoveNext())
					{
						ParameterDefinition current6 = enumerator4.Current;
						((MethodReference)val5).Parameters.Add(Extensions.Clone(current6));
					}
				}
				finally
				{
					((IDisposable)enumerator4).Dispose();
				}
				Enumerator<CustomAttribute> enumerator = method.CustomAttributes.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						CustomAttribute current7 = enumerator.Current;
						val5.CustomAttributes.Add(Extensions.Clone(current7));
					}
				}
				finally
				{
					((IDisposable)enumerator).Dispose();
				}
				Enumerator<MethodReference> enumerator2 = method.Overrides.GetEnumerator();
				try
				{
					while (enumerator2.MoveNext())
					{
						MethodReference current8 = enumerator2.Current;
						val5.Overrides.Add(current8);
					}
				}
				finally
				{
					((IDisposable)enumerator2).Dispose();
				}
				val5.CustomAttributes.Add(new CustomAttribute(GetMonoModAddedCtor()));
				targetType.Methods.Add(val5);
				method = val5;
			}
			if (val3 != null)
			{
				CustomAttribute val6 = new CustomAttribute(GetMonoModOriginalNameCtor());
				val6.ConstructorArguments.Add(new CustomAttributeArgument(Module.TypeSystem.String, (object)((MemberReference)val3).Name));
				method.CustomAttributes.Add(val6);
			}
			return method;
		}

		public virtual void PatchRefs()
		{
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			if (!UpgradeMSCORLIB.HasValue)
			{
				Version fckUnity = new Version(2, 0, 5, 0);
				UpgradeMSCORLIB = ((IEnumerable<AssemblyNameReference>)Module.AssemblyReferences).Any((AssemblyNameReference x) => x.Version == fckUnity);
			}
			if (UpgradeMSCORLIB.Value)
			{
				List<AssemblyNameReference> list = new List<AssemblyNameReference>();
				for (int i = 0; i < Module.AssemblyReferences.Count; i++)
				{
					AssemblyNameReference val = Module.AssemblyReferences[i];
					if (val.Name == "mscorlib")
					{
						list.Add(val);
					}
				}
				if (list.Count > 1)
				{
					AssemblyNameReference val2 = list.OrderByDescending((AssemblyNameReference x) => x.Version).First();
					if (DependencyCache.TryGetValue(val2.FullName, out var value))
					{
						for (int j = 0; j < Module.AssemblyReferences.Count; j++)
						{
							AssemblyNameReference val3 = Module.AssemblyReferences[j];
							if (val3.Name == "mscorlib" && val2.Version > val3.Version)
							{
								LogVerbose("[PatchRefs] Removing and relinking duplicate mscorlib: " + val3.Version);
								RelinkModuleMap[val3.FullName] = value;
								Module.AssemblyReferences.RemoveAt(j);
								j--;
							}
						}
					}
				}
			}
			Enumerator<TypeDefinition> enumerator = Module.Types.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					TypeDefinition current = enumerator.Current;
					PatchRefsInType(current);
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
		}

		public virtual void PatchRefs(ModuleDefinition mod)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Enumerator<TypeDefinition> enumerator = mod.Types.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					TypeDefinition current = enumerator.Current;
					PatchRefsInType(current);
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
		}

		public virtual void PatchRefsInType(TypeDefinition type)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//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_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Expected O, but got Unknown
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Expected O, but got Unknown
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Expected O, but got Unknown
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Expected O, but got Unknown
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Expected O, but got Unknown
			//IL_02a1: 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_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Expected O, but got Unknown
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Expected O, but got Unknown
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Expected O, but got Unknown
			LogVerbose($"[VERBOSE] [PatchRefsInType] Patching refs in {type}");
			if (type.BaseType != null)
			{
				type.BaseType = Extensions.Relink(type.BaseType, new Relinker(Relinker), (IGenericParameterProvider)(object)type);
			}
			for (int i = 0; i < ((TypeReference)type).GenericParameters.Count; i++)
			{
				((TypeReference)type).GenericParameters[i] = Extensions.Relink(((TypeReference)type).GenericParameters[i], new Relinker(Relinker), (IGenericParameterProvider)(object)type);
			}
			for (int j = 0; j < type.Interfaces.Count; j++)
			{
				InterfaceImplementation obj = type.Interfaces[j];
				InterfaceImplementation val = new InterfaceImplementation(Extensions.Relink(obj.InterfaceType, new Relinker(Relinker), (IGenericParameterProvider)(object)type));
				Enumerator<CustomAttribute> enumerator = obj.CustomAttributes.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						CustomAttribute current = enumerator.Current;
						val.CustomAttributes.Add(Extensions.Relink(current, new Relinker(Relinker), (IGenericParameterProvider)(object)type));
					}
				}
				finally
				{
					((IDisposable)enumerator).Dispose();
				}
				type.Interfaces[j] = val;
			}
			for (int k = 0; k < type.CustomAttributes.Count; k++)
			{
				type.CustomAttributes[k] = Extensions.Relink(type.CustomAttributes[k], new Relinker(Relinker), (IGenericParameterProvider)(object)type);
			}
			Enumerator<PropertyDefinition> enumerator2 = type.Properties.GetEnumerator();
			try
			{
				while (enumerator2.MoveNext())
				{
					PropertyDefinition current2 = enumerator2.Current;
					((PropertyReference)current2).PropertyType = Extensions.Relink(((PropertyReference)current2).PropertyType, new Relinker(Relinker), (IGenericParameterProvider)(object)type);
					for (int l = 0; l < current2.CustomAttributes.Count; l++)
					{
						current2.CustomAttributes[l] = Extensions.Relink(current2.CustomAttributes[l], new Relinker(Relinker), (IGenericParameterProvider)(object)type);
					}
				}
			}
			finally
			{
				((IDisposable)enumerator2).Dispose();
			}
			Enumerator<EventDefinition> enumerator3 = type.Events.GetEnumerator();
			try
			{
				while (enumerator3.MoveNext())
				{
					EventDefinition current3 = enumerator3.Current;
					((EventReference)current3).EventType = Extensions.Relink(((EventReference)current3).EventType, new Relinker(Relinker), (IGenericParameterProvider)(object)type);
					for (int m = 0; m < current3.CustomAttributes.Count; m++)
					{
						current3.CustomAttributes[m] = Extensions.Relink(current3.CustomAttributes[m], new Relinker(Relinker), (IGenericParameterProvider)(object)type);
					}
				}
			}
			finally
			{
				((IDisposable)enumerator3).Dispose();
			}
			Enumerator<MethodDefinition> enumerator4 = type.Methods.GetEnumerator();
			try
			{
				while (enumerator4.MoveNext())
				{
					MethodDefinition current4 = enumerator4.Current;
					PatchRefsInMethod(current4);
				}
			}
			finally
			{
				((IDisposable)enumerator4).Dispose();
			}
			Enumerator<FieldDefinition> enumerator5 = type.Fields.GetEnumerator();
			try
			{
				while (enumerator5.MoveNext())
				{
					FieldDefinition current5 = enumerator5.Current;
					((FieldReference)current5).FieldType = Extensions.Relink(((FieldReference)current5).FieldType, new Relinker(Relinker), (IGenericParameterProvider)(object)type);
					for (int n = 0; n < current5.CustomAttributes.Count; n++)
					{
						current5.CustomAttributes[n] = Extensions.Relink(current5.CustomAttributes[n], new Relinker(Relinker), (IGenericParameterProvider)(object)type);
					}
				}
			}
			finally
			{
				((IDisposable)enumerator5).Dispose();
			}
			for (int num = 0; num < type.NestedTypes.Count; num++)
			{
				PatchRefsInType(type.NestedTypes[num]);
			}
		}

		public virtual void PatchRefsInMethod(MethodDefinition method)
		{
			//IL_0030: Unknown result t

pachers/BepInEx.MonoMod.HookGenPatcher/MonoMod.RuntimeDetour.HookGen.dll

Decompiled 9 months ago
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Collections.Generic;
using MonoMod.Utils;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("0x0ade")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright 2021 0x0ade")]
[assembly: AssemblyDescription("Auto-generate hook helper .dlls, hook arbitrary methods via events: On.Namespace.Type.Method += YourHandlerHere;")]
[assembly: AssemblyFileVersion("21.8.5.1")]
[assembly: AssemblyInformationalVersion("21.08.05.01")]
[assembly: AssemblyProduct("MonoMod.RuntimeDetour.HookGen")]
[assembly: AssemblyTitle("MonoMod.RuntimeDetour.HookGen")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("21.8.5.1")]
[module: UnverifiableCode]
internal static class MultiTargetShims
{
	private static readonly object[] _NoArgs = new object[0];

	public static TypeReference GetConstraintType(this TypeReference type)
	{
		return type;
	}
}
namespace MonoMod
{
	internal static class MMDbgLog
	{
		public static readonly string Tag;

		public static TextWriter Writer;

		public static bool Debugging;

		static MMDbgLog()
		{
			Tag = typeof(MMDbgLog).Assembly.GetName().Name;
			if (Environment.GetEnvironmentVariable("MONOMOD_DBGLOG") == "1" || (Environment.GetEnvironmentVariable("MONOMOD_DBGLOG")?.ToLowerInvariant()?.Contains(Tag.ToLowerInvariant())).GetValueOrDefault())
			{
				Start();
			}
		}

		public static void WaitForDebugger()
		{
			if (!Debugging)
			{
				Debugging = true;
				Debugger.Launch();
				Thread.Sleep(6000);
				Debugger.Break();
			}
		}

		public static void Start()
		{
			if (Writer != null)
			{
				return;
			}
			string text = Environment.GetEnvironmentVariable("MONOMOD_DBGLOG_PATH");
			if (text == "-")
			{
				Writer = Console.Out;
				return;
			}
			if (string.IsNullOrEmpty(text))
			{
				text = "mmdbglog.txt";
			}
			text = Path.GetFullPath(Path.GetFileNameWithoutExtension(text) + "-" + Tag + Path.GetExtension(text));
			try
			{
				if (File.Exists(text))
				{
					File.Delete(text);
				}
			}
			catch
			{
			}
			try
			{
				string directoryName = Path.GetDirectoryName(text);
				if (!Directory.Exists(directoryName))
				{
					Directory.CreateDirectory(directoryName);
				}
				Writer = new StreamWriter(new FileStream(text, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite | FileShare.Delete), Encoding.UTF8);
			}
			catch
			{
			}
		}

		public static void Log(string str)
		{
			TextWriter writer = Writer;
			if (writer != null)
			{
				writer.WriteLine(str);
				writer.Flush();
			}
		}

		public static T Log<T>(string str, T value)
		{
			TextWriter writer = Writer;
			if (writer == null)
			{
				return value;
			}
			writer.WriteLine(string.Format(str, value));
			writer.Flush();
			return value;
		}
	}
}
namespace MonoMod.RuntimeDetour.HookGen
{
	public class HookGenerator
	{
		private const string ObsoleteMessageBackCompat = "This method only exists for backwards-compatibility purposes.";

		private static readonly Regex NameVerifyRegex;

		private static readonly Dictionary<Type, string> ReflTypeNameMap;

		private static readonly Dictionary<string, string> TypeNameMap;

		public MonoModder Modder;

		public ModuleDefinition OutputModule;

		public string Namespace;

		public string NamespaceIL;

		public bool HookOrig;

		public bool HookPrivate;

		public string HookExtName;

		public ModuleDefinition module_RuntimeDetour;

		public ModuleDefinition module_Utils;

		public TypeReference t_MulticastDelegate;

		public TypeReference t_IAsyncResult;

		public TypeReference t_AsyncCallback;

		public TypeReference t_MethodBase;

		public TypeReference t_RuntimeMethodHandle;

		public TypeReference t_EditorBrowsableState;

		public MethodReference m_Object_ctor;

		public MethodReference m_ObsoleteAttribute_ctor;

		public MethodReference m_EditorBrowsableAttribute_ctor;

		public MethodReference m_GetMethodFromHandle;

		public MethodReference m_Add;

		public MethodReference m_Remove;

		public MethodReference m_Modify;

		public MethodReference m_Unmodify;

		public TypeReference t_ILManipulator;

		static HookGenerator()
		{
			NameVerifyRegex = new Regex("[^a-zA-Z]");
			ReflTypeNameMap = new Dictionary<Type, string>
			{
				{
					typeof(string),
					"string"
				},
				{
					typeof(object),
					"object"
				},
				{
					typeof(bool),
					"bool"
				},
				{
					typeof(byte),
					"byte"
				},
				{
					typeof(char),
					"char"
				},
				{
					typeof(decimal),
					"decimal"
				},
				{
					typeof(double),
					"double"
				},
				{
					typeof(short),
					"short"
				},
				{
					typeof(int),
					"int"
				},
				{
					typeof(long),
					"long"
				},
				{
					typeof(sbyte),
					"sbyte"
				},
				{
					typeof(float),
					"float"
				},
				{
					typeof(ushort),
					"ushort"
				},
				{
					typeof(uint),
					"uint"
				},
				{
					typeof(ulong),
					"ulong"
				},
				{
					typeof(void),
					"void"
				}
			};
			TypeNameMap = new Dictionary<string, string>();
			foreach (KeyValuePair<Type, string> item in ReflTypeNameMap)
			{
				TypeNameMap[item.Key.FullName] = item.Value;
			}
		}

		public HookGenerator(MonoModder modder, string name)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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_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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Expected O, but got Unknown
			//IL_0326: Expected O, but got Unknown
			Modder = modder;
			OutputModule = ModuleDefinition.CreateModule(name, new ModuleParameters
			{
				Architecture = modder.Module.Architecture,
				AssemblyResolver = modder.Module.AssemblyResolver,
				Kind = (ModuleKind)0,
				Runtime = modder.Module.Runtime
			});
			modder.MapDependencies();
			Extensions.AddRange<AssemblyNameReference>(OutputModule.AssemblyReferences, (IEnumerable<AssemblyNameReference>)modder.Module.AssemblyReferences);
			modder.DependencyMap[OutputModule] = new List<ModuleDefinition>(modder.DependencyMap[modder.Module]);
			Namespace = Environment.GetEnvironmentVariable("MONOMOD_HOOKGEN_NAMESPACE");
			if (string.IsNullOrEmpty(Namespace))
			{
				Namespace = "On";
			}
			NamespaceIL = Environment.GetEnvironmentVariable("MONOMOD_HOOKGEN_NAMESPACE_IL");
			if (string.IsNullOrEmpty(NamespaceIL))
			{
				NamespaceIL = "IL";
			}
			HookOrig = Environment.GetEnvironmentVariable("MONOMOD_HOOKGEN_ORIG") == "1";
			HookPrivate = Environment.GetEnvironmentVariable("MONOMOD_HOOKGEN_PRIVATE") == "1";
			modder.MapDependency(modder.Module, "MonoMod.RuntimeDetour", (string)null, (AssemblyNameReference)null);
			if (!modder.DependencyCache.TryGetValue("MonoMod.RuntimeDetour", out module_RuntimeDetour))
			{
				throw new FileNotFoundException("MonoMod.RuntimeDetour not found!");
			}
			modder.MapDependency(modder.Module, "MonoMod.Utils", (string)null, (AssemblyNameReference)null);
			if (!modder.DependencyCache.TryGetValue("MonoMod.Utils", out module_Utils))
			{
				throw new FileNotFoundException("MonoMod.Utils not found!");
			}
			t_MulticastDelegate = OutputModule.ImportReference(modder.FindType("System.MulticastDelegate"));
			t_IAsyncResult = OutputModule.ImportReference(modder.FindType("System.IAsyncResult"));
			t_AsyncCallback = OutputModule.ImportReference(modder.FindType("System.AsyncCallback"));
			t_MethodBase = OutputModule.ImportReference(modder.FindType("System.Reflection.MethodBase"));
			t_RuntimeMethodHandle = OutputModule.ImportReference(modder.FindType("System.RuntimeMethodHandle"));
			t_EditorBrowsableState = OutputModule.ImportReference(modder.FindType("System.ComponentModel.EditorBrowsableState"));
			TypeDefinition type = module_RuntimeDetour.GetType("MonoMod.RuntimeDetour.HookGen.HookEndpointManager");
			t_ILManipulator = OutputModule.ImportReference((TypeReference)(object)module_Utils.GetType("MonoMod.Cil.ILContext/Manipulator"));
			m_Object_ctor = OutputModule.ImportReference((MethodReference)(object)Extensions.FindMethod(modder.FindType("System.Object").Resolve(), "System.Void .ctor()", true));
			m_ObsoleteAttribute_ctor = OutputModule.ImportReference((MethodReference)(object)Extensions.FindMethod(modder.FindType("System.ObsoleteAttribute").Resolve(), "System.Void .ctor(System.String,System.Boolean)", true));
			m_EditorBrowsableAttribute_ctor = OutputModule.ImportReference((MethodReference)(object)Extensions.FindMethod(modder.FindType("System.ComponentModel.EditorBrowsableAttribute").Resolve(), "System.Void .ctor(System.ComponentModel.EditorBrowsableState)", true));
			ModuleDefinition outputModule = OutputModule;
			MethodReference val = new MethodReference("GetMethodFromHandle", t_MethodBase, t_MethodBase);
			val.Parameters.Add(new ParameterDefinition(t_RuntimeMethodHandle));
			m_GetMethodFromHandle = outputModule.ImportReference(val);
			m_Add = OutputModule.ImportReference((MethodReference)(object)Extensions.FindMethod(type, "Add", true));
			m_Remove = OutputModule.ImportReference((MethodReference)(object)Extensions.FindMethod(type, "Remove", true));
			m_Modify = OutputModule.ImportReference((MethodReference)(object)Extensions.FindMethod(type, "Modify", true));
			m_Unmodify = OutputModule.ImportReference((MethodReference)(object)Extensions.FindMethod(type, "Unmodify", true));
		}

		public void Generate()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			Enumerator<TypeDefinition> enumerator = Modder.Module.Types.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					TypeDefinition current = enumerator.Current;
					GenerateFor(current, out var hookType, out var hookILType);
					if (hookType != null && hookILType != null && !((TypeReference)hookType).IsNested)
					{
						OutputModule.Types.Add(hookType);
						OutputModule.Types.Add(hookILType);
					}
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
		}

		public void GenerateFor(TypeDefinition type, out TypeDefinition hookType, out TypeDefinition hookILType)
		{
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Expected O, but got Unknown
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			hookType = (hookILType = null);
			if (((TypeReference)type).HasGenericParameters || type.IsRuntimeSpecialName || ((MemberReference)type).Name.StartsWith("<") || (!HookPrivate && type.IsNotPublic))
			{
				return;
			}
			Modder.LogVerbose("[HookGen] Generating for type " + ((MemberReference)type).FullName);
			hookType = new TypeDefinition(((TypeReference)type).IsNested ? null : (Namespace + (string.IsNullOrEmpty(((TypeReference)type).Namespace) ? "" : ("." + ((TypeReference)type).Namespace))), ((MemberReference)type).Name, (TypeAttributes)(((!((TypeReference)type).IsNested) ? 1 : 2) | 0x80 | 0x100 | 0), OutputModule.TypeSystem.Object);
			hookILType = new TypeDefinition(((TypeReference)type).IsNested ? null : (NamespaceIL + (string.IsNullOrEmpty(((TypeReference)type).Namespace) ? "" : ("." + ((TypeReference)type).Namespace))), ((MemberReference)type).Name, (TypeAttributes)(((!((TypeReference)type).IsNested) ? 1 : 2) | 0x80 | 0x100 | 0), OutputModule.TypeSystem.Object);
			bool flag = false;
			Enumerator<MethodDefinition> enumerator = type.Methods.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					MethodDefinition current = enumerator.Current;
					flag |= GenerateFor(hookType, hookILType, current);
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			Enumerator<TypeDefinition> enumerator2 = type.NestedTypes.GetEnumerator();
			try
			{
				while (enumerator2.MoveNext())
				{
					TypeDefinition current2 = enumerator2.Current;
					GenerateFor(current2, out var hookType2, out var hookILType2);
					if (hookType2 != null && hookILType2 != null)
					{
						flag = true;
						hookType.NestedTypes.Add(hookType2);
						hookILType.NestedTypes.Add(hookILType2);
					}
				}
			}
			finally
			{
				((IDisposable)enumerator2).Dispose();
			}
			if (!flag)
			{
				hookType = (hookILType = null);
			}
		}

		public bool GenerateFor(TypeDefinition hookType, TypeDefinition hookILType, MethodDefinition method)
		{
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Expected O, but got Unknown
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Expected O, but got Unknown
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Expected O, but got Unknown
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_039c: Expected O, but got Unknown
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Expected O, but got Unknown
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: Expected O, but got Unknown
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Expected O, but got Unknown
			//IL_0455: Unknown result type (might be due to invalid IL or missing references)
			//IL_045f: Expected O, but got Unknown
			//IL_0463: Unknown result type (might be due to invalid IL or missing references)
			//IL_046d: Expected O, but got Unknown
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0487: Unknown result type (might be due to invalid IL or missing references)
			//IL_0498: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04af: Expected O, but got Unknown
			//IL_04be: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0501: Expected O, but got Unknown
			//IL_0533: Unknown result type (might be due to invalid IL or missing references)
			//IL_053a: Expected O, but got Unknown
			//IL_0549: Unknown result type (might be due to invalid IL or missing references)
			//IL_0553: Expected O, but got Unknown
			//IL_0557: Unknown result type (might be due to invalid IL or missing references)
			//IL_0561: Expected O, but got Unknown
			//IL_056e: Unknown result type (might be due to invalid IL or missing references)
			//IL_057b: Unknown result type (might be due to invalid IL or missing references)
			//IL_058c: Unknown result type (might be due to invalid IL or missing references)
			//IL_059c: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a3: Expected O, but got Unknown
			//IL_05b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05be: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0601: Expected O, but got Unknown
			//IL_0610: Unknown result type (might be due to invalid IL or missing references)
			//IL_061a: Expected O, but got Unknown
			//IL_061e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0628: Expected O, but got Unknown
			//IL_0635: Unknown result type (might be due to invalid IL or missing references)
			//IL_0642: Unknown result type (might be due to invalid IL or missing references)
			//IL_0653: Unknown result type (might be due to invalid IL or missing references)
			//IL_0663: Unknown result type (might be due to invalid IL or missing references)
			//IL_066a: Expected O, but got Unknown
			//IL_0679: Unknown result type (might be due to invalid IL or missing references)
			//IL_0685: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c0: Expected O, but got Unknown
			if (((MethodReference)method).HasGenericParameters || method.IsAbstract || (method.IsSpecialName && !method.IsConstructor))
			{
				return false;
			}
			if (!HookOrig && ((MemberReference)method).Name.StartsWith("orig_"))
			{
				return false;
			}
			if (!HookPrivate && method.IsPrivate)
			{
				return false;
			}
			string name = GetFriendlyName((MethodReference)(object)method);
			bool flag = true;
			if (((MethodReference)method).Parameters.Count == 0)
			{
				flag = false;
			}
			IEnumerable<MethodDefinition> source = null;
			if (flag)
			{
				source = ((IEnumerable<MethodDefinition>)method.DeclaringType.Methods).Where((MethodDefinition other) => !((MethodReference)other).HasGenericParameters && GetFriendlyName((MethodReference)(object)other) == name && other != method);
				if (source.Count() == 0)
				{
					flag = false;
				}
			}
			if (flag)
			{
				StringBuilder stringBuilder = new StringBuilder();
				for (int parami = 0; parami < ((MethodReference)method).Parameters.Count; parami++)
				{
					ParameterDefinition param = ((MethodReference)method).Parameters[parami];
					if (!TypeNameMap.TryGetValue(((MemberReference)((ParameterReference)param).ParameterType).FullName, out var typeName))
					{
						typeName = GetFriendlyName(((ParameterReference)param).ParameterType, full: false);
					}
					if (source.Any(delegate(MethodDefinition other)
					{
						ParameterDefinition val11 = ((IEnumerable<ParameterDefinition>)((MethodReference)other).Parameters).ElementAtOrDefault(parami);
						return val11 != null && GetFriendlyName(((ParameterReference)val11).ParameterType, full: false) == typeName && ((ParameterReference)val11).ParameterType.Namespace != ((ParameterReference)param).ParameterType.Namespace;
					}))
					{
						typeName = GetFriendlyName(((ParameterReference)param).ParameterType, full: true);
					}
					stringBuilder.Append("_");
					stringBuilder.Append(typeName.Replace(".", "").Replace("`", ""));
				}
				name += stringBuilder.ToString();
			}
			if (Extensions.FindEvent(hookType, name) != null)
			{
				int num = 1;
				string text;
				while (Extensions.FindEvent(hookType, text = name + "_" + num) != null)
				{
					num++;
				}
				name = text;
			}
			TypeDefinition val = GenerateDelegateFor(method);
			((MemberReference)val).Name = "orig_" + name;
			val.CustomAttributes.Add(GenerateEditorBrowsable(EditorBrowsableState.Never));
			hookType.NestedTypes.Add(val);
			TypeDefinition val2 = GenerateDelegateFor(method);
			((MemberReference)val2).Name = "hook_" + name;
			((MethodReference)Extensions.FindMethod(val2, "Invoke", true)).Parameters.Insert(0, new ParameterDefinition("orig", (ParameterAttributes)0, (TypeReference)(object)val));
			((MethodReference)Extensions.FindMethod(val2, "BeginInvoke", true)).Parameters.Insert(0, new ParameterDefinition("orig", (ParameterAttributes)0, (TypeReference)(object)val));
			val2.CustomAttributes.Add(GenerateEditorBrowsable(EditorBrowsableState.Never));
			hookType.NestedTypes.Add(val2);
			MethodReference val3 = OutputModule.ImportReference((MethodReference)(object)method);
			MethodDefinition val4 = new MethodDefinition("add_" + name, (MethodAttributes)2198, OutputModule.TypeSystem.Void);
			((MethodReference)val4).Parameters.Add(new ParameterDefinition((string)null, (ParameterAttributes)0, (TypeReference)(object)val2));
			val4.Body = new MethodBody(val4);
			ILProcessor iLProcessor = val4.Body.GetILProcessor();
			iLProcessor.Emit(OpCodes.Ldtoken, val3);
			iLProcessor.Emit(OpCodes.Call, m_GetMethodFromHandle);
			iLProcessor.Emit(OpCodes.Ldarg_0);
			GenericInstanceMethod val5 = new GenericInstanceMethod(m_Add);
			val5.GenericArguments.Add((TypeReference)(object)val2);
			iLProcessor.Emit(OpCodes.Call, (MethodReference)(object)val5);
			iLProcessor.Emit(OpCodes.Ret);
			hookType.Methods.Add(val4);
			MethodDefinition val6 = new MethodDefinition("remove_" + name, (MethodAttributes)2198, OutputModule.TypeSystem.Void);
			((MethodReference)val6).Parameters.Add(new ParameterDefinition((string)null, (ParameterAttributes)0, (TypeReference)(object)val2));
			val6.Body = new MethodBody(val6);
			ILProcessor iLProcessor2 = val6.Body.GetILProcessor();
			iLProcessor2.Emit(OpCodes.Ldtoken, val3);
			iLProcessor2.Emit(OpCodes.Call, m_GetMethodFromHandle);
			iLProcessor2.Emit(OpCodes.Ldarg_0);
			val5 = new GenericInstanceMethod(m_Remove);
			val5.GenericArguments.Add((TypeReference)(object)val2);
			iLProcessor2.Emit(OpCodes.Call, (MethodReference)(object)val5);
			iLProcessor2.Emit(OpCodes.Ret);
			hookType.Methods.Add(val6);
			EventDefinition val7 = new EventDefinition(name, (EventAttributes)0, (TypeReference)(object)val2)
			{
				AddMethod = val4,
				RemoveMethod = val6
			};
			hookType.Events.Add(val7);
			MethodDefinition val8 = new MethodDefinition("add_" + name, (MethodAttributes)2198, OutputModule.TypeSystem.Void);
			((MethodReference)val8).Parameters.Add(new ParameterDefinition((string)null, (ParameterAttributes)0, t_ILManipulator));
			val8.Body = new MethodBody(val8);
			ILProcessor iLProcessor3 = val8.Body.GetILProcessor();
			iLProcessor3.Emit(OpCodes.Ldtoken, val3);
			iLProcessor3.Emit(OpCodes.Call, m_GetMethodFromHandle);
			iLProcessor3.Emit(OpCodes.Ldarg_0);
			val5 = new GenericInstanceMethod(m_Modify);
			val5.GenericArguments.Add((TypeReference)(object)val2);
			iLProcessor3.Emit(OpCodes.Call, (MethodReference)(object)val5);
			iLProcessor3.Emit(OpCodes.Ret);
			hookILType.Methods.Add(val8);
			MethodDefinition val9 = new MethodDefinition("remove_" + name, (MethodAttributes)2198, OutputModule.TypeSystem.Void);
			((MethodReference)val9).Parameters.Add(new ParameterDefinition((string)null, (ParameterAttributes)0, t_ILManipulator));
			val9.Body = new MethodBody(val9);
			ILProcessor iLProcessor4 = val9.Body.GetILProcessor();
			iLProcessor4.Emit(OpCodes.Ldtoken, val3);
			iLProcessor4.Emit(OpCodes.Call, m_GetMethodFromHandle);
			iLProcessor4.Emit(OpCodes.Ldarg_0);
			val5 = new GenericInstanceMethod(m_Unmodify);
			val5.GenericArguments.Add((TypeReference)(object)val2);
			iLProcessor4.Emit(OpCodes.Call, (MethodReference)(object)val5);
			iLProcessor4.Emit(OpCodes.Ret);
			hookILType.Methods.Add(val9);
			EventDefinition val10 = new EventDefinition(name, (EventAttributes)0, t_ILManipulator)
			{
				AddMethod = val8,
				RemoveMethod = val9
			};
			hookILType.Events.Add(val10);
			return true;
		}

		public TypeDefinition GenerateDelegateFor(MethodDefinition method)
		{
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Expected O, but got Unknown
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Expected O, but got Unknown
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Expected O, but got Unknown
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Expected O, but got Unknown
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Expected O, but got Unknown
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Expected O, but got Unknown
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Expected O, but got Unknown
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Expected O, but got Unknown
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Expected O, but got Unknown
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Expected O, but got Unknown
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Expected O, but got Unknown
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Expected O, but got Unknown
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Expected O, but got Unknown
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Expected O, but got Unknown
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Expected O, but got Unknown
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Expected O, but got Unknown
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Expected O, but got Unknown
			string name = GetFriendlyName((MethodReference)(object)method);
			int num = ((IEnumerable<MethodDefinition>)method.DeclaringType.Methods).Where((MethodDefinition other) => !((MethodReference)other).HasGenericParameters && GetFriendlyName((MethodReference)(object)other) == name).ToList().IndexOf(method);
			if (num != 0)
			{
				string suffix = num.ToString();
				do
				{
					name = name + "_" + suffix;
				}
				while (((IEnumerable<MethodDefinition>)method.DeclaringType.Methods).Any((MethodDefinition other) => !((MethodReference)other).HasGenericParameters && GetFriendlyName((MethodReference)(object)other) == name + suffix));
			}
			name = "d_" + name;
			TypeDefinition val = new TypeDefinition((string)null, (string)null, (TypeAttributes)258, t_MulticastDelegate);
			MethodDefinition val2 = new MethodDefinition(".ctor", (MethodAttributes)6278, OutputModule.TypeSystem.Void)
			{
				ImplAttributes = (MethodImplAttributes)3,
				HasThis = true
			};
			((MethodReference)val2).Parameters.Add(new ParameterDefinition(OutputModule.TypeSystem.Object));
			((MethodReference)val2).Parameters.Add(new ParameterDefinition(OutputModule.TypeSystem.IntPtr));
			val2.Body = new MethodBody(val2);
			val.Methods.Add(val2);
			MethodDefinition val3 = new MethodDefinition("Invoke", (MethodAttributes)454, ImportVisible(((MethodReference)method).ReturnType))
			{
				ImplAttributes = (MethodImplAttributes)3,
				HasThis = true
			};
			if (!method.IsStatic)
			{
				TypeReference val4 = ImportVisible((TypeReference)(object)method.DeclaringType);
				if (((TypeReference)method.DeclaringType).IsValueType)
				{
					val4 = (TypeReference)new ByReferenceType(val4);
				}
				((MethodReference)val3).Parameters.Add(new ParameterDefinition("self", (ParameterAttributes)0, val4));
			}
			Enumerator<ParameterDefinition> enumerator = ((MethodReference)method).Parameters.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					ParameterDefinition current = enumerator.Current;
					((MethodReference)val3).Parameters.Add(new ParameterDefinition(((ParameterReference)current).Name, (ParameterAttributes)(current.Attributes & 0xFFEF & 0xEFFF), ImportVisible(((ParameterReference)current).ParameterType)));
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			val3.Body = new MethodBody(val3);
			val.Methods.Add(val3);
			MethodDefinition val5 = new MethodDefinition("BeginInvoke", (MethodAttributes)454, t_IAsyncResult)
			{
				ImplAttributes = (MethodImplAttributes)3,
				HasThis = true
			};
			enumerator = ((MethodReference)val3).Parameters.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					ParameterDefinition current2 = enumerator.Current;
					((MethodReference)val5).Parameters.Add(new ParameterDefinition(((ParameterReference)current2).Name, current2.Attributes, ((ParameterReference)current2).ParameterType));
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			((MethodReference)val5).Parameters.Add(new ParameterDefinition("callback", (ParameterAttributes)0, t_AsyncCallback));
			((MethodReference)val5).Parameters.Add(new ParameterDefinition((string)null, (ParameterAttributes)0, OutputModule.TypeSystem.Object));
			val5.Body = new MethodBody(val5);
			val.Methods.Add(val5);
			MethodDefinition val6 = new MethodDefinition("EndInvoke", (MethodAttributes)454, OutputModule.TypeSystem.Object)
			{
				ImplAttributes = (MethodImplAttributes)3,
				HasThis = true
			};
			((MethodReference)val6).Parameters.Add(new ParameterDefinition("result", (ParameterAttributes)0, t_IAsyncResult));
			val6.Body = new MethodBody(val6);
			val.Methods.Add(val6);
			return val;
		}

		private string GetFriendlyName(MethodReference method)
		{
			string text = ((MemberReference)method).Name;
			if (text.StartsWith("."))
			{
				text = text.Substring(1);
			}
			return text.Replace('.', '_');
		}

		private string GetFriendlyName(TypeReference type, bool full)
		{
			if (type is TypeSpecification)
			{
				StringBuilder stringBuilder = new StringBuilder();
				BuildFriendlyName(stringBuilder, type, full);
				return stringBuilder.ToString();
			}
			if (!full)
			{
				return ((MemberReference)type).Name;
			}
			return ((MemberReference)type).FullName;
		}

		private void BuildFriendlyName(StringBuilder builder, TypeReference type, bool full)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			if (!(type is TypeSpecification))
			{
				builder.Append((full ? ((MemberReference)type).FullName : ((MemberReference)type).Name).Replace("_", ""));
				return;
			}
			if (type.IsByReference)
			{
				builder.Append("ref");
			}
			else if (type.IsPointer)
			{
				builder.Append("ptr");
			}
			BuildFriendlyName(builder, ((TypeSpecification)type).ElementType, full);
			if (type.IsArray)
			{
				builder.Append("Array");
			}
		}

		private bool IsPublic(TypeDefinition typeDef)
		{
			if (typeDef != null && (typeDef.IsNestedPublic || typeDef.IsPublic))
			{
				return !typeDef.IsNotPublic;
			}
			return false;
		}

		private bool HasPublicArgs(GenericInstanceType typeGen)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Enumerator<TypeReference> enumerator = typeGen.GenericArguments.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					TypeReference current = enumerator.Current;
					if (current.IsGenericParameter)
					{
						return false;
					}
					GenericInstanceType val = (GenericInstanceType)(object)((current is GenericInstanceType) ? current : null);
					if (val != null && !HasPublicArgs(val))
					{
						return false;
					}
					if (!IsPublic(Extensions.SafeResolve(current)))
					{
						return false;
					}
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			return true;
		}

		private TypeReference ImportVisible(TypeReference typeRef)
		{
			for (TypeDefinition val = ((typeRef != null) ? Extensions.SafeResolve(typeRef) : null); val != null; val = ((typeRef != null) ? Extensions.SafeResolve(typeRef) : null))
			{
				GenericInstanceType val2 = (GenericInstanceType)(object)((typeRef is GenericInstanceType) ? typeRef : null);
				if (val2 == null || HasPublicArgs(val2))
				{
					TypeDefinition val3 = val;
					while (true)
					{
						if (val3 != null)
						{
							if (IsPublic(val3) && (val3 == val || !((TypeReference)val3).HasGenericParameters))
							{
								val3 = val3.DeclaringType;
								continue;
							}
							if (!val.IsEnum)
							{
								break;
							}
							typeRef = ((FieldReference)Extensions.FindField(val, "value__")).FieldType;
						}
						try
						{
							return OutputModule.ImportReference(typeRef);
						}
						catch
						{
							return OutputModule.TypeSystem.Object;
						}
					}
				}
				typeRef = val.BaseType;
			}
			return OutputModule.TypeSystem.Object;
		}

		private CustomAttribute GenerateObsolete(string message, bool error)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			CustomAttribute val = new CustomAttribute(m_ObsoleteAttribute_ctor);
			val.ConstructorArguments.Add(new CustomAttributeArgument(OutputModule.TypeSystem.String, (object)message));
			val.ConstructorArguments.Add(new CustomAttributeArgument(OutputModule.TypeSystem.Boolean, (object)error));
			return val;
		}

		private CustomAttribute GenerateEditorBrowsable(EditorBrowsableState state)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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_0028: Expected O, but got Unknown
			CustomAttribute val = new CustomAttribute(m_EditorBrowsableAttribute_ctor);
			val.ConstructorArguments.Add(new CustomAttributeArgument(t_EditorBrowsableState, (object)state));
			return val;
		}
	}
	internal class Program
	{
		private static void Main(string[] args)
		{
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Expected O, but got Unknown
			Console.WriteLine("MonoMod.RuntimeDetour.HookGen " + typeof(Program).Assembly.GetName().Version);
			Console.WriteLine("using MonoMod " + typeof(MonoModder).Assembly.GetName().Version);
			Console.WriteLine("using MonoMod.RuntimeDetour " + typeof(Detour).Assembly.GetName().Version);
			if (args.Length == 0)
			{
				Console.WriteLine("No valid arguments (assembly path) passed.");
				if (Debugger.IsAttached)
				{
					Console.ReadKey();
				}
				return;
			}
			int num = 0;
			for (int i = 0; i < args.Length; i++)
			{
				if (args[i] == "--namespace" && i + 2 < args.Length)
				{
					i++;
					Environment.SetEnvironmentVariable("MONOMOD_HOOKGEN_NAMESPACE", args[i]);
					continue;
				}
				if (args[i] == "--namespace-il" && i + 2 < args.Length)
				{
					i++;
					Environment.SetEnvironmentVariable("MONOMOD_HOOKGEN_NAMESPACE_IL", args[i]);
					continue;
				}
				if (args[i] == "--orig")
				{
					Environment.SetEnvironmentVariable("MONOMOD_HOOKGEN_ORIG", "1");
					continue;
				}
				if (args[i] == "--private")
				{
					Environment.SetEnvironmentVariable("MONOMOD_HOOKGEN_PRIVATE", "1");
					continue;
				}
				num = i;
				break;
			}
			if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("MONOMOD_DEPENDENCY_MISSING_THROW")))
			{
				Environment.SetEnvironmentVariable("MONOMOD_DEPENDENCY_MISSING_THROW", "0");
			}
			if (num >= args.Length)
			{
				Console.WriteLine("No assembly path passed.");
				if (Debugger.IsAttached)
				{
					Console.ReadKey();
				}
				return;
			}
			string text = args[num];
			string text2 = ((args.Length != 1 && num != args.Length - 1) ? args[^1] : null);
			text2 = text2 ?? Path.Combine(Path.GetDirectoryName(text), "MMHOOK_" + Path.ChangeExtension(Path.GetFileName(text), "dll"));
			MonoModder val = new MonoModder
			{
				InputPath = text,
				OutputPath = text2,
				ReadingMode = (ReadingMode)2
			};
			try
			{
				val.Read();
				val.MapDependencies();
				if (File.Exists(text2))
				{
					val.Log("[HookGen] Clearing " + text2);
					File.Delete(text2);
				}
				val.Log("[HookGen] Starting HookGenerator");
				HookGenerator hookGenerator = new HookGenerator(val, Path.GetFileName(text2));
				ModuleDefinition outputModule = hookGenerator.OutputModule;
				try
				{
					hookGenerator.Generate();
					outputModule.Write(text2);
				}
				finally
				{
					((IDisposable)outputModule)?.Dispose();
				}
				val.Log("[HookGen] Done.");
			}
			finally
			{
				((IDisposable)val)?.Dispose();
			}
			if (Debugger.IsAttached)
			{
				Console.ReadKey();
			}
		}
	}
}

plugins/AutoCompanyBuilding.dll

Decompiled 9 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using AutoCompanyBuilding.Patches;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("AutoCompanyBuilding")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AutoCompanyBuilding")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c5bc747e-4294-4a2d-9cbf-71992f97b9de")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AutoCompanyBuilding
{
	[BepInPlugin("La_Chips.AutoCompanyBuilding", "Auto Company Building", "1.1.3.0")]
	public class AutoCompanyBuildingBase : BaseUnityPlugin
	{
		private const string PLUGIN_GUID = "La_Chips.AutoCompanyBuilding";

		private const string PLUGIN_NAME = "Auto Company Building";

		private const string PLUGIN_VERSION = "1.1.3.0";

		private readonly Harmony harmony = new Harmony("La_Chips.AutoCompanyBuilding");

		private static AutoCompanyBuildingBase Instance;

		public static ManualLogSource logSource;

		public static int groupCredits;

		public static bool hasRerouted;

		private void Awake()
		{
			logSource = Logger.CreateLogSource("La_Chips.AutoCompanyBuilding");
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
				logSource.LogInfo((object)"Creating static instance");
			}
			logSource.LogInfo((object)"Plugin La_Chips.AutoCompanyBuilding is loaded!");
			harmony.PatchAll(typeof(AutoCompanyBuildingBase));
			harmony.PatchAll(typeof(TerminalPatch));
			harmony.PatchAll(typeof(StartOfRoundPatch));
		}
	}
}
namespace AutoCompanyBuilding.Patches
{
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		private static GameNetworkManager ___gameNetworkManager = GameNetworkManager.Instance;

		[HarmonyPatch("EndOfGame")]
		[HarmonyPostfix]
		private static void ResetHasRerouted()
		{
			if (___gameNetworkManager.isHostingGame)
			{
				AutoCompanyBuildingBase.hasRerouted = false;
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void AutoShipToCompanyBuilding(StartOfRound __instance)
		{
			if (___gameNetworkManager.isHostingGame)
			{
				if (__instance.currentLevelID == 3)
				{
					AutoCompanyBuildingBase.hasRerouted = true;
				}
				else if (__instance.CanChangeLevels() && TimeOfDay.Instance.daysUntilDeadline == 0 && __instance.currentLevelID != 3 && !AutoCompanyBuildingBase.hasRerouted)
				{
					__instance.ChangeLevelServerRpc(3, AutoCompanyBuildingBase.groupCredits);
					__instance.ChangeLevel(3);
					AutoCompanyBuildingBase.hasRerouted = true;
				}
			}
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	internal class TerminalPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void gatherGroupCreditsValue(ref int ___groupCredits)
		{
			AutoCompanyBuildingBase.groupCredits = ___groupCredits;
		}
	}
}

plugins/backrooms/Backrooms.dll

Decompiled 9 months ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using DunGen.Graph;
using GameNetcodeStuff;
using HarmonyLib;
using Unity.AI.Navigation;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
internal class <Module>
{
	static <Module>()
	{
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<float>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<float>();
	}
}
[RequireComponent(typeof(SphereCollider))]
public class KillBox : MonoBehaviour
{
	private void OnTriggerEnter(Collider other)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
		if ((Object)(object)component != (Object)null)
		{
			component.KillPlayer(Vector3.zero, true, (CauseOfDeath)0, 0);
		}
	}
}
public class LightFlickerEffect : MonoBehaviour
{
	[Tooltip("External light to flicker; you can leave this null if you attach script to a light")]
	public Light light;

	[Tooltip("Minimum random light intensity")]
	public float minIntensity;

	[Tooltip("Maximum random light intensity")]
	public float maxIntensity = 1f;

	[Tooltip("How much to smooth out the randomness; lower values = sparks, higher = lantern")]
	[Range(1f, 50f)]
	public int smoothing = 5;

	private Queue<float> smoothQueue;

	private float lastSum;

	public void Reset()
	{
		smoothQueue.Clear();
		lastSum = 0f;
	}

	private void Start()
	{
		smoothQueue = new Queue<float>(smoothing);
		if ((Object)(object)light == (Object)null)
		{
			light = ((Component)this).GetComponent<Light>();
		}
	}

	private void Update()
	{
		if (!((Object)(object)light == (Object)null))
		{
			while (smoothQueue.Count >= smoothing)
			{
				lastSum -= smoothQueue.Dequeue();
			}
			float num = Random.Range(minIntensity, maxIntensity);
			smoothQueue.Enqueue(num);
			lastSum += num;
			light.intensity = lastSum / (float)smoothQueue.Count;
		}
	}
}
public class LookAtPlayer : MonoBehaviour
{
	private void Update()
	{
		//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_0024: Unknown result type (might be due to invalid IL or missing references)
		((Component)this).gameObject.transform.LookAt(((Component)GameNetworkManager.Instance.localPlayerController).transform.position + Vector3.up);
	}
}
public class SpawnPosition : MonoBehaviour
{
	private void Start()
	{
	}

	private void Update()
	{
	}
}
[CompilerGenerated]
[EditorBrowsable(EditorBrowsableState.Never)]
[GeneratedCode("Unity.MonoScriptGenerator.MonoScriptInfoGenerator", null)]
internal class UnitySourceGeneratedAssemblyMonoScriptTypes_v1
{
	private struct MonoScriptData
	{
		public byte[] FilePathsData;

		public byte[] TypesData;

		public int TotalTypes;

		public int TotalFiles;

		public bool IsEditorOnly;
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	private static MonoScriptData Get()
	{
		MonoScriptData result = default(MonoScriptData);
		result.FilePathsData = new byte[506]
		{
			0, 0, 0, 1, 0, 0, 0, 42, 92, 65,
			115, 115, 101, 116, 115, 92, 66, 97, 99, 107,
			114, 111, 111, 109, 115, 92, 83, 99, 114, 105,
			112, 116, 115, 92, 65, 114, 101, 89, 111, 117,
			87, 97, 116, 99, 104, 101, 100, 46, 99, 115,
			0, 0, 0, 1, 0, 0, 0, 38, 92, 65,
			115, 115, 101, 116, 115, 92, 66, 97, 99, 107,
			114, 111, 111, 109, 115, 92, 83, 99, 114, 105,
			112, 116, 115, 92, 66, 97, 99, 107, 114, 111,
			111, 109, 115, 46, 99, 115, 0, 0, 0, 1,
			0, 0, 0, 33, 92, 65, 115, 115, 101, 116,
			115, 92, 66, 97, 99, 107, 114, 111, 111, 109,
			115, 92, 83, 99, 114, 105, 112, 116, 115, 92,
			69, 120, 105, 116, 46, 99, 115, 0, 0, 0,
			1, 0, 0, 0, 33, 92, 65, 115, 115, 101,
			116, 115, 92, 66, 97, 99, 107, 114, 111, 111,
			109, 115, 92, 83, 99, 114, 105, 112, 116, 115,
			92, 72, 111, 111, 107, 46, 99, 115, 0, 0,
			0, 1, 0, 0, 0, 36, 92, 65, 115, 115,
			101, 116, 115, 92, 66, 97, 99, 107, 114, 111,
			111, 109, 115, 92, 83, 99, 114, 105, 112, 116,
			115, 92, 75, 105, 108, 108, 66, 111, 120, 46,
			99, 115, 0, 0, 0, 1, 0, 0, 0, 47,
			92, 65, 115, 115, 101, 116, 115, 92, 66, 97,
			99, 107, 114, 111, 111, 109, 115, 92, 83, 99,
			114, 105, 112, 116, 115, 92, 76, 105, 103, 104,
			116, 70, 108, 105, 99, 107, 101, 114, 69, 102,
			102, 101, 99, 116, 46, 99, 115, 0, 0, 0,
			1, 0, 0, 0, 35, 92, 65, 115, 115, 101,
			116, 115, 92, 66, 97, 99, 107, 114, 111, 111,
			109, 115, 92, 83, 99, 114, 105, 112, 116, 115,
			92, 76, 111, 97, 100, 101, 114, 46, 99, 115,
			0, 0, 0, 1, 0, 0, 0, 41, 92, 65,
			115, 115, 101, 116, 115, 92, 66, 97, 99, 107,
			114, 111, 111, 109, 115, 92, 83, 99, 114, 105,
			112, 116, 115, 92, 76, 111, 111, 107, 65, 116,
			80, 108, 97, 121, 101, 114, 46, 99, 115, 0,
			0, 0, 1, 0, 0, 0, 36, 92, 65, 115,
			115, 101, 116, 115, 92, 66, 97, 99, 107, 114,
			111, 111, 109, 115, 92, 83, 99, 114, 105, 112,
			116, 115, 92, 83, 107, 105, 98, 105, 100, 105,
			46, 99, 115, 0, 0, 0, 1, 0, 0, 0,
			35, 92, 65, 115, 115, 101, 116, 115, 92, 66,
			97, 99, 107, 114, 111, 111, 109, 115, 92, 83,
			99, 114, 105, 112, 116, 115, 92, 83, 109, 105,
			108, 101, 114, 46, 99, 115, 0, 0, 0, 1,
			0, 0, 0, 42, 92, 65, 115, 115, 101, 116,
			115, 92, 66, 97, 99, 107, 114, 111, 111, 109,
			115, 92, 83, 99, 114, 105, 112, 116, 115, 92,
			83, 112, 97, 119, 110, 80, 111, 115, 105, 116,
			105, 111, 110, 46, 99, 115
		};
		result.TypesData = new byte[233]
		{
			0, 0, 0, 0, 25, 66, 97, 99, 107, 114,
			111, 111, 109, 115, 124, 66, 97, 99, 107, 114,
			111, 111, 109, 115, 72, 101, 108, 112, 101, 114,
			0, 0, 0, 0, 19, 66, 97, 99, 107, 114,
			111, 111, 109, 115, 124, 66, 97, 99, 107, 114,
			111, 111, 109, 115, 0, 0, 0, 0, 14, 66,
			97, 99, 107, 114, 111, 111, 109, 115, 124, 69,
			120, 105, 116, 0, 0, 0, 0, 14, 66, 97,
			99, 107, 114, 111, 111, 109, 115, 124, 72, 111,
			111, 107, 0, 0, 0, 0, 8, 124, 75, 105,
			108, 108, 66, 111, 120, 0, 0, 0, 0, 19,
			124, 76, 105, 103, 104, 116, 70, 108, 105, 99,
			107, 101, 114, 69, 102, 102, 101, 99, 116, 0,
			0, 0, 0, 16, 66, 97, 99, 107, 114, 111,
			111, 109, 115, 124, 76, 111, 97, 100, 101, 114,
			0, 0, 0, 0, 13, 124, 76, 111, 111, 107,
			65, 116, 80, 108, 97, 121, 101, 114, 0, 0,
			0, 0, 20, 66, 97, 99, 107, 114, 111, 111,
			109, 115, 124, 83, 111, 117, 110, 100, 80, 97,
			116, 99, 104, 0, 0, 0, 0, 16, 66, 97,
			99, 107, 114, 111, 111, 109, 115, 124, 83, 109,
			105, 108, 101, 114, 0, 0, 0, 0, 14, 124,
			83, 112, 97, 119, 110, 80, 111, 115, 105, 116,
			105, 111, 110
		};
		result.TotalFiles = 11;
		result.TotalTypes = 11;
		result.IsEditorOnly = false;
		return result;
	}
}
namespace Backrooms;

public class BackroomsHelper : MonoBehaviour
{
	public bool HasBeenInTheBackrooms;

	private void Start()
	{
	}

	private void Update()
	{
	}
}
public class Backrooms : NetworkBehaviour
{
	public static Backrooms Instance;

	public GameObject Floor;

	public GameObject Wall;

	public GameObject Ceiling;

	public GameObject LightlessCeiling;

	public GameObject Pillar;

	public GameObject Room;

	public static float Offset = -500f;

	private int Width = 30;

	private int Height = 30;

	public List<Vector2> PossibleSpawnPoint;

	public List<PlayerControllerB> playerInBackrooms;

	public NetworkVariable<float> SharedOdds = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

	private float initialValue;

	public DungeonFlow Flow;

	public GameObject Child;

	public override void OnNetworkSpawn()
	{
		if (((NetworkBehaviour)this).IsServer)
		{
			initialValue = Loader.TeleportationOdds.Value;
			SharedOdds.Value = initialValue;
			((NetworkBehaviour)this).NetworkManager.OnClientConnectedCallback += NetworkManager_OnClientConnectedCallback;
			return;
		}
		if (SharedOdds.Value != initialValue)
		{
			Debug.LogWarning((object)($"NetworkVariable was {SharedOdds.Value} upon being spawned" + $" when it should have been {initialValue}"));
		}
		else
		{
			Debug.Log((object)$"NetworkVariable is {SharedOdds.Value} when spawned.");
		}
		NetworkVariable<float> sharedOdds = SharedOdds;
		sharedOdds.OnValueChanged = (OnValueChangedDelegate<float>)(object)Delegate.Combine((Delegate?)(object)sharedOdds.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<float>(OnSomeValueChanged));
	}

	private void NetworkManager_OnClientConnectedCallback(ulong obj)
	{
		StartChangingNetworkVariable();
	}

	private void OnSomeValueChanged(float previous, float current)
	{
		Debug.Log((object)$"Detected NetworkVariable Change: Previous: {previous} | Current: {current}");
	}

	private void StartChangingNetworkVariable()
	{
		((NetworkBehaviour)this).NetworkManager.OnClientConnectedCallback -= NetworkManager_OnClientConnectedCallback;
	}

	private void Awake()
	{
		PossibleSpawnPoint = new List<Vector2>();
		playerInBackrooms = new List<PlayerControllerB>();
	}

	private void Start()
	{
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
	}

	private IEnumerator Teleport()
	{
		yield return (object)new WaitForSeconds(10f);
		for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
		{
			if (StartOfRound.Instance.allPlayerScripts[i].isPlayerControlled)
			{
				TeleportToBackroomsClientRpc(i);
			}
		}
	}

	public void ServerGenerate()
	{
		int seed = Random.Range(0, 1000000);
		GenerateClientRpc(seed);
	}

	public void ServerClean()
	{
		Smiler[] array = Object.FindObjectsOfType<Smiler>();
		for (int i = 0; i < array.Length; i++)
		{
			((Component)array[i]).GetComponent<NetworkObject>().Despawn(true);
		}
		playerInBackrooms.Clear();
		CleanBackroomsClientRpc();
	}

	[ClientRpc]
	public void CleanBackroomsClientRpc()
	{
		//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_00cf: 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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2180494496u, val, (RpcDelivery)0);
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2180494496u, val, (RpcDelivery)0);
		}
		if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
		{
			return;
		}
		foreach (Transform item in ((Component)this).transform)
		{
			Object.Destroy((Object)(object)((Component)item).gameObject);
		}
		PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
		for (int i = 0; i < allPlayerScripts.Length; i++)
		{
			((Component)allPlayerScripts[i]).GetComponent<BackroomsHelper>().HasBeenInTheBackrooms = false;
		}
	}

	[ServerRpc(RequireOwnership = false)]
	public void TeleportToBackroomsServerRpc(int client)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2541916904u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, client);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2541916904u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				TeleportToBackroomsClientRpc(client);
			}
		}
	}

	[ClientRpc]
	public void TeleportToBackroomsClientRpc(int client)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: 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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3078584200u, val, (RpcDelivery)0);
			BytePacker.WriteValueBitPacked(val2, client);
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3078584200u, val, (RpcDelivery)0);
		}
		if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
		{
			PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[client];
			Random.InitState(client);
			Vector2 val4 = PossibleSpawnPoint[Random.Range(0, PossibleSpawnPoint.Count)];
			val3.TeleportPlayer(new Vector3(val4.x, Offset, val4.y), false, 0f, false, true);
			val3.isInsideFactory = true;
			val3.ResetFallGravity();
			((Component)val3).GetComponent<BackroomsHelper>().HasBeenInTheBackrooms = true;
			if (((NetworkBehaviour)this).IsServer)
			{
				playerInBackrooms.Add(val3);
			}
		}
	}

	[ClientRpc]
	public void TeleportOutOfBackroomsClientRpc(int client)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1623403188u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, client);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1623403188u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				PlayerControllerB obj = StartOfRound.Instance.allPlayerScripts[client];
				obj.TeleportPlayer(StartOfRound.Instance.playerSpawnPositions[0].position, false, 0f, false, true);
				obj.isInsideFactory = false;
			}
		}
	}

	[ClientRpc]
	public void GenerateClientRpc(int seed)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_022b: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: 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)
		//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0271: Unknown result type (might be due to invalid IL or missing references)
		//IL_0285: Unknown result type (might be due to invalid IL or missing references)
		//IL_0331: Unknown result type (might be due to invalid IL or missing references)
		//IL_0345: Unknown result type (might be due to invalid IL or missing references)
		//IL_0373: Unknown result type (might be due to invalid IL or missing references)
		//IL_0387: Unknown result type (might be due to invalid IL or missing references)
		//IL_0545: Unknown result type (might be due to invalid IL or missing references)
		//IL_054a: Unknown result type (might be due to invalid IL or missing references)
		//IL_054d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0559: Unknown result type (might be due to invalid IL or missing references)
		//IL_0560: Unknown result type (might be due to invalid IL or missing references)
		//IL_0565: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_049a: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_0458: Unknown result type (might be due to invalid IL or missing references)
		//IL_046c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0417: Unknown result type (might be due to invalid IL or missing references)
		//IL_042b: 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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(890432861u, val, (RpcDelivery)0);
			BytePacker.WriteValueBitPacked(val2, seed);
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 890432861u, val, (RpcDelivery)0);
		}
		if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
		{
			return;
		}
		PossibleSpawnPoint.Clear();
		playerInBackrooms.Clear();
		Random random = new Random(seed);
		Debug.Log((object)"Generate floor and ceiling");
		for (int i = -Width / 2; i < Width / 2; i++)
		{
			for (int j = -Height / 2; j < Height / 2; j++)
			{
				Object.Instantiate<GameObject>(Floor, new Vector3((float)(i * 6), Offset, (float)(j * 6)), Quaternion.Euler(-90f, 0f, 0f), ((Component)this).transform);
				if (random.Next(100) < 85)
				{
					Object.Instantiate<GameObject>(LightlessCeiling, new Vector3((float)(i * 6), Offset + 5f, (float)(j * 6)), Quaternion.Euler(-90f, 0f, 0f), ((Component)this).transform);
				}
				else
				{
					Object.Instantiate<GameObject>(Ceiling, new Vector3((float)(i * 6), Offset + 5f, (float)(j * 6)), Quaternion.Euler(-90f, 0f, 0f), ((Component)this).transform);
				}
			}
		}
		Debug.Log((object)"Generate walls");
		for (int k = -Width / 2; k < Width / 2; k++)
		{
			Object.Instantiate<GameObject>(Wall, new Vector3((float)(-Width / 2 * 6 - 3), Offset, (float)(k * 6)), Quaternion.Euler(-90f, 0f, 0f), ((Component)this).transform);
			if (k != 0)
			{
				Object.Instantiate<GameObject>(Wall, new Vector3((float)(Width / 2 * 6 - 3), Offset, (float)(k * 6)), Quaternion.Euler(-90f, 0f, 0f), ((Component)this).transform);
				continue;
			}
			Debug.Log((object)"Generate room");
			Object.Instantiate<GameObject>(Room, new Vector3((float)(Width / 2 * 6 - 3), Offset, (float)(k * 6)), Quaternion.Euler(0f, 90f, 0f), ((Component)this).transform);
		}
		Debug.Log((object)"Generate walls 2");
		for (int l = -Width / 2; l < Width / 2; l++)
		{
			Object.Instantiate<GameObject>(Wall, new Vector3((float)(l * 6), Offset, (float)(-Height / 2 * 6 - 3)), Quaternion.Euler(-90f, 90f, 0f), ((Component)this).transform);
			Object.Instantiate<GameObject>(Wall, new Vector3((float)(l * 6), Offset, (float)(Height / 2 * 6 - 3)), Quaternion.Euler(-90f, 90f, 0f), ((Component)this).transform);
		}
		Debug.Log((object)"Generate inside 2");
		for (int m = -Width / 2; m < Width / 2; m++)
		{
			for (int n = -Height / 2; n < Height / 2; n++)
			{
				if (m == 0 && n == 0)
				{
					continue;
				}
				int num = random.Next(20);
				if (num < 15)
				{
					if (random.Next(10) < 5)
					{
						Object.Instantiate<GameObject>(Wall, new Vector3((float)(m * 6 - 3), Offset, (float)(n * 6)), Quaternion.Euler(-90f, 0f, 0f), ((Component)this).transform);
					}
					else
					{
						Object.Instantiate<GameObject>(Wall, new Vector3((float)(m * 6), Offset, (float)(n * 6 - 3)), Quaternion.Euler(-90f, 90f, 0f), ((Component)this).transform);
					}
				}
				else if (num == 16)
				{
					Object.Instantiate<GameObject>(Pillar, new Vector3((float)(m * 6), Offset, (float)(n * 6)), Quaternion.Euler(-90f, 0f, 0f), ((Component)this).transform);
				}
				else
				{
					PossibleSpawnPoint.Add(new Vector2((float)(m * 6), (float)(n * 6)));
				}
			}
		}
		if (((NetworkBehaviour)this).IsServer)
		{
			((Component)this).GetComponent<NavMeshSurface>().BuildNavMesh();
			GameObject val3 = Loader.AssetBundle.LoadAsset<GameObject>("assets/backrooms/smile.prefab");
			for (int num2 = 0; num2 < Loader.NumberOfSmilers.Value; num2++)
			{
				Vector2 val4 = PossibleSpawnPoint[Random.Range(0, PossibleSpawnPoint.Count)];
				Object.Instantiate<GameObject>(val3, new Vector3(val4.x, Offset, val4.y), Quaternion.identity, ((Component)this).transform).GetComponent<NetworkObject>().Spawn(false);
			}
		}
	}

	[ServerRpc(RequireOwnership = false)]
	public void TeleportOutOfBackroomsServerRpc(ulong clientId)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3409688981u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, clientId);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3409688981u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				TeleportOutOfBackroomsClientRpc((int)clientId);
			}
		}
	}

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

	[RuntimeInitializeOnLoadMethod]
	internal static void InitializeRPCS_Backrooms()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Expected O, but got Unknown
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Expected O, but got Unknown
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Expected O, but got Unknown
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Expected O, but got Unknown
		NetworkManager.__rpc_func_table.Add(2180494496u, new RpcReceiveHandler(__rpc_handler_2180494496));
		NetworkManager.__rpc_func_table.Add(2541916904u, new RpcReceiveHandler(__rpc_handler_2541916904));
		NetworkManager.__rpc_func_table.Add(3078584200u, new RpcReceiveHandler(__rpc_handler_3078584200));
		NetworkManager.__rpc_func_table.Add(1623403188u, new RpcReceiveHandler(__rpc_handler_1623403188));
		NetworkManager.__rpc_func_table.Add(890432861u, new RpcReceiveHandler(__rpc_handler_890432861));
		NetworkManager.__rpc_func_table.Add(3409688981u, new RpcReceiveHandler(__rpc_handler_3409688981));
	}

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

	private static void __rpc_handler_2541916904(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			int client = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref client);
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((Backrooms)(object)target).TeleportToBackroomsServerRpc(client);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_3078584200(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			int client = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref client);
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((Backrooms)(object)target).TeleportToBackroomsClientRpc(client);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_1623403188(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			int client = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref client);
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((Backrooms)(object)target).TeleportOutOfBackroomsClientRpc(client);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_890432861(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			int seed = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref seed);
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((Backrooms)(object)target).GenerateClientRpc(seed);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_3409688981(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			ulong clientId = default(ulong);
			ByteUnpacker.ReadValueBitPacked(reader, ref clientId);
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((Backrooms)(object)target).TeleportOutOfBackroomsServerRpc(clientId);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	protected internal override string __getTypeName()
	{
		return "Backrooms";
	}
}
public class Exit : MonoBehaviour
{
	private void Start()
	{
	}

	private IEnumerator Teleport(ulong playerClientId)
	{
		StartOfRound.Instance.allPlayerScripts[playerClientId].beamOutParticle.Play();
		yield return (object)new WaitForSeconds(3f);
		Backrooms.Instance.TeleportOutOfBackroomsServerRpc(playerClientId);
	}

	private void OnTriggerEnter(Collider other)
	{
		PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
		if ((Object)(object)component != (Object)null)
		{
			((MonoBehaviour)this).StartCoroutine(Teleport(component.playerClientId));
			Backrooms.Instance.TeleportOutOfBackroomsServerRpc(component.playerClientId);
		}
	}
}
public static class Hook
{
	[HarmonyPatch(typeof(KillLocalPlayer), "KillPlayer")]
	[HarmonyPrefix]
	private static bool BeforeKilling(PlayerControllerB playerWhoTriggered)
	{
		if (playerWhoTriggered.isPlayerDead || !playerWhoTriggered.AllowPlayerDeath())
		{
			return true;
		}
		if (((Component)playerWhoTriggered).GetComponent<BackroomsHelper>().HasBeenInTheBackrooms)
		{
			return true;
		}
		Debug.Log((object)$"Killzone {Backrooms.Instance.SharedOdds.Value}");
		if ((float)Random.Range(0, 100) < Backrooms.Instance.SharedOdds.Value)
		{
			Backrooms.Instance.TeleportToBackroomsServerRpc((int)playerWhoTriggered.playerClientId);
			return false;
		}
		return true;
	}

	[HarmonyPatch(typeof(PlayerControllerB), "DamagePlayer")]
	[HarmonyPrefix]
	private static bool BeforeDamage(PlayerControllerB __instance)
	{
		if (__instance.isPlayerDead || !__instance.AllowPlayerDeath())
		{
			return true;
		}
		if (((Component)__instance).GetComponent<BackroomsHelper>().HasBeenInTheBackrooms)
		{
			return true;
		}
		Debug.Log((object)$"Damage taken {Backrooms.Instance.SharedOdds.Value}");
		if ((float)Random.Range(0, 100) < Backrooms.Instance.SharedOdds.Value)
		{
			Backrooms.Instance.TeleportToBackroomsServerRpc((int)__instance.playerClientId);
			return false;
		}
		return true;
	}

	[HarmonyPatch(typeof(PlayerControllerB), "Start")]
	[HarmonyPostfix]
	private static void AddComponents(PlayerControllerB __instance)
	{
		((Component)__instance).gameObject.AddComponent<BackroomsHelper>();
	}

	[HarmonyPatch(typeof(RoundManager), "Start")]
	[HarmonyPostfix]
	private static void SpawnBackrooms(RoundManager __instance)
	{
		//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)
		if (((NetworkBehaviour)__instance).IsServer)
		{
			Debug.Log((object)"Spawning backrooms");
			Object.Instantiate<GameObject>(Loader.AssetBundle.LoadAsset<GameObject>("assets/backrooms/backrooms.prefab"), new Vector3(0f, Backrooms.Offset, 0f), Quaternion.identity).GetComponent<NetworkObject>().Spawn(false);
		}
	}

	[HarmonyPatch(typeof(RoundManager), "UnloadSceneObjectsEarly")]
	[HarmonyPostfix]
	public static void DeleteBackrooms(RoundManager __instance)
	{
		if (((NetworkBehaviour)__instance).IsServer)
		{
			Backrooms.Instance.ServerClean();
		}
	}

	[HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
	[HarmonyPrefix]
	public static void GenerateBackrooms(RoundManager __instance)
	{
		if (((NetworkBehaviour)__instance).IsServer)
		{
			Backrooms.Instance.ServerGenerate();
		}
	}

	[HarmonyPatch(typeof(StartOfRound), "WritePlayerNotes")]
	[HarmonyPostfix]
	public static void BackroomsPlayerNote(StartOfRound __instance)
	{
		for (int i = 0; i < __instance.gameStats.allPlayerStats.Length; i++)
		{
			if (__instance.gameStats.allPlayerStats[i].isActivePlayer && ((Component)__instance.allPlayerScripts[i]).GetComponent<BackroomsHelper>().HasBeenInTheBackrooms)
			{
				if (__instance.allPlayerScripts[i].isPlayerDead)
				{
					__instance.gameStats.allPlayerStats[i].playerNotes.Add("Should have been more careful in the Backrooms.");
				}
				else
				{
					__instance.gameStats.allPlayerStats[i].playerNotes.Add("Had a blast in the Backrooms.");
				}
			}
		}
	}

	[HarmonyPatch(typeof(MenuManager), "Start")]
	[HarmonyPostfix]
	public static void NetworkManagerPatch(MenuManager __instance)
	{
		if (!NetworkManager.Singleton.NetworkConfig.Prefabs.Prefabs.Select((NetworkPrefab pref) => ((Object)pref.Prefab).name).Contains("backrooms"))
		{
			Debug.Log((object)"Load prefabs to Network Manager");
			string[] array = new string[2] { "assets/backrooms/backrooms.prefab", "assets/backrooms/smile.prefab" };
			foreach (string text in array)
			{
				GameObject val = Loader.AssetBundle.LoadAsset<GameObject>(text);
				NetworkManager.Singleton.AddNetworkPrefab(val);
			}
		}
	}
}
[BepInPlugin("Neekhaulas.Backrooms", "Backrooms", "0.1.3")]
public class Loader : BaseUnityPlugin
{
	public static AssetBundle AssetBundle { get; private set; }

	public static ConfigEntry<float> TeleportationOdds { get; private set; }

	public static ConfigEntry<int> NumberOfSmilers { get; private set; }

	private void Awake()
	{
		TeleportationOdds = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Teleportation odds", 3f, "Odds to be teleported (in %) - This settings has to be changed by the host");
		NumberOfSmilers = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Number of smilers", 1, "Number of smilers to spawn in the Backrooms - This settings has to be changed by the host");
		AssetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "backrooms"));
		Harmony.CreateAndPatchAll(typeof(Hook), (string)null);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Backrooms is loaded!");
		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);
				}
			}
		}
	}
}
public class SoundPatch : MonoBehaviour
{
	private void Start()
	{
		((Component)this).gameObject.AddComponent<OccludeAudio>();
		((Component)this).GetComponent<AudioSource>().Play();
	}
}
public class Smiler : NetworkBehaviour
{
	private NavMeshAgent NavMeshAgent;

	private PlayerControllerB Target;

	private void Start()
	{
		NavMeshAgent = ((Component)this).GetComponent<NavMeshAgent>();
	}

	private void Update()
	{
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: 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_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		if (!((NetworkBehaviour)this).IsServer)
		{
			return;
		}
		if ((Object)(object)Target != (Object)null && Target.isPlayerDead)
		{
			Target = null;
			NavMeshAgent.speed = 2f;
		}
		if (!NavMeshAgent.pathPending && NavMeshAgent.remainingDistance <= NavMeshAgent.stoppingDistance)
		{
			if (NavMeshAgent.hasPath)
			{
				Vector3 velocity = NavMeshAgent.velocity;
				if (((Vector3)(ref velocity)).sqrMagnitude != 0f)
				{
					goto IL_00f0;
				}
			}
			if ((Object)(object)Target != (Object)null)
			{
				NavMeshAgent.SetDestination(((Component)Target).transform.position);
			}
			else
			{
				int index = Random.Range(0, Backrooms.Instance.PossibleSpawnPoint.Count);
				NavMeshAgent.SetDestination(Vector2.op_Implicit(Backrooms.Instance.PossibleSpawnPoint[index]));
			}
		}
		goto IL_00f0;
		IL_00f0:
		for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
		{
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[i];
			if (val.isPlayerControlled && !val.isPlayerDead)
			{
				if (val.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up, 45f, 15, -1f))
				{
					Target = val;
					NavMeshAgent.SetDestination(((Component)val).transform.position);
					NavMeshAgent.speed = 7f;
					break;
				}
				bool flag = false;
				if ((Object)(object)val.currentlyHeldObjectServer != (Object)null && ((object)val.currentlyHeldObjectServer).GetType() == typeof(FlashlightItem) && val.currentlyHeldObjectServer.isBeingUsed)
				{
					flag = true;
				}
				if ((Object)(object)val.pocketedFlashlight != (Object)null && ((object)val.pocketedFlashlight).GetType() == typeof(FlashlightItem) && val.pocketedFlashlight.isBeingUsed)
				{
					flag = true;
				}
				if (flag && val.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up, 45f, 100, -1f))
				{
					Target = val;
					NavMeshAgent.SetDestination(((Component)val).transform.position);
					NavMeshAgent.speed = 7f;
				}
			}
		}
	}

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

	protected internal override string __getTypeName()
	{
		return "Smiler";
	}
}

plugins/BetterShotgunShells.dll

Decompiled 9 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalLib.Modules;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BuyableShells")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BuyableShells")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f1098099-7d96-4f78-bd10-8cf743e1f445")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BuyableShells;

[BepInPlugin("SalakStudios.BetterShotgunShells", "BetterShotgunShells", "1.0.2")]
public class Plugin : BaseUnityPlugin
{
	private const string modGUID = "SalakStudios.BetterShotgunShells";

	private const string modName = "BetterShotgunShells";

	private const string modVersion = "1.0.2";

	private readonly Harmony harmony = new Harmony("SalakStudios.BetterShotgunShells");

	internal static Plugin Instance;

	public static ManualLogSource mls;

	public bool added;

	public static ConfigEntry<int> ShellPrice;

	public static ConfigEntry<int> ItemRarityRend;

	public static ConfigEntry<int> ItemRarityDine;

	public static ConfigEntry<int> ItemRarityTitan;

	public List<Item> AllItems => Resources.FindObjectsOfTypeAll<Item>().Concat(Object.FindObjectsByType<Item>((FindObjectsInactive)1, (FindObjectsSortMode)1)).ToList();

	public Item ShotgunShell => ((IEnumerable<Item>)AllItems).FirstOrDefault((Func<Item, bool>)((Item item) => ((Object)item).name == "GunAmmo"));

	private void Awake()
	{
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		harmony.PatchAll(typeof(Plugin));
		mls = Logger.CreateLogSource("SalakStudios.BetterShotgunShells");
		mls.LogInfo((object)"BetterShotgunShells Enabled");
		SceneManager.sceneLoaded += OnSceneLoaded;
		ShellPrice = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Shell Price", 80, "How many credits the shotgun shell costs");
		ItemRarityRend = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Shell Rarity Rend", 2, "How rare the shell is to find on Rend (Lower = Rarer, Higher = More Common)");
		ItemRarityDine = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Shell Rarity Dine", 3, "How rare the shell is to find on Dine (Lower = Rarer, Higher = More Common)");
		ItemRarityTitan = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Shell Rarity Titan", 5, "How rare the shell is to find on Titan (Lower = Rarer, Higher = More Common)");
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		if (!added && ((Scene)(ref scene)).name == "MainMenu")
		{
			added = true;
			ShotgunShell.itemName = "Shells";
			ShotgunShell.creditsWorth = 0;
			Items.RegisterShopItem(ShotgunShell, ShellPrice.Value);
			Items.RegisterScrap(ShotgunShell, ItemRarityRend.Value, (LevelTypes)128);
			Items.RegisterScrap(ShotgunShell, ItemRarityDine.Value, (LevelTypes)256);
			Items.RegisterScrap(ShotgunShell, ItemRarityTitan.Value, (LevelTypes)512);
		}
	}
}

plugins/BetterTeleporter.dll

Decompiled 9 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BetterTeleporter.Config;
using BetterTeleporter.Patches;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BetterTeleporter")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Better Teleporters for Lethal Company")]
[assembly: AssemblyFileVersion("1.2.2.0")]
[assembly: AssemblyInformationalVersion("1.2.2")]
[assembly: AssemblyProduct("BetterTeleporter")]
[assembly: AssemblyTitle("BetterTeleporter")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BetterTeleporter
{
	[BepInPlugin("BetterTeleporter", "BetterTeleporter", "1.2.2")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("BetterTeleporter");

		internal static ManualLogSource log;

		public static Plugin instance { get; private set; }

		private void Awake()
		{
			instance = this;
			log = ((BaseUnityPlugin)this).Logger;
			ConfigSettings.Bind();
			harmony.PatchAll(typeof(ConfigSync));
			harmony.PatchAll(typeof(ShipTeleporterPatch));
			harmony.PatchAll(typeof(StartOfRoundPatch));
			log.LogInfo((object)"Plugin BetterTeleporter is loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "BetterTeleporter";

		public const string PLUGIN_NAME = "BetterTeleporter";

		public const string PLUGIN_VERSION = "1.2.2";
	}
}
namespace BetterTeleporter.Config
{
	public static class ConfigSettings
	{
		public static int cooldownAmmount;

		public static int cooldownAmmountInverse;

		public static bool cooldownEnd;

		public static string[] keepListItems;

		public static string[] keepListItemsInverse;

		public static bool doDrainItems;

		public static float drainItemsPercent;

		public static ConfigEntry<int> cooldown;

		public static ConfigEntry<int> cooldownInverse;

		public static ConfigEntry<bool> cooldownEndDay;

		public static ConfigEntry<string> keepList;

		public static ConfigEntry<string> keepListInverse;

		public static ConfigEntry<bool> doDrain;

		public static ConfigEntry<float> drainPercent;

		public static void Bind()
		{
			cooldown = ((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("General", "Cooldown", 10, "Number of seconds between teleporter uses");
			cooldownInverse = ((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("General", "CooldownInverse", 210, "Number of seconds between teleporter uses");
			cooldownEndDay = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("General", "CooldownEndsOnNewDay", true, "true/false if cooldown should end on new day");
			keepList = ((BaseUnityPlugin)Plugin.instance).Config.Bind<string>("General", "KeepItemList", "KeyItem,FlashlightItem,WalkieTalkie", "Comma-seperated list of items to be kept when teleported");
			keepListInverse = ((BaseUnityPlugin)Plugin.instance).Config.Bind<string>("General", "KeepItemListInverse", "KeyItem,FlashlightItem,WalkieTalkie,RadarBoosterItem", "Comma-seperated list of items to be kept when teleported with inverse teleporter");
			doDrain = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("General", "DrainItem", true, "true/false if items should drain battery charge");
			drainPercent = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("General", "DrainPercent", 0.5f, "The percentage (as float 0 to 1) of total charge that battery items lose when teleporting");
			cooldownAmmount = cooldown.Value;
			cooldownAmmountInverse = cooldownInverse.Value;
			cooldownEnd = cooldownEndDay.Value;
			SetKeepList(keepList.Value);
			SetKeepList(keepListInverse.Value, inverse: true);
			doDrainItems = doDrain.Value;
			drainItemsPercent = drainPercent.Value;
		}

		public static void SetKeepList(string list, bool inverse = false)
		{
			if (inverse)
			{
				keepListItemsInverse = list.Split(',');
				for (int i = 0; i < keepListItemsInverse.Length; i++)
				{
					keepListItemsInverse[i] = keepListItemsInverse[i].Trim();
				}
			}
			else
			{
				keepListItems = list.Split(',');
				for (int j = 0; j < keepListItems.Length; j++)
				{
					keepListItems[j] = keepListItems[j].Trim();
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	public class ConfigSync
	{
		[HarmonyPatch("ConnectClientToPlayerObject")]
		[HarmonyPostfix]
		public static void InitializeLocalPlayer()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			if (NetworkManager.Singleton.IsServer)
			{
				NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("BetterTeleporterConfigSync", new HandleNamedMessageDelegate(OnReceiveConfigSyncRequest));
				return;
			}
			NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("BetterTeleporterReceiveConfigSync", new HandleNamedMessageDelegate(OnReceiveConfigSync));
			NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("BetterTeleporterReceiveConfigSync_KeepList", new HandleNamedMessageDelegate(OnReceiveConfigSync_KeepList));
			NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("BetterTeleporterReceiveConfigSync_KeepListInverse", new HandleNamedMessageDelegate(OnReceiveConfigSync_KeepListInverse));
			RequestConfigSync();
		}

		public static void RequestConfigSync()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton.IsClient)
			{
				Plugin.log.LogInfo((object)"Sending config sync request to server.");
				FastBufferWriter val = default(FastBufferWriter);
				((FastBufferWriter)(ref val))..ctor(16, (Allocator)2, -1);
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("BetterTeleporterConfigSync", 0uL, val, (NetworkDelivery)3);
			}
			else
			{
				Plugin.log.LogWarning((object)"Failed to send config sync request.");
			}
		}

		public static void OnReceiveConfigSyncRequest(ulong clientId, FastBufferReader reader)
		{
			//IL_0051: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton.IsServer)
			{
				Plugin.log.LogInfo((object)("Receiving sync request from client with id: " + clientId + ". Sending config sync to client."));
				FastBufferWriter val = default(FastBufferWriter);
				((FastBufferWriter)(ref val))..ctor(14, (Allocator)2, -1);
				int value = ConfigSettings.cooldown.Value;
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref value, default(ForPrimitives));
				value = ConfigSettings.cooldownInverse.Value;
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref value, default(ForPrimitives));
				bool value2 = ConfigSettings.cooldownEndDay.Value;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref value2, default(ForPrimitives));
				value2 = ConfigSettings.doDrain.Value;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref value2, default(ForPrimitives));
				float value3 = ConfigSettings.drainPercent.Value;
				((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref value3, default(ForPrimitives));
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("BetterTeleporterReceiveConfigSync", clientId, val, (NetworkDelivery)3);
				FastBufferWriter val2 = default(FastBufferWriter);
				((FastBufferWriter)(ref val2))..ctor(ConfigSettings.keepList.Value.Length * 2, (Allocator)2, -1);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ConfigSettings.keepList.Value, true);
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("BetterTeleporterReceiveConfigSync_KeepList", clientId, val2, (NetworkDelivery)3);
				FastBufferWriter val3 = default(FastBufferWriter);
				((FastBufferWriter)(ref val3))..ctor(ConfigSettings.keepListInverse.Value.Length * 2, (Allocator)2, -1);
				((FastBufferWriter)(ref val3)).WriteValueSafe(ConfigSettings.keepListInverse.Value, true);
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("BetterTeleporterReceiveConfigSync_KeepListInverse", clientId, val3, (NetworkDelivery)3);
			}
		}

		public static void OnReceiveConfigSync(ulong clientId, FastBufferReader reader)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: 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)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: 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)
			FastBufferReader val = reader;
			if (((FastBufferReader)(ref val)).TryBeginRead(4))
			{
				Plugin.log.LogInfo((object)"Receiving sync from server.");
				val = reader;
				int num = default(int);
				((FastBufferReader)(ref val)).ReadValueSafe<int>(ref num, default(ForPrimitives));
				ConfigSettings.cooldownAmmount = num;
				Plugin.log.LogInfo((object)$"Recieved 'cooldownAmmount = {num}");
				val = reader;
				int num2 = default(int);
				((FastBufferReader)(ref val)).ReadValueSafe<int>(ref num2, default(ForPrimitives));
				ConfigSettings.cooldownAmmountInverse = num2;
				Plugin.log.LogInfo((object)$"Recieved 'cooldownAmmountInverse = {num2}");
				val = reader;
				bool flag = default(bool);
				((FastBufferReader)(ref val)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				ConfigSettings.cooldownEnd = flag;
				Plugin.log.LogInfo((object)$"Recieved 'cooldownEnd = {flag}");
				val = reader;
				bool flag2 = default(bool);
				((FastBufferReader)(ref val)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
				ConfigSettings.doDrainItems = flag2;
				Plugin.log.LogInfo((object)$"Recieved 'doDrainItems = {flag2}");
				val = reader;
				float num3 = default(float);
				((FastBufferReader)(ref val)).ReadValueSafe<float>(ref num3, default(ForPrimitives));
				ConfigSettings.drainItemsPercent = num3;
				Plugin.log.LogInfo((object)$"Recieved 'drainItemsPercent = {num3}");
			}
			else
			{
				Plugin.log.LogWarning((object)"Error receiving config sync from server.");
			}
		}

		public static void OnReceiveConfigSync_KeepList(ulong clientId, FastBufferReader reader)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			FastBufferReader val = reader;
			if (((FastBufferReader)(ref val)).TryBeginRead(4))
			{
				Plugin.log.LogInfo((object)"Receiving sync from server.");
				val = reader;
				string text = default(string);
				((FastBufferReader)(ref val)).ReadValueSafe(ref text, true);
				ConfigSettings.SetKeepList(text);
				Plugin.log.LogInfo((object)("Recieved 'keepList = " + text));
			}
			else
			{
				Plugin.log.LogWarning((object)"Error receiving keepList config sync from server.");
			}
		}

		public static void OnReceiveConfigSync_KeepListInverse(ulong clientId, FastBufferReader reader)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			FastBufferReader val = reader;
			if (((FastBufferReader)(ref val)).TryBeginRead(4))
			{
				Plugin.log.LogInfo((object)"Receiving sync from server.");
				val = reader;
				string text = default(string);
				((FastBufferReader)(ref val)).ReadValueSafe(ref text, true);
				ConfigSettings.SetKeepList(text, inverse: true);
				Plugin.log.LogInfo((object)("Recieved 'keepListInverse = " + text));
			}
			else
			{
				Plugin.log.LogWarning((object)"Error receiving keepListInverse config sync from server.");
			}
		}
	}
}
namespace BetterTeleporter.Patches
{
	[HarmonyPatch(typeof(ShipTeleporter))]
	public class ShipTeleporterPatch
	{
		private static readonly CodeMatch[] inverseTeleporterPatchIlMatch = (CodeMatch[])(object)new CodeMatch[4]
		{
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.IsLdloc(i, (LocalBuilder)null)), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsConstant(i, 1L)), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsConstant(i, 0L)), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Calls(i, originalMethodInfo)), (string)null)
		};

		private static readonly CodeMatch[] teleporterPatchIlMatch = (CodeMatch[])(object)new CodeMatch[5]
		{
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.IsLdarg(i, (int?)0)), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldfld), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsConstant(i, 1L)), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsConstant(i, 0L)), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Calls(i, originalMethodInfo)), (string)null)
		};

		private static readonly MethodInfo originalMethodInfo = typeof(PlayerControllerB).GetMethod("DropAllHeldItems", BindingFlags.Instance | BindingFlags.Public);

		private static readonly MethodInfo replaceMethodInfo = typeof(ShipTeleporterPatch).GetMethod("DropSomeItems", BindingFlags.Static | BindingFlags.NonPublic);

		[HarmonyTranspiler]
		[HarmonyPatch("TeleportPlayerOutWithInverseTeleporter")]
		public static IEnumerable<CodeInstruction> InverseTeleporterDropAllButHeldItem(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			val.Start();
			val.MatchForward(false, inverseTeleporterPatchIlMatch);
			val.Advance(1);
			val.RemoveInstructionsWithOffsets(0, 2);
			val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Ldc_I4_0, (object)1)
			});
			val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Ldc_I4_1, (object)1)
			});
			val.Insert((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Callvirt, (object)replaceMethodInfo)
			});
			Plugin.log.LogInfo((object)"Patched 'ShipTeleporterPatch.TeleportPlayerOutWithInverseTeleporter'");
			return val.Instructions();
		}

		[HarmonyTranspiler]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public static IEnumerable<CodeInstruction> TeleporterDropAllButHeldItem(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			val.End();
			val.MatchBack(false, teleporterPatchIlMatch);
			val.Advance(2);
			val.RemoveInstructionsWithOffsets(0, 2);
			val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Ldc_I4_0, (object)0)
			});
			val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Ldc_I4_1, (object)1)
			});
			val.Insert((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Callvirt, (object)replaceMethodInfo)
			});
			Plugin.log.LogInfo((object)"Patched 'ShipTeleporterPatch.beamUpPlayer'");
			return val.Instructions();
		}

		[HarmonyPatch("Awake")]
		[HarmonyPrefix]
		private static void Awake(ref bool ___isInverseTeleporter, ref float ___cooldownAmount)
		{
			if (___isInverseTeleporter)
			{
				___cooldownAmount = ConfigSettings.cooldownAmmountInverse;
			}
			else
			{
				___cooldownAmount = ConfigSettings.cooldownAmmount;
			}
		}

		private static void DropSomeItems(PlayerControllerB player, bool inverse = false, bool itemsFall = true)
		{
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			MethodInfo method = ((object)player).GetType().GetMethod("SetSpecialGrabAnimationBool", BindingFlags.Instance | BindingFlags.NonPublic);
			string[] source = ConfigSettings.keepListItems;
			if (inverse)
			{
				source = ConfigSettings.keepListItemsInverse;
			}
			float num = 1f;
			bool twoHanded = false;
			for (int i = 0; i < player.ItemSlots.Length; i++)
			{
				GrabbableObject val = player.ItemSlots[i];
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				if (source.Contains(((object)val).GetType().ToString()))
				{
					if (val.insertedBattery != null && ConfigSettings.doDrainItems)
					{
						float num2 = val.insertedBattery.charge - val.insertedBattery.charge * ConfigSettings.drainItemsPercent;
						if (num2 < 0f)
						{
							num2 = 0f;
						}
						val.insertedBattery = new Battery(num2 != 0f, num2);
						val.SyncBatteryServerRpc((int)(num2 * 100f));
					}
					num += Mathf.Clamp(val.itemProperties.weight - 1f, 0f, 10f);
					continue;
				}
				if (itemsFall)
				{
					val.parentObject = null;
					val.heldByPlayerOnServer = false;
					if (player.isInElevator)
					{
						((Component)val).transform.SetParent(player.playersManager.elevatorTransform, true);
					}
					else
					{
						((Component)val).transform.SetParent(player.playersManager.propsContainer, true);
					}
					player.SetItemInElevator(player.isInHangarShipRoom, player.isInElevator, val);
					val.EnablePhysics(true);
					val.EnableItemMeshes(true);
					((Component)val).transform.localScale = val.originalScale;
					val.isHeld = false;
					val.isPocketed = false;
					val.startFallingPosition = ((Component)val).transform.parent.InverseTransformPoint(((Component)val).transform.position);
					val.FallToGround(true);
					val.fallTime = Random.Range(-0.3f, 0.05f);
					if (((NetworkBehaviour)player).IsOwner)
					{
						val.DiscardItemOnClient();
					}
					else if (!val.itemProperties.syncDiscardFunction)
					{
						val.playerHeldBy = null;
					}
				}
				if (((NetworkBehaviour)player).IsOwner)
				{
					((Behaviour)HUDManager.Instance.holdingTwoHandedItem).enabled = false;
					((Behaviour)HUDManager.Instance.itemSlotIcons[i]).enabled = false;
					HUDManager.Instance.ClearControlTips();
					player.activatingItem = false;
				}
				player.ItemSlots[i] = null;
			}
			GrabbableObject val2 = player.ItemSlots[player.currentItemSlot];
			if ((Object)(object)val2 == (Object)null)
			{
				player.isHoldingObject = false;
				if ((Object)(object)player.currentlyHeldObjectServer != (Object)null)
				{
					method.Invoke(player, new object[2] { false, player.currentlyHeldObjectServer });
				}
				player.playerBodyAnimator.SetBool("cancelHolding", true);
				player.playerBodyAnimator.SetTrigger("Throw");
			}
			else
			{
				twoHanded = val2.itemProperties.twoHanded;
			}
			player.twoHanded = twoHanded;
			player.carryWeight = num;
			player.currentlyHeldObjectServer = val2;
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		private static readonly FieldInfo cooldownProp = typeof(ShipTeleporter).GetField("cooldownTime", BindingFlags.Instance | BindingFlags.NonPublic);

		[HarmonyPatch("StartGame")]
		[HarmonyPostfix]
		private static void StartGame()
		{
			if (ConfigSettings.cooldownEnd)
			{
				ResetCooldown();
			}
		}

		[HarmonyPatch("EndOfGame")]
		[HarmonyPostfix]
		private static void EndOfGame()
		{
			if (ConfigSettings.cooldownEnd)
			{
				ResetCooldown();
			}
		}

		[HarmonyPatch("EndOfGameClientRpc")]
		[HarmonyPostfix]
		private static void EndOfGameClientRpc()
		{
			if (ConfigSettings.cooldownEnd)
			{
				ResetCooldown();
			}
		}

		private static void ResetCooldown()
		{
			ShipTeleporter[] array = Object.FindObjectsOfType<ShipTeleporter>();
			ShipTeleporter[] array2 = array;
			foreach (ShipTeleporter obj in array2)
			{
				cooldownProp.SetValue(obj, 0f);
			}
		}
	}
}

plugins/BuyableShotgun.dll

Decompiled 9 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("BuyableShotgun")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("Copyright © 2023 MegaPiggy")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f4271793e57a966e00668122ac278845cc79146b")]
[assembly: AssemblyProduct("BuyableShotgun")]
[assembly: AssemblyTitle("BuyableShotgun")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BuyableShotgun
{
	[BepInDependency("evaisa.lethallib", "0.13.2")]
	[BepInPlugin("MegaPiggy.BuyableShotgun", "Buyable Shotgun", "1.0.4")]
	public class BuyableShotgun : BaseUnityPlugin
	{
		private const string modGUID = "MegaPiggy.BuyableShotgun";

		private const string modName = "Buyable Shotgun";

		private const string modVersion = "1.0.4";

		private readonly Harmony harmony = new Harmony("MegaPiggy.BuyableShotgun");

		private static BuyableShotgun Instance;

		private ConfigEntry<int> ShotgunPriceConfig;

		private static Dictionary<string, TerminalNode> infoNodes = new Dictionary<string, TerminalNode>();

		private static ManualLogSource LoggerInstance => ((BaseUnityPlugin)Instance).Logger;

		public List<Item> AllItems => Resources.FindObjectsOfTypeAll<Item>().Concat(Object.FindObjectsByType<Item>((FindObjectsInactive)1, (FindObjectsSortMode)1)).ToList();

		public Item Shotgun => ((IEnumerable<Item>)AllItems).FirstOrDefault((Func<Item, bool>)((Item item) => ((Object)item).name.Equals("Shotgun")));

		public Item ShotgunClone { get; private set; }

		public int ShotgunPrice => ShotgunPriceConfig.Value;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			harmony.PatchAll();
			ShotgunPriceConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Prices", "ShotgunPrice", 700, "Credits needed to buy shotgun");
			SceneManager.sceneLoaded += OnSceneLoaded;
			ShotgunClone = MakeNonScrap(ShotgunPrice);
			AddToShop();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Buyable Shotgun is loaded with version 1.0.4!");
		}

		private Item MakeNonScrap(int price)
		{
			//IL_00cb: 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)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			Item val = ScriptableObject.CreateInstance<Item>();
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).name = "Error";
			val.itemName = "Error";
			val.itemId = 6624;
			val.isScrap = false;
			val.creditsWorth = price;
			val.canBeGrabbedBeforeGameStart = true;
			val.automaticallySetUsingPower = false;
			val.batteryUsage = 300f;
			val.canBeInspected = false;
			val.isDefensiveWeapon = true;
			val.saveItemVariable = true;
			val.syncGrabFunction = false;
			val.twoHandedAnimation = true;
			val.verticalOffset = 0.25f;
			GameObject val2 = NetworkPrefabs.CreateNetworkPrefab("Cube");
			GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)3);
			val3.transform.SetParent(val2.transform, false);
			((Renderer)val3.GetComponent<MeshRenderer>()).sharedMaterial.shader = Shader.Find("HDRP/Lit");
			val2.AddComponent<BoxCollider>().size = Vector3.one * 2f;
			val2.AddComponent<AudioSource>();
			PhysicsProp val4 = val2.AddComponent<PhysicsProp>();
			((GrabbableObject)val4).itemProperties = val;
			((GrabbableObject)val4).grabbable = true;
			val.spawnPrefab = val2;
			val2.tag = "PhysicsProp";
			val2.layer = LayerMask.NameToLayer("Props");
			val3.layer = LayerMask.NameToLayer("Props");
			try
			{
				GameObject val5 = Object.Instantiate<GameObject>(Items.scanNodePrefab, val2.transform);
				((Object)val5).name = "ScanNode";
				val5.transform.localPosition = new Vector3(0f, 0f, 0f);
				Transform transform = val5.transform;
				transform.localScale *= 2f;
				ScanNodeProperties component = val5.GetComponent<ScanNodeProperties>();
				component.nodeType = 1;
				component.headerText = "Error";
				component.subText = "A mod is incompatible with Buyable Shotgun";
			}
			catch (Exception ex)
			{
				LoggerInstance.LogError((object)ex.ToString());
			}
			val2.transform.localScale = Vector3.one / 2f;
			return val;
		}

		private void CloneNonScrap(Item original, Item clone, int price)
		{
			Object.DontDestroyOnLoad((Object)(object)original.spawnPrefab);
			CopyFields(original, clone);
			((Object)clone).name = "Buyable" + ((Object)original).name;
			clone.creditsWorth = price;
		}

		public static void CopyFields(Item source, Item destination)
		{
			FieldInfo[] fields = typeof(Item).GetFields();
			FieldInfo[] array = fields;
			foreach (FieldInfo fieldInfo in array)
			{
				fieldInfo.SetValue(destination, fieldInfo.GetValue(source));
			}
		}

		private TerminalNode CreateInfoNode(string name, string description)
		{
			if (infoNodes.ContainsKey(name))
			{
				return infoNodes[name];
			}
			TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
			Object.DontDestroyOnLoad((Object)(object)val);
			val.clearPreviousText = true;
			((Object)val).name = name + "InfoNode";
			val.displayText = description + "\n\n";
			infoNodes.Add(name, val);
			return val;
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			LoggerInstance.LogInfo((object)("Scene \"" + ((Scene)(ref scene)).name + "\" loaded with " + ((object)(LoadSceneMode)(ref mode)).ToString() + " mode."));
			if (!((Object)(object)Shotgun == (Object)null))
			{
				CloneNonScrap(Shotgun, ShotgunClone, ShotgunPrice);
			}
		}

		private void AddToShop()
		{
			Item shotgunClone = ShotgunClone;
			int shotgunPrice = ShotgunPrice;
			Items.RegisterShopItem(shotgunClone, (TerminalNode)null, (TerminalNode)null, CreateInfoNode("Shotgun", "Nutcracker's shotgun. Can hold 2 shells. Recommended to keep safety on while not using or it might shoot randomly."), shotgunPrice);
			LoggerInstance.LogInfo((object)$"Shotgun added to Shop for {ShotgunPrice} credits");
		}
	}
}

plugins/ChillaxMods.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ChillaxMods.NetcodePatcher;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib;
using LethalLib.Extras;
using LethalLib.Modules;
using LethalThings;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using Unity.Netcode.Components;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ChillaxMods")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Chillax Mods")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ChillaxMods")]
[assembly: AssemblyTitle("ChillaxMods")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>();
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ChillaxMods
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "ChillaxMods";

		public const string PLUGIN_NAME = "ChillaxMods";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace Chillax.Bastard.BogBog
{
	public class Boink : NoisemakerProp
	{
		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_001f: 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_0033: 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_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)
			if (!((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)null))
			{
				PlayerControllerB playerHeldBy = ((GrabbableObject)this).playerHeldBy;
				Vector3 val = -((Component)this).transform.forward + Vector3.up;
				playerHeldBy.externalForces = ((Vector3)(ref val)).normalized * 500f;
				ChillaxModPlugin.logger.LogInfo((object)"[CHILLAX] ACTIVATE BOINK!");
				((NoisemakerProp)this).ItemActivate(used, buttonDown);
			}
		}

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

		protected internal override string __getTypeName()
		{
			return "Boink";
		}
	}
	[BepInPlugin("chillax.bastard.mod", "Chillax Mods", "0.6.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class ChillaxModPlugin : BaseUnityPlugin
	{
		public static ManualLogSource logger;

		public const string PluginGuid = "chillax.bastard.mod";

		public const string PluginName = "Chillax Mods";

		public const string PluginVersion = "0.6.0";

		public static readonly Harmony harmony = new Harmony("chillax.bastard.mod");

		public static ConfigFile config;

		public void Awake()
		{
			logger = ((BaseUnityPlugin)this).Logger;
			config = ((BaseUnityPlugin)this).Config;
			Config.Load();
			Content.Load();
			harmony.PatchAll(typeof(ChillaxModPlugin));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"CHILLAX Plugin Loaded");
		}
	}
	public class Config
	{
		public static ConfigEntry<int> boinkSpawnChance;

		public static ConfigEntry<int> cupNoodleSpawnChance;

		public static ConfigEntry<int> freddySpawnChance;

		public static ConfigEntry<int> nokiaSpawnChance;

		public static ConfigEntry<int> moaiSpawnChance;

		public static ConfigEntry<int> froggySpawnChance;

		public static ConfigEntry<int> eeveeSpawnChance;

		public static ConfigEntry<int> deathNoteSpawnChance;

		public static ConfigEntry<int> unoReverseSpawnChance;

		public static ConfigEntry<bool> canUseDeathNote;

		public static void Load()
		{
			boinkSpawnChance = ChillaxModPlugin.config.Bind<int>("Scrap", "Boink", 25, "How much does this Item spawn, higher = more common");
			cupNoodleSpawnChance = ChillaxModPlugin.config.Bind<int>("Scrap", "CupNoodle", 40, "How much does this Item spawn, higher = more common");
			freddySpawnChance = ChillaxModPlugin.config.Bind<int>("Scrap", "Freddy", 15, "How much does this Item spawn, higher = more common");
			nokiaSpawnChance = ChillaxModPlugin.config.Bind<int>("Scrap", "Nokia", 25, "How much does this Item spawn, higher = more common");
			moaiSpawnChance = ChillaxModPlugin.config.Bind<int>("Scrap", "Moai", 20, "How much does this Item spawn, higher = more common");
			froggySpawnChance = ChillaxModPlugin.config.Bind<int>("Scrap", "Froggy", 25, "How much does this Item spawn, higher = more common");
			eeveeSpawnChance = ChillaxModPlugin.config.Bind<int>("Scrap", "Eevee", 25, "How much does this Item spawn, higher = more common");
			deathNoteSpawnChance = ChillaxModPlugin.config.Bind<int>("Scrap", "DeathNote", 20, "How much does this Item spawn, higher = more common");
			canUseDeathNote = ChillaxModPlugin.config.Bind<bool>("Death Note", "DeathNoteActive", true, "Can the Death Note be used, turn this off to avoid griefing");
			unoReverseSpawnChance = ChillaxModPlugin.config.Bind<int>("Scrap", "UnoReverse", 20, "How much does this Item spawn, higher = more common");
		}
	}
	public class Content
	{
		public class CustomItem
		{
			public string name = "";

			public string itemPath = "";

			public string infoPath = "";

			public Action<Item> itemAction = delegate
			{
			};

			public bool enabled = true;

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

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

		public class CustomUnlockable
		{
			public string name = "";

			public string unlockablePath = "";

			public string infoPath = "";

			public Action<UnlockableItem> unlockableAction = delegate
			{
			};

			public bool enabled = true;

			public int unlockCost = -1;

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

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

		public class CustomShopItem : CustomItem
		{
			public int itemPrice;

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

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

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

			public int rarity;

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

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

		public class CustomEnemy
		{
			public string name;

			public string enemyPath;

			public int rarity;

			public LevelTypes levelFlags;

			public SpawnType spawnType;

			public string infoKeyword;

			public string infoNode;

			public bool enabled = true;

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

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

		public class CustomMapObject
		{
			public string name;

			public string objectPath;

			public LevelTypes levelFlags;

			public Func<SelectableLevel, AnimationCurve> spawnRateFunction;

			public bool enabled = true;

			public CustomMapObject(string name, string objectPath, LevelTypes levelFlags, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null, bool enabled = false)
			{
				//IL_001e: 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)
				this.name = name;
				this.objectPath = objectPath;
				this.levelFlags = levelFlags;
				this.spawnRateFunction = spawnRateFunction;
				this.enabled = enabled;
			}

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

		public static AssetBundle MainAssets;

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

		public static List<CustomUnlockable> customUnlockables;

		public static List<CustomItem> customItems;

		public static List<CustomEnemy> customEnemies;

		public static List<CustomMapObject> customMapObjects;

		public static GameObject ConfigManagerPrefab;

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

		public static void Load()
		{
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_0444: Unknown result type (might be due to invalid IL or missing references)
			//IL_044b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
			TryLoadAssets();
			customItems = new List<CustomItem>
			{
				CustomScrap.Add("Boink", "Assets/Chillax/ChillaxMods/Boink/Boink.asset", (LevelTypes)(-1), Config.boinkSpawnChance.Value),
				CustomScrap.Add("MamaMooSup", "Assets/Chillax/ChillaxMods/Cup Noodle/Cup Noodle.asset", (LevelTypes)(-1), Config.cupNoodleSpawnChance.Value),
				CustomScrap.Add("Freddy", "Assets/Chillax/ChillaxMods/FreddyFastBear/Freddy.asset", (LevelTypes)(-1), Config.freddySpawnChance.Value),
				CustomScrap.Add("Nokia", "Assets/Chillax/ChillaxMods/Nokia/Nokia.asset", (LevelTypes)(-1), Config.nokiaSpawnChance.Value),
				CustomScrap.Add("Moai", "Assets/Chillax/ChillaxMods/Moai/Moai.asset", (LevelTypes)(-1), Config.moaiSpawnChance.Value),
				CustomScrap.Add("Froggy", "Assets/Chillax/ChillaxMods/Froggy Chair/Froggy Chair.asset", (LevelTypes)(-1), Config.froggySpawnChance.Value),
				CustomScrap.Add("Eevee", "Assets/Chillax/ChillaxMods/Eevee Plush/Eevee.asset", (LevelTypes)(-1), Config.eeveeSpawnChance.Value),
				CustomScrap.Add("DeathNote", "Assets/Chillax/ChillaxMods/DeathNote/DeathNote.asset", (LevelTypes)(-1), Config.deathNoteSpawnChance.Value),
				CustomScrap.Add("UnoReverse", "Assets/Chillax/ChillaxMods/UnoReverse/UnoReverse.asset", (LevelTypes)(-1), Config.unoReverseSpawnChance.Value)
			};
			customEnemies = new List<CustomEnemy>();
			customUnlockables = new List<CustomUnlockable>();
			customMapObjects = new List<CustomMapObject>();
			foreach (CustomItem customItem in customItems)
			{
				if (customItem.enabled)
				{
					Item val = MainAssets.LoadAsset<Item>(customItem.itemPath);
					if ((Object)(object)val.spawnPrefab.GetComponent<NetworkTransform>() == (Object)null)
					{
						val.spawnPrefab.AddComponent<NetworkTransform>();
					}
					Prefabs.Add(customItem.name, val.spawnPrefab);
					NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
					customItem.itemAction(val);
					if (customItem is CustomShopItem)
					{
						TerminalNode val2 = MainAssets.LoadAsset<TerminalNode>(customItem.infoPath);
						Plugin.logger.LogInfo((object)$"Registering shop item {customItem.name} with price {((CustomShopItem)customItem).itemPrice}");
						Items.RegisterShopItem(val, (TerminalNode)null, (TerminalNode)null, val2, ((CustomShopItem)customItem).itemPrice);
					}
					else if (customItem is CustomScrap customScrap)
					{
						ChillaxModPlugin.logger.LogInfo((object)$"[CHILLAX] Registering... {val.itemName} at rarity {customScrap.rarity}");
						Items.RegisterScrap(val, customScrap.rarity, customScrap.levelType);
					}
				}
			}
			foreach (CustomUnlockable customUnlockable in customUnlockables)
			{
				if (customUnlockable.enabled)
				{
					UnlockableItem unlockable = MainAssets.LoadAsset<UnlockableItemDef>(customUnlockable.unlockablePath).unlockable;
					if ((Object)(object)unlockable.prefabObject != (Object)null)
					{
						NetworkPrefabs.RegisterNetworkPrefab(unlockable.prefabObject);
					}
					Prefabs.Add(customUnlockable.name, unlockable.prefabObject);
					TerminalNode val3 = null;
					if (customUnlockable.infoPath != null)
					{
						val3 = MainAssets.LoadAsset<TerminalNode>(customUnlockable.infoPath);
					}
					Unlockables.RegisterUnlockable(unlockable, (StoreType)2, (TerminalNode)null, (TerminalNode)null, val3, customUnlockable.unlockCost);
				}
			}
			foreach (CustomEnemy customEnemy in customEnemies)
			{
				if (customEnemy.enabled)
				{
					EnemyType val4 = MainAssets.LoadAsset<EnemyType>(customEnemy.enemyPath);
					TerminalNode val5 = MainAssets.LoadAsset<TerminalNode>(customEnemy.infoNode);
					TerminalKeyword val6 = null;
					if (customEnemy.infoKeyword != null)
					{
						val6 = MainAssets.LoadAsset<TerminalKeyword>(customEnemy.infoKeyword);
					}
					NetworkPrefabs.RegisterNetworkPrefab(val4.enemyPrefab);
					Prefabs.Add(customEnemy.name, val4.enemyPrefab);
					Enemies.RegisterEnemy(val4, customEnemy.rarity, customEnemy.levelFlags, customEnemy.spawnType, val5, val6);
				}
			}
			foreach (CustomMapObject customMapObject in customMapObjects)
			{
				if (customMapObject.enabled)
				{
					SpawnableMapObjectDef val7 = MainAssets.LoadAsset<SpawnableMapObjectDef>(customMapObject.objectPath);
					NetworkPrefabs.RegisterNetworkPrefab(val7.spawnableMapObject.prefabToSpawn);
					Prefabs.Add(customMapObject.name, val7.spawnableMapObject.prefabToSpawn);
					MapObjects.RegisterMapObject(val7, customMapObject.levelFlags, customMapObject.spawnRateFunction);
				}
			}
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			foreach (Type type in types)
			{
				MethodInfo[] methods = type.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);
					}
				}
			}
			Plugin.logger.LogInfo((object)"[CHILLAX] Custom content loaded!");
		}
	}
	public class DeathNote : NoisemakerProp
	{
		private NetworkVariable<bool> canUseDeathNote = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		[SerializeField]
		private AudioClip killSfx;

		[SerializeField]
		private GameObject canvasPrefab;

		private float _currentCooldown;

		[SerializeField]
		private float checkRate;

		[SerializeField]
		private Renderer deathNoteRenderer;

		[SerializeField]
		private Material[] materials;

		[SerializeField]
		private string[] textNodes;

		[SerializeField]
		private Sprite[] icons;

		[SerializeField]
		private ScanNodeProperties scanNodeProperties;

		private DeathNoteCanvas _temp;

		public List<PlayerControllerB> playerList;

		public List<EnemyAI> enemyList;

		private bool _opened;

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			canUseDeathNote = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);
			playerList = new List<PlayerControllerB>();
			enemyList = new List<EnemyAI>();
			Item itemProperties = Object.Instantiate<Item>(((GrabbableObject)this).itemProperties);
			((GrabbableObject)this).itemProperties = itemProperties;
			UpdateList();
			_opened = false;
			((MonoBehaviour)this).InvokeRepeating("ProcessCooldown", checkRate, checkRate);
			if (((NetworkBehaviour)this).IsHost)
			{
				canUseDeathNote.Value = Config.canUseDeathNote.Value;
				UpdateVisuals(0);
				UpdateVisualsClientRpc(0);
			}
		}

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

		private void UpdateVisuals(int index)
		{
			if ((Object)(object)deathNoteRenderer.material != (Object)(object)materials[index])
			{
				deathNoteRenderer.material = materials[index];
			}
			scanNodeProperties.headerText = textNodes[index];
			((GrabbableObject)this).itemProperties.itemName = textNodes[index];
			((GrabbableObject)this).itemProperties.itemIcon = icons[index];
		}

		[ServerRpc(RequireOwnership = false)]
		private void StartCooldownServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(246655775u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 246655775u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					Random random = new Random();
					StartCooldownClientRpc(_currentCooldown = random.Next(600, 1800));
				}
			}
		}

		[ClientRpc]
		private void StartCooldownClientRpc(float cooldown)
		{
			//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(316831956u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref cooldown, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 316831956u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					_currentCooldown = cooldown;
				}
			}
		}

		private void ProcessCooldown()
		{
			if (_currentCooldown > 0f)
			{
				_currentCooldown -= checkRate;
				UpdateVisuals(1);
			}
			else
			{
				UpdateVisuals(0);
			}
		}

		private void UpdateList()
		{
			List<PlayerControllerB> list = Object.FindObjectsOfType<PlayerControllerB>().ToList();
			List<PlayerControllerB> list2 = new List<PlayerControllerB>(list);
			foreach (PlayerControllerB item in list)
			{
				if (item.playerSteamId == 0)
				{
					list2.Remove(item);
				}
			}
			playerList = list2;
			enemyList = Object.FindObjectsOfType<EnemyAI>().ToList();
		}

		private void OnDisable()
		{
			if ((Object)(object)_temp != (Object)null)
			{
				_temp.Close();
			}
		}

		public override void DiscardItem()
		{
			((GrabbableObject)this).DiscardItem();
			if ((Object)(object)_temp != (Object)null)
			{
				_temp.Close();
			}
		}

		public override void PocketItem()
		{
			((GrabbableObject)this).PocketItem();
			if ((Object)(object)_temp != (Object)null)
			{
				_temp.Close();
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			if (canUseDeathNote.Value && !_opened && !(_currentCooldown > 0f))
			{
				((NoisemakerProp)this).ItemActivate(used, buttonDown);
				if (((NetworkBehaviour)((GrabbableObject)this).playerHeldBy).IsOwner)
				{
					UpdateList();
					_temp = Object.Instantiate<GameObject>(canvasPrefab, ((Component)this).transform).GetComponent<DeathNoteCanvas>();
					_temp.Initialize(this);
					_opened = true;
					Cursor.visible = true;
					Cursor.lockState = (CursorLockMode)0;
					DeathNoteCanvas temp = _temp;
					temp.onExit = (Action)Delegate.Combine(temp.onExit, new Action(OnExit));
				}
			}
		}

		private void OnExit()
		{
			Cursor.visible = false;
			Cursor.lockState = (CursorLockMode)1;
			_opened = false;
		}

		public void ActivateDeathNote(GameObject objectToKill)
		{
			OnExit();
			if (Object.op_Implicit((Object)(object)objectToKill.GetComponent<PlayerControllerB>()))
			{
				KillPlayer(objectToKill.GetComponent<PlayerControllerB>());
			}
			if (Object.op_Implicit((Object)(object)objectToKill.GetComponent<EnemyAI>()))
			{
				KillEnemy(objectToKill.GetComponent<EnemyAI>());
			}
			StartCooldownServerRpc();
		}

		private void KillPlayer(PlayerControllerB controller)
		{
			if (!((Object)(object)controller == (Object)null))
			{
				Debug.Log((object)("[CHILLAX] [DEATH NOTE] killing off player: " + controller.playerUsername));
				DeathNoteServerRpc(controller.playerClientId, ((NetworkBehaviour)controller).OwnerClientId);
			}
		}

		private void KillEnemy(EnemyAI enemy)
		{
			if (!((Object)(object)enemy == (Object)null))
			{
				Debug.Log((object)("[CHILLAX] [DEATH NOTE] killing off enemy: " + enemy.enemyType.enemyName));
				enemy.KillEnemyServerRpc(false);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void DeathNoteServerRpc(ulong playerID, ulong clientID)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2937588739u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerID);
					BytePacker.WriteValueBitPacked(val2, clientID);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2937588739u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					PlayerControllerB component = StartOfRound.Instance.allPlayerObjects[playerID].GetComponent<PlayerControllerB>();
					Debug.Log((object)("[DEATH NOTE] Receive Server RPC, player to kill: " + component.playerUsername));
					ClientRpcParams val3 = default(ClientRpcParams);
					val3.Send = new ClientRpcSendParams
					{
						TargetClientIds = new ulong[1] { clientID }
					};
					ClientRpcParams clientRpcParams = val3;
					DeathNoteClientRpc(component.playerClientId, clientRpcParams);
				}
			}
		}

		[ClientRpc]
		private void DeathNoteClientRpc(ulong playerID, ClientRpcParams clientRpcParams = default(ClientRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2281964886u, clientRpcParams, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val, playerID);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 2281964886u, clientRpcParams, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					PlayerControllerB component = StartOfRound.Instance.allPlayerObjects[playerID].GetComponent<PlayerControllerB>();
					Debug.Log((object)("[DEATH NOTE] Receive Client RPC, player to kill: " + component.playerUsername));
					Debug.Log((object)("[DEATH NOTE] Killing: " + component.playerUsername));
					((MonoBehaviour)this).StartCoroutine(KilLDelay(component));
				}
			}
		}

		private IEnumerator KilLDelay(PlayerControllerB controller)
		{
			if (((NetworkBehaviour)controller).IsOwner)
			{
				AudioSource tempSource = ((Component)controller).gameObject.AddComponent<AudioSource>();
				tempSource.PlayOneShot(killSfx);
				Object.Destroy((Object)(object)tempSource, 3f);
			}
			yield return (object)new WaitForSeconds(3f);
			controller.KillPlayer(Vector3.up * 10f, true, (CauseOfDeath)0, 0);
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_DeathNote()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(531245751u, new RpcReceiveHandler(__rpc_handler_531245751));
			NetworkManager.__rpc_func_table.Add(246655775u, new RpcReceiveHandler(__rpc_handler_246655775));
			NetworkManager.__rpc_func_table.Add(316831956u, new RpcReceiveHandler(__rpc_handler_316831956));
			NetworkManager.__rpc_func_table.Add(2937588739u, new RpcReceiveHandler(__rpc_handler_2937588739));
			NetworkManager.__rpc_func_table.Add(2281964886u, new RpcReceiveHandler(__rpc_handler_2281964886));
		}

		private static void __rpc_handler_531245751(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int index = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref index);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((DeathNote)(object)target).UpdateVisualsClientRpc(index);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		private static void __rpc_handler_316831956(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float cooldown = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref cooldown, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((DeathNote)(object)target).StartCooldownClientRpc(cooldown);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2937588739(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong playerID = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerID);
				ulong clientID = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref clientID);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((DeathNote)(object)target).DeathNoteServerRpc(playerID, clientID);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2281964886(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong playerID = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerID);
				ClientRpcParams client = rpcParams.Client;
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((DeathNote)(object)target).DeathNoteClientRpc(playerID, client);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "DeathNote";
		}
	}
	public class DeathNoteCanvas : MonoBehaviour
	{
		[SerializeField]
		private Button closeButton;

		[SerializeField]
		private GameObject namesPrefab;

		[SerializeField]
		private Transform contentContainer;

		private string _chosenName;

		private DeathNote _deathNote;

		public Action onExit;

		public void Initialize(DeathNote deathNote)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			foreach (Transform item in contentContainer)
			{
				Transform val = item;
				Object.Destroy((Object)(object)((Component)val).gameObject);
			}
			((UnityEvent)closeButton.onClick).AddListener(new UnityAction(Close));
			_deathNote = deathNote;
			onExit = (Action)Delegate.Combine(onExit, new Action(OnExit));
			foreach (PlayerControllerB player in deathNote.playerList)
			{
				if (!player.isPlayerDead)
				{
					DeathNoteName component = Object.Instantiate<GameObject>(namesPrefab, contentContainer).GetComponent<DeathNoteName>();
					component.Initialize(((Component)player).gameObject, _deathNote, this);
				}
			}
			foreach (EnemyAI enemy in deathNote.enemyList)
			{
				if (!enemy.isEnemyDead && enemy.enemyType.canDie)
				{
					DeathNoteName component2 = Object.Instantiate<GameObject>(namesPrefab, contentContainer).GetComponent<DeathNoteName>();
					component2.Initialize(((Component)enemy).gameObject, _deathNote, this);
				}
			}
		}

		private void OnExit()
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		public void Close()
		{
			onExit?.Invoke();
		}
	}
	public class DeathNoteName : MonoBehaviour
	{
		[SerializeField]
		private TMP_Text nameText;

		[SerializeField]
		private Button killButton;

		private GameObject _objectToKill;

		private DeathNote _deathNote;

		private DeathNoteCanvas _deathNoteCanvas;

		public void Initialize(GameObject objectToKill, DeathNote deathNote, DeathNoteCanvas deathNoteCanvas)
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			_deathNote = deathNote;
			_objectToKill = objectToKill;
			_deathNoteCanvas = deathNoteCanvas;
			if (Object.op_Implicit((Object)(object)objectToKill.GetComponent<PlayerControllerB>()))
			{
				nameText.text = objectToKill.GetComponent<PlayerControllerB>().playerUsername;
			}
			else
			{
				nameText.text = ((object)objectToKill.GetComponent<EnemyAI>().enemyType).ToString();
			}
			((UnityEvent)killButton.onClick).AddListener(new UnityAction(Kill));
		}

		private void Kill()
		{
			_deathNote.ActivateDeathNote(_objectToKill);
			_deathNoteCanvas.Close();
		}
	}
	public class Food : NoisemakerProp
	{
		[SerializeField]
		private int healAmount;

		[SerializeField]
		private float refuelAmount;

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			if (!((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)null))
			{
				if (((GrabbableObject)this).playerHeldBy.sprintMeter + refuelAmount > 1f)
				{
					((GrabbableObject)this).playerHeldBy.sprintMeter = 1f;
				}
				else
				{
					PlayerControllerB playerHeldBy = ((GrabbableObject)this).playerHeldBy;
					playerHeldBy.sprintMeter += refuelAmount;
				}
				if (((GrabbableObject)this).playerHeldBy.health + healAmount > 100)
				{
					((GrabbableObject)this).playerHeldBy.health = 100;
				}
				else
				{
					PlayerControllerB playerHeldBy2 = ((GrabbableObject)this).playerHeldBy;
					playerHeldBy2.health += healAmount;
				}
				((MonoBehaviour)this).StartCoroutine(DestroyDelay());
				ChillaxModPlugin.logger.LogInfo((object)"[CHILLAX] EAT FOOD!!");
				((NoisemakerProp)this).ItemActivate(used, buttonDown);
			}
		}

		private IEnumerator DestroyDelay()
		{
			yield return (object)new WaitForSeconds(0.5f);
			((GrabbableObject)this).DestroyObjectInHand(((GrabbableObject)this).playerHeldBy);
		}

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

		protected internal override string __getTypeName()
		{
			return "Food";
		}
	}
	public class UnoReverse : NoisemakerProp
	{
		public AudioClip teleportClip;

		public List<PlayerControllerB> playerList;

		public List<EnemyAI> outsideEnemyList;

		public List<EnemyAI> insideEnemyList;

		private bool _isRed = false;

		[SerializeField]
		private Renderer renderer;

		[SerializeField]
		private Material blueUnoMat;

		[SerializeField]
		private Material redUnoMat;

		private bool _used;

		public override void OnNetworkSpawn()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			((NetworkBehaviour)this).OnNetworkSpawn();
			playerList = new List<PlayerControllerB>();
			_used = false;
			if (((NetworkBehaviour)this).IsHost)
			{
				ReplicateBoolClientRpc(_isRed = Random.Range(0f, 100f) > 50f);
			}
		}

		private void FixedUpdate()
		{
			if ((Object)(object)renderer != (Object)null)
			{
				renderer.material = (_isRed ? redUnoMat : blueUnoMat);
			}
		}

		[ClientRpc(/*Could not decode attribute arguments.*/)]
		private void ReplicateBoolClientRpc(bool chance, ClientRpcParams clientRpcParams = default(ClientRpcParams))
		{
			//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))
				{
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(223203488u, clientRpcParams, (RpcDelivery)0);
					((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref chance, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 223203488u, clientRpcParams, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					_isRed = chance;
				}
			}
		}

		private void UpdateList()
		{
			List<PlayerControllerB> list = Object.FindObjectsOfType<PlayerControllerB>().ToList();
			List<PlayerControllerB> list2 = new List<PlayerControllerB>(list);
			foreach (PlayerControllerB item in list)
			{
				if (item.playerSteamId == 0)
				{
					list2.Remove(item);
				}
			}
			playerList = list2;
			outsideEnemyList = new List<EnemyAI>();
			insideEnemyList = new List<EnemyAI>();
			foreach (EnemyAI outsideEnemy in outsideEnemyList)
			{
				Debug.Log((object)("[UNO REVERSE CARD] Outside Enemy: " + outsideEnemy.enemyType.enemyName));
			}
			foreach (EnemyAI outsideEnemy2 in outsideEnemyList)
			{
				Debug.Log((object)("[UNO REVERSE CARD] Inside Enemy: " + outsideEnemy2.enemyType.enemyName));
			}
			outsideEnemyList.Clear();
			insideEnemyList.Clear();
			List<EnemyAI> list3 = Object.FindObjectsOfType<EnemyAI>().ToList();
			foreach (EnemyAI item2 in list3)
			{
				if (item2.enemyType.isOutsideEnemy)
				{
					outsideEnemyList.Add(item2);
				}
				else
				{
					insideEnemyList.Add(item2);
				}
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: 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)
			if (!((NetworkBehaviour)((GrabbableObject)this).playerHeldBy).IsOwner || _used)
			{
				return;
			}
			((NoisemakerProp)this).ItemActivate(used, buttonDown);
			UpdateList();
			int num = 0;
			if (_isRed)
			{
				if (((GrabbableObject)this).playerHeldBy.isInsideFactory)
				{
					num = Random.Range(0, insideEnemyList.Count);
					if (insideEnemyList.Count > 0)
					{
						foreach (EnemyAI insideEnemy in insideEnemyList)
						{
							Debug.Log((object)("[CHILLAX] [UNO REVERSE] Enemies in Game: " + insideEnemy.enemyType.enemyName));
						}
						SwapEnemyServerRpc(num);
						((MonoBehaviour)this).StartCoroutine(DestroyDelay());
						return;
					}
				}
				else
				{
					num = Random.Range(0, outsideEnemyList.Count);
					if (outsideEnemyList.Count > 0)
					{
						foreach (EnemyAI outsideEnemy in outsideEnemyList)
						{
							Debug.Log((object)("[CHILLAX] [UNO REVERSE] Enemies in Game: " + outsideEnemy.enemyType.enemyName));
						}
						SwapEnemyServerRpc(num, outside: true);
						((MonoBehaviour)this).StartCoroutine(DestroyDelay());
						return;
					}
				}
			}
			foreach (PlayerControllerB player in playerList)
			{
				Debug.Log((object)("[CHILLAX] [UNO REVERSE] Players in Game: " + player.playerUsername));
			}
			playerList.Remove(((GrabbableObject)this).playerHeldBy);
			num = Random.Range(0, playerList.Count);
			if (playerList.Count <= 0)
			{
				Debug.LogWarning((object)"[CHILLAX] [UNO REVERSE] No players to swap with");
			}
			foreach (PlayerControllerB player2 in playerList)
			{
				Debug.Log((object)("[CHILLAX] [UNO REVERSE] Potential Swappers: " + player2.playerUsername));
			}
			PlayerControllerB val = playerList[num];
			Vector3 position = GetPosition(((GrabbableObject)this).playerHeldBy);
			Vector3 position2 = GetPosition(val);
			Vector3 val2 = position2;
			string? text = ((object)(Vector3)(ref val2)).ToString();
			val2 = position;
			Debug.Log((object)("Teleporting to: " + text + " From: " + ((object)(Vector3)(ref val2)).ToString()));
			_used = true;
			SwapServerRpc(position, position2, val.actualClientId, val.playerClientId);
			((MonoBehaviour)this).StartCoroutine(DestroyDelay());
		}

		private Vector3 GetPosition(PlayerControllerB player)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(((Component)player).transform.position, RoundManager.Instance.navHit, 2.7f, -1);
			((Vector3)(ref navMeshPosition))..ctor(((Component)player).transform.position.x, navMeshPosition.y, ((Component)player).transform.position.z);
			return navMeshPosition;
		}

		private Vector3 GetPosition(Vector3 pos)
		{
			//IL_0006: 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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(pos, RoundManager.Instance.navHit, 2.7f, -1);
			((Vector3)(ref navMeshPosition))..ctor(pos.x, navMeshPosition.y, pos.z);
			return navMeshPosition;
		}

		[ServerRpc(RequireOwnership = false)]
		private void SwapServerRpc(Vector3 firstPosition, Vector3 secondPosition, ulong otherId, ulong otherPlayerId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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_008b: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1017133487u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref firstPosition);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref secondPosition);
					BytePacker.WriteValueBitPacked(val2, otherId);
					BytePacker.WriteValueBitPacked(val2, otherPlayerId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1017133487u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					_used = true;
					Debug.Log((object)"Teleporting... SERVER RPC");
					Teleport(firstPosition, secondPosition, otherId, otherPlayerId);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void SwapEnemyServerRpc(int randIndex, bool outside = false)
		{
			//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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: 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_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: 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_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1470963546u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, randIndex);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref outside, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1470963546u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					_used = true;
					EnemyAI val3 = (outside ? outsideEnemyList[randIndex] : insideEnemyList[randIndex]);
					ClientRpcParams val4 = default(ClientRpcParams);
					val4.Send = new ClientRpcSendParams
					{
						TargetClientIds = new ulong[1] { ((NetworkBehaviour)((GrabbableObject)this).playerHeldBy).OwnerClientId }
					};
					ClientRpcParams clientRpcParams = val4;
					Vector3 position = GetPosition(((Component)((GrabbableObject)this).playerHeldBy).transform.position);
					Vector3 position2 = GetPosition(((Component)val3).transform.position);
					Utilities.TeleportPlayer((int)((GrabbableObject)this).playerHeldBy.playerClientId, position2);
					TeleportOnClientRpc(position2, ((GrabbableObject)this).playerHeldBy.isInElevator, ((GrabbableObject)this).playerHeldBy.isInHangarShipRoom, ((GrabbableObject)this).playerHeldBy.isInsideFactory, clientRpcParams);
					Utilities.TeleportEnemy(val3, position);
					TeleportEnemyClientRpc(randIndex, position, outside);
				}
			}
		}

		[ClientRpc]
		private void TeleportEnemyClientRpc(int randIndex, Vector3 playerPosition, bool outside = false)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: 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(1745445435u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, randIndex);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref playerPosition);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref outside, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1745445435u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					EnemyAI val3 = (outside ? outsideEnemyList[randIndex] : insideEnemyList[randIndex]);
					Utilities.TeleportEnemy(val3, playerPosition);
				}
			}
		}

		private void Teleport(Vector3 firstPosition, Vector3 secondPosition, ulong otherClientId, ulong otherPlayerId)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_007b: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			ClientRpcParams val = default(ClientRpcParams);
			val.Send = new ClientRpcSendParams
			{
				TargetClientIds = new ulong[1] { ((NetworkBehaviour)((GrabbableObject)this).playerHeldBy).OwnerClientId }
			};
			ClientRpcParams clientRpcParams = val;
			val = default(ClientRpcParams);
			val.Send = new ClientRpcSendParams
			{
				TargetClientIds = new ulong[1] { otherClientId }
			};
			ClientRpcParams clientRpcParams2 = val;
			Utilities.TeleportPlayer((int)((GrabbableObject)this).playerHeldBy.playerClientId, secondPosition);
			Utilities.TeleportPlayer((int)otherPlayerId, firstPosition);
			if (!((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)null))
			{
				PlayerControllerB val2 = StartOfRound.Instance.allPlayerScripts[((GrabbableObject)this).playerHeldBy.playerClientId];
				PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[otherPlayerId];
				TeleportOnClientRpc(secondPosition, val3.isInElevator, val3.isInHangarShipRoom, val3.isInsideFactory, clientRpcParams);
				TeleportOnClientRpc(firstPosition, val2.isInElevator, val2.isInHangarShipRoom, val2.isInsideFactory, clientRpcParams2);
				bool isInElevator = ((GrabbableObject)this).playerHeldBy.isInElevator;
				bool isInHangarShipRoom = ((GrabbableObject)this).playerHeldBy.isInHangarShipRoom;
				bool isInsideFactory = ((GrabbableObject)this).playerHeldBy.isInsideFactory;
				val2.isInElevator = val3.isInElevator;
				val2.isInHangarShipRoom = val3.isInHangarShipRoom;
				val2.isInsideFactory = val3.isInsideFactory;
				val3.isInElevator = isInElevator;
				val3.isInHangarShipRoom = isInHangarShipRoom;
				val3.isInsideFactory = isInsideFactory;
				PlayExtraClipClientRpc(clientRpcParams2);
			}
		}

		[ClientRpc]
		private void TeleportOnClientRpc(Vector3 position, bool inElevator, bool inHangar, bool inFactory, ClientRpcParams clientRpcParams = default(ClientRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: 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))
				{
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2006694156u, clientRpcParams, (RpcDelivery)0);
					((FastBufferWriter)(ref val)).WriteValueSafe(ref position);
					((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref inElevator, default(ForPrimitives));
					((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref inHangar, default(ForPrimitives));
					((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref inFactory, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 2006694156u, clientRpcParams, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
					localPlayerController.isInElevator = inElevator;
					localPlayerController.isInHangarShipRoom = inHangar;
					localPlayerController.isInsideFactory = inFactory;
					_used = true;
					Utilities.TeleportPlayer((int)StartOfRound.Instance.localPlayerController.playerClientId, position);
				}
			}
		}

		[ClientRpc]
		private void PlayExtraClipClientRpc(ClientRpcParams clientRpcParams = default(ClientRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(457107265u, clientRpcParams, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 457107265u, clientRpcParams, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				AudioSource val2 = ((Component)StartOfRound.Instance.localPlayerController).gameObject.AddComponent<AudioSource>();
				if (!((Object)(object)teleportClip == (Object)null))
				{
					val2.PlayOneShot(teleportClip);
					Object.Destroy((Object)(object)val2, 2f);
				}
			}
		}

		private IEnumerator DestroyDelay()
		{
			yield return (object)new WaitForSeconds(1f);
			((GrabbableObject)this).DestroyObjectInHand(((GrabbableObject)this).playerHeldBy);
			DestroyServerRpc();
		}

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

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

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_UnoReverse()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(223203488u, new RpcReceiveHandler(__rpc_handler_223203488));
			NetworkManager.__rpc_func_table.Add(1017133487u, new RpcReceiveHandler(__rpc_handler_1017133487));
			NetworkManager.__rpc_func_table.Add(1470963546u, new RpcReceiveHandler(__rpc_handler_1470963546));
			NetworkManager.__rpc_func_table.Add(1745445435u, new RpcReceiveHandler(__rpc_handler_1745445435));
			NetworkManager.__rpc_func_table.Add(2006694156u, new RpcReceiveHandler(__rpc_handler_2006694156));
			NetworkManager.__rpc_func_table.Add(457107265u, new RpcReceiveHandler(__rpc_handler_457107265));
			NetworkManager.__rpc_func_table.Add(3051293639u, new RpcReceiveHandler(__rpc_handler_3051293639));
			NetworkManager.__rpc_func_table.Add(1058296590u, new RpcReceiveHandler(__rpc_handler_1058296590));
		}

		private static void __rpc_handler_223203488(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_003e: 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_0044: 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_005d: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool chance = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref chance, default(ForPrimitives));
				ClientRpcParams client = rpcParams.Client;
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((UnoReverse)(object)target).ReplicateBoolClientRpc(chance, client);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1017133487(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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_006c: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 firstPosition = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref firstPosition);
				Vector3 secondPosition = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref secondPosition);
				ulong otherId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref otherId);
				ulong otherPlayerId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref otherPlayerId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((UnoReverse)(object)target).SwapServerRpc(firstPosition, secondPosition, otherId, otherPlayerId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1470963546(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int randIndex = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref randIndex);
				bool outside = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref outside, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((UnoReverse)(object)target).SwapEnemyServerRpc(randIndex, outside);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1745445435(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int randIndex = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref randIndex);
				Vector3 playerPosition = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref playerPosition);
				bool outside = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref outside, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((UnoReverse)(object)target).TeleportEnemyClientRpc(randIndex, playerPosition, outside);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2006694156(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				bool inElevator = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref inElevator, default(ForPrimitives));
				bool inHangar = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref inHangar, default(ForPrimitives));
				bool inFactory = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref inFactory, default(ForPrimitives));
				ClientRpcParams client = rpcParams.Client;
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((UnoReverse)(object)target).TeleportOnClientRpc(position, inElevator, inHangar, inFactory, client);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_457107265(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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ClientRpcParams client = rpcParams.Client;
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((UnoReverse)(object)target).PlayExtraClipClientRpc(client);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

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

		protected internal override string __getTypeName()
		{
			return "UnoReverse";
		}
	}
	public class Utilities
	{
		public static void TeleportPlayer(int playerObj, Vector3 teleportPos)
		{
			//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_0030: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerObj];
			val.averageVelocity = 0f;
			val.velocityLastFrame = Vector3.zero;
			StartOfRound.Instance.allPlayerScripts[playerObj].TeleportPlayer(teleportPos, false, 0f, false, true);
			StartOfRound.Instance.allPlayerScripts[playerObj].beamOutParticle.Play();
			if ((Object)(object)val == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
			}
		}
	}
}
namespace ChillaxMods.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}

plugins/com.github.zehsteam.Hitmarker.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using com.github.zehsteam.Hitmarker.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.zehsteam.Hitmarker")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Shows a hitmarker when you successfully hit an enemy. (Client-side)")]
[assembly: AssemblyFileVersion("1.1.4.0")]
[assembly: AssemblyInformationalVersion("1.1.4+a7c2365da6322e73bda02c35a038243249fa59d9")]
[assembly: AssemblyProduct("Hitmarker")]
[assembly: AssemblyTitle("com.github.zehsteam.Hitmarker")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.4.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace com.github.zehsteam.Hitmarker
{
	internal class CanvasBehaviour : MonoBehaviour
	{
		public static CanvasBehaviour Instance;

		private Image hitmarkerImage;

		private Transform messageList;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
		}

		private void Start()
		{
			hitmarkerImage = ((Component)((Component)this).transform.GetChild(0)).gameObject.GetComponent<Image>();
			((Component)hitmarkerImage).gameObject.SetActive(false);
			messageList = ((Component)this).transform.GetChild(1);
			SetHitmarkerImageSize(HitmarkerBase.Instance.configManager.HitmarkerImageSize);
		}

		public void SetHitmarkerImageSize(int size)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)hitmarkerImage).rectTransform.sizeDelta = new Vector2((float)size, (float)size);
		}

		public void ShowHitmarker(bool killed)
		{
			if (HitmarkerBase.Instance.configManager.ShowHitmarkerImage)
			{
				((MonoBehaviour)this).StopCoroutine("ShowHitmarkerImage");
				((MonoBehaviour)this).StartCoroutine(ShowHitmarkerImage(0.3f, killed));
			}
			if (HitmarkerBase.Instance.configManager.PlayHitmarkerSound)
			{
				HUDManager.Instance.UIAudio.PlayOneShot(HitmarkerBase.Instance.hitSFX);
			}
		}

		private IEnumerator ShowHitmarkerImage(float time, bool killed)
		{
			if (killed)
			{
				((Graphic)hitmarkerImage).color = Color.red;
			}
			((Component)hitmarkerImage).gameObject.SetActive(true);
			yield return (object)new WaitForSeconds(time);
			((Component)hitmarkerImage).gameObject.SetActive(false);
			((Graphic)hitmarkerImage).color = Color.white;
		}

		public void ShowDamageMessage(string message)
		{
			if (HitmarkerBase.Instance.configManager.ShowDamageMessage)
			{
				ShowMessage(message);
			}
		}

		public void ShowKillMessage(string message, bool fromLocalPlayer)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			if (HitmarkerBase.Instance.configManager.ShowKillMessage && (!HitmarkerBase.Instance.configManager.OnlyShowLocalKillMessage || fromLocalPlayer))
			{
				ShowMessage(message, Color.red);
			}
		}

		public void ShowMessage(string message)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			ShowMessage(message, Color.white);
		}

		public void ShowMessage(string message, Color color)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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)
			GameObject val = Object.Instantiate<GameObject>(HitmarkerBase.Instance.messageTextPrefab, Vector3.zero, Quaternion.identity, messageList);
			TextBehaviour component = val.GetComponent<TextBehaviour>();
			component.SetText(message, color);
		}
	}
	internal class ConfigManager
	{
		private ConfigEntry<bool> ShowHitmarkerImageCfg;

		private ConfigEntry<int> HitmarkerImageSizeCfg;

		private ConfigEntry<bool> PlayHitmarkerSoundCfg;

		private ConfigEntry<bool> UseOriginalEnemyNamesCfg;

		private ConfigEntry<bool> ShowDamageMessageCfg;

		private ConfigEntry<bool> ShowKillMessageCfg;

		private ConfigEntry<bool> OnlyShowLocalKillMessageCfg;

		internal bool ShowHitmarkerImage
		{
			get
			{
				return ShowHitmarkerImageCfg.Value;
			}
			set
			{
				ShowHitmarkerImageCfg.Value = value;
			}
		}

		internal int HitmarkerImageSize
		{
			get
			{
				return HitmarkerImageSizeCfg.Value;
			}
			set
			{
				int num = Math.Clamp(value, 10, 500);
				HitmarkerImageSizeCfg.Value = num;
				CanvasBehaviour.Instance.SetHitmarkerImageSize(num);
			}
		}

		internal bool PlayHitmarkerSound
		{
			get
			{
				return PlayHitmarkerSoundCfg.Value;
			}
			set
			{
				PlayHitmarkerSoundCfg.Value = value;
			}
		}

		internal bool UseOriginalEnemyNames
		{
			get
			{
				return UseOriginalEnemyNamesCfg.Value;
			}
			set
			{
				UseOriginalEnemyNamesCfg.Value = value;
			}
		}

		internal bool ShowDamageMessage
		{
			get
			{
				return ShowDamageMessageCfg.Value;
			}
			set
			{
				ShowDamageMessageCfg.Value = value;
			}
		}

		internal bool ShowKillMessage
		{
			get
			{
				return ShowKillMessageCfg.Value;
			}
			set
			{
				ShowKillMessageCfg.Value = value;
			}
		}

		internal bool OnlyShowLocalKillMessage
		{
			get
			{
				return OnlyShowLocalKillMessageCfg.Value;
			}
			set
			{
				OnlyShowLocalKillMessageCfg.Value = value;
			}
		}

		public ConfigManager()
		{
			BindConfigs();
		}

		private void BindConfigs()
		{
			//IL_0018: 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_0033: Expected O, but got Unknown
			//IL_0033: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_0060: Expected O, but got Unknown
			//IL_0071: 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_008c: Expected O, but got Unknown
			//IL_008c: Expected O, but got Unknown
			//IL_009d: 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_00b8: Expected O, but got Unknown
			//IL_00b8: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Expected O, but got Unknown
			//IL_00e4: Expected O, but got Unknown
			//IL_00f5: 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)
			//IL_0110: Expected O, but got Unknown
			//IL_0110: Expected O, but got Unknown
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Expected O, but got Unknown
			//IL_013c: Expected O, but got Unknown
			ConfigFile config = ((BaseUnityPlugin)HitmarkerBase.Instance).Config;
			ShowHitmarkerImageCfg = config.Bind<bool>(new ConfigDefinition("Hitmarker Settings", "showHitmarkerImage"), true, new ConfigDescription("Do you want to show the hitmarker image?", (AcceptableValueBase)null, Array.Empty<object>()));
			HitmarkerImageSizeCfg = config.Bind<int>(new ConfigDefinition("Hitmarker Settings", "hitmarkerImageSize"), 40, new ConfigDescription("The size of the hitmarker image in pixels.", (AcceptableValueBase)null, Array.Empty<object>()));
			PlayHitmarkerSoundCfg = config.Bind<bool>(new ConfigDefinition("Hitmarker Settings", "playHitmarkerSound"), true, new ConfigDescription("Do you want to play the hitmarker sound?", (AcceptableValueBase)null, Array.Empty<object>()));
			UseOriginalEnemyNamesCfg = config.Bind<bool>(new ConfigDefinition("Message Settings", "useOriginalEnemyNames"), true, new ConfigDescription("Messages will use the original enemy names.", (AcceptableValueBase)null, Array.Empty<object>()));
			ShowDamageMessageCfg = config.Bind<bool>(new ConfigDefinition("Message Settings", "showDamageMessage"), true, new ConfigDescription("Shows a message of how much damage you did to an enemy.", (AcceptableValueBase)null, Array.Empty<object>()));
			ShowKillMessageCfg = config.Bind<bool>(new ConfigDefinition("Message Settings", "showKillMessage"), true, new ConfigDescription("Shows a message when an enemy is killed.", (AcceptableValueBase)null, Array.Empty<object>()));
			OnlyShowLocalKillMessageCfg = config.Bind<bool>(new ConfigDefinition("Message Settings", "onlyShowLocalKillMessage"), true, new ConfigDescription("Will only show your kill messages.", (AcceptableValueBase)null, Array.Empty<object>()));
		}
	}
	[BepInPlugin("com.github.zehsteam.Hitmarker", "Hitmarker", "1.1.4")]
	public class HitmarkerBase : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("com.github.zehsteam.Hitmarker");

		internal static HitmarkerBase Instance;

		internal static ManualLogSource mls;

		internal ConfigManager configManager;

		public GameObject canvasPrefab;

		public AudioClip hitSFX;

		public GameObject messageTextPrefab;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("com.github.zehsteam.Hitmarker");
			mls.LogInfo((object)"Hitmarker has awoken!");
			harmony.PatchAll(typeof(RoundManagerPatch));
			harmony.PatchAll(typeof(HUDManagerPatch));
			harmony.PatchAll(typeof(EnemyAIPatch));
			configManager = new ConfigManager();
			LoadAssetsFromAssetBundle();
		}

		private void LoadAssetsFromAssetBundle()
		{
			try
			{
				string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
				string text = Path.Combine(directoryName, "hitmarker_assets");
				AssetBundle val = AssetBundle.LoadFromFile(text);
				canvasPrefab = val.LoadAsset<GameObject>("HitmarkerCanvas");
				canvasPrefab.AddComponent<CanvasBehaviour>();
				hitSFX = val.LoadAsset<AudioClip>("HitSFX");
				messageTextPrefab = val.LoadAsset<GameObject>("MessageText");
				messageTextPrefab.AddComponent<TextBehaviour>();
				mls.LogInfo((object)"Successfully loaded assets from AssetBundle!");
			}
			catch (Exception arg)
			{
				mls.LogError((object)$"Error: Failed to load assets from AssetBundle.\n\n{arg}");
			}
		}

		public void OnNewLevelLoaded(int randomMapSeed)
		{
			EnemyAIPatch.Initialize();
		}

		public void SpawnCanvas()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)CanvasBehaviour.Instance != (Object)null))
			{
				GameObject val = Object.Instantiate<GameObject>(canvasPrefab, Vector3.zero, Quaternion.identity);
				SceneManager.MoveGameObjectToScene(val, SceneManager.GetActiveScene());
				mls.LogInfo((object)"Spawned HitmarkerCanvas.");
			}
		}
	}
	internal class TextBehaviour : MonoBehaviour
	{
		private Animation fadeOutAnimation;

		private void Start()
		{
			fadeOutAnimation = ((Component)this).gameObject.GetComponent<Animation>();
			((MonoBehaviour)this).StartCoroutine(FadeOutAndDestroy(3f));
		}

		private IEnumerator FadeOutAndDestroy(float time)
		{
			yield return (object)new WaitForSeconds(time);
			fadeOutAnimation.Play();
			float length = fadeOutAnimation.clip.length + 0.5f;
			yield return (object)new WaitForSeconds(length);
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		public void SetText(string message, Color color)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI component = ((Component)this).gameObject.GetComponent<TextMeshProUGUI>();
			((TMP_Text)component).text = message;
			((Graphic)component).color = color;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.github.zehsteam.Hitmarker";

		public const string PLUGIN_NAME = "Hitmarker";

		public const string PLUGIN_VERSION = "1.1.4";
	}
}
namespace com.github.zehsteam.Hitmarker.Patches
{
	[HarmonyPatch(typeof(EnemyAI))]
	internal class EnemyAIPatch
	{
		private static List<string> deadEnemyIDs;

		public static void Initialize()
		{
			deadEnemyIDs = new List<string>();
		}

		[HarmonyPatch("HitEnemyOnLocalClient")]
		[HarmonyPrefix]
		private static void HitEnemyOnLocalClientPatch(ref EnemyAI __instance, PlayerControllerB playerWhoHit, int force)
		{
			if (!((Object)(object)playerWhoHit == (Object)null) && (Object)(object)StartOfRound.Instance.localPlayerController == (Object)(object)playerWhoHit)
			{
				HitmarkerBase.mls.LogInfo((object)$"[LOCAL] HitEnemyOnLocalClient(); {playerWhoHit.playerUsername} hit {__instance.enemyType.enemyName} ({__instance.enemyHP - force} HP)");
				HitEnemy(__instance, playerWhoHit, force, fromLocalPlayer: true);
			}
		}

		[HarmonyPatch("HitEnemyServerRpc")]
		[HarmonyPrefix]
		private static void HitEnemyServerRpcPatch(ref EnemyAI __instance, int playerWhoHit, int force)
		{
			if (playerWhoHit != -1)
			{
				PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerWhoHit];
				if (!((Object)(object)StartOfRound.Instance.localPlayerController == (Object)(object)val))
				{
					HitmarkerBase.mls.LogInfo((object)$"[SERVER] HitEnemyServerRpc(); {val.playerUsername} hit {__instance.enemyType.enemyName} ({__instance.enemyHP - force} HP)");
					HitEnemy(__instance, val, force, fromLocalPlayer: false);
				}
			}
		}

		[HarmonyPatch("HitEnemyClientRpc")]
		[HarmonyPrefix]
		private static void HitEnemyClientRpcPatch(ref EnemyAI __instance, int playerWhoHit, int force)
		{
			if (playerWhoHit != -1)
			{
				bool flag = NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer;
				PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerWhoHit];
				bool flag2 = (Object)(object)StartOfRound.Instance.localPlayerController == (Object)(object)val;
				if (!flag && !flag2)
				{
					HitmarkerBase.mls.LogInfo((object)$"[CLIENT] HitEnemyClientRpc(); {val.playerUsername} hit {__instance.enemyType.enemyName} ({__instance.enemyHP - force} HP)");
					HitEnemy(__instance, val, force, fromLocalPlayer: false);
				}
			}
		}

		private static void HitEnemy(EnemyAI enemyAI, PlayerControllerB playerWhoHit, int damage, bool fromLocalPlayer)
		{
			if ((Object)(object)enemyAI == (Object)null || (Object)(object)playerWhoHit == (Object)null || enemyAI.enemyHP <= 0 || !enemyAI.enemyType.canDie)
			{
				return;
			}
			string enemyID = GetEnemyID(enemyAI);
			if (!deadEnemyIDs.Contains(enemyID))
			{
				string enemyName = GetEnemyName(enemyAI);
				bool flag = enemyAI.enemyHP - damage <= 0;
				LogInfo(enemyAI, playerWhoHit, damage, fromLocalPlayer);
				if (fromLocalPlayer)
				{
					CanvasBehaviour.Instance.ShowHitmarker(flag);
					CanvasBehaviour.Instance.ShowDamageMessage($"{enemyName} -{damage} HP");
				}
				if (flag)
				{
					deadEnemyIDs.Add(enemyID);
					string text = (fromLocalPlayer ? ("Killed " + enemyName) : (playerWhoHit.playerUsername + " Killed " + enemyName));
					CanvasBehaviour.Instance.ShowKillMessage(text.Trim(), fromLocalPlayer);
				}
			}
		}

		private static void LogInfo(EnemyAI enemyAI, PlayerControllerB playerWhoHit, int damage, bool fromLocalPlayer)
		{
			string empty = string.Empty;
			empty = empty + "HitEnemy - " + enemyAI.enemyType.enemyName + "\n";
			empty = empty + "PlayerWhoHit - " + playerWhoHit.playerUsername + "\n\n";
			empty += $"Hit from LocalPlayer? {fromLocalPlayer}\n";
			empty += $"Current HP: {enemyAI.enemyHP}, Damage: {damage}, New HP: {enemyAI.enemyHP - damage}\n";
			HitmarkerBase.mls.LogInfo((object)("\n\n" + empty.Trim() + "\n"));
		}

		private static string GetEnemyName(EnemyAI enemyAI)
		{
			string enemyName = enemyAI.enemyType.enemyName;
			if (HitmarkerBase.Instance.configManager.UseOriginalEnemyNames)
			{
				return enemyName;
			}
			return enemyName switch
			{
				"Centipede" => "Snare Flea", 
				"Crawler" => "Thumper", 
				"Girl" => "Ghost Girl", 
				"Puffer" => "Spore Lizard", 
				"Spring" => "Coil-Head", 
				"Masked" => "Mimic", 
				"Flowerman" => "Bracken", 
				_ => enemyName, 
			};
		}

		private static string GetEnemyID(EnemyAI enemyAI)
		{
			NetworkObject component = ((Component)enemyAI).gameObject.GetComponent<NetworkObject>();
			string enemyName = enemyAI.enemyType.enemyName;
			string text = ((Object)((Component)enemyAI).gameObject).GetInstanceID().ToString();
			string text2 = component.NetworkObjectId.ToString();
			return enemyName + "_" + text + "_" + text2;
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal class HUDManagerPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch()
		{
			HitmarkerBase.Instance.SpawnCanvas();
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatch
	{
		[HarmonyPatch("LoadNewLevel")]
		[HarmonyPostfix]
		private static void LoadNewLevelPatch(int randomSeed)
		{
			HitmarkerBase.Instance.OnNewLevelLoaded(randomSeed);
		}

		[HarmonyPatch("GenerateNewLevelClientRpc")]
		[HarmonyPrefix]
		private static void GenerateNewLevelClientRpcPatch(int randomSeed)
		{
			if (!NetworkManager.Singleton.IsHost && !NetworkManager.Singleton.IsServer)
			{
				HitmarkerBase.Instance.OnNewLevelLoaded(randomSeed);
			}
		}
	}
}

plugins/com.github.zehsteam.ToilHead.dll

Decompiled 9 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using com.github.zehsteam.ToilHead.NetcodePatcher;
using com.github.zehsteam.ToilHead.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.zehsteam.ToilHead")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Coil-Heads can sometimes spawn with a turret on their head.")]
[assembly: AssemblyFileVersion("1.0.5.0")]
[assembly: AssemblyInformationalVersion("1.0.5+15a7529ad0c6fb33a3c4c3b1609e168630aee318")]
[assembly: AssemblyProduct("ToilHead")]
[assembly: AssemblyTitle("com.github.zehsteam.ToilHead")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.5.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace com.github.zehsteam.ToilHead
{
	internal class ConfigManager
	{
		private ConfigEntry<int> SpawnChanceCfg;

		private ConfigEntry<int> MaxSpawnsCfg;

		private ConfigEntry<int> SpawnTurretFacingForwardWeightCfg;

		private ConfigEntry<int> SpawnTurretFacingBackwardWeightCfg;

		internal int SpawnChance
		{
			get
			{
				return SpawnChanceCfg.Value;
			}
			set
			{
				SpawnChanceCfg.Value = Math.Clamp(value, 0, 100);
			}
		}

		internal int MaxSpawns
		{
			get
			{
				return MaxSpawnsCfg.Value;
			}
			set
			{
				MaxSpawnsCfg.Value = value;
			}
		}

		internal int SpawnTurretFacingForwardWeight
		{
			get
			{
				return SpawnTurretFacingForwardWeightCfg.Value;
			}
			set
			{
				SpawnTurretFacingForwardWeightCfg.Value = value;
			}
		}

		internal int SpawnTurretFacingBackwardWeight
		{
			get
			{
				return SpawnTurretFacingBackwardWeightCfg.Value;
			}
			set
			{
				SpawnTurretFacingBackwardWeightCfg.Value = value;
			}
		}

		public ConfigManager()
		{
			BindConfigs();
		}

		private void BindConfigs()
		{
			//IL_0018: 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_003b: Expected O, but got Unknown
			//IL_003b: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_0067: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			//IL_009a: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			//IL_00cd: Expected O, but got Unknown
			ConfigFile config = ((BaseUnityPlugin)ToilHeadBase.Instance).Config;
			SpawnChanceCfg = config.Bind<int>(new ConfigDefinition("Settings", "spawnChance"), 60, new ConfigDescription("The percent chance for a Coil-Head to turn into a Toil-Head.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			MaxSpawnsCfg = config.Bind<int>(new ConfigDefinition("Settings", "maxSpawns"), 3, new ConfigDescription("The max amount of Toil-Heads that can spawn.", (AcceptableValueBase)null, Array.Empty<object>()));
			SpawnTurretFacingForwardWeightCfg = config.Bind<int>(new ConfigDefinition("Settings", "spawnTurretFacingForwardWeight"), 1, new ConfigDescription("The weight chance for the turret to spawn facing forward.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			SpawnTurretFacingBackwardWeightCfg = config.Bind<int>(new ConfigDefinition("Settings", "spawnTurretFacingBackwardWeight"), 3, new ConfigDescription("The weight chance for the turret to spawn facing backward.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
		}
	}
	internal class ParentToTransformBehaviour : MonoBehaviour
	{
		private Transform parent;

		private Vector3 positionOffset;

		private Vector3 rotationOffset;

		private void Update()
		{
			//IL_0019: 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_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_0030: 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)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)parent == (Object)null))
			{
				Vector3 localPosition = parent.localPosition + positionOffset;
				((Component)this).transform.localPosition = localPosition;
				((Component)this).transform.localRotation = parent.localRotation;
				((Component)this).transform.Rotate(rotationOffset, (Space)1);
			}
		}

		public void SetParent(Transform parent)
		{
			this.parent = parent;
		}

		public void SetPositionOffset(Vector3 positionOffset)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			this.positionOffset = positionOffset;
		}

		public void SetRotationOffset(Vector3 rotationOffset)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			this.rotationOffset = rotationOffset;
		}
	}
	[BepInPlugin("com.github.zehsteam.ToilHead", "ToilHead", "1.0.5")]
	public class ToilHeadBase : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("com.github.zehsteam.ToilHead");

		internal static ToilHeadBase Instance;

		internal static ManualLogSource mls;

		internal ConfigManager configManager;

		public GameObject turretPrefab;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("com.github.zehsteam.ToilHead");
			mls.LogInfo((object)"ToilHead has awoken!");
			harmony.PatchAll(typeof(GameNetworkManagerPatch));
			harmony.PatchAll(typeof(StartOfRoundPatch));
			harmony.PatchAll(typeof(RoundManagerPatch));
			harmony.PatchAll(typeof(EnemyAIPatch));
			configManager = new ConfigManager();
			NetcodePatcherAwake();
		}

		private void NetcodePatcherAwake()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}

		public void OnNewLevelLoaded(int randomMapSeed)
		{
			EnemyAIPatch.Initialize(randomMapSeed);
			Secret.SpawnAsteroid13Secrets();
		}

		public void SetToilHeadOnServer(EnemyAI enemyAI)
		{
			if ((Object)(object)enemyAI == (Object)null)
			{
				mls.LogError((object)"Error: enemy could not be found.");
				return;
			}
			if ((Object)(object)turretPrefab == (Object)null)
			{
				mls.LogError((object)"Error: turret prefab could not be found.");
				return;
			}
			NetworkObject component = ((Component)enemyAI).gameObject.GetComponent<NetworkObject>();
			int num = configManager.SpawnTurretFacingForwardWeight * 100;
			int num2 = configManager.SpawnTurretFacingBackwardWeight * 100;
			bool turretFacingForward = EnemyAIPatch.random.Next(1, num + num2) <= num;
			SpawnTurretOnServer(((Component)enemyAI).gameObject.transform);
			PluginNetworkBehaviour.Instance.SetToilHeadClientRpc((int)component.NetworkObjectId, turretFacingForward);
			SetToilHeadOnLocalClient(((Component)enemyAI).gameObject, turretFacingForward);
		}

		private GameObject SpawnTurretOnServer(Transform parent)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(turretPrefab, parent.localPosition, Quaternion.identity, parent);
			NetworkObject component = val.GetComponent<NetworkObject>();
			component.Spawn(true);
			val.transform.SetParent(parent);
			return val;
		}

		public void SetToilHeadOnLocalClient(GameObject enemy, bool turretFacingForward)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			GameObject gameObject = ((Component)enemy.transform.GetChild(1)).gameObject;
			Transform val = enemy.transform.GetChild(0).Find("Head");
			gameObject.transform.localPosition = val.localPosition;
			ParentToTransformBehaviour parentToTransformBehaviour = gameObject.AddComponent<ParentToTransformBehaviour>();
			parentToTransformBehaviour.SetParent(val);
			if (turretFacingForward)
			{
				parentToTransformBehaviour.SetRotationOffset(new Vector3(90f, 0f, 0f));
			}
			else
			{
				parentToTransformBehaviour.SetRotationOffset(new Vector3(-20f, 180f, 0f));
			}
			DisableCollidersForTurret(gameObject);
			mls.LogInfo((object)"Spawned Toil-Head, Good luck :3");
		}

		private void DisableCollidersForTurret(GameObject turret)
		{
			List<Collider> list = turret.GetComponentsInChildren<Collider>().ToList();
			list.ForEach(delegate(Collider collider)
			{
				if (!(((Object)((Component)collider).gameObject).name == "ScanNode"))
				{
					collider.enabled = false;
				}
			});
			mls.LogInfo((object)"Removed the colliders from the turret on the Coil-Head.");
		}
	}
	internal class PluginNetworkBehaviour : NetworkBehaviour
	{
		public static PluginNetworkBehaviour Instance;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
		}

		[ClientRpc]
		public void SetToilHeadClientRpc(int networkObjectId, bool turretFacingForward)
		{
			//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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2237688886u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, networkObjectId);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref turretFacingForward, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2237688886u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsHost && !((NetworkBehaviour)this).IsServer)
				{
					NetworkObject networkObjectById = GetNetworkObjectById(networkObjectId);
					ToilHeadBase.Instance.SetToilHeadOnLocalClient(((Component)networkObjectById).gameObject, turretFacingForward);
				}
			}
		}

		public NetworkObject GetNetworkObjectById(int networkObjectId)
		{
			return NetworkManager.Singleton.SpawnManager.SpawnedObjects[(ulong)networkObjectId];
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_PluginNetworkBehaviour()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2237688886u, new RpcReceiveHandler(__rpc_handler_2237688886));
		}

		private static void __rpc_handler_2237688886(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int networkObjectId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref networkObjectId);
				bool turretFacingForward = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref turretFacingForward, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PluginNetworkBehaviour)(object)target).SetToilHeadClientRpc(networkObjectId, turretFacingForward);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "PluginNetworkBehaviour";
		}
	}
	internal class Secret
	{
		public static GameObject turretPropPrefab;

		public static void SpawnAsteroid13Secrets()
		{
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: 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_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: 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_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: 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_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			if (!(((Object)StartOfRound.Instance.currentLevel).name != "57 Asteroid-13"))
			{
				GameObject parent = GameObject.Find("/asteroid(Clone)/coilheadstuck_model");
				GameObject parent2 = GameObject.Find("/asteroid(Clone)/coilheadrigged");
				GameObject parent3 = GameObject.Find("/asteroid(Clone)/coilheadstuck_model (5)");
				GameObject parent4 = GameObject.Find("/asteroid(Clone)/coilheadstuck_model (7)");
				GameObject parent5 = GameObject.Find("/asteroid(Clone)/coilheadstuck_model (8)");
				GameObject parent6 = GameObject.Find("/asteroid(Clone)/coilheadstuck_model (9)");
				GameObject parent7 = GameObject.Find("/asteroid(Clone)/coilheadstuck_model (10)");
				GameObject parent8 = GameObject.Find("/asteroid(Clone)/coilheadstuck_model (6)");
				GameObject parent9 = GameObject.Find("/asteroid(Clone)/coilheadstuck_2_model (7)");
				GameObject parent10 = GameObject.Find("/asteroid(Clone)/coilheadstuck_2_model (1)");
				GameObject parent11 = GameObject.Find("/asteroid(Clone)/coilheadstuck_model (11)");
				Vector3 val = turretPropPrefab.transform.localScale * 1.3f;
				SpawnTurretProp(parent, new Vector3(-0.05f, 2.4f, -0.15f), new Vector3(19f, 180f, 0f), val);
				SpawnTurretProp(parent2, new Vector3(-0.15f, 4.8f, -0.2f), new Vector3(0f, 180f, 0f), val * 2f);
				SpawnTurretProp(parent3, new Vector3(-0.05f, 2.4f, -0.25f), new Vector3(15f, 180f, 0f), val);
				SpawnTurretProp(parent4, new Vector3(-0.05f, 2.4f, -0.25f), new Vector3(15f, 180f, 0f), val);
				SpawnTurretProp(parent5, new Vector3(-0.05f, 2.4f, -0.25f), new Vector3(15f, 180f, 0f), val);
				SpawnTurretProp(parent6, new Vector3(-0.05f, 2.4f, -0.25f), new Vector3(15f, 180f, 0f), val);
				SpawnTurretProp(parent7, new Vector3(-0.05f, 2.4f, -0.25f), new Vector3(15f, 180f, 0f), val);
				SpawnTurretProp(parent8, new Vector3(-0.05f, 2.4f, -0.25f), new Vector3(15f, 180f, 0f), val);
				SpawnTurretProp(parent9, new Vector3(-0.05f, 2.4f, -0.05f), new Vector3(3f, 180f, 0f), val);
				SpawnTurretProp(parent10, new Vector3(-0.05f, 2.45f, -0.05f), new Vector3(0f, 180f, 0f), val);
				SpawnTurretProp(parent11, new Vector3(-0.05f, 2.5f, -0.1f), new Vector3(25f, 180f, 0f), val);
			}
		}

		private static void SpawnTurretProp(GameObject parent, Vector3 positionOffset, Vector3 rotationOffset)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			SpawnTurretProp(parent, positionOffset, rotationOffset, turretPropPrefab.transform.localScale);
		}

		private static void SpawnTurretProp(GameObject parent, Vector3 positionOffset, Vector3 rotationOffset, Vector3 scale)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)parent == (Object)null))
			{
				GameObject val = Object.Instantiate<GameObject>(turretPropPrefab, parent.transform.position, Quaternion.identity);
				((Object)val).name = "TurretProp";
				val.transform.SetParent(parent.transform);
				val.transform.localPosition = positionOffset;
				val.transform.localRotation = Quaternion.identity;
				val.transform.localScale = scale;
				val.transform.Rotate(rotationOffset, (Space)1);
				List<Collider> list = val.GetComponentsInChildren<Collider>().ToList();
				list.ForEach(delegate(Collider collider)
				{
					collider.enabled = false;
				});
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.github.zehsteam.ToilHead";

		public const string PLUGIN_NAME = "ToilHead";

		public const string PLUGIN_VERSION = "1.0.5";
	}
}
namespace com.github.zehsteam.ToilHead.Patches
{
	[HarmonyPatch(typeof(EnemyAI))]
	internal class EnemyAIPatch
	{
		public static Random random;

		public static int toilHeadSpawns;

		public static void Initialize(int randomMapSeed)
		{
			random = new Random(randomMapSeed + 420);
			toilHeadSpawns = 0;
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch(ref EnemyAI __instance)
		{
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				CheckEnemy(__instance);
			}
		}

		private static void CheckEnemy(EnemyAI enemyAI)
		{
			string enemyName = enemyAI.enemyType.enemyName;
			if (enemyName == "Spring")
			{
				EnemyIsCoilHead(enemyAI);
			}
		}

		private static void EnemyIsCoilHead(EnemyAI enemyAI)
		{
			if (random.Next(0, 100) <= ToilHeadBase.Instance.configManager.SpawnChance && toilHeadSpawns < ToilHeadBase.Instance.configManager.MaxSpawns)
			{
				ToilHeadBase.Instance.SetToilHeadOnServer(enemyAI);
				toilHeadSpawns++;
			}
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal class GameNetworkManagerPatch
	{
		public static GameObject networkPrefab;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch()
		{
			LoadAssetsFromAssetBundle();
		}

		private static void LoadAssetsFromAssetBundle()
		{
			if ((Object)(object)networkPrefab != (Object)null)
			{
				return;
			}
			try
			{
				string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)ToilHeadBase.Instance).Info.Location);
				string text = Path.Combine(directoryName, "toilhead_assets");
				AssetBundle val = AssetBundle.LoadFromFile(text);
				networkPrefab = val.LoadAsset<GameObject>("NetworkHandler");
				networkPrefab.AddComponent<PluginNetworkBehaviour>();
				NetworkManager.Singleton.AddNetworkPrefab(networkPrefab);
				ToilHeadBase.mls.LogInfo((object)"Successfully loaded assets from AssetBundle!");
			}
			catch (Exception arg)
			{
				ToilHeadBase.mls.LogError((object)$"Error: failed to load assets from AssetBundle.\n\n{arg}");
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		[HarmonyPriority(int.MinValue)]
		private static void StartPatch()
		{
			SetTurretPrefab();
		}

		[HarmonyPatch("LoadNewLevel")]
		[HarmonyPostfix]
		private static void LoadNewLevelPatch(int randomSeed)
		{
			ToilHeadBase.Instance.OnNewLevelLoaded(randomSeed);
		}

		[HarmonyPatch("GenerateNewLevelClientRpc")]
		[HarmonyPrefix]
		private static void GenerateNewLevelClientRpcPatch(int randomSeed)
		{
			if (!NetworkManager.Singleton.IsHost && !NetworkManager.Singleton.IsServer)
			{
				ToilHeadBase.Instance.OnNewLevelLoaded(randomSeed);
			}
		}

		private static void SetTurretPrefab()
		{
			if (!((Object)(object)ToilHeadBase.Instance.turretPrefab != (Object)null))
			{
				GameObject hazardPrefab = GetHazardPrefab("TurretContainer");
				ToilHeadBase.Instance.turretPrefab = hazardPrefab;
				SetTurretPropPrefab(hazardPrefab);
			}
		}

		private static void SetTurretPropPrefab(GameObject turretPrefab)
		{
			if (!((Object)(object)turretPrefab == (Object)null))
			{
				Secret.turretPropPrefab = ((Component)turretPrefab.transform.GetChild(1)).gameObject;
			}
		}

		private static GameObject GetHazardPrefab(string name)
		{
			List<SpawnableMapObject> list = RoundManager.Instance.spawnableMapObjects.ToList();
			GameObject prefab = null;
			list.ForEach(delegate(SpawnableMapObject spawnableMapObject)
			{
				if (!(((Object)spawnableMapObject.prefabToSpawn).name != name))
				{
					prefab = spawnableMapObject.prefabToSpawn;
				}
			});
			if ((Object)(object)prefab == (Object)null)
			{
				ToilHeadBase.mls.LogError((object)("Error: could not find hazard \"" + name + "\""));
			}
			return prefab;
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void AwakePatch()
		{
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				SpawnNetworkHandler();
			}
		}

		private static void SpawnNetworkHandler()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(GameNetworkManagerPatch.networkPrefab, Vector3.zero, Quaternion.identity);
			val.GetComponent<NetworkObject>().Spawn(false);
		}
	}
}
namespace com.github.zehsteam.ToilHead.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}

plugins/DiscountAlert.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using DiscountAlert;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("DiscountAlert")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("2.3.0.0")]
[assembly: AssemblyInformationalVersion("2.3.0.0")]
[assembly: AssemblyProduct("DiscountAlert")]
[assembly: AssemblyTitle("DiscountAlert")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.3.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[HarmonyPatch(typeof(StartMatchLever))]
public class StartMatchLever_Patches
{
	private static string priceUpColor = Plugin.Instance.PRICE_UP_COLOR;

	private static string priceDownColor = Plugin.Instance.PRICE_DOWN_COLOR;

	private static string noDiscountColor = Plugin.Instance.NO_DISCOUNT_COLOR;

	private static string noDiscountText = Plugin.Instance.noDiscountText.Value;

	private static string titleColor = Plugin.Instance.TITLE_COLOR;

	private static string titleText = Plugin.Instance.titleText.Value;

	private static int delayAfterLeverIsPulled = Plugin.Instance.delayAfterLeverIsPulled.Value;

	private static bool colorsEnabled = Plugin.Instance.colorsEnabled.Value;

	private static bool alertEnabledWhenNoDiscounts = Plugin.Instance.alertEnabledWhenNoDiscounts.Value;

	public static bool playerAlerted = false;

	public static int counter = 0;

	[HarmonyPatch("PlayLeverPullEffectsClientRpc")]
	[HarmonyPostfix]
	public static void PlayLeverPullEffectsClientRpcPatch()
	{
		playerAlerted = false;
		counter++;
		if (StartOfRound.Instance.inShipPhase && !playerAlerted && counter == 1)
		{
			playerAlerted = true;
			((MonoBehaviour)HUDManager.Instance).StartCoroutine(DisplayAlert());
		}
		else if (counter > 1)
		{
			counter = 0;
		}
	}

	private static IEnumerator DisplayAlert()
	{
		yield return (object)new WaitForSeconds((float)delayAfterLeverIsPulled);
		Debug.Log((object)"Displaying alert");
		StringBuilder discount_list = new StringBuilder();
		for (int i = 0; i < HUDManager.Instance.terminalScript.buyableItemsList.Length; i++)
		{
			if (HUDManager.Instance.terminalScript.itemSalesPercentages[i] != 100)
			{
				if (HUDManager.Instance.terminalScript.itemSalesPercentages[i] < 0)
				{
					discount_list.Append("\n" + ((priceUpColor != null) ? ("<color=" + priceUpColor + ">* ") : "* ") + HUDManager.Instance.terminalScript.buyableItemsList[i].itemName + $" ${(float)HUDManager.Instance.terminalScript.buyableItemsList[i].creditsWorth * (1f - (float)HUDManager.Instance.terminalScript.itemSalesPercentages[i] / 100f)} " + string.Format("({0}% UP!){1}", Math.Abs(HUDManager.Instance.terminalScript.itemSalesPercentages[i]), (priceUpColor != null) ? "</color>" : ""));
				}
				else if (HUDManager.Instance.terminalScript.itemSalesPercentages[i] > 0)
				{
					discount_list.Append("\n" + ((priceDownColor != null) ? ("<color=" + priceDownColor + ">* ") : "* ") + HUDManager.Instance.terminalScript.buyableItemsList[i].itemName + $" ${(float)HUDManager.Instance.terminalScript.buyableItemsList[i].creditsWorth * (float)HUDManager.Instance.terminalScript.itemSalesPercentages[i] / 100f} " + string.Format("({0}% OFF!){1}", 100 - HUDManager.Instance.terminalScript.itemSalesPercentages[i], (priceDownColor != null) ? "</color>" : ""));
				}
			}
		}
		if ((!(discount_list.ToString() == "") && discount_list != null) || alertEnabledWhenNoDiscounts)
		{
			if ((discount_list.ToString() == "" || discount_list == null) && alertEnabledWhenNoDiscounts)
			{
				discount_list.Append(((noDiscountColor != null) ? ("<color=" + noDiscountColor + "> ") : " ") + noDiscountText + ((noDiscountColor != null) ? "</color>" : ""));
			}
			HUDManager.Instance.DisplayTip(((titleColor != null) ? ("<color=" + titleColor + "> ") : " ") + titleText + ((titleColor != null) ? "</color>" : ""), discount_list.ToString(), false, false, "LC_Tip1");
		}
	}
}
namespace DiscountAlert
{
	[BepInPlugin("discount.alert", "DiscountAlert", "2.3.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "discount.alert";

		private const string modName = "DiscountAlert";

		private const string modVersion = "2.3.0.0";

		public ConfigEntry<string> priceUpColor;

		public ConfigEntry<string> priceDownColor;

		public ConfigEntry<string> noDiscountColor;

		public ConfigEntry<string> noDiscountText;

		public ConfigEntry<string> titleColor;

		public ConfigEntry<string> titleText;

		public ConfigEntry<int> delayAfterLeverIsPulled;

		public ConfigEntry<bool> colorsEnabled;

		public ConfigEntry<bool> alertEnabledWhenNoDiscounts;

		public string PRICE_UP_COLOR;

		public string PRICE_DOWN_COLOR;

		public string NO_DISCOUNT_COLOR;

		public string TITLE_COLOR;

		private readonly Harmony harmony = new Harmony("discount.alert");

		public static Plugin? Instance;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			priceUpColor = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "PriceUpColor", "#990000", "Text color when the price goes up (currently only possible with other mods)");
			priceDownColor = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "PriceDownColor", "#008000", "Text color when the price goes down");
			delayAfterLeverIsPulled = ((BaseUnityPlugin)this).Config.Bind<int>("Alert", "DelayAfterLeverIsPulled", 4, "Number of seconds to wait after the \"Land ship\" or \"Start Game\" lever is pulled before showing the alert.");
			colorsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Alert", "ColorsEnabled", true, "Enable or disable text colors");
			noDiscountColor = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "NoDiscountColor", "", "Text color when there are no discounts");
			titleColor = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "TitleColor", "", "Text color for the alert's title");
			titleText = ((BaseUnityPlugin)this).Config.Bind<string>("Alert", "TitleText", "Today's discounts", "Alert title text");
			noDiscountText = ((BaseUnityPlugin)this).Config.Bind<string>("Alert", "NoDiscountText", "None :( \n Check back tomorrow!", "Alert text when there are no discounts");
			alertEnabledWhenNoDiscounts = ((BaseUnityPlugin)this).Config.Bind<bool>("Alert", "AlertEnabledWhenNoDiscounts", true, "Show alert when there are no discounts");
			if (!IsValidHexCode(priceUpColor.Value))
			{
				PRICE_UP_COLOR = null;
			}
			else
			{
				PRICE_UP_COLOR = priceUpColor.Value;
			}
			if (!IsValidHexCode(priceDownColor.Value))
			{
				PRICE_DOWN_COLOR = null;
			}
			else
			{
				PRICE_DOWN_COLOR = priceDownColor.Value;
			}
			if (!IsValidHexCode(noDiscountColor.Value))
			{
				NO_DISCOUNT_COLOR = null;
			}
			else
			{
				NO_DISCOUNT_COLOR = noDiscountColor.Value;
			}
			if (!IsValidHexCode(titleColor.Value))
			{
				TITLE_COLOR = null;
			}
			else
			{
				TITLE_COLOR = titleColor.Value;
			}
			if (!colorsEnabled.Value)
			{
				PRICE_UP_COLOR = null;
				PRICE_DOWN_COLOR = null;
				NO_DISCOUNT_COLOR = null;
				TITLE_COLOR = null;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin discount.alert is loaded!");
			harmony.PatchAll();
		}

		public static bool IsValidHexCode(string hexCode)
		{
			string pattern = "^#?([0-9A-Fa-f]{3}){1,2}$";
			return Regex.IsMatch(hexCode, pattern);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

plugins/DroneEnemy.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DroneEnemy.NetcodePatcher;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DroneEnemy")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Drone Enemy for Lethal Company.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DroneEnemy")]
[assembly: AssemblyTitle("DroneEnemy")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace DroneEnemy
{
	internal class DroneEnemyAI : EnemyAI
	{
		private enum State
		{
			IdleRoaming,
			Scanning
		}

		public Transform scanArea;

		public AISearchRoutine scoutingSearchRoutine;

		public AudioSource mineAudio;

		public AudioSource mineFarAudio;

		public AudioSource scanAudio;

		public AudioSource idleSound;

		public AudioClip antennaBeep;

		public AudioClip beginScanSound;

		public AudioClip scanSound;

		public AudioClip mineDetonate;

		public AudioClip mineTrigger;

		public AudioClip mineDetonateFar;

		public ParticleSystem shockwaveParticle;

		public Light antennaLight;

		public BoxCollider enemyCollider;

		public Material[] antennaMats;

		private bool sendingExplosionRPC;

		private float timeSincePrevScan;

		private int randomScanInterval = Plugin.minAttackTime.Value;

		private bool hasExploded;

		private bool isDeadAnimationDone;

		private bool stunnedAnimation;

		private Random enemyRandom;

		private int hitCount = 0;

		public override void Start()
		{
			((EnemyAI)this).Start();
			Debug.Log((object)"Drone Enemy Spawned");
			timeSincePrevScan = 0f;
			((Collider)enemyCollider).isTrigger = !Plugin.hasCollision.Value;
			hasExploded = false;
			enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
			isDeadAnimationDone = false;
			((MonoBehaviour)this).StartCoroutine(AntennaCoroutine());
			base.currentBehaviourStateIndex = 0;
		}

		public override void Update()
		{
			((EnemyAI)this).Update();
			if (base.isEnemyDead)
			{
				if (!isDeadAnimationDone)
				{
					isDeadAnimationDone = true;
					base.creatureVoice.Stop();
					base.creatureVoice.PlayOneShot(base.dieSFX);
				}
				return;
			}
			if (((NetworkBehaviour)this).IsServer && base.stunNormalizedTimer <= 0f)
			{
				timeSincePrevScan += Time.deltaTime;
			}
			if (base.stunNormalizedTimer > 0f && !stunnedAnimation)
			{
				base.agent.speed = 0f;
				base.creatureAnimator.SetBool("stunned", true);
				stunnedAnimation = true;
			}
			else if (stunnedAnimation && base.stunNormalizedTimer <= 0f)
			{
				base.creatureAnimator.SetBool("stunned", false);
				stunnedAnimation = false;
			}
		}

		public IEnumerator AntennaCoroutine()
		{
			Debug.Log((object)"Start Antenna Loop");
			while (true)
			{
				((Renderer)base.skinnedMeshRenderers[0]).materials[2] = antennaMats[1];
				((Behaviour)antennaLight).enabled = true;
				idleSound.PlayOneShot(antennaBeep);
				yield return (object)new WaitForSeconds(0.3f);
				((Renderer)base.skinnedMeshRenderers[0]).materials[2] = antennaMats[0];
				((Behaviour)antennaLight).enabled = false;
				yield return (object)new WaitForSeconds(3f);
			}
		}

		public override void SetEnemyStunned(bool setToStunned, float setToStunTime = 1f, PlayerControllerB setStunnedByPlayer = null)
		{
			((EnemyAI)this).SetEnemyStunned(setToStunned, setToStunTime, setStunnedByPlayer);
		}

		public override void DoAIInterval()
		{
			((EnemyAI)this).DoAIInterval();
			if (!base.isEnemyDead && !StartOfRound.Instance.allPlayersDead)
			{
				ScanningUpdate(ref scoutingSearchRoutine);
				switch (base.currentBehaviourStateIndex)
				{
				case 0:
					base.agent.speed = 2f;
					break;
				case 1:
					base.agent.speed = 0f;
					break;
				default:
					Debug.Log((object)"This Behavior State doesn't exist!");
					break;
				}
			}
		}

		private void ScanningUpdate(ref AISearchRoutine routine)
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)this).IsServer)
			{
				int num = (int)(timeSincePrevScan % 60f);
				if (num > randomScanInterval)
				{
					randomScanInterval = enemyRandom.Next(Plugin.minAttackTime.Value, Plugin.maxAttackTime.Value);
					timeSincePrevScan = 0f;
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
					TriggerScanOnClientsServerRpc();
				}
			}
			if (!routine.inProgress)
			{
				Debug.Log((object)"Roam");
				((EnemyAI)this).StartSearch(((Component)this).transform.position, routine);
			}
		}

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

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

		private IEnumerator Scan()
		{
			if (base.isEnemyDead)
			{
				yield break;
			}
			scanAudio.PlayOneShot(beginScanSound);
			WalkieTalkie.TransmitOneShotAudio(scanAudio, beginScanSound, 1f);
			yield return (object)new WaitForSeconds(3f);
			DoAnimationTriggerClientRpc("scan");
			yield return (object)new WaitForSeconds(0.5f);
			scanAudio.PlayOneShot(scanSound);
			WalkieTalkie.TransmitOneShotAudio(scanAudio, scanSound, 1f);
			float num = Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, ((Component)this).transform.position);
			if (num < 14f)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)3);
			}
			else if (num < 24f)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
			}
			shockwaveParticle.Emit(1);
			int defaultLayer = 1;
			int playerLayer = 8;
			int roomLayer = 256;
			int combinedLayer = defaultLayer | playerLayer | roomLayer;
			Collider[] hitColliders = Physics.OverlapBox(scanArea.position, scanArea.localScale, Quaternion.identity, playerLayer);
			List<PlayerControllerB> playersToSlow = new List<PlayerControllerB>();
			if (hitColliders.Length != 0)
			{
				Collider[] array = hitColliders;
				RaycastHit hit = default(RaycastHit);
				foreach (Collider playerCollider in array)
				{
					Vector3 position = ((Component)this).transform.position;
					Bounds bounds = playerCollider.bounds;
					if (Physics.Linecast(position, ((Bounds)(ref bounds)).center, ref hit, combinedLayer))
					{
						Debug.Log((object)("Collider: " + ((Object)((RaycastHit)(ref hit)).collider).name));
						if ((Object)(object)((RaycastHit)(ref hit)).collider != (Object)(object)playerCollider && !Plugin.hitThroughWalls.Value)
						{
							continue;
						}
					}
					PlayerControllerB playerControllerB = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(playerCollider, false, false);
					if ((Object)(object)playerControllerB != (Object)null)
					{
						playerControllerB.DamagePlayer(enemyRandom.Next(10, 25), true, true, (CauseOfDeath)0, 0, false, default(Vector3));
						playerControllerB.isMovementHindered++;
						playerControllerB.hinderedMultiplier *= 2f;
						playersToSlow.Add(playerControllerB);
					}
					hit = default(RaycastHit);
				}
				yield return (object)new WaitForSeconds((float)enemyRandom.Next(1, 5));
				foreach (PlayerControllerB player in playersToSlow)
				{
					player.isMovementHindered--;
					player.hinderedMultiplier *= 0.4f;
				}
			}
			yield return (object)new WaitForSeconds(2f);
			((EnemyAI)this).SwitchToBehaviourClientRpc(0);
		}

		public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false)
		{
			((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX);
			DoAnimationTriggerClientRpc("HitEnemy");
			hitCount++;
			if (enemyRandom.Next(1, 4) > hitCount)
			{
				((MonoBehaviour)this).StopCoroutine(Scan());
				SetOffMineAnimation();
				sendingExplosionRPC = true;
				ExplodeMineServerRpc();
			}
		}

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

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

		public void SetOffMineAnimation()
		{
			hasExploded = true;
			mineAudio.PlayOneShot(mineTrigger, 1f);
			((MonoBehaviour)this).StartCoroutine(detonateMineDelayed());
		}

		private IEnumerator detonateMineDelayed()
		{
			yield return (object)new WaitForSeconds(0.5f);
			Detonate();
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		public void Detonate()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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)
			mineAudio.pitch = Random.Range(0.93f, 1.07f);
			mineAudio.PlayOneShot(mineDetonate, 1f);
			CreateExplosion(((Component)this).transform.position + Vector3.up, spawnExplosionEffect: true, 100, 5.7f, 6.4f, 6, (CauseOfDeath)3);
		}

		[ClientRpc]
		public void DoAnimationTriggerClientRpc(string animationName)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_00ba: 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(945943318u, val, (RpcDelivery)0);
				bool flag = animationName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(animationName, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 945943318u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.creatureAnimator.SetTrigger(animationName);
			}
		}

		[ClientRpc]
		public void DoAnimationFloatClientRpc(string animationName, float value)
		{
			//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(3014858118u, val, (RpcDelivery)0);
				bool flag = animationName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(animationName, false);
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref value, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3014858118u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.creatureAnimator.SetFloat(animationName, value);
			}
		}

		private static IEnumerator TriggerOtherMineDelayed(Landmine mine)
		{
			if (!mine.hasExploded)
			{
				mine.mineAudio.pitch = Random.Range(0.75f, 1.07f);
				mine.hasExploded = true;
				yield return (object)new WaitForSeconds(0.2f);
				mine.SetOffMineAnimation();
			}
		}

		public static void CreateExplosion(Vector3 explosionPosition, bool spawnExplosionEffect = false, int damage = 20, float minDamageRange = 0f, float maxDamageRange = 1f, int enemyHitForce = 6, CauseOfDeath causeOfDeath = 3, PlayerControllerB attacker = null)
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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_007f: 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)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: 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_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"Spawning explosion at pos: {explosionPosition}");
			Transform val = null;
			if ((Object)(object)RoundManager.Instance != (Object)null && (Object)(object)RoundManager.Instance.mapPropsContainer != (Object)null && (Object)(object)RoundManager.Instance.mapPropsContainer.transform != (Object)null)
			{
				val = RoundManager.Instance.mapPropsContainer.transform;
			}
			if (spawnExplosionEffect)
			{
				Object.Instantiate<GameObject>(StartOfRound.Instance.explosionPrefab, explosionPosition, Quaternion.Euler(-90f, 0f, 0f), val).SetActive(true);
			}
			float num = Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, explosionPosition);
			if (num < 14f)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
			}
			else if (num < 25f)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
			}
			Collider[] array = Physics.OverlapSphere(explosionPosition, maxDamageRange, 2621448, (QueryTriggerInteraction)2);
			PlayerControllerB val2 = null;
			for (int i = 0; i < array.Length; i++)
			{
				float num2 = Vector3.Distance(explosionPosition, ((Component)array[i]).transform.position);
				if (num2 > 4f && Physics.Linecast(explosionPosition, ((Component)array[i]).transform.position + Vector3.up * 0.3f, 256, (QueryTriggerInteraction)1))
				{
					continue;
				}
				if (((Component)array[i]).gameObject.layer == 3)
				{
					val2 = ((Component)array[i]).gameObject.GetComponent<PlayerControllerB>();
					if ((Object)(object)val2 != (Object)null && ((NetworkBehaviour)val2).IsOwner)
					{
						float num3 = 1f - Mathf.Clamp01((num2 - minDamageRange) / (maxDamageRange - minDamageRange));
						val2.DamagePlayer((int)((float)damage * num3), true, true, causeOfDeath, 0, false, default(Vector3));
					}
				}
				else if (((Component)array[i]).gameObject.layer == 21)
				{
					Landmine componentInChildren = ((Component)array[i]).gameObject.GetComponentInChildren<Landmine>();
					if ((Object)(object)componentInChildren != (Object)null && !componentInChildren.hasExploded && num2 < 6f)
					{
						Debug.Log((object)"Setting off other mine");
						((MonoBehaviour)componentInChildren).StartCoroutine(TriggerOtherMineDelayed(componentInChildren));
					}
				}
				else if (((Component)array[i]).gameObject.layer == 19)
				{
					EnemyAICollisionDetect componentInChildren2 = ((Component)array[i]).gameObject.GetComponentInChildren<EnemyAICollisionDetect>();
					if ((Object)(object)componentInChildren2 != (Object)null && ((NetworkBehaviour)componentInChildren2.mainScript).IsOwner && num2 < 4.5f)
					{
						componentInChildren2.mainScript.HitEnemyOnLocalClient(enemyHitForce, default(Vector3), attacker, false);
					}
				}
			}
			int num4 = ~LayerMask.GetMask(new string[1] { "Room" });
			num4 = ~LayerMask.GetMask(new string[1] { "Colliders" });
			array = Physics.OverlapSphere(explosionPosition, 10f, num4);
			for (int j = 0; j < array.Length; j++)
			{
				Rigidbody component = ((Component)array[j]).GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					component.AddExplosionForce(70f, explosionPosition, 10f);
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_DroneEnemyAI()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(555519031u, new RpcReceiveHandler(__rpc_handler_555519031));
			NetworkManager.__rpc_func_table.Add(4128408083u, new RpcReceiveHandler(__rpc_handler_4128408083));
			NetworkManager.__rpc_func_table.Add(1032796482u, new RpcReceiveHandler(__rpc_handler_1032796482));
			NetworkManager.__rpc_func_table.Add(202708153u, new RpcReceiveHandler(__rpc_handler_202708153));
			NetworkManager.__rpc_func_table.Add(945943318u, new RpcReceiveHandler(__rpc_handler_945943318));
			NetworkManager.__rpc_func_table.Add(3014858118u, new RpcReceiveHandler(__rpc_handler_3014858118));
		}

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

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

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

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

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

		private static void __rpc_handler_3014858118(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 animationName = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref animationName, false);
				}
				float value = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref value, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((DroneEnemyAI)(object)target).DoAnimationFloatClientRpc(animationName, value);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "DroneEnemyAI";
		}
	}
	public static class PluginInformation
	{
		public const string PLUGIN_GUID = "droneenemy";

		public const string PLUGIN_NAME = "Drone Enemy";

		public const string PLUGIN_VERSION = "1.0.0";
	}
	[BepInPlugin("droneenemy", "Drone Enemy", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static Harmony _harmony;

		public static AssetBundle MainAssetBundle;

		public static EnemyType DroneEnemy;

		internal static ManualLogSource Logger;

		public static ConfigFile config;

		public static ConfigEntry<int> spawnWeight;

		public static ConfigEntry<int> minAttackTime;

		public static ConfigEntry<int> maxAttackTime;

		public static ConfigEntry<bool> hitThroughWalls;

		public static ConfigEntry<bool> hasCollision;

		private void Awake()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			MainAssetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "droneenemyassets"));
			_harmony = new Harmony("droneenemy");
			InitializeConfig();
			DroneEnemy = MainAssetBundle.LoadAsset<EnemyType>("DroneEnemy");
			TerminalNode val = MainAssetBundle.LoadAsset<TerminalNode>("DroneEnemyTN");
			TerminalKeyword val2 = MainAssetBundle.LoadAsset<TerminalKeyword>("DroneEnemyTK");
			NetworkPrefabs.RegisterNetworkPrefab(DroneEnemy.enemyPrefab);
			Enemies.RegisterEnemy(DroneEnemy, spawnWeight.Value, (LevelTypes)(-1), (SpawnType)0, val, val2);
			Logger.LogInfo((object)"Plugin droneenemy is loaded!");
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}

		private void InitializeConfig()
		{
			spawnWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Drone", "SpawnWeight", 60, "SpawnWeight for the Drone 1 - 100");
			minAttackTime = ((BaseUnityPlugin)this).Config.Bind<int>("Drone", "MinAttackTime", 15, "Minimum Attack Time Interval (Actual Seconds)");
			maxAttackTime = ((BaseUnityPlugin)this).Config.Bind<int>("Drone", "MaxAttackTime", 60, "Maximum Attack Time Interval (Actual Seconds)");
			hitThroughWalls = ((BaseUnityPlugin)this).Config.Bind<bool>("Drone", "HitThroughWalls", false, "If the Drones attacks can hit through walls");
			hasCollision = ((BaseUnityPlugin)this).Config.Bind<bool>("Drone", "HasCollision", true, "If the Drone can collide with the player");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "DroneEnemy";

		public const string PLUGIN_NAME = "DroneEnemy";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace DroneEnemy.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}

plugins/ForestGiantMotionsense.dll

Decompiled 9 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("TanmanG")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("CC BY-NC-SA")]
[assembly: AssemblyDescription("A Harmony patch to adjust Forest Giant AI to only detect motion.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ForestGiantMotionsense")]
[assembly: AssemblyTitle("ForestGiantMotionsense")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/TanmanG/LethalCompany_ForestGiantMotionsense")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ForestGiantMotionsense;

[BepInPlugin("ForestGiantMotionsense", "ForestGiantMotionsense", "1.0.0")]
public class FoGiMoSeMod : BaseUnityPlugin
{
	private static FoGiMoSeMod Instance;

	private void Awake()
	{
		Instance = this;
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin ForestGiantMotionsense is loaded!");
		Harmony.CreateAndPatchAll(typeof(FoGiMoSeMod), (string)null);
	}

	[HarmonyPatch(typeof(ForestGiantAI), "LookForPlayers")]
	[HarmonyTranspiler]
	private static IEnumerable<CodeInstruction> MotionPatch(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Expected O, but got Unknown
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Expected O, but got Unknown
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Expected O, but got Unknown
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Expected O, but got Unknown
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Expected O, but got Unknown
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Expected O, but got Unknown
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Expected O, but got Unknown
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Expected O, but got Unknown
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Expected O, but got Unknown
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Expected O, but got Unknown
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Expected O, but got Unknown
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Expected O, but got Unknown
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: Expected O, but got Unknown
		//IL_022a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0230: Expected O, but got Unknown
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0243: Expected O, but got Unknown
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_0256: Expected O, but got Unknown
		//IL_025e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0264: Expected O, but got Unknown
		//IL_0281: Unknown result type (might be due to invalid IL or missing references)
		//IL_0287: Expected O, but got Unknown
		//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02aa: Expected O, but got Unknown
		//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bf: Expected O, but got Unknown
		//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ce: Expected O, but got Unknown
		//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f2: Expected O, but got Unknown
		//IL_0304: Unknown result type (might be due to invalid IL or missing references)
		//IL_030a: Expected O, but got Unknown
		//IL_0313: Unknown result type (might be due to invalid IL or missing references)
		//IL_0319: Expected O, but got Unknown
		//IL_0322: Unknown result type (might be due to invalid IL or missing references)
		//IL_0328: Expected O, but got Unknown
		//IL_0331: Unknown result type (might be due to invalid IL or missing references)
		//IL_0337: Expected O, but got Unknown
		//IL_0355: Unknown result type (might be due to invalid IL or missing references)
		//IL_035b: Expected O, but got Unknown
		//IL_0377: Unknown result type (might be due to invalid IL or missing references)
		//IL_037d: Expected O, but got Unknown
		//IL_0386: Unknown result type (might be due to invalid IL or missing references)
		//IL_038c: Expected O, but got Unknown
		//IL_0395: Unknown result type (might be due to invalid IL or missing references)
		//IL_039b: Expected O, but got Unknown
		//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03aa: Expected O, but got Unknown
		//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b9: Expected O, but got Unknown
		//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cd: Expected O, but got Unknown
		LocalBuilder localBuilder = generator.DeclareLocal(typeof(bool));
		LocalBuilder localBuilder2 = generator.DeclareLocal(typeof(bool));
		CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
		val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[5]
		{
			new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldelem_Ref, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null)
		}).Advance(1);
		((BaseUnityPlugin)Instance).Logger.LogInfo((object)$"First: {val.Remaining}");
		if (val.Remaining == 0)
		{
			((BaseUnityPlugin)Instance).Logger.LogFatal((object)"Could not find first LookForPlayers patch, flagging to abort!");
		}
		Label label = val.Instruction.labels.First();
		val.MatchBack(false, (CodeMatch[])(object)new CodeMatch[6]
		{
			new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldelem_R4, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ble_Un, (object)null, (string)null)
		});
		((BaseUnityPlugin)Instance).Logger.LogInfo((object)$"Second: {val.Remaining}");
		if (val.Remaining == 0)
		{
			((BaseUnityPlugin)Instance).Logger.LogFatal((object)"Could not find second LookForPlayers patch, flagging to abort!");
		}
		CodeInstruction instruction = val.Advance(2).Instruction;
		CodeInstruction instruction2 = val.Advance(2).Instruction;
		val.Advance(-4);
		val.RemoveInstructions(6).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[24]
		{
			new CodeInstruction(OpCodes.Ldarg_0, (object)null),
			new CodeInstruction(OpCodes.Ldfld, (object)typeof(ForestGiantAI).GetField("playerStealthMeters", BindingFlags.Instance | BindingFlags.Public)),
			instruction,
			new CodeInstruction(OpCodes.Ldelem_R4, (object)null),
			instruction2,
			new CodeInstruction(OpCodes.Cgt, (object)null),
			new CodeInstruction(OpCodes.Stloc_S, (object)localBuilder),
			new CodeInstruction(OpCodes.Call, (object)typeof(StartOfRound).GetMethod("get_Instance", BindingFlags.Static | BindingFlags.Public)),
			new CodeInstruction(OpCodes.Ldfld, (object)typeof(StartOfRound).GetField("allPlayerScripts", BindingFlags.Instance | BindingFlags.Public)),
			instruction,
			new CodeInstruction(OpCodes.Ldelem_Ref, (object)null),
			new CodeInstruction(OpCodes.Dup, (object)null),
			new CodeInstruction(OpCodes.Ldfld, (object)typeof(PlayerControllerB).GetField("timeSincePlayerMoving", BindingFlags.Instance | BindingFlags.Public)),
			new CodeInstruction(OpCodes.Ldc_R4, (object)2.25f),
			new CodeInstruction(OpCodes.Clt, (object)null),
			new CodeInstruction(OpCodes.Stloc_S, (object)localBuilder2),
			new CodeInstruction(OpCodes.Ldarg_0, (object)null),
			new CodeInstruction(OpCodes.Ldfld, (object)typeof(ForestGiantAI).GetField("chasingPlayer", BindingFlags.Instance | BindingFlags.Public)),
			new CodeInstruction(OpCodes.Call, (object)typeof(Object).GetMethod("op_Equality")),
			new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder2),
			new CodeInstruction(OpCodes.Or, (object)null),
			new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder),
			new CodeInstruction(OpCodes.And, (object)null),
			new CodeInstruction(OpCodes.Brfalse_S, (object)label)
		});
		return val.InstructionEnumeration();
	}

	[HarmonyPatch(typeof(PlayerControllerB), "UpdatePlayerPositionClientRpc")]
	[HarmonyTranspiler]
	private static IEnumerable<CodeInstruction> TimeSinceMovePatch(IEnumerable<CodeInstruction> instructions)
	{
		//IL_0003: 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_0023: Expected O, but got Unknown
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Expected O, but got Unknown
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Expected O, but got Unknown
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Expected O, but got Unknown
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Expected O, but got Unknown
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Expected O, but got Unknown
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Expected O, but got Unknown
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Expected O, but got Unknown
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Expected O, but got Unknown
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Expected O, but got Unknown
		CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[8]
		{
			new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Dup, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Add, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Stfld, (object)null, (string)null)
		});
		((BaseUnityPlugin)Instance).Logger.LogInfo((object)$"First RPC: {val.Remaining}");
		if (val.Remaining == 0)
		{
			((BaseUnityPlugin)Instance).Logger.LogFatal((object)"Could not find UpdatePlayerPositionClientRPC patch location, flagging to abort!");
		}
		val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[3]
		{
			new CodeInstruction(OpCodes.Ldarg_0, (object)null),
			new CodeInstruction(OpCodes.Ldc_R4, (object)0f),
			new CodeInstruction(OpCodes.Stfld, (object)typeof(PlayerControllerB).GetField("timeSincePlayerMoving", BindingFlags.Instance | BindingFlags.Public))
		});
		return val.InstructionEnumeration();
	}
}
public static class PluginInfo
{
	public const string PLUGIN_GUID = "ForestGiantMotionsense";

	public const string PLUGIN_NAME = "ForestGiantMotionsense";

	public const string PLUGIN_VERSION = "1.0.0";
}

plugins/GamblersMod.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GamblersMod.Patches;
using GamblersMod.Player;
using GamblersMod.RoundManagerCustomSpace;
using GamblersMod.config;
using GameNetcodeStuff;
using HarmonyLib;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("GamblersMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GamblersMod")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4389dd08-eb54-4b6f-955c-5f772ecc6fc7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace GamblersMod
{
	public class GamblingMachineManager : MonoBehaviour
	{
		public List<GameObject> GamblingMachines;

		public static GamblingMachineManager Instance { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			else
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			Plugin.mls.LogMessage((object)"Gambling machine manager has awoken!");
			GamblingMachines = new List<GameObject>();
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
		}

		public void Spawn(Vector3 spawnPoint, Quaternion quaternion)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			Plugin.mls.LogMessage((object)$"Spawning gambling machine... #{GamblingMachines.Count}");
			GameObject val = Object.Instantiate<GameObject>(Plugin.GamblingMachine, spawnPoint, quaternion);
			val.tag = "Untagged";
			val.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f);
			val.layer = LayerMask.NameToLayer("InteractableObject");
			val.GetComponent<NetworkObject>().Spawn(false);
			if (GamblingMachines.Count >= 1)
			{
				val.GetComponent<AudioSource>().Pause();
			}
			GamblingMachines.Add(val);
		}

		public void DespawnAll()
		{
			Plugin.mls.LogMessage((object)"Despwawning gambling machine...");
			foreach (GameObject gamblingMachine in GamblingMachines)
			{
				gamblingMachine.GetComponent<NetworkObject>().Despawn(true);
			}
			Reset();
		}

		public void Reset()
		{
			Plugin.mls.LogInfo((object)"Resetting gambling machine manager state...");
			GamblingMachines.Clear();
		}
	}
	[BepInPlugin("Junypai.GamblersMod", "Gamblers Mod", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string modGUID = "Junypai.GamblersMod";

		public const string modName = "Gamblers Mod";

		public const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Junypai.GamblersMod");

		public static Plugin Instance;

		public static GameObject GamblingMachine;

		public static AudioClip GamblingJackpotScrapAudio;

		public static AudioClip GamblingHalveScrapAudio;

		public static AudioClip GamblingRemoveScrapAudio;

		public static AudioClip GamblingDoubleScrapAudio;

		public static AudioClip GamblingTripleScrapAudio;

		public static AudioClip GamblingDrumrollScrapAudio;

		public static GameObject GamblingATMMachine;

		public static AudioClip GamblingMachineMusicAudio;

		public static GameObject GamblingMachineResultCanvas;

		public static Font GamblingFont;

		public static GameObject GamblingHandIcon;

		public static GambleConfigSettingsSerializable UserConfigSnapshot;

		public static GambleConfigSettingsSerializable RecentHostConfig;

		public static GambleConfigSettingsSerializable CurrentUserConfig;

		public static ManualLogSource mls;

		private void Awake()
		{
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			NetcodeWeaver();
			mls = Logger.CreateLogSource("Junypai.GamblersMod");
			CurrentUserConfig = new GambleConfigSettingsSerializable(((BaseUnityPlugin)this).Config);
			RecentHostConfig = new GambleConfigSettingsSerializable(((BaseUnityPlugin)this).Config);
			UserConfigSnapshot = new GambleConfigSettingsSerializable(((BaseUnityPlugin)this).Config);
			string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			mls.LogInfo((object)"Loading gambler bundle assets");
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(directoryName, "gamblingmachinebundle"));
			if (!Object.op_Implicit((Object)(object)val))
			{
				mls.LogError((object)"Unable to load gambler bundle assets");
			}
			else
			{
				mls.LogInfo((object)"Gamblers bundle assets successfully loaded");
			}
			GamblingDrumrollScrapAudio = LoadAssetFromAssetBundleAndLogInfo<AudioClip>(val, "drumroll");
			GamblingJackpotScrapAudio = LoadAssetFromAssetBundleAndLogInfo<AudioClip>(val, "holyshit");
			GamblingHalveScrapAudio = LoadAssetFromAssetBundleAndLogInfo<AudioClip>(val, "cricket");
			GamblingRemoveScrapAudio = LoadAssetFromAssetBundleAndLogInfo<AudioClip>(val, "womp");
			GamblingMachineMusicAudio = LoadAssetFromAssetBundleAndLogInfo<AudioClip>(val, "machineMusic");
			GamblingDoubleScrapAudio = LoadAssetFromAssetBundleAndLogInfo<AudioClip>(val, "doublekill");
			GamblingTripleScrapAudio = LoadAssetFromAssetBundleAndLogInfo<AudioClip>(val, "triplekill");
			GamblingFont = LoadAssetFromAssetBundleAndLogInfo<Font>(val, "3270-Regular");
			GamblingMachine = LoadAssetFromAssetBundleAndLogInfo<GameObject>(val, "GamblingMachine");
			GamblingHandIcon = LoadAssetFromAssetBundleAndLogInfo<GameObject>(val, "HandIconGO");
			GamblingMachine.AddComponent<GamblingMachine>();
			new GameObject().AddComponent<GamblingMachineManager>();
			harmony.PatchAll(typeof(Plugin));
			harmony.PatchAll(typeof(GameNetworkManagerPatch));
			harmony.PatchAll(typeof(PlayerControllerBPatch));
			harmony.PatchAll(typeof(RoundManagerPatch));
			harmony.PatchAll(typeof(StartOfRoundPatch));
		}

		private T LoadAssetFromAssetBundleAndLogInfo<T>(AssetBundle bundle, string assetName) where T : Object
		{
			T val = bundle.LoadAsset<T>(assetName);
			if (!Object.op_Implicit((Object)(object)val))
			{
				mls.LogError((object)(assetName + " asset failed to load"));
			}
			else
			{
				mls.LogInfo((object)(assetName + " asset successfully loaded"));
			}
			return val;
		}

		private static void NetcodeWeaver()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public class StartOfRoundCustom : NetworkBehaviour
	{
		private void Awake()
		{
		}

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

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_StartOfRoundCustom()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1680317104u, new RpcReceiveHandler(__rpc_handler_1680317104));
		}

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

		protected internal override string __getTypeName()
		{
			return "StartOfRoundCustom";
		}
	}
}
namespace GamblersMod.RoundManagerCustomSpace
{
	internal class RoundManagerCustom : NetworkBehaviour
	{
		public RoundManager RoundManager;

		private List<Vector3> spawnPoints;

		private void Awake()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			RoundManager = ((Component)this).GetComponent<RoundManager>();
			spawnPoints = new List<Vector3>();
			spawnPoints.Add(new Vector3(-27.808f, -2.6256f, -9.7409f));
			spawnPoints.Add(new Vector3(-27.808f, -2.6256f, -4.7409f));
			spawnPoints.Add(new Vector3(-27.808f, -2.6256f, 0.7409f));
			spawnPoints.Add(new Vector3(-27.808f, -2.6256f, 6.7409f));
		}

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

		[ServerRpc]
		public void SpawnGamblingMachineServerRpc()
		{
			//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
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: 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)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2764001088u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2764001088u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				Plugin.mls.LogInfo((object)("Attempting to spawn gambling machine at " + ((Object)RoundManager.currentLevel).name));
				for (int i = 0; i < Plugin.CurrentUserConfig.configNumberOfMachines && i < spawnPoints.Count; i++)
				{
					GamblingMachineManager.Instance.Spawn(spawnPoints[i], Quaternion.Euler(0f, 90f, 0f));
					Plugin.mls.LogInfo((object)$"Spawned machine number: {i}");
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_RoundManagerCustom()
		{
			//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(3258984052u, new RpcReceiveHandler(__rpc_handler_3258984052));
			NetworkManager.__rpc_func_table.Add(2764001088u, new RpcReceiveHandler(__rpc_handler_2764001088));
		}

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

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

		protected internal override string __getTypeName()
		{
			return "RoundManagerCustom";
		}
	}
}
namespace GamblersMod.Player
{
	internal class PlayerControllerCustom : NetworkBehaviour
	{
		private PlayerGamblingUIManager PlayerGamblingUIManager;

		private PlayerControllerB PlayerControllerOriginal;

		public bool isUsingGamblingMachine;

		private void Awake()
		{
			PlayerGamblingUIManager = ((Component)this).gameObject.AddComponent<PlayerGamblingUIManager>();
			PlayerControllerOriginal = ((Component)this).gameObject.GetComponent<PlayerControllerB>();
		}

		private void Update()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)this).IsOwner)
			{
				return;
			}
			Camera gameplayCamera = PlayerControllerOriginal.gameplayCamera;
			Vector3 position = ((Component)gameplayCamera).transform.position;
			Vector3 forward = ((Component)gameplayCamera).transform.forward;
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(position, forward);
			float num = 5f;
			int num2 = 512;
			RaycastHit val2 = default(RaycastHit);
			bool flag = Physics.Raycast(val, ref val2, num, num2);
			if (Object.op_Implicit((Object)(object)((RaycastHit)(ref val2)).collider))
			{
				GameObject gameObject = ((Component)((RaycastHit)(ref val2)).transform).gameObject;
				if (((Object)gameObject).name.Contains("GamblingMachine"))
				{
					PlayerGamblingUIManager.ShowInteractionText();
					GrabbableObject val3 = PlayerControllerOriginal.ItemSlots[PlayerControllerOriginal.currentItemSlot];
					GamblingMachine component = gameObject.GetComponent<GamblingMachine>();
					if (component.isInCooldownPhase())
					{
						PlayerGamblingUIManager.SetInteractionText($"Cooling down... {component.gamblingMachineCurrentCooldown}");
					}
					else if (component.numberOfUses <= 0)
					{
						PlayerGamblingUIManager.SetInteractionText("This machine is all used up");
					}
					else
					{
						string bindingDisplayString = InputActionRebindingExtensions.GetBindingDisplayString(IngamePlayerSettings.Instance.playerInput.actions.FindAction("Interact", false), 0, (DisplayStringOptions)0);
						if (isUsingGamblingMachine)
						{
							PlayerGamblingUIManager.SetInteractionText("You're already using a machine");
						}
						else
						{
							PlayerGamblingUIManager.SetInteractionText("Gamble: [" + bindingDisplayString + "]");
						}
					}
					if (Object.op_Implicit((Object)(object)val3))
					{
						PlayerGamblingUIManager.SetInteractionSubText($"Scrap value on hand: ■{val3.scrapValue}");
					}
					else
					{
						PlayerGamblingUIManager.SetInteractionSubText("Please hold a scrap on your hand");
					}
				}
				if (((Object)gameObject).name.Contains("GamblingMachine") && IngamePlayerSettings.Instance.playerInput.actions.FindAction("Interact", false).triggered)
				{
					GamblingMachine component2 = gameObject.GetComponent<GamblingMachine>();
					handleGamblingMachineInput(component2);
				}
			}
			else
			{
				PlayerGamblingUIManager.HideInteractionText();
			}
		}

		public void ReleaseGamblingMachineLock()
		{
			Plugin.mls.LogInfo((object)$"Releasing gambling machine lock for: {((NetworkBehaviour)this).OwnerClientId}");
			isUsingGamblingMachine = false;
		}

		public void LockGamblingMachine()
		{
			Plugin.mls.LogInfo((object)$"Locking gambling machine for: {((NetworkBehaviour)this).OwnerClientId}");
			isUsingGamblingMachine = true;
		}

		private void handleGamblingMachineInput(GamblingMachine GamblingMachineHit)
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			GrabbableObject val = PlayerControllerOriginal.ItemSlots[PlayerControllerOriginal.currentItemSlot];
			if (Object.op_Implicit((Object)(object)val) && !GamblingMachineHit.isInCooldownPhase() && GamblingMachineHit.numberOfUses > 0 && !isUsingGamblingMachine)
			{
				Plugin.mls.LogInfo((object)("Gambling machine was interacted with by: " + PlayerControllerOriginal.playerUsername));
				GamblingMachineHit.SetCurrentGamblingCooldownToMaxCooldown();
				Plugin.mls.LogMessage((object)$"Scrap value of {((Object)val).name} on hand: ▊{val.scrapValue}");
				GamblingMachineHit.ActivateGamblingMachineServerRPC(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)val), NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)this));
				PlayerGamblingUIManager.SetInteractionText($"Cooling down... {GamblingMachineHit.gamblingMachineCurrentCooldown}");
			}
		}

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

		protected internal override string __getTypeName()
		{
			return "PlayerControllerCustom";
		}
	}
}
namespace GamblersMod.Patches
{
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal class GameNetworkManagerPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void StartPatch(GameNetworkManager __instance)
		{
			Plugin.mls.LogInfo((object)"Adding Gambling machine to network prefab");
			NetworkManager.Singleton.AddNetworkPrefab(Plugin.GamblingMachine);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")]
		public static void StartDisconnectPatch()
		{
			Plugin.mls.LogInfo((object)"Player disconnected. Resetting the user's configuration settings.");
			Plugin.CurrentUserConfig = Plugin.UserConfigSnapshot;
			GamblingMachineManager.Instance.Reset();
		}
	}
	[HarmonyPatch(typeof(GrabbableObject))]
	internal class GrabbableObjectPatch
	{
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void AwakePatch(StartOfRound __instance)
		{
			Plugin.mls.LogInfo((object)"StartOfRoundPatch has awoken");
		}
	}
	public class PlayerGamblingUIManager : NetworkBehaviour
	{
		private GameObject gamblingMachineInteractionTextCanvasObject;

		private Canvas gamblingMachineInteractionTextCanvas;

		private GameObject gamblingMachineInteractionTextObject;

		private GameObject gamblingMachineInteractionScrapInfoTextObject;

		private Text gamblingMachineInteractionScrapInfoText;

		private Text gamblingMachineInteractionText;

		private string interactionName;

		private string interactionText;

		private void Awake()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			//IL_00e2: 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)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Expected O, but got Unknown
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: 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_02c5: Unknown result type (might be due to invalid IL or missing references)
			gamblingMachineInteractionTextCanvasObject = new GameObject();
			gamblingMachineInteractionTextCanvasObject.transform.parent = ((Component)this).transform;
			interactionName = "gamblingMachine";
			((Object)gamblingMachineInteractionTextCanvasObject).name = interactionName + "InteractionTextCanvasObject";
			gamblingMachineInteractionTextCanvasObject.AddComponent<Canvas>();
			gamblingMachineInteractionTextCanvasObject.SetActive(false);
			gamblingMachineInteractionTextCanvas = gamblingMachineInteractionTextCanvasObject.GetComponent<Canvas>();
			gamblingMachineInteractionTextCanvas.renderMode = (RenderMode)0;
			gamblingMachineInteractionTextCanvasObject.AddComponent<CanvasScaler>();
			gamblingMachineInteractionTextCanvasObject.AddComponent<GraphicRaycaster>();
			gamblingMachineInteractionTextObject = new GameObject();
			((Object)gamblingMachineInteractionTextObject).name = interactionName + "InteractionTextObject";
			gamblingMachineInteractionTextObject.AddComponent<Text>();
			Transform transform = gamblingMachineInteractionTextObject.transform;
			Rect rect = ((Component)gamblingMachineInteractionTextCanvas).GetComponent<RectTransform>().rect;
			float num = ((Rect)(ref rect)).width / 2f - 20f;
			rect = ((Component)gamblingMachineInteractionTextCanvas).GetComponent<RectTransform>().rect;
			transform.localPosition = new Vector3(num, ((Rect)(ref rect)).height / 2f - 50f, 0f);
			gamblingMachineInteractionText = gamblingMachineInteractionTextObject.GetComponent<Text>();
			gamblingMachineInteractionText.text = interactionText;
			gamblingMachineInteractionText.alignment = (TextAnchor)4;
			gamblingMachineInteractionText.font = Plugin.GamblingFont;
			((Graphic)gamblingMachineInteractionText).rectTransform.sizeDelta = new Vector2(500f, 400f);
			gamblingMachineInteractionText.fontSize = 26;
			((Component)gamblingMachineInteractionText).transform.parent = gamblingMachineInteractionTextCanvasObject.transform;
			gamblingMachineInteractionScrapInfoTextObject = new GameObject();
			((Object)gamblingMachineInteractionScrapInfoTextObject).name = interactionName + "InteractionScrapInfoTextObject";
			gamblingMachineInteractionScrapInfoTextObject.AddComponent<Text>();
			Transform transform2 = gamblingMachineInteractionScrapInfoTextObject.transform;
			rect = ((Component)gamblingMachineInteractionTextCanvas).GetComponent<RectTransform>().rect;
			float num2 = ((Rect)(ref rect)).width / 2f - 20f;
			rect = ((Component)gamblingMachineInteractionTextCanvas).GetComponent<RectTransform>().rect;
			transform2.localPosition = new Vector3(num2, ((Rect)(ref rect)).height / 2f - 100f, 0f);
			gamblingMachineInteractionScrapInfoText = gamblingMachineInteractionScrapInfoTextObject.GetComponent<Text>();
			gamblingMachineInteractionScrapInfoText.text = interactionText;
			gamblingMachineInteractionScrapInfoText.alignment = (TextAnchor)4;
			gamblingMachineInteractionScrapInfoText.font = Plugin.GamblingFont;
			((Graphic)gamblingMachineInteractionScrapInfoText).rectTransform.sizeDelta = new Vector2(500f, 300f);
			gamblingMachineInteractionScrapInfoText.fontSize = 18;
			((Graphic)gamblingMachineInteractionScrapInfoText).color = Color.green;
			((Component)gamblingMachineInteractionScrapInfoText).transform.parent = gamblingMachineInteractionTextCanvasObject.transform;
		}

		public void SetInteractionText(string text)
		{
			gamblingMachineInteractionText.text = text;
		}

		public void SetInteractionSubText(string text)
		{
			gamblingMachineInteractionScrapInfoText.text = text;
		}

		public void ShowInteractionText()
		{
			gamblingMachineInteractionTextCanvasObject.SetActive(true);
		}

		public void HideInteractionText()
		{
			gamblingMachineInteractionTextCanvasObject.SetActive(false);
		}

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

		protected internal override string __getTypeName()
		{
			return "PlayerGamblingUIManager";
		}
	}
	internal class GamblingMachine : NetworkBehaviour
	{
		private int gamblingMachineMaxCooldown;

		public int gamblingMachineCurrentCooldown = 0;

		private float jackpotMultiplier;

		private float tripleMultiplier;

		private float doubleMultiplier;

		private float halvedMultiplier;

		private float zeroMultiplier;

		private int jackpotPercentage;

		private int triplePercentage;

		private int doublePercentage;

		private int halvedPercentage;

		private int removedPercentage;

		private bool isMusicEnabled = true;

		private float musicVolume = 0.35f;

		private int rollMinValue;

		private int rollMaxValue;

		private int currentRoll = 100;

		public float currentGamblingOutcomeMultiplier = 1f;

		public string currentGamblingOutcome = GambleConstants.GamblingOutcome.DEFAULT;

		private Coroutine CountdownCooldownCoroutineBeingRan;

		private bool lockGamblingMachineServer = false;

		public int numberOfUses;

		private void Awake()
		{
			Plugin.mls.LogInfo((object)"GamblingMachine has Awoken");
			gamblingMachineMaxCooldown = Plugin.CurrentUserConfig.configMaxCooldown;
			numberOfUses = Plugin.CurrentUserConfig.configNumberOfUses;
			jackpotMultiplier = Plugin.CurrentUserConfig.configJackpotMultiplier;
			tripleMultiplier = Plugin.CurrentUserConfig.configTripleMultiplier;
			doubleMultiplier = Plugin.CurrentUserConfig.configDoubleMultiplier;
			halvedMultiplier = Plugin.CurrentUserConfig.configHalveMultiplier;
			zeroMultiplier = Plugin.CurrentUserConfig.configZeroMultiplier;
			jackpotPercentage = Plugin.CurrentUserConfig.configJackpotChance;
			triplePercentage = Plugin.CurrentUserConfig.configTripleChance;
			doublePercentage = Plugin.CurrentUserConfig.configDoubleChance;
			halvedPercentage = Plugin.CurrentUserConfig.configHalveChance;
			removedPercentage = Plugin.CurrentUserConfig.configZeroChance;
			isMusicEnabled = Plugin.CurrentUserConfig.configGamblingMusicEnabled;
			musicVolume = Plugin.CurrentUserConfig.configGamblingMusicVolume;
			Plugin.mls.LogInfo((object)$"GamblingMachine: gamblingMachineMaxCooldown loaded from config: {gamblingMachineMaxCooldown}");
			Plugin.mls.LogInfo((object)$"GamblingMachine: jackpotMultiplier loaded from config: {jackpotMultiplier}");
			Plugin.mls.LogInfo((object)$"GamblingMachine: tripleMultiplier loaded from config: {tripleMultiplier}");
			Plugin.mls.LogInfo((object)$"GamblingMachine: doubleMultiplier loaded from config: {doubleMultiplier}");
			Plugin.mls.LogInfo((object)$"GamblingMachine: halvedMultiplier loaded from config: {halvedMultiplier}");
			Plugin.mls.LogInfo((object)$"GamblingMachine: zeroMultiplier loaded from config: {zeroMultiplier}");
			Plugin.mls.LogInfo((object)$"GamblingMachine: jackpotPercentage loaded from config: {jackpotPercentage}");
			Plugin.mls.LogInfo((object)$"GamblingMachine: triplePercentage loaded from config: {triplePercentage}");
			Plugin.mls.LogInfo((object)$"GamblingMachine: doublePercentage loaded from config: {doublePercentage}");
			Plugin.mls.LogInfo((object)$"GamblingMachine: halvedPercentage loaded from config: {halvedPercentage}");
			Plugin.mls.LogInfo((object)$"GamblingMachine: removedPercentage loaded from config: {removedPercentage}");
			Plugin.mls.LogInfo((object)$"GamblingMachine: gamblingMusicEnabled loaded from config: {isMusicEnabled}");
			Plugin.mls.LogInfo((object)$"GamblingMachine: gamblingMusicVolume loaded from config: {musicVolume}");
			InitAudioSource();
			rollMinValue = 1;
			rollMaxValue = jackpotPercentage + triplePercentage + doublePercentage + halvedPercentage + removedPercentage;
		}

		private void Start()
		{
			Plugin.mls.LogInfo((object)"GamblingMachine has Started");
		}

		public void GenerateGamblingOutcomeFromCurrentRoll()
		{
			bool flag = currentRoll >= rollMinValue && currentRoll <= jackpotPercentage;
			int num = jackpotPercentage;
			int num2 = jackpotPercentage + triplePercentage;
			bool flag2 = currentRoll > num && currentRoll <= num2;
			int num3 = num2;
			int num4 = num2 + doublePercentage;
			bool flag3 = currentRoll > num3 && currentRoll <= num4;
			int num5 = num4;
			int num6 = num4 + halvedPercentage;
			bool flag4 = currentRoll > num5 && currentRoll <= num6;
			if (flag)
			{
				Plugin.mls.LogMessage((object)"Rolled Jackpot");
				currentGamblingOutcomeMultiplier = jackpotMultiplier;
				currentGamblingOutcome = GambleConstants.GamblingOutcome.JACKPOT;
			}
			else if (flag2)
			{
				Plugin.mls.LogMessage((object)"Rolled Triple");
				currentGamblingOutcomeMultiplier = tripleMultiplier;
				currentGamblingOutcome = GambleConstants.GamblingOutcome.TRIPLE;
			}
			else if (flag3)
			{
				Plugin.mls.LogMessage((object)"Rolled Double");
				currentGamblingOutcomeMultiplier = doubleMultiplier;
				currentGamblingOutcome = GambleConstants.GamblingOutcome.DOUBLE;
			}
			else if (flag4)
			{
				Plugin.mls.LogMessage((object)"Rolled Halved");
				currentGamblingOutcomeMultiplier = halvedMultiplier;
				currentGamblingOutcome = GambleConstants.GamblingOutcome.HALVE;
			}
			else
			{
				Plugin.mls.LogMessage((object)"Rolled Remove");
				currentGamblingOutcomeMultiplier = zeroMultiplier;
				currentGamblingOutcome = GambleConstants.GamblingOutcome.REMOVE;
			}
		}

		public void PlayGambleResultAudio(string outcome)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			if (outcome == GambleConstants.GamblingOutcome.JACKPOT)
			{
				AudioSource.PlayClipAtPoint(Plugin.GamblingJackpotScrapAudio, ((Component)this).transform.position, 0.6f);
			}
			else if (outcome == GambleConstants.GamblingOutcome.TRIPLE)
			{
				AudioSource.PlayClipAtPoint(Plugin.GamblingTripleScrapAudio, ((Component)this).transform.position, 0.6f);
			}
			else if (outcome == GambleConstants.GamblingOutcome.DOUBLE)
			{
				AudioSource.PlayClipAtPoint(Plugin.GamblingDoubleScrapAudio, ((Component)this).transform.position, 0.6f);
			}
			else if (outcome == GambleConstants.GamblingOutcome.HALVE)
			{
				AudioSource.PlayClipAtPoint(Plugin.GamblingHalveScrapAudio, ((Component)this).transform.position, 0.6f);
			}
			else if (outcome == GambleConstants.GamblingOutcome.REMOVE)
			{
				AudioSource.PlayClipAtPoint(Plugin.GamblingRemoveScrapAudio, ((Component)this).transform.position, 0.6f);
			}
		}

		public void PlayDrumRoll()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			AudioSource.PlayClipAtPoint(Plugin.GamblingDrumrollScrapAudio, ((Component)this).transform.position, 0.6f);
		}

		public void BeginGamblingMachineCooldown(Action onCountdownFinish)
		{
			SetCurrentGamblingCooldownToMaxCooldown();
			if (CountdownCooldownCoroutineBeingRan != null)
			{
				((MonoBehaviour)this).StopCoroutine(CountdownCooldownCoroutineBeingRan);
			}
			CountdownCooldownCoroutineBeingRan = ((MonoBehaviour)this).StartCoroutine(CountdownCooldownCoroutine(onCountdownFinish));
		}

		public bool isInCooldownPhase()
		{
			return gamblingMachineCurrentCooldown > 0;
		}

		private IEnumerator CountdownCooldownCoroutine(Action onCountdownFinish)
		{
			Plugin.mls.LogInfo((object)"Start gambling machine cooldown");
			while (gamblingMachineCurrentCooldown > 0)
			{
				yield return (object)new WaitForSeconds(1f);
				gamblingMachineCurrentCooldown--;
				Plugin.mls.LogMessage((object)$"Gambling machine cooldown: {gamblingMachineCurrentCooldown}");
			}
			onCountdownFinish();
			Plugin.mls.LogMessage((object)"End gambling machine cooldown");
		}

		public void SetCurrentGamblingCooldownToMaxCooldown()
		{
			gamblingMachineCurrentCooldown = gamblingMachineMaxCooldown;
		}

		public void SetRoll(int newRoll)
		{
			currentRoll = newRoll;
		}

		public int RollDice()
		{
			int result = Random.Range(rollMinValue, rollMaxValue);
			Plugin.mls.LogMessage((object)$"rollMinValue: {rollMinValue}");
			Plugin.mls.LogMessage((object)$"rollMaxValue: {rollMaxValue}");
			Plugin.mls.LogMessage((object)$"Roll value: {currentRoll}");
			return result;
		}

		public int GetScrapValueBasedOnGambledOutcome(GrabbableObject scrap)
		{
			return (int)Mathf.Floor((float)scrap.scrapValue * currentGamblingOutcomeMultiplier);
		}

		[ServerRpc(RequireOwnership = false)]
		public void ActivateGamblingMachineServerRPC(NetworkBehaviourReference scrapBeingGambledRef, NetworkBehaviourReference playerWhoGambledRef, ServerRpcParams serverRpcParams = default(ServerRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_0098: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: 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)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3977934568u, serverRpcParams, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe<NetworkBehaviourReference>(ref scrapBeingGambledRef, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val)).WriteValueSafe<NetworkBehaviourReference>(ref playerWhoGambledRef, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 3977934568u, serverRpcParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost) || !((NetworkBehaviour)this).IsServer)
			{
				return;
			}
			if (numberOfUses <= 0)
			{
				Plugin.mls.LogWarning((object)"ActivateGamblingMachineServerRPC: Machine usage limit has been reached");
				return;
			}
			if (lockGamblingMachineServer)
			{
				Plugin.mls.LogWarning((object)$"Gambling machine is already processing one client's request. Throwing away a request for... {serverRpcParams.Receive.SenderClientId}");
				return;
			}
			lockGamblingMachineServer = true;
			numberOfUses--;
			Plugin.mls.LogInfo((object)$"ActivateGamblingMachineServerRPC: Number of uses left: {numberOfUses}");
			GrabbableObject scrap = default(GrabbableObject);
			if (!((NetworkBehaviourReference)(ref scrapBeingGambledRef)).TryGet<GrabbableObject>(ref scrap, (NetworkManager)null))
			{
				Plugin.mls.LogError((object)"ActivateGamblingMachineServerRPC: Failed to get scrap value on client side.");
				return;
			}
			BeginGamblingMachineCooldownClientRpc();
			Plugin.mls.LogMessage((object)("ActivateGamblingMachineServerRPC: Starting gambling machine cooldown phase in the server invoked by: " + serverRpcParams.Receive.SenderClientId));
			SetRoll(RollDice());
			GenerateGamblingOutcomeFromCurrentRoll();
			int scrapValueBasedOnGambledOutcome = GetScrapValueBasedOnGambledOutcome(scrap);
			ActivateGamblingMachineClientRPC(scrapBeingGambledRef, playerWhoGambledRef, serverRpcParams.Receive.SenderClientId, scrapValueBasedOnGambledOutcome, currentGamblingOutcome, numberOfUses);
		}

		[ClientRpc]
		private void ActivateGamblingMachineClientRPC(NetworkBehaviourReference scrapBeingGambledRef, NetworkBehaviourReference playerWhoGambledRef, ulong invokerId, int updatedScrapValue, string outcome, int numberOfUsesServer)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: 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_0098: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: 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_00ff: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(875756295u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref scrapBeingGambledRef, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref playerWhoGambledRef, default(ForNetworkSerializable));
				BytePacker.WriteValueBitPacked(val2, invokerId);
				BytePacker.WriteValueBitPacked(val2, updatedScrapValue);
				bool flag = outcome != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(outcome, false);
				}
				BytePacker.WriteValueBitPacked(val2, numberOfUsesServer);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 875756295u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			NetworkBehaviourReference scrapBeingGambledRef2 = scrapBeingGambledRef;
			int updatedScrapValue2 = updatedScrapValue;
			string outcome2 = outcome;
			Plugin.mls.LogInfo((object)"ActivateGamblingMachineClientRPC: Activiating gambling machines on client...");
			numberOfUses = numberOfUsesServer;
			Plugin.mls.LogInfo((object)$"ActivateGamblingMachineClientRPC: Number of uses left: {numberOfUses}");
			PlayerControllerCustom playerWhoGambled = default(PlayerControllerCustom);
			if (!((NetworkBehaviourReference)(ref playerWhoGambledRef)).TryGet<PlayerControllerCustom>(ref playerWhoGambled, (NetworkManager)null))
			{
				Plugin.mls.LogError((object)"ActivateGamblingMachineClientRPC: Failed to get player who gambled.");
				return;
			}
			playerWhoGambled.LockGamblingMachine();
			PlayDrumRoll();
			BeginGamblingMachineCooldown(delegate
			{
				GrabbableObject val3 = default(GrabbableObject);
				if (!((NetworkBehaviourReference)(ref scrapBeingGambledRef2)).TryGet<GrabbableObject>(ref val3, (NetworkManager)null))
				{
					Plugin.mls.LogError((object)"ActivateGamblingMachineClientRPC: Failed to get scrap value on client side.");
				}
				else
				{
					Plugin.mls.LogInfo((object)$"Setting scrap value to: {updatedScrapValue2}");
					val3.SetScrapValue(updatedScrapValue2);
					PlayGambleResultAudio(outcome2);
					playerWhoGambled.ReleaseGamblingMachineLock();
					if (((NetworkBehaviour)this).IsServer)
					{
						Plugin.mls.LogMessage((object)"Unlocking gambling machine");
						lockGamblingMachineServer = false;
					}
				}
			});
		}

		[ClientRpc]
		private void BeginGamblingMachineCooldownClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1546410253u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1546410253u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					Plugin.mls.LogInfo((object)"Setting machine cooldown to max");
					SetCurrentGamblingCooldownToMaxCooldown();
				}
			}
		}

		private void InitAudioSource()
		{
			if (!isMusicEnabled)
			{
				((Component)this).GetComponent<AudioSource>().Pause();
			}
			((Component)this).GetComponent<AudioSource>().volume = musicVolume;
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_GamblingMachine()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3977934568u, new RpcReceiveHandler(__rpc_handler_3977934568));
			NetworkManager.__rpc_func_table.Add(875756295u, new RpcReceiveHandler(__rpc_handler_875756295));
			NetworkManager.__rpc_func_table.Add(1546410253u, new RpcReceiveHandler(__rpc_handler_1546410253));
		}

		private static void __rpc_handler_3977934568(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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference scrapBeingGambledRef = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref scrapBeingGambledRef, default(ForNetworkSerializable));
				NetworkBehaviourReference playerWhoGambledRef = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref playerWhoGambledRef, default(ForNetworkSerializable));
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((GamblingMachine)(object)target).ActivateGamblingMachineServerRPC(scrapBeingGambledRef, playerWhoGambledRef, server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_875756295(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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference scrapBeingGambledRef = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref scrapBeingGambledRef, default(ForNetworkSerializable));
				NetworkBehaviourReference playerWhoGambledRef = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref playerWhoGambledRef, default(ForNetworkSerializable));
				ulong invokerId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref invokerId);
				int updatedScrapValue = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref updatedScrapValue);
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string outcome = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref outcome, false);
				}
				int numberOfUsesServer = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref numberOfUsesServer);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((GamblingMachine)(object)target).ActivateGamblingMachineClientRPC(scrapBeingGambledRef, playerWhoGambledRef, invokerId, updatedScrapValue, outcome, numberOfUsesServer);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		protected internal override string __getTypeName()
		{
			return "GamblingMachine";
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPrefix]
		public static void Awake(PlayerControllerB __instance)
		{
			((Component)__instance).gameObject.AddComponent<PlayerControllerCustom>();
		}

		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		[HarmonyPostfix]
		public static void ConnectClientToPlayerObjectPatch()
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			Plugin.mls.LogInfo((object)"ConnectClientToPlayerObjectPatch");
			if (NetworkManager.Singleton.IsHost)
			{
				Plugin.mls.LogInfo((object)("Registering host config message handler: Junypai.GamblersMod_" + GambleConstants.ON_HOST_RECIEVES_CLIENT_CONFIG_REQUEST));
				NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("Junypai.GamblersMod_" + GambleConstants.ON_HOST_RECIEVES_CLIENT_CONFIG_REQUEST, new HandleNamedMessageDelegate(GambleConfigNetworkHelper.OnHostRecievesClientConfigRequest));
			}
			else
			{
				NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("Junypai.GamblersMod_" + GambleConstants.ON_CLIENT_RECIEVES_HOST_CONFIG_REQUEST, new HandleNamedMessageDelegate(GambleConfigNetworkHelper.OnClientRecievesHostConfigRequest));
				GambleConfigNetworkHelper.StartClientRequestConfigFromHost();
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatch
	{
		public static RoundManagerCustom RoundManagerCustom;

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		public static void AwakePatch(RoundManager __instance)
		{
			Plugin.mls.LogInfo((object)"RoundManagerPatch has awoken");
			RoundManagerCustom = ((Component)__instance).gameObject.AddComponent<RoundManagerCustom>();
		}

		[HarmonyPatch("LoadNewLevelWait")]
		[HarmonyPrefix]
		public static void LoadNewLevelWaitPatch(RoundManager __instance)
		{
			Plugin.mls.LogInfo((object)"FinishGeneratingNewLevelServerRpcPatch was called");
			if (__instance.currentLevel.levelID != 3)
			{
				Plugin.mls.LogInfo((object)"Despawning gambling machine...");
				RoundManagerCustom.DespawnGamblingMachineServerRpc();
			}
			if (__instance.currentLevel.levelID == 3)
			{
				Plugin.mls.LogInfo((object)"Spawning gambling machine...");
				RoundManagerCustom.SpawnGamblingMachineServerRpc();
			}
		}

		[HarmonyPatch("DespawnPropsAtEndOfRound")]
		[HarmonyPostfix]
		public static void DespawnPropsAtEndOfRoundPatch()
		{
			Plugin.mls.LogInfo((object)"End of round: despawning gambling machines");
			RoundManagerCustom.DespawnGamblingMachineServerRpc();
		}
	}
}
namespace GamblersMod.GrabbableObjectCustom
{
	internal class GrabbableObjectCustom
	{
	}
}
namespace GamblersMod.config
{
	public class GambleConfigNetworkHelper
	{
		public static void OnHostRecievesClientConfigRequest(ulong clientId, FastBufferReader _)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsHost)
			{
				return;
			}
			Plugin.mls.LogInfo((object)"Host recieved client config request.");
			Plugin.mls.LogInfo((object)"Serializing host config data...");
			byte[] serializedSettings = SerializerHelper.GetSerializedSettings(Plugin.CurrentUserConfig);
			Plugin.mls.LogInfo((object)"Start writing host config data...");
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(serializedSettings.Length + 4, (Allocator)2, -1);
			FastBufferWriter val2 = val;
			try
			{
				Plugin.mls.LogInfo((object)"Writing host config data");
				int num = serializedSettings.Length;
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteBytesSafe(serializedSettings, -1, 0);
				Plugin.mls.LogInfo((object)$"Sending host config data to client with id of {clientId}...");
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("Junypai.GamblersMod_" + GambleConstants.ON_CLIENT_RECIEVES_HOST_CONFIG_REQUEST, clientId, val, (NetworkDelivery)4);
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val2)).Dispose();
			}
		}

		public static void StartClientRequestConfigFromHost()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton.IsClient)
			{
				Plugin.mls.LogInfo((object)"Client is requesting configuration from host");
				FastBufferWriter val = default(FastBufferWriter);
				((FastBufferWriter)(ref val))..ctor(4, (Allocator)2, -1);
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("Junypai.GamblersMod_" + GambleConstants.ON_HOST_RECIEVES_CLIENT_CONFIG_REQUEST, 0uL, val, (NetworkDelivery)3);
			}
		}

		public static void OnClientRecievesHostConfigRequest(ulong _, FastBufferReader reader)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			Plugin.mls.LogInfo((object)"Client recieved configuration message from host");
			if (!((FastBufferReader)(ref reader)).TryBeginRead(4))
			{
				Plugin.mls.LogError((object)"Could not sync client configuration with host. The stream sent by StartClientRequestConfigFromHost was invalid.");
				return;
			}
			int num = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
			if (!((FastBufferReader)(ref reader)).TryBeginRead(num))
			{
				Plugin.mls.LogError((object)"Could not sync client configuration with host. Host could not serialize the data.");
			}
			byte[] settingsAsBytes = new byte[num];
			((FastBufferReader)(ref reader)).ReadBytesSafe(ref settingsAsBytes, num, 0);
			Plugin.RecentHostConfig = SerializerHelper.GetDeserializedSettings<GambleConfigSettingsSerializable>(settingsAsBytes);
			Plugin.CurrentUserConfig = Plugin.RecentHostConfig;
			Plugin.CurrentUserConfig.configGamblingMusicEnabled = Plugin.UserConfigSnapshot.configGamblingMusicEnabled;
			Plugin.CurrentUserConfig.configGamblingMusicVolume = Plugin.UserConfigSnapshot.configGamblingMusicVolume;
			ManualLogSource mls = Plugin.mls;
			mls.LogInfo((object)$"Cooldown value from config: {Plugin.CurrentUserConfig.configMaxCooldown}");
			mls.LogInfo((object)$"Jackpot chance value from config: {Plugin.CurrentUserConfig.configJackpotChance}");
			mls.LogInfo((object)$"Triple chance value from config: {Plugin.CurrentUserConfig.configTripleChance}");
			mls.LogInfo((object)$"Double chance value from config: {Plugin.CurrentUserConfig.configDoubleChance}");
			mls.LogInfo((object)$"Halve chance value from config: {Plugin.CurrentUserConfig.configHalveChance}");
			mls.LogInfo((object)$"Zero chance value from config: {Plugin.CurrentUserConfig.configZeroChance}");
			mls.LogInfo((object)$"Jackpot multiplier value from config: {Plugin.CurrentUserConfig.configJackpotMultiplier}");
			mls.LogInfo((object)$"Triple multiplier value from config: {Plugin.CurrentUserConfig.configTripleMultiplier}");
			mls.LogInfo((object)$"Double multiplier value from config: {Plugin.CurrentUserConfig.configDoubleMultiplier}");
			mls.LogInfo((object)$"Halve multiplier value from config: {Plugin.CurrentUserConfig.configHalveMultiplier}");
			mls.LogInfo((object)$"Zero multiplier value from config: {Plugin.CurrentUserConfig.configZeroMultiplier}");
			mls.LogInfo((object)$"Audio enabled from config: {Plugin.CurrentUserConfig.configGamblingMusicEnabled}");
			mls.LogInfo((object)$"Audio volume from config: {Plugin.CurrentUserConfig.configGamblingMusicVolume}");
			mls.LogInfo((object)$"Number of uses from config: {Plugin.CurrentUserConfig.configNumberOfUses}");
			mls.LogInfo((object)$"Number of machines from config: {Plugin.CurrentUserConfig.configNumberOfMachines}");
			Plugin.mls.LogInfo((object)"Successfully synced a client with host configuration");
		}
	}
	public class GambleConstants
	{
		[StructLayout(LayoutKind.Sequential, Size = 1)]
		public struct GamblingOutcome
		{
			public static string JACKPOT = "JACKPOT";

			public static string TRIPLE = "TRIPLE";

			public static string DOUBLE = "DOUBLE";

			public static string HALVE = "HALVE";

			public static string REMOVE = "REMOVE";

			public static string DEFAULT = "DEFAULT";
		}

		public static readonly string GAMBLING_GENERAL_SECTION_KEY = "General Machine Settings";

		public static readonly string GAMBLING_CHANCE_SECTION_KEY = "Gambling Chances";

		public static readonly string GAMBLING_MULTIPLIERS_SECTION_KEY = "Gambling Multipliers";

		public static readonly string GAMBLING_AUDIO_SECTION_KEY = "Audio";

		public static readonly string CONFIG_MAXCOOLDOWN = "gamblingMachineMaxCooldown";

		public static readonly string CONFIG_NUMBER_OF_USES = "Number Of Uses";

		public static readonly string CONFIG_NUMBER_OF_MACHINES = "Number Of Machines";

		public static readonly string CONFIG_JACKPOT_CHANCE_KEY = "JackpotChance";

		public static readonly string CONFIG_TRIPLE_CHANCE_KEY = "TripleChance";

		public static readonly string CONFIG_DOUBLE_CHANCE_KEY = "DoubleChance";

		public static readonly string CONFIG_HALVE_CHANCE_KEY = "HalveChance";

		public static readonly string CONFIG_ZERO_CHANCE_KEY = "ZeroChance";

		public static readonly string CONFIG_JACKPOT_MULTIPLIER = "JackpotMultiplier";

		public static readonly string CONFIG_TRIPLE_MULTIPLIER = "TripleMultiplier";

		public static readonly string CONFIG_DOUBLE_MULTIPLIER = "DoubleMultiplier";

		public static readonly string CONFIG_HALVE_MULTIPLIER = "HalveMultiplier";

		public static readonly string CONFIG_ZERO_MULTIPLIER = "ZeroMultiplier";

		public static readonly string CONFIG_GAMBLING_MUSIC_ENABLED = "GambleMachineMusicEnabled";

		public static readonly string CONFIG_GAMBLING_MUSIC_VOLUME = "GambleMachineMusicVolume";

		public static readonly string ON_HOST_RECIEVES_CLIENT_CONFIG_REQUEST = "OnHostRecievesClientConfigRequest";

		public static readonly string ON_CLIENT_RECIEVES_HOST_CONFIG_REQUEST = "OnClientRecievesHostConfigRequest";
	}
	[Serializable]
	public class GambleConfigSettingsSerializable
	{
		public int configMaxCooldown;

		public int configNumberOfUses;

		public int configNumberOfMachines;

		public int configJackpotChance;

		public int configTripleChance;

		public int configDoubleChance;

		public int configHalveChance;

		public int configZeroChance;

		public float configJackpotMultiplier;

		public float configTripleMultiplier;

		public float configDoubleMultiplier;

		public float configHalveMultiplier;

		public float configZeroMultiplier;

		public bool configGamblingMusicEnabled;

		public float configGamblingMusicVolume;

		public GambleConfigSettingsSerializable(ConfigFile configFile)
		{
			configFile.Bind<int>(GambleConstants.GAMBLING_GENERAL_SECTION_KEY, GambleConstants.CONFIG_MAXCOOLDOWN, 4, "Cooldown of the machine. Reducing this will cause the drumroll sound to not sync & may also cause latency issues");
			configFile.Bind<int>(GambleConstants.GAMBLING_GENERAL_SECTION_KEY, GambleConstants.CONFIG_NUMBER_OF_USES, 9999, "Number of times a gambling machine can be used");
			configFile.Bind<int>(GambleConstants.GAMBLING_GENERAL_SECTION_KEY, GambleConstants.CONFIG_NUMBER_OF_MACHINES, 3, "How many gambling machines will be spawned (max 4)");
			configFile.Bind<int>(GambleConstants.GAMBLING_CHANCE_SECTION_KEY, GambleConstants.CONFIG_JACKPOT_CHANCE_KEY, 3, "Chance to roll a jackpot. Ex. If set to 3, you have a 3% chance to get a jackpot. Make sure ALL your chance values add up to 100 or else the math won't make sense!");
			configFile.Bind<int>(GambleConstants.GAMBLING_CHANCE_SECTION_KEY, GambleConstants.CONFIG_TRIPLE_CHANCE_KEY, 11, "Chance to roll a triple. Ex. If set to 11, you have a 11% chance to get a triple. Make sure ALL your chance values add up to 100 or else the math won't make sense!");
			configFile.Bind<int>(GambleConstants.GAMBLING_CHANCE_SECTION_KEY, GambleConstants.CONFIG_DOUBLE_CHANCE_KEY, 27, "Chance to roll a double. Ex. If set to 27, you have a 27% chance to get a double. Make sure ALL your chance values add up to 100 or else the math won't make sense!");
			configFile.Bind<int>(GambleConstants.GAMBLING_CHANCE_SECTION_KEY, GambleConstants.CONFIG_HALVE_CHANCE_KEY, 50, "Chance to roll a halve. Ex. If set to 47, you have a 47% chance to get a halve. Make sure ALL your chance values add up to 100 or else the math won't make sense!");
			configFile.Bind<int>(GambleConstants.GAMBLING_CHANCE_SECTION_KEY, GambleConstants.CONFIG_ZERO_CHANCE_KEY, 9, "Chance to roll a zero. Ex. If set to 12, you have a 12% chance to get a zero. Make sure ALL your chance values add up to 100 or else the math won't make sense!");
			configFile.Bind<float>(GambleConstants.GAMBLING_MULTIPLIERS_SECTION_KEY, GambleConstants.CONFIG_JACKPOT_MULTIPLIER, 10f, "Jackpot multiplier");
			configFile.Bind<float>(GambleConstants.GAMBLING_MULTIPLIERS_SECTION_KEY, GambleConstants.CONFIG_TRIPLE_MULTIPLIER, 3f, "Triple multiplier");
			configFile.Bind<float>(GambleConstants.GAMBLING_MULTIPLIERS_SECTION_KEY, GambleConstants.CONFIG_DOUBLE_MULTIPLIER, 2f, "Double multiplier");
			configFile.Bind<float>(GambleConstants.GAMBLING_MULTIPLIERS_SECTION_KEY, GambleConstants.CONFIG_HALVE_MULTIPLIER, 0.5f, "Halve multiplier");
			configFile.Bind<float>(GambleConstants.GAMBLING_MULTIPLIERS_SECTION_KEY, GambleConstants.CONFIG_ZERO_MULTIPLIER, 0f, "Zero multiplier");
			configFile.Bind<bool>(GambleConstants.GAMBLING_AUDIO_SECTION_KEY, GambleConstants.CONFIG_GAMBLING_MUSIC_ENABLED, true, "Enable gambling machine music (CLIENT SIDE)");
			configFile.Bind<float>(GambleConstants.GAMBLING_AUDIO_SECTION_KEY, GambleConstants.CONFIG_GAMBLING_MUSIC_VOLUME, 0.35f, "Gambling machine music volume (CLIENT SIDE)");
			configMaxCooldown = GetConfigFileKeyValue<int>(configFile, GambleConstants.GAMBLING_GENERAL_SECTION_KEY, GambleConstants.CONFIG_MAXCOOLDOWN);
			configJackpotChance = GetConfigFileKeyValue<int>(configFile, GambleConstants.GAMBLING_CHANCE_SECTION_KEY, GambleConstants.CONFIG_JACKPOT_CHANCE_KEY);
			configTripleChance = GetConfigFileKeyValue<int>(configFile, GambleConstants.GAMBLING_CHANCE_SECTION_KEY, GambleConstants.CONFIG_TRIPLE_CHANCE_KEY);
			configDoubleChance = GetConfigFileKeyValue<int>(configFile, GambleConstants.GAMBLING_CHANCE_SECTION_KEY, GambleConstants.CONFIG_DOUBLE_CHANCE_KEY);
			configHalveChance = GetConfigFileKeyValue<int>(configFile, GambleConstants.GAMBLING_CHANCE_SECTION_KEY, GambleConstants.CONFIG_HALVE_CHANCE_KEY);
			configZeroChance = GetConfigFileKeyValue<int>(configFile, GambleConstants.GAMBLING_CHANCE_SECTION_KEY, GambleConstants.CONFIG_ZERO_CHANCE_KEY);
			configJackpotMultiplier = GetConfigFileKeyValue<float>(configFile, GambleConstants.GAMBLING_MULTIPLIERS_SECTION_KEY, GambleConstants.CONFIG_JACKPOT_MULTIPLIER);
			configTripleMultiplier = GetConfigFileKeyValue<float>(configFile, GambleConstants.GAMBLING_MULTIPLIERS_SECTION_KEY, GambleConstants.CONFIG_TRIPLE_MULTIPLIER);
			configDoubleMultiplier = GetConfigFileKeyValue<float>(configFile, GambleConstants.GAMBLING_MULTIPLIERS_SECTION_KEY, GambleConstants.CONFIG_DOUBLE_MULTIPLIER);
			configHalveMultiplier = GetConfigFileKeyValue<float>(configFile, GambleConstants.GAMBLING_MULTIPLIERS_SECTION_KEY, GambleConstants.CONFIG_HALVE_MULTIPLIER);
			configZeroMultiplier = GetConfigFileKeyValue<float>(configFile, GambleConstants.GAMBLING_MULTIPLIERS_SECTION_KEY, GambleConstants.CONFIG_ZERO_MULTIPLIER);
			configGamblingMusicEnabled = GetConfigFileKeyValue<bool>(configFile, GambleConstants.GAMBLING_AUDIO_SECTION_KEY, GambleConstants.CONFIG_GAMBLING_MUSIC_ENABLED);
			configGamblingMusicVolume = GetConfigFileKeyValue<float>(configFile, GambleConstants.GAMBLING_AUDIO_SECTION_KEY, GambleConstants.CONFIG_GAMBLING_MUSIC_VOLUME);
			configNumberOfUses = GetConfigFileKeyValue<int>(configFile, GambleConstants.GAMBLING_GENERAL_SECTION_KEY, GambleConstants.CONFIG_NUMBER_OF_USES);
			configNumberOfMachines = GetConfigFileKeyValue<int>(configFile, GambleConstants.GAMBLING_GENERAL_SECTION_KEY, GambleConstants.CONFIG_NUMBER_OF_MACHINES);
			LogInitializedConfigsValues();
		}

		private void LogInitializedConfigsValues()
		{
			ManualLogSource mls = Plugin.mls;
			mls.LogInfo((object)$"Cooldown value from config: {configMaxCooldown}");
			mls.LogInfo((object)$"Jackpot chance value from config: {configJackpotChance}");
			mls.LogInfo((object)$"Triple chance value from config: {configTripleChance}");
			mls.LogInfo((object)$"Double chance value from config: {configDoubleChance}");
			mls.LogInfo((object)$"Halve chance value from config: {configHalveChance}");
			mls.LogInfo((object)$"Zero chance value from config: {configZeroChance}");
			mls.LogInfo((object)$"Jackpot multiplier value from config: {configJackpotMultiplier}");
			mls.LogInfo((object)$"Triple multiplier value from config: {configTripleMultiplier}");
			mls.LogInfo((object)$"Double multiplier value from config: {configDoubleMultiplier}");
			mls.LogInfo((object)$"Halve multiplier value from config: {configHalveMultiplier}");
			mls.LogInfo((object)$"Zero multiplier value from config: {configZeroMultiplier}");
			mls.LogInfo((object)$"Music enabled from config: {configGamblingMusicEnabled}");
			mls.LogInfo((object)$"Music volume from config: {configGamblingMusicVolume}");
			mls.LogInfo((object)$"Number of uses from config: {configNumberOfUses}");
			mls.LogInfo((object)$"Number of machines from config: {configNumberOfMachines}");
		}

		private T GetConfigFileKeyValue<T>(ConfigFile configFile, string section, string key)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			ConfigDefinition val = new ConfigDefinition(section, key);
			Plugin.mls.LogInfo((object)("Getting configuration entry: Section: " + section + " Key: " + key));
			ConfigEntry<T> val2 = default(ConfigEntry<T>);
			if (!configFile.TryGetEntry<T>(val, ref val2))
			{
				Plugin.mls.LogError((object)("Failed to get configuration value. Section: " + section + " Key: " + key));
			}
			return val2.Value;
		}
	}
	internal class SerializerHelper
	{
		public static byte[] GetSerializedSettings<T>(T valToSerialize)
		{
			MemoryStream memoryStream = new MemoryStream();
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			try
			{
				binaryFormatter.Serialize(memoryStream, valToSerialize);
			}
			catch (SerializationException ex)
			{
				Plugin.mls.LogError((object)("Config serialization failed: " + ex.Message));
			}
			byte[] result = memoryStream.ToArray();
			memoryStream.Close();
			return result;
		}

		public static T GetDeserializedSettings<T>(byte[] settingsAsBytes)
		{
			MemoryStream memoryStream = new MemoryStream();
			memoryStream.Write(settingsAsBytes, 0, settingsAsBytes.Length);
			memoryStream.Seek(0L, SeekOrigin.Begin);
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			try
			{
				object obj = binaryFormatter.Deserialize(memoryStream);
				memoryStream.Close();
				return (T)obj;
			}
			catch (SerializationException ex)
			{
				Plugin.mls.LogError((object)("Config deserialization failed: " + ex.Message));
			}
			memoryStream.Close();
			return default(T);
		}
	}
}

plugins/hehe/BrackenPlush.dll

Decompiled 9 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BrackenPlush")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BrackenPlush")]
[assembly: AssemblyTitle("BrackenPlush")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace BrackenPlush
{
	[BepInPlugin("scin.BrackenPlush", "Bracken Plushie", "1.0.3")]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "scin.BrackenPlush";

		private const string NAME = "Bracken Plushie";

		private const string VERSION = "1.0.3";

		public static Plugin instance;

		private void Awake()
		{
			instance = this;
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "brackenasset");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			Item val2 = val.LoadAsset<Item>("Assets/MY STUFF/Bracken Plush/BrackenPlush.asset");
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			Items.RegisterScrap(val2, 20, (LevelTypes)(-1));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded Bracken Plushie");
		}
	}
}

plugins/hehe/BunkspidPlush.dll

Decompiled 9 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BunkspidPlush")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BunkspidPlush")]
[assembly: AssemblyTitle("BunkspidPlush")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace bunkspidPlushie
{
	[BepInPlugin("scin.bunkspidPlushie", "Bunk Spider Plushie", "1.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "scin.bunkspidPlushie";

		private const string NAME = "Bunk Spider Plushie";

		private const string VERSION = "1.0.1";

		public static Plugin instance;

		private void Awake()
		{
			instance = this;
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "bunkspidasset");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			Item val2 = val.LoadAsset<Item>("Assets/MY STUFF/Bunkspid/BunkspidItem.asset");
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			Items.RegisterScrap(val2, 20, (LevelTypes)(-1));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded Bunker Spider plushie");
		}
	}
}

plugins/hehe/CoilheadPlush.dll

Decompiled 9 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CoilheadPlush")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CoilheadPlush")]
[assembly: AssemblyTitle("CoilheadPlush")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace CoilheadPlushie
{
	[BepInPlugin("scin.CoilheadPlushie", "Coil head Plushie", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "scin.CoilheadPlushie";

		private const string NAME = "Coil head Plushie";

		private const string VERSION = "1.0.2";

		public static Plugin instance;

		private void Awake()
		{
			instance = this;
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "coilplushasset");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			Item val2 = val.LoadAsset<Item>("Assets/MY STUFF/Coil head/CoilHeadPlush.asset");
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			Items.RegisterScrap(val2, 20, (LevelTypes)(-1));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded Coilhead Plushie");
		}
	}
}

plugins/hehe/Comedymask.dll

Decompiled 9 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Comedymask")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Comedymask")]
[assembly: AssemblyTitle("Comedymask")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace ComedyPlush
{
	[BepInPlugin("scin.ComedymaskPlush", "Comedy mask Plushie", "1.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "scin.ComedymaskPlush";

		private const string NAME = "Comedy mask Plushie";

		private const string VERSION = "1.0.1";

		public static Plugin instance;

		private void Awake()
		{
			instance = this;
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "comedyplush");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			Item val2 = val.LoadAsset<Item>("Assets/MY STUFF/Masked/comedyplushitem.asset");
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			Items.RegisterScrap(val2, 5, (LevelTypes)(-1));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded Comedy mask Plushie");
		}
	}
}

plugins/hehe/Jesterplushie.dll

Decompiled 9 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Jesterplushie")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Jesterplushie")]
[assembly: AssemblyTitle("Jesterplushie")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace JesterPlushie
{
	[BepInPlugin("scin.JesterPlushie", "Jester Plushie", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "scin.JesterPlushie";

		private const string NAME = "Jester Plushie";

		private const string VERSION = "1.0.0";

		public static Plugin instance;

		private void Awake()
		{
			instance = this;
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "jesterplushasset");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			Item val2 = val.LoadAsset<Item>("Assets/MY STUFF/Jester/jesterplushie.asset");
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			Items.RegisterScrap(val2, 10, (LevelTypes)896);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded Jester Plushie");
		}
	}
}

plugins/hehe/LootbugPlush.dll

Decompiled 9 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LootbugPlush")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LootbugPlush")]
[assembly: AssemblyTitle("LootbugPlush")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace HoardingBugPlush
{
	[BepInPlugin("scin.Hoarding-BugPlushPlush", "Hoarding Bug Plushie", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "scin.Hoarding-BugPlushPlush";

		private const string NAME = "Hoarding Bug Plushie";

		private const string VERSION = "1.0.2";

		public static Plugin instance;

		private void Awake()
		{
			instance = this;
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "lootbugplushasset");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			Item val2 = val.LoadAsset<Item>("Assets/MY STUFF/Lootbug/lootbugPlush.asset");
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			Items.RegisterScrap(val2, 20, (LevelTypes)(-1));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded Lootbug Plushie");
		}
	}
}

plugins/hehe/tragedyplush.dll

Decompiled 9 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("tragedyplush")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("tragedyplush")]
[assembly: AssemblyTitle("tragedyplush")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace TragedymaskPlush
{
	[BepInPlugin("scin.TragedymaskPlush", "Tragedy mask Plushie", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "scin.TragedymaskPlush";

		private const string NAME = "Tragedy mask Plushie";

		private const string VERSION = "1.0.2";

		public static Plugin instance;

		private void Awake()
		{
			instance = this;
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "tragedyasset");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			Item val2 = val.LoadAsset<Item>("Assets/MY STUFF/Masked/Tragedyplushitem.asset");
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			Items.RegisterScrap(val2, 5, (LevelTypes)(-1));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded Tragedy mask Plushie");
		}
	}
}

plugins/HoarderBud.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using GameNetcodeStuff;
using HoarderBud.Components;
using HoarderBud.Patches;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using On;
using On.GameNetcodeStuff;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace HoarderBud
{
	[BepInPlugin("HoarderBud", "HoarderBud", "1.0.11")]
	public class HoarderBudPlugin : BaseUnityPlugin
	{
		[Serializable]
		internal class ConfigPayload
		{
			public bool ShouldBugsDance = true;

			public float DanceAmplitude = 0.7f;

			public float DanceSpeed = 4f;

			public bool MakeBugsFriendly = true;

			public bool MakeBugsGatherAtMainEntrance = true;

			public bool DisableOutsideEnemies = false;

			public bool DisableInsideEnemies = true;

			public bool OpenAllDoors = true;

			public bool AddSpawnerItem = true;

			public int SpawnerItemPrice = 30;
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static hook_PerformEmote <0>__PlayerControllerB_PerformEmote;

			public static HandleNamedMessageDelegate <1>__OnRequestSync;

			public static HandleNamedMessageDelegate <2>__OnReceiveSync;
		}

		public static ManualLogSource mls;

		internal static bool IsSynced;

		internal static GameObject LootBugModel;

		public static bool HasLethalEscape;

		internal static CustomMessagingManager MessageManager => NetworkManager.Singleton.CustomMessagingManager;

		internal static bool IsClient => NetworkManager.Singleton.IsClient;

		internal static bool IsHost => NetworkManager.Singleton.IsHost;

		private void Awake()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			mls = ((BaseUnityPlugin)this).Logger;
			HoarderBugPatches.Apply();
			object obj = <>O.<0>__PlayerControllerB_PerformEmote;
			if (obj == null)
			{
				hook_PerformEmote val = PlayerControllerB_PerformEmote;
				<>O.<0>__PlayerControllerB_PerformEmote = val;
				obj = (object)val;
			}
			PlayerControllerB.PerformEmote += (hook_PerformEmote)obj;
			GameNetworkManager.StartDisconnect += new hook_StartDisconnect(LoadConfigOnDisconnect);
			PlayerControllerB.ConnectClientToPlayerObject += new hook_ConnectClientToPlayerObject(AttachNetworkManager);
			BoomboxPatches.Apply();
			RemoveOutsideMobsPatches.Apply();
			RemoveInsideMobsPatches.Apply();
			OpenAllDoorsPatches.Apply();
			HoarderBudSpawnerPatches.Apply();
			ApplyLocalSettings();
			mls.LogInfo((object)"Plugin HoarderBud is loaded!");
		}

		private void LoadConfigOnDisconnect(orig_StartDisconnect orig, GameNetworkManager self)
		{
			orig.Invoke(self);
			ApplyLocalSettings();
			IsSynced = false;
			MessageManager.UnregisterNamedMessageHandler("HoarderBud_OnRequestConfigSync");
			MessageManager.UnregisterNamedMessageHandler("HoarderBud_OnReceiveConfigSync");
		}

		private void AttachNetworkManager(orig_ConnectClientToPlayerObject orig, PlayerControllerB self)
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//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_004c: Expected O, but got Unknown
			orig.Invoke(self);
			HasLethalEscape = Chainloader.PluginInfos.ContainsKey("xCeezy.LethalEscape");
			if (IsHost)
			{
				CustomMessagingManager messageManager = MessageManager;
				object obj = <>O.<1>__OnRequestSync;
				if (obj == null)
				{
					HandleNamedMessageDelegate val = OnRequestSync;
					<>O.<1>__OnRequestSync = val;
					obj = (object)val;
				}
				messageManager.RegisterNamedMessageHandler("HoarderBud_OnRequestConfigSync", (HandleNamedMessageDelegate)obj);
				IsSynced = true;
				return;
			}
			IsSynced = false;
			CustomMessagingManager messageManager2 = MessageManager;
			object obj2 = <>O.<2>__OnReceiveSync;
			if (obj2 == null)
			{
				HandleNamedMessageDelegate val2 = OnReceiveSync;
				<>O.<2>__OnReceiveSync = val2;
				obj2 = (object)val2;
			}
			messageManager2.RegisterNamedMessageHandler("HoarderBud_OnReceiveConfigSync", (HandleNamedMessageDelegate)obj2);
			RequestSync();
		}

		public static void RequestSync()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (!IsClient)
			{
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(4, (Allocator)2, -1);
			try
			{
				MessageManager.SendNamedMessage("HoarderBud_OnRequestConfigSync", 0uL, val, (NetworkDelivery)3);
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		public static void OnRequestSync(ulong clientId, FastBufferReader _)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			if (!IsHost)
			{
				return;
			}
			mls.LogInfo((object)$"Config sync request received from client: {clientId}");
			byte[] array = SerializeToBytes();
			int num = array.Length;
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(num + 4, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteBytesSafe(array, -1, 0);
				MessageManager.SendNamedMessage("HoarderBud_OnReceiveConfigSync", clientId, val, (NetworkDelivery)3);
			}
			catch (Exception arg)
			{
				mls.LogInfo((object)$"Error occurred syncing config with client: {clientId}\n{arg}");
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		public static void OnReceiveSync(ulong _, FastBufferReader reader)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			if (!((FastBufferReader)(ref reader)).TryBeginRead(4))
			{
				mls.LogError((object)"Config sync error: Could not begin reading buffer.");
				return;
			}
			int num = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
			if (!((FastBufferReader)(ref reader)).TryBeginRead(num))
			{
				mls.LogError((object)"Config sync error: Host could not sync.");
				return;
			}
			byte[] data = new byte[num];
			((FastBufferReader)(ref reader)).ReadBytesSafe(ref data, num, 0);
			ParsePacket(data);
			mls.LogInfo((object)"Successfully synced config with host.");
		}

		private static byte[] SerializeToBytes()
		{
			ConfigPayload graph = new ConfigPayload
			{
				ShouldBugsDance = BoomboxPatches.enabled,
				DanceAmplitude = BoomboxPatches.amplitude,
				DanceSpeed = BoomboxPatches.danceSpeed,
				MakeBugsFriendly = HoarderBugPatches.MakeBugsFriendly,
				MakeBugsGatherAtMainEntrance = HoarderBugPatches.MakeBugsGatherAtMainEntrance,
				DisableOutsideEnemies = RemoveOutsideMobsPatches.enabled,
				DisableInsideEnemies = RemoveInsideMobsPatches.enabled,
				OpenAllDoors = OpenAllDoorsPatches.enabled,
				AddSpawnerItem = HoarderBudSpawnerPatches.enabled,
				SpawnerItemPrice = HoarderBudSpawnerPatches.SpawnerItemPrice
			};
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream memoryStream = new MemoryStream();
			binaryFormatter.Serialize(memoryStream, graph);
			return memoryStream.ToArray();
		}

		private static void ParsePacket(byte[] data)
		{
			using MemoryStream memoryStream = new MemoryStream();
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			memoryStream.Write(data, 0, data.Length);
			memoryStream.Seek(0L, SeekOrigin.Begin);
			ConfigPayload configPayload = (ConfigPayload)binaryFormatter.Deserialize(memoryStream);
			BoomboxPatches.enabled = configPayload.ShouldBugsDance;
			BoomboxPatches.amplitude = configPayload.DanceAmplitude;
			BoomboxPatches.danceSpeed = configPayload.DanceSpeed;
			HoarderBugPatches.MakeBugsFriendly = configPayload.MakeBugsFriendly;
			HoarderBugPatches.MakeBugsGatherAtMainEntrance = configPayload.MakeBugsGatherAtMainEntrance;
			RemoveOutsideMobsPatches.enabled = configPayload.DisableOutsideEnemies;
			RemoveInsideMobsPatches.enabled = configPayload.DisableInsideEnemies;
			OpenAllDoorsPatches.enabled = configPayload.OpenAllDoors;
			HoarderBudSpawnerPatches.enabled = configPayload.AddSpawnerItem;
			HoarderBudSpawnerPatches.SpawnerItemPrice = configPayload.SpawnerItemPrice;
			HoarderBudSpawnerPatches.UpdateItem();
			IsSynced = true;
			mls.LogInfo((object)"Config: Loaded remote config");
			DumpConfig();
		}

		private void ApplyLocalSettings()
		{
			BoomboxPatches.enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Boombox", "ShouldBugsDance", true, "Should hoarder bugs dance when music is playing?").Value;
			BoomboxPatches.amplitude = ((BaseUnityPlugin)this).Config.Bind<float>("Boombox", "DanceAmplitude", 0.7f, "Dance amplitude").Value;
			BoomboxPatches.danceSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Boombox", "DanceSpeed", 4f, "Dance speed").Value;
			HoarderBugPatches.MakeBugsFriendly = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "MakeBugsFriendly", true, "Makes hoarder bugs not attack you").Value;
			HoarderBugPatches.MakeBugsGatherAtMainEntrance = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "MakeBugsGatherAtMainEntrance", true, "Makes hoarder bugs nest near the main entrance").Value;
			RemoveOutsideMobsPatches.enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableOutsideEnemies", false, "Disables all outside enemies").Value;
			RemoveInsideMobsPatches.enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableInsideEnemies", true, "Disables all inside enemies except for Hoarder Buddy, also increases his spawnrate").Value;
			OpenAllDoorsPatches.enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "OpenAllDoors", true, "Starts game with all the inside doors open").Value;
			HoarderBudSpawnerPatches.enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AddSpawnerItem", true, "Adds a throwable HoarderBug egg").Value;
			HoarderBudSpawnerPatches.SpawnerItemPrice = ((BaseUnityPlugin)this).Config.Bind<int>("General", "SpawnerItemPrice", 30, "Throwable HoarderBug egg price").Value;
			HoarderBudSpawnerPatches.UpdateItem();
			mls.LogInfo((object)"Config: Loaded local config");
			DumpConfig();
		}

		private static void DumpConfig()
		{
			mls.LogInfo((object)("Config: ShouldBugsDance - " + BoomboxPatches.enabled));
			mls.LogInfo((object)("Config: DanceAmplitude - " + BoomboxPatches.amplitude));
			mls.LogInfo((object)("Config: DanceSpeed - " + BoomboxPatches.danceSpeed));
			mls.LogInfo((object)("Config: MakeBugsFriendly - " + HoarderBugPatches.MakeBugsFriendly));
			mls.LogInfo((object)("Config: MakeBugsGatherAtMainEntrance - " + HoarderBugPatches.MakeBugsGatherAtMainEntrance));
			mls.LogInfo((object)("Config: DisableOutsideEnemies - " + RemoveOutsideMobsPatches.enabled));
			mls.LogInfo((object)("Config: DisableInsideEnemies - " + RemoveInsideMobsPatches.enabled));
			mls.LogInfo((object)("Config: OpenAllDoors - " + OpenAllDoorsPatches.enabled));
			mls.LogInfo((object)("Config: AddSpawnerItem - " + HoarderBudSpawnerPatches.enabled));
			mls.LogInfo((object)("Config: SpawnerItemPrice - " + HoarderBudSpawnerPatches.SpawnerItemPrice));
		}

		private static void PlayerControllerB_PerformEmote(orig_PerformEmote orig, PlayerControllerB self, CallbackContext context, int emoteID)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource obj = mls;
			Vector3 val = ((Component)self).transform.position;
			string? text = ((object)(Vector3)(ref val)).ToString();
			val = self.serverPlayerPosition;
			obj.LogDebug((object)("Player pos: " + text + "|" + ((object)(Vector3)(ref val)).ToString()));
			orig.Invoke(self, context, emoteID);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "HoarderBud";

		public const string PLUGIN_NAME = "HoarderBud";

		public const string PLUGIN_VERSION = "1.0.11";
	}
}
namespace HoarderBud.Patches
{
	internal class HoarderMusicFlag : MonoBehaviour
	{
		public bool canHearMusic = false;
	}
	internal class BoomboxPatches
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Update <0>__UpdateDance;

			public static hook_Update <1>__RoundManager_Update;

			public static hook_DetectNoise <2>__HoarderBugAI_DetectNoise;
		}

		public static bool enabled = true;

		private static readonly float startingY = 1.5863f;

		private static float t = 0f;

		private static float direction = 1f;

		public static float amplitude = 0.7f;

		public static float danceSpeed = 4f;

		public static void Apply()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			object obj = <>O.<0>__UpdateDance;
			if (obj == null)
			{
				hook_Update val = UpdateDance;
				<>O.<0>__UpdateDance = val;
				obj = (object)val;
			}
			HoarderBugAI.Update += (hook_Update)obj;
			object obj2 = <>O.<1>__RoundManager_Update;
			if (obj2 == null)
			{
				hook_Update val2 = RoundManager_Update;
				<>O.<1>__RoundManager_Update = val2;
				obj2 = (object)val2;
			}
			RoundManager.Update += (hook_Update)obj2;
			object obj3 = <>O.<2>__HoarderBugAI_DetectNoise;
			if (obj3 == null)
			{
				hook_DetectNoise val3 = HoarderBugAI_DetectNoise;
				<>O.<2>__HoarderBugAI_DetectNoise = val3;
				obj3 = (object)val3;
			}
			HoarderBugAI.DetectNoise += (hook_DetectNoise)obj3;
		}

		private static void HoarderBugAI_DetectNoise(orig_DetectNoise orig, HoarderBugAI self, Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot, int noiseID)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, noisePosition, noiseLoudness, timesPlayedInOneSpot, noiseID);
			if (enabled)
			{
				HoarderMusicFlag hoarderMusicFlag = default(HoarderMusicFlag);
				if (!((Component)self).gameObject.TryGetComponent<HoarderMusicFlag>(ref hoarderMusicFlag))
				{
					HoarderBudPlugin.mls.LogDebug((object)"Flag is null, assigning");
					((Component)self).gameObject.AddComponent<HoarderMusicFlag>();
				}
				hoarderMusicFlag = ((Component)self).gameObject.GetComponent<HoarderMusicFlag>();
				if ((Object)(object)hoarderMusicFlag == (Object)null)
				{
					HoarderBudPlugin.mls.LogDebug((object)"Flag is null even after assigning, shouldnt be happening");
				}
				else if (noiseID == 5 && !Physics.Linecast(((Component)self).transform.position, noisePosition, StartOfRound.Instance.collidersAndRoomMask) && Vector3.Distance(((Component)self).transform.position, noisePosition) < 12f)
				{
					hoarderMusicFlag.canHearMusic = true;
					HoarderBudPlugin.mls.LogDebug((object)"Can hear music assigned");
				}
				else
				{
					hoarderMusicFlag.canHearMusic = false;
					HoarderBudPlugin.mls.LogDebug((object)"Cant hear music assigned");
				}
			}
		}

		private static void RoundManager_Update(orig_Update orig, RoundManager self)
		{
			orig.Invoke(self);
			if (enabled)
			{
				t += danceSpeed * Time.deltaTime * direction;
				if (t > 1f)
				{
					direction *= -1f;
					t = 1f;
				}
				else if (t < 0f)
				{
					direction *= -1f;
					t = 0f;
				}
			}
		}

		private static void UpdateDance(orig_Update orig, HoarderBugAI self)
		{
			//IL_0079: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			if (enabled)
			{
				Transform val = ((Component)self).gameObject.transform.Find("HoarderBugModel").Find("AnimContainer").Find("Armature")
					.Find("Abdomen")
					.Find("Chest");
				HoarderMusicFlag component = ((Component)self).gameObject.GetComponent<HoarderMusicFlag>();
				bool flag = (Object)(object)component != (Object)null && component.canHearMusic;
				val.localPosition = new Vector3(val.localPosition.x, flag ? Mathf.Lerp(startingY - amplitude, startingY + amplitude, t) : startingY, val.localPosition.z);
			}
		}
	}
	internal class HoarderBudSpawnerPatches
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Awake <0>__CopyOriginalAssets;

			public static hook_Start <1>__GameNetworkManager_Start;
		}

		public static bool enabled = true;

		public static int SpawnerItemPrice = 30;

		private static GameObject HoarderBugModel = null;

		private static Item HoarderBugSpawnerItem;

		private static ManualLogSource mls => HoarderBudPlugin.mls;

		public static void Apply()
		{
			//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_0103: Expected O, but got Unknown
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Expected O, but got Unknown
			string[] manifestResourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames();
			foreach (string text in manifestResourceNames)
			{
				mls.LogInfo((object)("Found resource called " + text));
			}
			AssetBundle val = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetManifestResourceNames()[0]));
			string[] allAssetNames = val.GetAllAssetNames();
			foreach (string text2 in allAssetNames)
			{
				mls.LogInfo((object)("Found asset " + text2));
			}
			HoarderBugSpawnerItem = val.LoadAsset<Item>("assets/templates/bang/hoarderspawner.asset");
			if ((Object)(object)HoarderBugSpawnerItem == (Object)null)
			{
				mls.LogError((object)"asset is null");
			}
			Utilities.FixMixerGroups(HoarderBugSpawnerItem.spawnPrefab);
			HoarderBugSpawnerItem.isScrap = false;
			HoarderBugSpawnerItem.creditsWorth = 0;
			object obj = <>O.<0>__CopyOriginalAssets;
			if (obj == null)
			{
				hook_Awake val2 = CopyOriginalAssets;
				<>O.<0>__CopyOriginalAssets = val2;
				obj = (object)val2;
			}
			StartOfRound.Awake += (hook_Awake)obj;
			object obj2 = <>O.<1>__GameNetworkManager_Start;
			if (obj2 == null)
			{
				hook_Start val3 = GameNetworkManager_Start;
				<>O.<1>__GameNetworkManager_Start = val3;
				obj2 = (object)val3;
			}
			GameNetworkManager.Start += (hook_Start)obj2;
		}

		private static void GameNetworkManager_Start(orig_Start orig, GameNetworkManager self)
		{
			orig.Invoke(self);
			NetworkManager.Singleton.AddNetworkPrefab(HoarderBugSpawnerItem.spawnPrefab);
		}

		public static void UpdateItem()
		{
			if (enabled)
			{
				if (Items.shopItems.Any((ShopItem item) => (Object)(object)item.item == (Object)(object)HoarderBugSpawnerItem))
				{
					Items.UpdateShopItemPrice(HoarderBugSpawnerItem, SpawnerItemPrice);
				}
				else
				{
					Items.RegisterShopItem(HoarderBugSpawnerItem, SpawnerItemPrice);
				}
			}
			else if (Items.shopItems.Any((ShopItem item) => (Object)(object)item.item == (Object)(object)HoarderBugSpawnerItem))
			{
				Items.RemoveShopItem(HoarderBugSpawnerItem);
			}
		}

		private static void CopyOriginalAssets(orig_Awake orig, StartOfRound startOfRound)
		{
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			bool flag2 = false;
			foreach (Item items in startOfRound.allItemsList.itemsList)
			{
				mls.LogDebug((object)("Item name: " + items.itemName));
				if (items.itemName == "Jar of pickles" && !flag)
				{
					HoarderBugSpawnerItem.dropSFX = items.dropSFX;
					HoarderBugSpawnerItem.grabSFX = items.grabSFX;
					HoarderBugSpawnerItem.pocketSFX = items.pocketSFX;
					HoarderBugSpawnerItem.itemIcon = items.itemIcon;
					flag = true;
				}
				if (items.itemName == "Stun grenade" && !flag2)
				{
					HoarderBugSpawnerItem.throwSFX = items.throwSFX;
					ThrowableItemComponent component = HoarderBugSpawnerItem.spawnPrefab.GetComponent<ThrowableItemComponent>();
					StunGrenadeItem component2 = items.spawnPrefab.GetComponent<StunGrenadeItem>();
					mls.LogDebug((object)("Throwable is null? " + ((Object)(object)component == (Object)null) + "Stun is null? " + ((Object)(object)component2 == (Object)null)));
					component.grenadeHit = component2.grenadeHit;
					component.grenadeThrowRay = component2.grenadeThrowRay;
					component.grenadeFallCurve = component2.grenadeFallCurve;
					component.grenadeVerticalFallCurve = component2.grenadeVerticalFallCurve;
					component.grenadeVerticalFallCurveNoBounce = component2.grenadeVerticalFallCurveNoBounce;
					flag2 = true;
				}
				if (flag2 && flag)
				{
					break;
				}
			}
			SelectableLevel[] levels = startOfRound.levels;
			foreach (SelectableLevel val in levels)
			{
				if ((Object)(object)HoarderBugModel != (Object)null)
				{
					break;
				}
				foreach (SpawnableEnemyWithRarity enemy in val.Enemies)
				{
					if (!(((Object)enemy.enemyType).name == "HoarderBug"))
					{
						continue;
					}
					HoarderBugModel = ((Component)enemy.enemyType.enemyPrefab.transform.Find("HoarderBugModel")).gameObject;
					if ((Object)(object)ThrowableItemComponent.HoarderType == (Object)null)
					{
						ThrowableItemComponent.HoarderType = enemy.enemyType;
					}
					if ((Object)(object)HoarderBugModel == (Object)null)
					{
						HoarderBudPlugin.mls.LogError((object)"model not found in bug");
						break;
					}
					GameObject val2 = Object.Instantiate<GameObject>(HoarderBugModel);
					val2.transform.parent = HoarderBugSpawnerItem.spawnPrefab.transform;
					val2.transform.localScale = new Vector3(0.025f, 0.025f, 0.025f);
					val2.transform.localPosition = new Vector3(val2.transform.localPosition.x, val2.transform.localPosition.y + 0.1f, val2.transform.localPosition.z);
					for (int j = 0; j < val2.transform.childCount; j++)
					{
						try
						{
							Object.Destroy((Object)(object)((Component)val2.transform.GetChild(j)).gameObject.GetComponent<EnemyAICollisionDetect>());
						}
						catch (Exception)
						{
						}
					}
					Object.Destroy((Object)(object)val2.GetComponent<EnemyAICollisionDetect>());
					break;
				}
			}
			orig.Invoke(startOfRound);
		}
	}
	internal class HoarderBugPatches
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_LoadNewLevelWait <0>__RoundManager_LoadNewLevelWait;

			public static hook_SetBigDoorCodes <1>__RoundManager_SetBigDoorCodes;

			public static hook_SyncNestPositionServerRpc <2>__ReplaceNestWithEntrance;

			public static hook_IsHoarderBugAngry <3>__DontBeAngry;
		}

		public static Vector3 properNest = new Vector3(-12.17f, -219.56f, 65.56f);

		public static Dictionary<int, Vector3> nests = new Dictionary<int, Vector3>();

		public static bool MakeBugsFriendly = true;

		public static bool MakeBugsGatherAtMainEntrance = true;

		public static void Apply()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			object obj = <>O.<0>__RoundManager_LoadNewLevelWait;
			if (obj == null)
			{
				hook_LoadNewLevelWait val = RoundManager_LoadNewLevelWait;
				<>O.<0>__RoundManager_LoadNewLevelWait = val;
				obj = (object)val;
			}
			RoundManager.LoadNewLevelWait += (hook_LoadNewLevelWait)obj;
			object obj2 = <>O.<1>__RoundManager_SetBigDoorCodes;
			if (obj2 == null)
			{
				hook_SetBigDoorCodes val2 = RoundManager_SetBigDoorCodes;
				<>O.<1>__RoundManager_SetBigDoorCodes = val2;
				obj2 = (object)val2;
			}
			RoundManager.SetBigDoorCodes += (hook_SetBigDoorCodes)obj2;
			object obj3 = <>O.<2>__ReplaceNestWithEntrance;
			if (obj3 == null)
			{
				hook_SyncNestPositionServerRpc val3 = ReplaceNestWithEntrance;
				<>O.<2>__ReplaceNestWithEntrance = val3;
				obj3 = (object)val3;
			}
			HoarderBugAI.SyncNestPositionServerRpc += (hook_SyncNestPositionServerRpc)obj3;
			object obj4 = <>O.<3>__DontBeAngry;
			if (obj4 == null)
			{
				hook_IsHoarderBugAngry val4 = DontBeAngry;
				<>O.<3>__DontBeAngry = val4;
				obj4 = (object)val4;
			}
			HoarderBugAI.IsHoarderBugAngry += (hook_IsHoarderBugAngry)obj4;
		}

		private static bool DontBeAngry(orig_IsHoarderBugAngry orig, HoarderBugAI self)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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)
			if (!MakeBugsFriendly)
			{
				return orig.Invoke(self);
			}
			self.angryAtPlayer = null;
			if (!((EnemyAI)self).isOutside)
			{
				self.nestPosition = nests.GetValueOrDefault(((Object)self).GetInstanceID(), properNest + new Vector3(Random.Range(-2f, 2f), 0f, Random.Range(-2f, 2f)));
				nests[((Object)self).GetInstanceID()] = self.nestPosition;
			}
			return false;
		}

		private static void ReplaceNestWithEntrance(orig_SyncNestPositionServerRpc orig, HoarderBugAI self, Vector3 newNestPosition)
		{
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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)
			if (MakeBugsGatherAtMainEntrance)
			{
				ManualLogSource mls = HoarderBudPlugin.mls;
				Vector3 val = properNest;
				mls.LogDebug((object)("pre synced nest " + ((object)(Vector3)(ref val)).ToString()));
				if (!((EnemyAI)self).isOutside)
				{
					self.nestPosition = nests.GetValueOrDefault(((Object)self).GetInstanceID(), properNest + new Vector3(Random.Range(-2f, 2f), 0f, Random.Range(-2f, 2f)));
					nests[((Object)self).GetInstanceID()] = self.nestPosition;
				}
			}
			orig.Invoke(self, self.nestPosition);
		}

		private static void RoundManager_SetBigDoorCodes(orig_SetBigDoorCodes orig, RoundManager self, Vector3 mainEntrancePosition)
		{
			//IL_0003: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, mainEntrancePosition);
			if (MakeBugsGatherAtMainEntrance)
			{
				ManualLogSource mls = HoarderBudPlugin.mls;
				Vector3 val = mainEntrancePosition;
				mls.LogDebug((object)("SetBigDoorCodes: expected main entrance: " + ((object)(Vector3)(ref val)).ToString()));
				properNest = mainEntrancePosition + new Vector3(5f, -1.4f, 0f);
			}
		}

		private static IEnumerator RoundManager_LoadNewLevelWait(orig_LoadNewLevelWait orig, RoundManager self, int randomSeed)
		{
			nests = new Dictionary<int, Vector3>();
			return orig.Invoke(self, randomSeed);
		}
	}
	internal class OpenAllDoorsPatches
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_SetBigDoorCodes <0>__RoundManager_SetBigDoorCodes;
		}

		public static bool enabled = true;

		public static void Apply()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			object obj = <>O.<0>__RoundManager_SetBigDoorCodes;
			if (obj == null)
			{
				hook_SetBigDoorCodes val = RoundManager_SetBigDoorCodes;
				<>O.<0>__RoundManager_SetBigDoorCodes = val;
				obj = (object)val;
			}
			RoundManager.SetBigDoorCodes += (hook_SetBigDoorCodes)obj;
		}

		private static void RoundManager_SetBigDoorCodes(orig_SetBigDoorCodes orig, RoundManager self, Vector3 mainEntrancePosition)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, mainEntrancePosition);
			if (enabled)
			{
				TerminalAccessibleObject[] array = (from door in Object.FindObjectsOfType<TerminalAccessibleObject>()
					where door.isBigDoor
					select door).ToArray();
				for (int i = 0; i < array.Length; i++)
				{
					array[i].SetDoorOpen(true);
				}
			}
		}
	}
	internal class RemoveInsideMobsPatches
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_AssignRandomEnemyToVent <0>__RoundManager_AssignRandomEnemyToVent;

			public static hook_AdvanceHourAndSpawnNewBatchOfEnemies <1>__RoundManager_AdvanceHourAndSpawnNewBatchOfEnemies;
		}

		public static bool enabled = true;

		public static void Apply()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			object obj = <>O.<0>__RoundManager_AssignRandomEnemyToVent;
			if (obj == null)
			{
				hook_AssignRandomEnemyToVent val = RoundManager_AssignRandomEnemyToVent;
				<>O.<0>__RoundManager_AssignRandomEnemyToVent = val;
				obj = (object)val;
			}
			RoundManager.AssignRandomEnemyToVent += (hook_AssignRandomEnemyToVent)obj;
			object obj2 = <>O.<1>__RoundManager_AdvanceHourAndSpawnNewBatchOfEnemies;
			if (obj2 == null)
			{
				hook_AdvanceHourAndSpawnNewBatchOfEnemies val2 = RoundManager_AdvanceHourAndSpawnNewBatchOfEnemies;
				<>O.<1>__RoundManager_AdvanceHourAndSpawnNewBatchOfEnemies = val2;
				obj2 = (object)val2;
			}
			RoundManager.AdvanceHourAndSpawnNewBatchOfEnemies += (hook_AdvanceHourAndSpawnNewBatchOfEnemies)obj2;
		}

		private static bool RoundManager_AssignRandomEnemyToVent(orig_AssignRandomEnemyToVent orig, RoundManager self, EnemyVent vent, float spawnTime)
		{
			if (!enabled)
			{
				return orig.Invoke(self, vent, spawnTime);
			}
			int num = 0;
			bool flag = false;
			for (int i = 0; i < self.currentLevel.Enemies.Count; i++)
			{
				if (((Object)self.currentLevel.Enemies[i].enemyType).name == "HoarderBug")
				{
					num = i;
					flag = true;
				}
				else
				{
					self.currentLevel.Enemies[i].rarity = 0;
				}
			}
			if (!flag)
			{
				return orig.Invoke(self, vent, spawnTime);
			}
			self.currentEnemyPower += self.currentLevel.Enemies[num].enemyType.PowerLevel;
			vent.enemyType = self.currentLevel.Enemies[num].enemyType;
			vent.enemyTypeIndex = num;
			vent.occupied = true;
			vent.spawnTime = spawnTime;
			EnemyType enemyType = self.currentLevel.Enemies[num].enemyType;
			enemyType.numberSpawned++;
			return true;
		}

		private static void RoundManager_AdvanceHourAndSpawnNewBatchOfEnemies(orig_AdvanceHourAndSpawnNewBatchOfEnemies orig, RoundManager self)
		{
			if (enabled)
			{
				RoundManager.Instance.currentLevel.maxEnemyPowerCount = int.MaxValue;
				if (RoundManager.Instance.minEnemiesToSpawn < 5)
				{
					RoundManager.Instance.minEnemiesToSpawn = 5;
				}
			}
			orig.Invoke(self);
		}
	}
	internal class RemoveOutsideMobsPatches
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_LoadNewLevelWait <0>__RoundManager_LoadNewLevelWait;

			public static hook_AdvanceHourAndSpawnNewBatchOfEnemies <1>__RoundManager_AdvanceHourAndSpawnNewBatchOfEnemies;
		}

		public static bool enabled = true;

		public static void Apply()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			object obj = <>O.<0>__RoundManager_LoadNewLevelWait;
			if (obj == null)
			{
				hook_LoadNewLevelWait val = RoundManager_LoadNewLevelWait;
				<>O.<0>__RoundManager_LoadNewLevelWait = val;
				obj = (object)val;
			}
			RoundManager.LoadNewLevelWait += (hook_LoadNewLevelWait)obj;
			object obj2 = <>O.<1>__RoundManager_AdvanceHourAndSpawnNewBatchOfEnemies;
			if (obj2 == null)
			{
				hook_AdvanceHourAndSpawnNewBatchOfEnemies val2 = RoundManager_AdvanceHourAndSpawnNewBatchOfEnemies;
				<>O.<1>__RoundManager_AdvanceHourAndSpawnNewBatchOfEnemies = val2;
				obj2 = (object)val2;
			}
			RoundManager.AdvanceHourAndSpawnNewBatchOfEnemies += (hook_AdvanceHourAndSpawnNewBatchOfEnemies)obj2;
		}

		private static void RoundManager_AdvanceHourAndSpawnNewBatchOfEnemies(orig_AdvanceHourAndSpawnNewBatchOfEnemies orig, RoundManager self)
		{
			if (enabled)
			{
				RoundManager.Instance.currentLevel.maxOutsideEnemyPowerCount = 0;
			}
			orig.Invoke(self);
		}

		private static IEnumerator RoundManager_LoadNewLevelWait(orig_LoadNewLevelWait orig, RoundManager self, int randomSeed)
		{
			if (!enabled)
			{
				return orig.Invoke(self, randomSeed);
			}
			IEnumerator result = orig.Invoke(self, randomSeed);
			if ((Object)(object)self.currentLevel != (Object)null)
			{
				self.currentLevel.maxOutsideEnemyPowerCount = 0;
			}
			return result;
		}
	}
}
namespace HoarderBud.Components
{
	internal class ThrowableItemComponent : PhysicsProp
	{
		public RaycastHit grenadeHit;

		public Ray grenadeThrowRay;

		public AnimationCurve grenadeFallCurve;

		public AnimationCurve grenadeVerticalFallCurve;

		public AnimationCurve grenadeVerticalFallCurveNoBounce;

		public bool wasThrown = false;

		public static EnemyType HoarderType;

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			HoarderBudPlugin.mls.LogInfo((object)("IsHost:" + NetworkManager.Singleton.IsHost + " IsOwner: " + ((NetworkBehaviour)this).IsOwner));
			if (((NetworkBehaviour)this).IsOwner || NetworkManager.Singleton.IsHost)
			{
				if (((GrabbableObject)this).playerHeldBy.isInsideFactory || HoarderBudPlugin.HasLethalEscape)
				{
					wasThrown = true;
				}
				((GrabbableObject)this).playerHeldBy.DiscardHeldObject(true, (NetworkObject)null, GetGrenadeThrowDestination(), true);
			}
		}

		public override void FallWithCurve()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: 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_00f3: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((GrabbableObject)this).startFallingPosition - ((GrabbableObject)this).targetFloorPosition;
			float magnitude = ((Vector3)(ref val)).magnitude;
			((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(((GrabbableObject)this).itemProperties.restingRotation.x, ((Component)this).transform.eulerAngles.y, ((GrabbableObject)this).itemProperties.restingRotation.z), 14f * Time.deltaTime / magnitude);
			((Component)this).transform.localPosition = Vector3.Lerp(((GrabbableObject)this).startFallingPosition, ((GrabbableObject)this).targetFloorPosition, grenadeFallCurve.Evaluate(((GrabbableObject)this).fallTime));
			if (magnitude > 5f)
			{
				((Component)this).transform.localPosition = Vector3.Lerp(new Vector3(((Component)this).transform.localPosition.x, ((GrabbableObject)this).startFallingPosition.y, ((Component)this).transform.localPosition.z), new Vector3(((Component)this).transform.localPosition.x, ((GrabbableObject)this).targetFloorPosition.y, ((Component)this).transform.localPosition.z), grenadeVerticalFallCurveNoBounce.Evaluate(((GrabbableObject)this).fallTime));
			}
			else
			{
				((Component)this).transform.localPosition = Vector3.Lerp(new Vector3(((Component)this).transform.localPosition.x, ((GrabbableObject)this).startFallingPosition.y, ((Component)this).transform.localPosition.z), new Vector3(((Component)this).transform.localPosition.x, ((GrabbableObject)this).targetFloorPosition.y, ((Component)this).transform.localPosition.z), grenadeVerticalFallCurve.Evaluate(((GrabbableObject)this).fallTime));
			}
			((GrabbableObject)this).fallTime = ((GrabbableObject)this).fallTime + Mathf.Abs(Time.deltaTime * 12f / magnitude);
			if (((GrabbableObject)this).fallTime > 1f && wasThrown)
			{
				HoarderBudPlugin.mls.LogInfo((object)"Stopped rolling");
				if (NetworkManager.Singleton.IsHost)
				{
					SpawnBug();
				}
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		public Vector3 GetGrenadeThrowDestination()
		{
			//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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_00c7: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)this).transform.position;
			Debug.DrawRay(((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.position, ((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.forward, Color.yellow, 15f);
			grenadeThrowRay = new Ray(((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.position, ((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.forward);
			position = ((!Physics.Raycast(grenadeThrowRay, ref grenadeHit, 12f, StartOfRound.Instance.collidersAndRoomMaskAndDefault)) ? ((Ray)(ref grenadeThrowRay)).GetPoint(10f) : ((Ray)(ref grenadeThrowRay)).GetPoint(((RaycastHit)(ref grenadeHit)).distance - 0.05f));
			Debug.DrawRay(position, Vector3.down, Color.blue, 15f);
			grenadeThrowRay = new Ray(position, Vector3.down);
			if (Physics.Raycast(grenadeThrowRay, ref grenadeHit, 30f, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
			{
				return ((RaycastHit)(ref grenadeHit)).point + Vector3.up * 0.05f;
			}
			return ((Ray)(ref grenadeThrowRay)).GetPoint(30f);
		}

		private void SpawnBug()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)HoarderType == (Object)null)
			{
				HoarderBudPlugin.mls.LogError((object)"BUG IS NOT PRESENT");
			}
			else
			{
				RoundManager.Instance.SpawnEnemyGameObject(((Component)this).transform.position, 0f, -1, HoarderType);
			}
		}
	}
}

plugins/IntroSpeechRemix/IntroSpeechRemix.dll

Decompiled 9 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using IntroSpeechRemix.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("IntroSpeechRemix")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("IntroSpeechRemix")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3344c1de-484f-4116-87fe-61301ca3236f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace IntroSpeechRemix
{
	[BepInPlugin("Poseidon.IntroSpeechRemix", "Intro Speech Extended Remix Mod", "1.0.0")]
	public class IntroRemixModBase : BaseUnityPlugin
	{
		private const string modGUID = "Poseidon.IntroSpeechRemix";

		private const string modName = "Intro Speech Extended Remix Mod";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Poseidon.IntroSpeechRemix");

		private static IntroRemixModBase Instance;

		internal ManualLogSource mls;

		internal static List<AudioClip> NewMusic;

		internal static AssetBundle Bundle;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Poseidon.IntroSpeechRemix");
			mls.LogInfo((object)"Loaded Mod Successfully.");
			harmony.PatchAll(typeof(StartOfRoundPatch));
			mls = ((BaseUnityPlugin)this).Logger;
			NewMusic = new List<AudioClip>();
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			location = location.TrimEnd("IntroSpeechRemix.dll".ToCharArray());
			Bundle = AssetBundle.LoadFromFile(location + "introspeechremix");
			if ((Object)(object)Bundle != (Object)null)
			{
				mls.LogInfo((object)"Loaded Asset Bundle Successfully.");
				NewMusic = Bundle.LoadAllAssets<AudioClip>().ToList();
			}
			else
			{
				mls.LogError((object)"Failed to Asset Bundle :(");
			}
		}
	}
}
namespace IntroSpeechRemix.Patches
{
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OverrideAudio(StartOfRound __instance)
		{
			__instance.shipIntroSpeechSFX = IntroRemixModBase.NewMusic[0];
		}
	}
}

plugins/JetpackFallFix.dll

Decompiled 9 months ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using IL.GameNetcodeStuff;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.GameNetcodeStuff;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("JetpackFallFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A lethal company mod which fixes buggy jetpack fall damage logic.")]
[assembly: AssemblyFileVersion("2.0.1.0")]
[assembly: AssemblyInformationalVersion("2.0.1")]
[assembly: AssemblyProduct("JetpackFallFix")]
[assembly: AssemblyTitle("JetpackFallFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace JetpackFallFix
{
	internal class Patches
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Awake <0>__PlayerControllerB_Awake;

			public static Manipulator <1>__PlayerControllerB_Update;

			public static Manipulator <2>__PlayerControllerB_PlayerHitGroundEffects;

			public static hook_PlayerHitGroundEffects <3>__On_PlayerControllerB_PlayerHitGroundEffects;
		}

		private static void LogIfDebugBuild(string text)
		{
		}

		internal static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			object obj = <>O.<0>__PlayerControllerB_Awake;
			if (obj == null)
			{
				hook_Awake val = PlayerControllerB_Awake;
				<>O.<0>__PlayerControllerB_Awake = val;
				obj = (object)val;
			}
			PlayerControllerB.Awake += (hook_Awake)obj;
			object obj2 = <>O.<1>__PlayerControllerB_Update;
			if (obj2 == null)
			{
				Manipulator val2 = PlayerControllerB_Update;
				<>O.<1>__PlayerControllerB_Update = val2;
				obj2 = (object)val2;
			}
			PlayerControllerB.Update += (Manipulator)obj2;
			object obj3 = <>O.<2>__PlayerControllerB_PlayerHitGroundEffects;
			if (obj3 == null)
			{
				Manipulator val3 = PlayerControllerB_PlayerHitGroundEffects;
				<>O.<2>__PlayerControllerB_PlayerHitGroundEffects = val3;
				obj3 = (object)val3;
			}
			PlayerControllerB.PlayerHitGroundEffects += (Manipulator)obj3;
			object obj4 = <>O.<3>__On_PlayerControllerB_PlayerHitGroundEffects;
			if (obj4 == null)
			{
				hook_PlayerHitGroundEffects val4 = On_PlayerControllerB_PlayerHitGroundEffects;
				<>O.<3>__On_PlayerControllerB_PlayerHitGroundEffects = val4;
				obj4 = (object)val4;
			}
			PlayerControllerB.PlayerHitGroundEffects += (hook_PlayerHitGroundEffects)obj4;
		}

		private static void PlayerControllerB_Awake(orig_Awake orig, PlayerControllerB self)
		{
			orig.Invoke(self);
			self.velocityAverageCount = 21;
		}

		private static void PlayerControllerB_Update(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			val.GotoNext(new Func<Instruction, bool>[8]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<PlayerControllerB>(x, "gameplayCamera"),
				(Instruction x) => ILPatternMatchingExt.MatchCallvirt<Component>(x, "get_transform"),
				(Instruction x) => ILPatternMatchingExt.MatchCallvirt<Transform>(x, "get_position"),
				(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 3f),
				(Instruction x) => ILPatternMatchingExt.MatchCall<StartOfRound>(x, "get_Instance"),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<StartOfRound>(x, "collidersAndRoomMaskAndDefault"),
				(Instruction x) => ILPatternMatchingExt.MatchCall<Physics>(x, "CheckSphere")
			});
			val.Index += 7;
			val.Remove();
			val.Emit(OpCodes.Ldc_I4_1);
			val.Emit(OpCodes.Call, (MethodBase)(from x in typeof(Physics).GetMethods()
				where x.Name == "CheckSphere"
				select x).FirstOrDefault());
		}

		private static void On_PlayerControllerB_PlayerHitGroundEffects(orig_PlayerHitGroundEffects orig, PlayerControllerB self)
		{
			orig.Invoke(self);
			self.averageVelocity = 0f;
		}

		private static void PlayerControllerB_PlayerHitGroundEffects(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			ILLabel val5 = default(ILLabel);
			ILLabel val4 = default(ILLabel);
			ILLabel val3 = default(ILLabel);
			ILLabel val2 = default(ILLabel);
			val.GotoNext(new Func<Instruction, bool>[12]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<PlayerControllerB>(x, "takingFallDamage"),
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref val5),
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<PlayerControllerB>(x, "jetpackControls"),
				(Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref val4),
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<PlayerControllerB>(x, "disablingJetpackControls"),
				(Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref val3),
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<PlayerControllerB>(x, "isSpeedCheating"),
				(Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref val2)
			});
			val.Index += 4;
			val.RemoveRange(4);
			val.EmitDelegate<Func<PlayerControllerB, bool>>((Func<PlayerControllerB, bool>)delegate(PlayerControllerB self)
			{
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				if (!self.jetpackControls && !self.disablingJetpackControls)
				{
					LogIfDebugBuild("Take normal fall damage.");
					return false;
				}
				if (self.thisController.velocity.y < -15f)
				{
					LogIfDebugBuild("Take fall damage with jetpack.");
					self.fallValueUncapped = self.thisController.velocity.y;
					return false;
				}
				LogIfDebugBuild("Prevented fall damage bug!");
				self.takingFallDamage = false;
				return true;
			});
		}
	}
	[BepInPlugin("JetpackFallFix", "JetpackFallFix", "2.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin JetpackFallFix is loaded!");
			Patches.Init();
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "JetpackFallFix";

		public const string PLUGIN_NAME = "JetpackFallFix";

		public const string PLUGIN_VERSION = "2.0.1";
	}
}

plugins/LC_HandHeldDevice.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LC_HandHeldDevice.Patches;
using LethalLib.Modules;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LC_HandHeldDevice")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LC_HandHeldDevice")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2e45d23a-326c-4621-879f-642402b89ccd")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LC_HandHeldDevice
{
	[BepInPlugin("Mellowdy.HandHeldMapMod", "HandHeldMapMod", "1.3.0")]
	public class HandHeldMapMod : BaseUnityPlugin
	{
		private const string modGUID = "Mellowdy.HandHeldMapMod";

		private const string modName = "HandHeldMapMod";

		private const string modVersion = "1.3.0";

		private const string assetName = "map.device";

		private const string gameObjectName = "HandHeldMapDevice.prefab";

		private readonly Harmony harmony = new Harmony("Mellowdy.HandHeldMapMod");

		public static ManualLogSource mls;

		private static HandHeldMapMod instance;

		private static string Name = "Hand-held Map";

		private static ConfigEntry<int> price;

		private static ConfigEntry<float> BatteryUsage;

		private static ConfigEntry<float> TurnOnBatteryUsage;

		private static ConfigEntry<bool> BatteryFail;

		private static ConfigEntry<float> FailureBreakPoint;

		private static ConfigEntry<float> BaseChance;

		private static ConfigEntry<float> Size;

		private static ConfigEntry<bool> Light;

		public static GameObject cameraPrefab;

		public static Material backUpMaterialOff;

		public static Material backUpMaterialOn;

		private void Awake()
		{
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			mls = Logger.CreateLogSource("Mellowdy.HandHeldMapMod");
			harmony.PatchAll();
			price = ((BaseUnityPlugin)this).Config.Bind<int>("Price", "MapPrice", 45, "Credits needed to buy the hand-held map");
			BatteryUsage = ((BaseUnityPlugin)this).Config.Bind<float>("Battery", "Battery Charge", 120f, "The amount of time in seconds the map can be active");
			TurnOnBatteryUsage = ((BaseUnityPlugin)this).Config.Bind<float>("Battery", "Turn on requirement", 0.05f, "The percent of battery that gets drained when the map gets turned on (0.1 = 10% drain each time its turned on)");
			BatteryFail = ((BaseUnityPlugin)this).Config.Bind<bool>("Battery", "Battery Failure", true, "decription");
			FailureBreakPoint = ((BaseUnityPlugin)this).Config.Bind<float>("Battery", "Battery Failure Break Point", 0.5f, "The charge breakpoint where the map will begin to glitch and fail to update as often (0.5 = map will start failing at 50% charge)");
			BaseChance = ((BaseUnityPlugin)this).Config.Bind<float>("Battery", "Base Chance", 2f, "The base chance for the map to update every second after battery failure");
			HandHeldMap.pocketTurnOff = ((BaseUnityPlugin)this).Config.Bind<bool>("Battery", "Turn off when pocketed", true, "Should the map turn off when pocketed or dropped").Value;
			Size = ((BaseUnityPlugin)this).Config.Bind<float>("Map Properties", "Size", 0.75f, "The size of the map compared to the monitor map in the ship");
			Light = ((BaseUnityPlugin)this).Config.Bind<bool>("Map Properties", "Light", false, "If the map should have nightvision like the map in the ship or not");
			HandHeldMap.BatteryUsage = BatteryUsage.Value;
			HandHeldMap.TurnOnBatteryUsage = TurnOnBatteryUsage.Value;
			HandHeldMap.BatteryFail = BatteryFail.Value;
			HandHeldMap.FailureBreakPoint = FailureBreakPoint.Value;
			HandHeldMap.BaseChance = BaseChance.Value;
			HandHeldMap.Size = Size.Value;
			HandHeldMap.LightOn = Light.Value;
			HandHeldMap.ShowEnemies = ((BaseUnityPlugin)this).Config.Bind<bool>("Visibility", "Show Enemies", true, "Should Enemies be shown").Value;
			HandHeldMap.ShowScrap = ((BaseUnityPlugin)this).Config.Bind<bool>("Visibility", "Show Scrap", true, "Should Scrap be shown").Value;
			HandHeldMap.ShowPlayers = ((BaseUnityPlugin)this).Config.Bind<bool>("Visibility", "Show Players", true, "Should Players be shown").Value;
			HandHeldMap.ShowDeadPlayers = ((BaseUnityPlugin)this).Config.Bind<bool>("Visibility", "Show Dead Players", true, "Should Dead Players be shown").Value;
			HandHeldMap.ShowDoors = ((BaseUnityPlugin)this).Config.Bind<bool>("Visibility", "Show Doors", true, "Should Doors be shown").Value;
			HandHeldMap.ShowMines = ((BaseUnityPlugin)this).Config.Bind<bool>("Visibility", "Show Mines", true, "Should Landmines be shown").Value;
			HandHeldMap.ShowTurrets = ((BaseUnityPlugin)this).Config.Bind<bool>("Visibility", "Show Turrets", true, "Should Turrets be shown").Value;
			HandHeldMap.resetTime = ((BaseUnityPlugin)this).Config.Bind<float>("Preformance", "Update Rate", 2.5f, "How often the map should update the visibility settings").Value;
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			string text = Path.Combine(directoryName, "map.device").Replace("\\", "/");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			Item val2 = val.LoadAsset<Item>("Map.asset");
			GameObject val3 = val.LoadAsset<GameObject>("HandHeldMapDevice.prefab");
			cameraPrefab = val.LoadAsset<GameObject>("Camera.prefab");
			HandHeldMap.turnOn = val.LoadAsset<AudioClip>("On.wav");
			HandHeldMap.turnOff = val.LoadAsset<AudioClip>("Off.wav");
			HandHeldMap handHeldMap = val3.AddComponent<HandHeldMap>();
			((GrabbableObject)handHeldMap).originalScale = val3.transform.localScale;
			((GrabbableObject)handHeldMap).grabbable = true;
			((GrabbableObject)handHeldMap).itemProperties = val2;
			((GrabbableObject)handHeldMap).floorYRot = -1;
			val2.spawnPrefab = val3;
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Items.RegisterItem(val2);
			Items.RegisterShopItem(val2, (TerminalNode)null, (TerminalNode)null, CreateInfoNode("Hand-heldMapDevice", "Allows easy viewing of the map from anywhere."), price.Value);
			mls.LogInfo((object)"HandHeldMap mod is active");
		}

		private TerminalNode CreateInfoNode(string name, string description)
		{
			TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
			val.clearPreviousText = true;
			((Object)val).name = name + "InfoNode";
			val.displayText = description + "\n\n";
			return val;
		}

		public static GameObject[] FindAndRemap(int layer)
		{
			GameObject[] array = Object.FindObjectsOfType<GameObject>();
			List<GameObject> list = new List<GameObject>();
			for (int i = 0; i < array.Length; i++)
			{
				if (array[i].layer == layer)
				{
					list.Add(array[i]);
				}
			}
			if (list.Count == 0)
			{
				return null;
			}
			return list.ToArray();
		}
	}
}
namespace LC_HandHeldDevice.Patches
{
	[HarmonyPatch(typeof(GrabbableObject))]
	internal class GrabbableObjectPatch
	{
		[HarmonyPatch("LateUpdate")]
		[HarmonyPostfix]
		private static void LootVisibilityOnMapPatch(GrabbableObject __instance)
		{
			if (!HandHeldMap.ShowScrap && (Object)(object)__instance != (Object)null && (Object)(object)__instance.radarIcon != (Object)null && (Object)(object)((Component)__instance.radarIcon).gameObject != (Object)null && HandHeldMap.currentlyShowScrap != ((Component)__instance.radarIcon).gameObject.activeSelf)
			{
				((Component)__instance.radarIcon).gameObject.SetActive(HandHeldMap.currentlyShowScrap);
			}
		}
	}
	public class HandHeldMap : GrabbableObject
	{
		private ManualCameraRenderer mcr;

		private RenderTexture renderTexture;

		public static AudioClip turnOn;

		public static AudioClip turnOff;

		public static float BatteryUsage;

		public static float TurnOnBatteryUsage;

		public static bool BatteryFail;

		public static float FailureBreakPoint;

		public static float BaseChance;

		public static float Size = 1f;

		public static bool LightOn = true;

		public static bool pocketTurnOff = true;

		public AudioSource audioSource;

		public float MaxCharge = 0f;

		private bool isOn = false;

		public static bool ShowEnemies;

		public static bool ShowScrap;

		public static bool currentlyShowScrap;

		public static bool ShowPlayers;

		public static bool ShowDeadPlayers;

		public static bool ShowDoors;

		public static bool ShowTurrets;

		public static bool ShowMines;

		public bool culled = false;

		public float cullTimer;

		public static float resetTime = 2.5f;

		public static int MaxMaps;

		public static bool ShouldUpdateOutsideLocalPlayer;

		public static int MinUpdateDistance;

		public static int activeMaps;

		private static ManualCameraRenderer originalMCR = null;

		public bool isInHand;

		public override void Start()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Expected O, but got Unknown
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Expected O, but got Unknown
			((GrabbableObject)this).Start();
			activeMaps++;
			base.insertedBattery = new Battery(false, 1f);
			MaxCharge = base.insertedBattery.charge;
			base.itemProperties.batteryUsage = BatteryUsage;
			try
			{
				if ((Object)(object)((Component)this).transform.parent == (Object)null && base.isInShipRoom && base.isInElevator && (Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)StartOfRound.Instance.elevatorTransform != (Object)null)
				{
					((Component)this).transform.SetParent(StartOfRound.Instance.elevatorTransform, false);
					base.targetFloorPosition = ((Component)this).transform.localPosition - ((Component)this).transform.parent.position;
				}
				base.mainObjectRenderer = ((Component)this).GetComponent<MeshRenderer>();
				audioSource = ((Component)this).GetComponent<AudioSource>();
				GameObject val = GameObject.Find("CameraMonitorScript");
				if ((Object)(object)originalMCR == (Object)null && (Object)(object)val != (Object)null)
				{
					originalMCR = val.GetComponent<ManualCameraRenderer>();
				}
				if ((Object)(object)originalMCR == (Object)null)
				{
					originalMCR = Object.FindObjectOfType<ManualCameraRenderer>();
				}
				GameObject val2;
				if ((Object)(object)originalMCR != (Object)null && (Object)(object)originalMCR.cam != (Object)null)
				{
					val2 = ((Component)originalMCR.cam).gameObject;
				}
				else
				{
					val2 = HandHeldMapMod.cameraPrefab;
					HUDManager.Instance.DisplayTip("HandheldMap", "Failed to load proper camera for the map. Deploying safe guard. If you get this error contact the mod developer to get it fixed.", true, false, "LC_Tip1");
				}
				mcr = ((Component)this).gameObject.AddComponent<ManualCameraRenderer>();
				mcr.mesh = base.mainObjectRenderer;
				GameObject val3 = Object.Instantiate<GameObject>(val2);
				Camera component = val3.GetComponent<Camera>();
				renderTexture = new RenderTexture(((Texture)component.targetTexture).width, ((Texture)component.targetTexture).height, component.targetTexture.depth);
				mcr.mapCameraLight = val3.GetComponentInChildren<Light>();
				mcr.mapCameraAnimator = val3.GetComponentInChildren<Animator>();
				mcr.cam = component;
				mcr.mapCamera = component;
				component.targetTexture = renderTexture;
				HandHeldMapMod.mls.LogMessage((object)$"Camera size: {component.orthographicSize}");
				component.orthographicSize *= Size;
				mcr.materialIndex = 0;
				if ((Object)(object)originalMCR != (Object)null)
				{
					mcr.onScreenMat = Object.Instantiate<Material>(originalMCR.onScreenMat);
					mcr.offScreenMat = originalMCR.offScreenMat;
					mcr.shipArrowUI = originalMCR.shipArrowUI;
					mcr.shipArrowPointer = originalMCR.shipArrowPointer;
				}
				else
				{
					mcr.onScreenMat = Object.Instantiate<Material>(HandHeldMapMod.backUpMaterialOn);
					mcr.offScreenMat = HandHeldMapMod.backUpMaterialOff;
					mcr.shipArrowPointer = ((Component)this).transform;
					mcr.shipArrowUI = new GameObject();
				}
				mcr.onScreenMat.mainTexture = (Texture)(object)renderTexture;
				TurnOn(on: false);
				mcr.radarTargets.Clear();
				mcr.AddTransformAsTargetToRadar(((Component)this).transform, "You are here", true);
			}
			catch (Exception ex)
			{
				HUDManager.Instance.DisplayTip("HandheldMap", "Failed to load. " + ex, true, false, "LC_Tip1");
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		public override void Update()
		{
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).Update();
			if (!base.isHeld || !isInHand || !((Object)(object)base.playerHeldBy != (Object)null) || !((Object)(object)mcr != (Object)null) || !UpdateOtherMaps())
			{
				return;
			}
			if ((Object)(object)mcr.mapCameraLight != (Object)null && !((Behaviour)mcr.mapCameraLight).enabled && LightOn)
			{
				((Behaviour)mcr.mapCameraLight).enabled = LightOn;
			}
			if ((Object)(object)mcr.cam != (Object)null)
			{
				((Behaviour)mcr.cam).enabled = true;
				if (base.insertedBattery.charge / MaxCharge < FailureBreakPoint && BatteryFail)
				{
					float num = (BaseChance + base.insertedBattery.charge / MaxCharge) * Time.deltaTime;
					float num2 = Random.Range(0f, 1f);
					if (num2 <= num)
					{
						mcr.cam.Render();
					}
				}
				else
				{
					mcr.cam.Render();
				}
				if ((Object)(object)mcr.targetedPlayer != (Object)(object)base.playerHeldBy)
				{
					mcr.targetedPlayer = base.playerHeldBy;
				}
			}
			if (cullTimer <= 0f)
			{
				cullTimer = resetTime;
				bool flag = culled;
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				if (localPlayerController.isInElevator || localPlayerController.isInHangarShipRoom || Vector3.Distance(((Component)localPlayerController).transform.position, StartOfRound.Instance.elevatorTransform.position) < 10f)
				{
					culled = false;
				}
				else
				{
					culled = true;
				}
				CullRelevantGameObjects(!culled);
			}
			else
			{
				cullTimer -= Time.deltaTime;
			}
		}

		public bool UpdateOtherMaps()
		{
			PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
			return (Object)(object)base.playerHeldBy == (Object)(object)localPlayerController;
		}

		public void TurnOn(bool on)
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			bool flag = isOn != on;
			isOn = on;
			base.isBeingUsed = on;
			mcr.SwitchScreenOn(on);
			if (!flag)
			{
				return;
			}
			if (on)
			{
				audioSource.PlayOneShot(turnOn);
				if (base.insertedBattery.charge != 1f)
				{
					((MonoBehaviour)this).StartCoroutine((IEnumerator)Drain(1f));
				}
			}
			else
			{
				audioSource.PlayOneShot(turnOff);
			}
			RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 10f, 0.65f, 0, base.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			TurnOn(used);
		}

		public override void UseUpBatteries()
		{
			((GrabbableObject)this).UseUpBatteries();
			TurnOn(on: false);
		}

		public override void GrabItem()
		{
			mcr.targetedPlayer = base.playerHeldBy;
			((GrabbableObject)this).GrabItem();
			isInHand = true;
			((Behaviour)mcr).enabled = true;
			((Behaviour)mcr.cam).enabled = true;
		}

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

		public override void PocketItem()
		{
			((GrabbableObject)this).PocketItem();
			if (pocketTurnOff)
			{
				TurnOn(on: false);
			}
			isInHand = false;
		}

		public override void DiscardItem()
		{
			((GrabbableObject)this).DiscardItem();
			if (pocketTurnOff)
			{
				TurnOn(on: false);
			}
			isInHand = false;
			((Behaviour)mcr).enabled = false;
			((Behaviour)mcr.cam).enabled = false;
		}

		public override void ChargeBatteries()
		{
			((GrabbableObject)this).ChargeBatteries();
			MaxCharge = base.insertedBattery.charge;
		}

		public IEnumerator<WaitForEndOfFrame> Drain(float Duration)
		{
			float t = 0f;
			while (t < Duration)
			{
				base.insertedBattery.charge = Mathf.Max(base.insertedBattery.charge - MaxCharge * TurnOnBatteryUsage * Time.deltaTime / Duration, 0f);
				t += Time.deltaTime;
				yield return new WaitForEndOfFrame();
			}
		}

		public override void OnDestroy()
		{
			((NetworkBehaviour)this).OnDestroy();
			renderTexture.Release();
			Object.Destroy((Object)(object)((Component)mcr.cam).gameObject);
			activeMaps--;
		}

		public static void CullRelevantGameObjects(bool cull)
		{
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Expected O, but got Unknown
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Expected O, but got Unknown
			if (!ShowEnemies)
			{
				EnemyAI[] array = Object.FindObjectsOfType<EnemyAI>(true);
				EnemyAI[] array2 = array;
				foreach (EnemyAI val in array2)
				{
					GameObject val2 = ((!((Object)(object)((Component)val).transform.parent != (Object)null)) ? FindMapDot(((Component)val).gameObject) : FindMapDot(((Component)((Component)val).transform.parent).gameObject));
					if ((Object)(object)val2 != (Object)null)
					{
						val2.SetActive(cull);
					}
				}
			}
			if (!ShowScrap)
			{
				currentlyShowScrap = cull;
			}
			if (!ShowPlayers)
			{
				PlayerControllerB[] array3 = Object.FindObjectsOfType<PlayerControllerB>(true);
				PlayerControllerB[] array4 = array3;
				foreach (PlayerControllerB val3 in array4)
				{
					Animator mapRadarDotAnimator = val3.mapRadarDotAnimator;
					if ((Object)(object)mapRadarDotAnimator != (Object)null)
					{
						((Component)mapRadarDotAnimator).gameObject.SetActive(cull);
					}
				}
			}
			if (!ShowDeadPlayers)
			{
				DeadBodyInfo[] array5 = Object.FindObjectsOfType<DeadBodyInfo>(true);
				DeadBodyInfo[] array6 = array5;
				foreach (DeadBodyInfo val4 in array6)
				{
					((Component)val4.radarDot).gameObject.SetActive(cull);
				}
			}
			if (!ShowDoors)
			{
				GameObject val5 = GameObject.Find("Systems/GameSystems/ItemSystems/MapScreenUIWorldSpace");
				if ((Object)(object)val5 != (Object)null)
				{
					foreach (Transform item in val5.transform)
					{
						Transform val6 = item;
						((Component)val6).gameObject.SetActive(cull);
					}
				}
			}
			if (!ShowMines)
			{
				Landmine[] array7 = Object.FindObjectsOfType<Landmine>(true);
				Landmine[] array8 = array7;
				foreach (Landmine val7 in array8)
				{
					Transform val8 = ((Component)val7).transform.parent.Find("ScanSphere");
					if ((Object)(object)val8 != (Object)null)
					{
						((Component)val8).gameObject.SetActive(cull);
					}
				}
			}
			if (ShowTurrets)
			{
				return;
			}
			Turret[] array9 = Object.FindObjectsOfType<Turret>(true);
			Turret[] array10 = array9;
			foreach (Turret val9 in array10)
			{
				foreach (Transform item2 in ((Component)val9).transform.parent.Find("MeshContainer").Find("RotatingRodContainer"))
				{
					Transform val10 = item2;
					if (((Object)val10).name.StartsWith("Plane"))
					{
						((Component)val10).gameObject.SetActive(cull);
					}
				}
			}
		}

		private static GameObject FindMapDot(GameObject enemyObject, bool isModel = false)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			foreach (Transform item in enemyObject.transform)
			{
				Transform val = item;
				if (((Object)val).name.StartsWith("MapDot"))
				{
					return ((Component)val).gameObject;
				}
				if ((!isModel && ((Object)val).name.EndsWith("Model")) || ((Object)val).name.EndsWith("ModelContainer"))
				{
					GameObject val2 = FindMapDot(((Component)val).gameObject);
					if ((Object)(object)val2 != (Object)null)
					{
						return val2;
					}
				}
			}
			return null;
		}
	}
}

plugins/LC_LandminesForAll.dll

Decompiled 9 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LC_LandminesForAll.Patches;
using LC_LandminesForAll.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LC_LandminesForAll")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Templete")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+d2a1d9af8893c2a3098c4da244d009911438c0a4")]
[assembly: AssemblyProduct("LC_LandminesForAll")]
[assembly: AssemblyTitle("LC_LandminesForAll")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LC_LandminesForAll
{
	public class MyPluginInfo
	{
		public const string PLUGIN_GUID = "sakura.lc.landminesforall";

		public const string PLUGIN_NAME = "LandminesForAll";

		public const string PLUGIN_VERSION = "1.0.1";
	}
	[BepInPlugin("sakura.lc.landminesforall", "LandminesForAll", "1.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony _harmony;

		internal static ManualLogSource Logger;

		public static string ThisPluginFolder => Path.Combine(Paths.PluginPath, "Sakura-LandminesForAll");

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			_harmony = new Harmony("sakura.lc.landminesforall");
			_harmony.PatchAll(typeof(LandminePatch));
			Logger.LogInfo((object)"Plugin sakura.lc.landminesforall is loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "LC_LandminesForAll";

		public const string PLUGIN_NAME = "LC_LandminesForAll";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}
namespace LC_LandminesForAll.Utils
{
	internal static class ReflectionUtils
	{
		public static void SetPrivateField<T>(this T instance, string fieldName, object value)
		{
			typeof(T).GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic).SetValue(instance, value);
		}

		public static void SetPrivateProperty<T>(this T instance, string propertyName, object value)
		{
			typeof(T).GetProperty(propertyName, BindingFlags.Instance | BindingFlags.NonPublic).SetValue(instance, value);
		}

		public static void SetPrivateStaticField<T>(string fieldName, object value)
		{
			typeof(T).GetField(fieldName, BindingFlags.Static | BindingFlags.NonPublic).SetValue(null, value);
		}

		public static void SetPrivateStaticProperty<T>(string propertyName, object value)
		{
			typeof(T).GetProperty(propertyName, BindingFlags.Static | BindingFlags.NonPublic).SetValue(null, value);
		}

		public static T GetPrivateField<T>(this object instance, string fieldName)
		{
			return (T)instance.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic).GetValue(instance);
		}

		public static T GetPrivateProperty<T>(this object instance, string propertyName)
		{
			return (T)instance.GetType().GetProperty(propertyName, BindingFlags.Instance | BindingFlags.NonPublic).GetValue(instance);
		}

		public static T GetPrivateStaticField<T>(string fieldName)
		{
			return (T)typeof(T).GetField(fieldName, BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
		}

		public static T GetPrivateStaticProperty<T>(string propertyName)
		{
			return (T)typeof(T).GetProperty(propertyName, BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
		}

		public static void InvokePrivateMethod<T>(this T instance, string methodName, params object[] parameters)
		{
			instance.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.NonPublic).Invoke(instance, parameters);
		}

		public static void InvokePrivateStaticMethod<T>(string methodName, params object[] parameters)
		{
			typeof(T).GetMethod(methodName, BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, parameters);
		}

		public static T CreatePrivateInstance<T>(params object[] parameters)
		{
			return (T)Activator.CreateInstance(typeof(T), BindingFlags.Instance | BindingFlags.NonPublic, null, parameters, null);
		}

		public static T CreatePrivateStaticInstance<T>(params object[] parameters)
		{
			return (T)Activator.CreateInstance(typeof(T), BindingFlags.Static | BindingFlags.NonPublic, null, parameters, null);
		}
	}
}
namespace LC_LandminesForAll.Patches
{
	[HarmonyPatch(typeof(Landmine))]
	internal class LandminePatch
	{
		private const int LineOfSightLayer = 18;

		private const int EnemyLayer = 19;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void Start(Landmine __instance)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			BoxCollider val = ((IEnumerable<BoxCollider>)((Component)__instance).GetComponents<BoxCollider>()).FirstOrDefault((Func<BoxCollider, bool>)((BoxCollider x) => ((Collider)x).isTrigger));
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Logger.LogError((object)$"Could not find mine trigger collider on mine at {((Component)__instance).transform.position}");
				return;
			}
			BoxCollider obj = ((Component)__instance).gameObject.AddComponent<BoxCollider>();
			((Collider)obj).isTrigger = true;
			obj.size = val.size * 2f;
			obj.center = val.center;
			((Collider)obj).enabled = true;
			((Collider)obj).includeLayers = LayerMask.op_Implicit(524288);
		}

		private static void TriggerDebounce(Landmine __instance)
		{
			//IL_0017: 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_0032: 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)
			Transform closestEnemyForLogging = GetClosestEnemyForLogging(__instance);
			Plugin.Logger.LogDebug((object)$"Triggering debounce on mine at {((Component)__instance).transform.position} with closest enemy at {closestEnemyForLogging.position} at {Vector3.Distance(((Component)__instance).transform.position, ((Component)closestEnemyForLogging).transform.position)} units away.");
			__instance.SetPrivateField<Landmine>("pressMineDebounceTimer", 0.5f);
			__instance.PressMineServerRpc();
		}

		private static void TriggerMineExplosion(Landmine __instance)
		{
			//IL_0017: 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_0032: 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)
			Transform closestEnemyForLogging = GetClosestEnemyForLogging(__instance);
			Plugin.Logger.LogDebug((object)$"Triggering debounce on mine at {((Component)__instance).transform.position} with closest enemy at {closestEnemyForLogging.position} at {Vector3.Distance(((Component)__instance).transform.position, ((Component)closestEnemyForLogging).transform.position)} units away.");
			__instance.InvokePrivateMethod<Landmine>("TriggerMineOnLocalClientByExiting", Array.Empty<object>());
		}

		private static Transform GetClosestEnemyForLogging(Landmine __instance)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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_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_0061: 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)
			LayerMask val = LayerMask.op_Implicit(524288);
			RaycastHit[] array = Physics.SphereCastAll(((Component)__instance).transform.position, 10000f, Vector3.up, 0f, LayerMask.op_Implicit(val));
			Transform result = null;
			float num = float.MaxValue;
			RaycastHit[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				RaycastHit val2 = array2[i];
				if (((Component)((RaycastHit)(ref val2)).collider).CompareTag("Enemy"))
				{
					float num2 = Vector3.Distance(((Component)__instance).transform.position, ((RaycastHit)(ref val2)).transform.position);
					if (num2 < num)
					{
						num = num2;
						result = ((RaycastHit)(ref val2)).transform;
					}
				}
			}
			return result;
		}

		[HarmonyPatch("OnTriggerEnter")]
		[HarmonyPrefix]
		private static bool OnTriggerEnter(Landmine __instance, Collider other)
		{
			if (__instance.hasExploded || __instance.GetPrivateField<float>("pressMineDebounceTimer") > 0f)
			{
				return true;
			}
			if (((Component)other).CompareTag("Enemy"))
			{
				TriggerDebounce(__instance);
				return false;
			}
			return true;
		}

		[HarmonyPatch("OnTriggerExit")]
		[HarmonyPrefix]
		private static bool OnTriggerExit(Landmine __instance, Collider other)
		{
			if (__instance.hasExploded || __instance.GetPrivateField<float>("pressMineDebounceTimer") > 0f)
			{
				return true;
			}
			if (((Component)other).CompareTag("Enemy"))
			{
				TriggerMineExplosion(__instance);
				return false;
			}
			return true;
		}
	}
}

plugins/LCOffice.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DunGen;
using DunGen.Graph;
using GameNetcodeStuff;
using HarmonyLib;
using LCOffice.Patches;
using LethalLevelLoader;
using LethalLib.Modules;
using LethalNetworkAPI;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Animations;
using UnityEngine.Animations.Rigging;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LcOffice")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LcOffice")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8ee335db-0cbe-470c-8fbc-69263f01b35a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LCOffice
{
	[BepInPlugin("Piggy.LCOffice", "LCOffice", "1.0.12")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(RoundManager))]
		internal class RoundManagerPatch
		{
			public static float spawnTimer;

			[HarmonyPatch("SpawnScrapInLevel")]
			[HarmonyPrefix]
			private static bool SetItemSpawnPoints(ref RuntimeDungeon ___dungeonGenerator)
			{
				//IL_003c: 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_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				if (((Object)___dungeonGenerator.Generator.DungeonFlow).name != "OfficeDungeonFlow")
				{
					return true;
				}
				RoundManager instance = RoundManager.Instance;
				Vector3 position = GameObject.Find("LevelGenerationRoot").transform.position;
				Object.Instantiate<GameObject>(extLevelGeneration, new Vector3(position.x - 130f, position.y, position.z - 130f), Quaternion.Euler(0f, 0f, 0f));
				dungeonGenerator = GameObject.Find("A_DungeonGenerator").GetComponent<RuntimeDungeon>();
				instance.SpawnSyncedProps();
				if ((Object)(object)GameObject.Find("OfficeTeleport(Clone)") != (Object)null)
				{
					EntranceTeleport component = GameObject.Find("OfficeTeleport(Clone)").GetComponent<EntranceTeleport>();
					component.entranceId = 40;
				}
				if ((Object)(object)GameObject.Find("OfficeOutsideTeleport(Clone)") != (Object)null)
				{
					EntranceTeleport component2 = GameObject.Find("OfficeOutsideTeleport(Clone)").GetComponent<EntranceTeleport>();
					component2.entranceId = 40;
				}
				return true;
			}
		}

		private const string modGUID = "Piggy.LCOffice";

		private const string modName = "LCOffice";

		private const string modVersion = "1.0.12";

		private readonly Harmony harmony = new Harmony("Piggy.LCOffice");

		private static Plugin Instance;

		public static ManualLogSource mls;

		public static AssetBundle Bundle;

		public static AudioClip ElevatorOpen;

		public static AudioClip ElevatorClose;

		public static AudioClip ElevatorUp;

		public static AudioClip ElevatorDown;

		public static AudioClip stanleyVoiceline1;

		public static AudioClip bossaLullaby;

		public static AudioClip shopTheme;

		public static AudioClip saferoomTheme;

		public static AudioClip cootieTheme;

		public static AudioClip garageDoorSlam;

		public static AudioClip garageSlide;

		public static AudioClip floorOpen;

		public static AudioClip floorClose;

		public static AudioClip footstep1;

		public static AudioClip footstep2;

		public static AudioClip footstep3;

		public static AudioClip footstep4;

		public static AudioClip dogEatItem;

		public static AudioClip bigGrowl;

		public static AudioClip enragedScream;

		public static AudioClip dogSprint;

		public static AudioClip ripPlayerApart;

		public static AudioClip cry1;

		public static AudioClip dogHowl;

		public static AudioClip stomachGrowl;

		public static AudioClip eatenExplode;

		public static AudioClip dogSneeze;

		public static GameObject shrimpPrefab;

		public static GameObject elevatorManager;

		public static GameObject storagePrefab;

		public static GameObject socketPrefab;

		public static GameObject socketInteractPrefab;

		public static GameObject insideCollider;

		public static EnemyType shrimpEnemy;

		public static GameObject officeRoundSystem;

		public static GameObject extLevelGeneration;

		public static ExtendedDungeonFlow officeExtendedDungeonFlow;

		public static DungeonArchetype officeArchetype;

		public static DungeonArchetype officeArchetype_A;

		public static DungeonFlow officeDungeonFlow;

		public static DungeonFlow officeDungeonFlow_A;

		public static TerminalNode shrimpTerminalNode;

		public static TerminalKeyword shrimpTerminalKeyword;

		public static Item coinItem;

		public static GameObject coinPrefab;

		public static Item toolBoxItem;

		public static GameObject toolBoxPrefab;

		public static Item screwDriverItem;

		public static GameObject screwDriverPrefab;

		public static Item laptopItem;

		public static GameObject laptopPrefab;

		public static Item wrenchItem;

		public static GameObject wrenchPrefab;

		public static RuntimeDungeon dungeonGenerator;

		public static string PluginDirectory;

		private ConfigEntry<bool> configGuaranteedOffice;

		private ConfigEntry<int> configOfficeRarity;

		private ConfigEntry<string> configMoons;

		private ConfigEntry<int> shrimpSpawnWeight;

		private ConfigEntry<int> configLengthOverride;

		private ConfigEntry<bool> configEnableScraps;

		public static bool setKorean;

		public static float musicVolume;

		public static Item bottleItem;

		public static Item goldencupItem;

		public static ItemGroup itemGroupGeneral;

		public static ItemGroup itemGroupTabletop;

		public static ItemGroup itemGroupSmall;

		private void Awake()
		{
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Expected O, but got Unknown
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Expected O, but got Unknown
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Expected O, but got Unknown
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Expected O, but got Unknown
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Expected O, but got Unknown
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Expected O, but got Unknown
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Expected O, but got Unknown
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Expected O, but got Unknown
			//IL_0404: Unknown result type (might be due to invalid IL or missing references)
			//IL_040e: Expected O, but got Unknown
			//IL_044d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_045e: Expected O, but got Unknown
			//IL_049d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Expected O, but got Unknown
			//IL_0592: Unknown result type (might be due to invalid IL or missing references)
			//IL_059c: Expected O, but got Unknown
			//IL_0626: Unknown result type (might be due to invalid IL or missing references)
			//IL_0630: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			PluginDirectory = ((BaseUnityPlugin)this).Info.Location;
			mls = Logger.CreateLogSource("Piggy.LCOffice");
			mls.LogInfo((object)"LC_Office is loaded!");
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			Bundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "lcoffice"));
			if ((Object)(object)Bundle == (Object)null)
			{
				mls.LogError((object)"Failed to load Office Dungeon assets.");
				return;
			}
			officeDungeonFlow = Bundle.LoadAsset<DungeonFlow>("OfficeDungeonFlow.asset");
			officeArchetype = Bundle.LoadAsset<DungeonArchetype>("OfficeArchetype.asset");
			extLevelGeneration = Bundle.LoadAsset<GameObject>("ExtLevelGeneration.prefab");
			configOfficeRarity = ((BaseUnityPlugin)this).Config.Bind<int>("General", "OfficeRarity", 40, new ConfigDescription("How rare it is for the office to be chosen. Higher values increases the chance of spawning the office.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 300), Array.Empty<object>()));
			configGuaranteedOffice = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "OfficeGuaranteed", false, new ConfigDescription("If enabled, the office will be effectively guaranteed to spawn. Only recommended for debugging/sightseeing purposes.", (AcceptableValueBase)null, Array.Empty<object>()));
			configMoons = ((BaseUnityPlugin)this).Config.Bind<string>("General", "OfficeMoonsList", "free", new ConfigDescription("The moon(s) that the office can spawn on, in the form of a comma separated list of selectable level names (e.g. \"TitanLevel,RendLevel,DineLevel\")\nNOTE: These must be the internal data names of the levels (all vanilla moons are \"MoonnameLevel\", for modded moon support you will have to find their name if it doesn't follow the convention).\nThe following strings: \"all\", \"vanilla\", \"modded\", \"paid\", \"free\", \"none\" are dynamic presets which add the dungeon to that specified group (string must only contain one of these, or a manual moon name list).\nDefault dungeon generation size is balanced around the dungeon scale multiplier of Titan (2.35), moons with significantly different dungeon size multipliers (see Lethal Company wiki for values) may result in dungeons that are extremely small/large.", (AcceptableValueBase)null, Array.Empty<object>()));
			configLengthOverride = ((BaseUnityPlugin)this).Config.Bind<int>("General", "OfficeLengthOverride", -1, new ConfigDescription(string.Format("If not -1, overrides the office length to whatever you'd like. Adjusts how long/large the dungeon generates.\nBe *EXTREMELY* careful not to set this too high (anything too big on a moon with a high dungeon size multipier can cause catastrophic problems, like crashing your computer or worse)\nFor reference, the default value for the current version [{0}] is {1}. If it's too big, make this lower e.g. 6, if it's too small use something like 10 (or higher, but don't go too crazy with it).", "1.0.4", officeDungeonFlow.Length.Min), (AcceptableValueBase)null, Array.Empty<object>()));
			configEnableScraps = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "OfficeCustomScrap", true, new ConfigDescription("When enabled, enables custom scrap spawning.", (AcceptableValueBase)null, Array.Empty<object>()));
			musicVolume = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ElevatorMusicVolume", 100f, "Set the volume of music played in the elevator. (0 - 100)").Value;
			shrimpSpawnWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Spawn", "ShrimpSpawnWeight", 5, new ConfigDescription("Sets the shrimp spawn weight for every moons.", (AcceptableValueBase)null, Array.Empty<object>()));
			setKorean = ((BaseUnityPlugin)this).Config.Bind<bool>("Translation", "Enable Korean", false, "Set language to Korean.").Value;
			if (configLengthOverride.Value == -1)
			{
				officeDungeonFlow.Length.Min = 6;
				officeDungeonFlow.Length.Max = 8;
			}
			else
			{
				mls.LogInfo((object)$"Office length override has been set to {configLengthOverride.Value}. Be careful with this value.");
				officeDungeonFlow.Length.Min = configLengthOverride.Value;
				officeDungeonFlow.Length.Max = configLengthOverride.Value;
			}
			ExtendedDungeonFlow val = ScriptableObject.CreateInstance<ExtendedDungeonFlow>();
			val.contentSourceName = "LC Office";
			val.dungeonFlow = officeDungeonFlow;
			val.dungeonDefaultRarity = 0;
			int num = (configGuaranteedOffice.Value ? 99999 : configOfficeRarity.Value);
			switch (configMoons.Value.ToLower())
			{
			case "all":
				val.manualContentSourceNameReferenceList.Add(new StringWithRarity("Lethal Company", num));
				val.manualContentSourceNameReferenceList.Add(new StringWithRarity("Custom", num));
				mls.LogInfo((object)"Registered Office dungeon for all moons.");
				break;
			case "vanilla":
				val.manualContentSourceNameReferenceList.Add(new StringWithRarity("Lethal Company", num));
				mls.LogInfo((object)"Registered Office dungeon for all vanilla moons.");
				break;
			case "modded":
				val.manualContentSourceNameReferenceList.Add(new StringWithRarity("Custom", num));
				mls.LogInfo((object)"Registered Office dungeon for all modded moons.");
				break;
			case "paid":
				val.dynamicRoutePricesList.Add(new Vector2WithRarity(new Vector2(1f, 9999f), num));
				mls.LogInfo((object)"Registered Office dungeon for all paid moons.");
				break;
			case "free":
				val.dynamicRoutePricesList.Add(new Vector2WithRarity(new Vector2(0f, 0f), num));
				mls.LogInfo((object)"Registered Office dungeon for all free moons.");
				break;
			default:
			{
				mls.LogInfo((object)"Registering Office dungeon for predefined moon list.");
				string[] array = configMoons.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
				List<StringWithRarity> list = new List<StringWithRarity>();
				for (int i = 0; i < array.Length; i++)
				{
					string[] array2 = array[i].Split(new char[1] { '@' }, StringSplitOptions.RemoveEmptyEntries);
					int num2 = array2.Length;
					int result;
					if (num2 > 2)
					{
						mls.LogError((object)("Invalid setup for moon rarity config: " + array[i] + ". Skipping."));
					}
					else if (num2 == 1)
					{
						mls.LogInfo((object)$"Registering Office dungeon for moon {array[i]} at default rarity {num}");
						list.Add(new StringWithRarity(array[i], num));
					}
					else if (!int.TryParse(array2[1], out result))
					{
						mls.LogError((object)("Failed to parse rarity value for moon " + array2[0] + ": " + array2[1] + ". Skipping."));
					}
					else
					{
						mls.LogInfo((object)$"Registering Office dungeon for moon {array[i]} at default rarity {num}");
						list.Add(new StringWithRarity(array2[0], result));
					}
				}
				val.manualPlanetNameReferenceList = list;
				break;
			}
			}
			val.dungeonSizeMin = 1f;
			val.dungeonSizeMax = 1f;
			val.dungeonSizeLerpPercentage = 0f;
			PatchedContent.RegisterExtendedDungeonFlow(val);
			shrimpPrefab = Bundle.LoadAsset<GameObject>("Shrimp.prefab");
			shrimpEnemy = Bundle.LoadAsset<EnemyType>("ShrimpEnemy.asset");
			elevatorManager = Bundle.LoadAsset<GameObject>("ElevatorSystem.prefab");
			storagePrefab = Bundle.LoadAsset<GameObject>("DepositPlace.prefab");
			socketPrefab = Bundle.LoadAsset<GameObject>("ElevatorSocket.prefab");
			socketInteractPrefab = Bundle.LoadAsset<GameObject>("LungPlacement.prefab");
			officeRoundSystem = Bundle.LoadAsset<GameObject>("OfficeRoundSystem.prefab");
			insideCollider = Bundle.LoadAsset<GameObject>("InsideCollider.prefab");
			bossaLullaby = Bundle.LoadAsset<AudioClip>("bossa_lullaby_refiltered.ogg");
			shopTheme = Bundle.LoadAsset<AudioClip>("shop_refiltered.ogg");
			saferoomTheme = Bundle.LoadAsset<AudioClip>("saferoom_refiltered.ogg");
			ElevatorOpen = Bundle.LoadAsset<AudioClip>("ElevatorOpen.ogg");
			ElevatorClose = Bundle.LoadAsset<AudioClip>("ElevatorClose.ogg");
			ElevatorDown = Bundle.LoadAsset<AudioClip>("ElevatorDown.ogg");
			ElevatorUp = Bundle.LoadAsset<AudioClip>("ElevatorUp.ogg");
			garageDoorSlam = Bundle.LoadAsset<AudioClip>("GarageDoorSlam.ogg");
			garageSlide = Bundle.LoadAsset<AudioClip>("GarageDoorSlide1.ogg");
			floorOpen = Bundle.LoadAsset<AudioClip>("FloorOpen.ogg");
			floorClose = Bundle.LoadAsset<AudioClip>("FloorClosed.ogg");
			footstep1 = Bundle.LoadAsset<AudioClip>("Footstep1.ogg");
			footstep2 = Bundle.LoadAsset<AudioClip>("Footstep2.ogg");
			footstep3 = Bundle.LoadAsset<AudioClip>("Footstep3.ogg");
			footstep4 = Bundle.LoadAsset<AudioClip>("Footstep4.ogg");
			dogEatItem = Bundle.LoadAsset<AudioClip>("DogEatObject.ogg");
			bigGrowl = Bundle.LoadAsset<AudioClip>("BigGrowl.ogg");
			enragedScream = Bundle.LoadAsset<AudioClip>("DogRage.ogg");
			dogSprint = Bundle.LoadAsset<AudioClip>("DogSprint.ogg");
			ripPlayerApart = Bundle.LoadAsset<AudioClip>("RipPlayerApart.ogg");
			cry1 = Bundle.LoadAsset<AudioClip>("Cry1.ogg");
			dogHowl = Bundle.LoadAsset<AudioClip>("DogHowl.ogg");
			stomachGrowl = Bundle.LoadAsset<AudioClip>("StomachGrowl.ogg");
			eatenExplode = Bundle.LoadAsset<AudioClip>("eatenExplode.ogg");
			dogSneeze = Bundle.LoadAsset<AudioClip>("Sneeze.ogg");
			stanleyVoiceline1 = Bundle.LoadAsset<AudioClip>("stanley.ogg");
			shrimpTerminalNode = Bundle.LoadAsset<TerminalNode>("ShrimpFile.asset");
			shrimpTerminalKeyword = Bundle.LoadAsset<TerminalKeyword>("shrimpTK.asset");
			if (!setKorean)
			{
				shrimpTerminalNode.displayText = "Shrimp\r\n\r\nSigurd’s Danger Level: 60%\r\n\r\n\nScientific name: Canispiritus-Artemus\r\n\r\nShrimps are dog-like creatures, known to be the first tenant of the Upturned Inn. For the most part, he is relatively friendly to humans, following them around, curiously stalking them. Unfortunately, their passive temperament comes with a dangerously vicious hunger.\r\nDue to the nature of their biology, he has a much more unique stomach organ than most other creatures. The stomach lining is flexible, yet hardy, allowing a Shrimp to digest and absorb the nutrients from anything, biological or not, so long as it isn’t too large.\r\n\r\nHowever, this evolutionary adaptation was most likely a result of their naturally rapid metabolism. He uses nutrients so quickly that he needs to eat multiple meals a day to survive. The time between these meals are inconsistent, as the rate of caloric consumption is variable. This can range from hours to even minutes and causes the shrimp to behave monstrously if he has not eaten for a while.\r\n\r\nKnown to live in abandoned buildings, shrimp can often be seen in large abandoned factories or offices scavenging for scrap metal, to eat. That isn’t to say he can’t be found elsewhere. He is usually a lone hunters and expert trackers out of necessity.\r\n\r\nSigurd’s Note:\r\nIf this guy spots you, you’ll want to drop something you’re holding and let him eat it. It’s either you or that piece of scrap on you.\r\n\r\nit’s best to avoid letting him spot you. I swear… it’s almost like his eyes are staring into your soul.\r\nI never want to see one of these guys behind me again.\r\n\r\n\r\nIK: <i>Sir, don't be sad! Shrimp didn't hate you.\r\nhe was just... hungry.</i>\r\n\r\n";
				shrimpTerminalNode.creatureName = "Shrimp";
				shrimpTerminalKeyword.word = "shrimp";
			}
			else
			{
				shrimpTerminalNode.displayText = "쉬림프\r\n\r\n시구르드의 위험 수준: 60%\r\n\r\n\n학명: 카니스피리투스-아르테무스\r\n\r\n쉬림프는 개를 닮은 생명체로 Upturned Inn의 첫 번째 세입자로 알려져 있습니다. 평소에는 상대적으로 우호적이며, 호기심을 가지고 인간을 따라다닙니다. 불행하게도 그는 위험할 정도로 굉장한 식욕을 가지고 있습니다.\r\n생물학적 특성으로 인해, 그는 대부분의 다른 생물보다 훨씬 더 독특한 위장 기관을 가지고 있습니다. 위 내막은 유연하면서도 견고하기 때문에 어떤 물체라도 영양분을 소화하고 흡수할 수 있습니다.\r\n그러나 이러한 진화적 적응은 자연적으로 빠른 신진대사의 결과일 가능성이 높습니다. 그는 영양분을 너무 빨리 사용하기 때문에 생존하려면 하루에 여러 끼를 먹어야 합니다.\r\n칼로리 소비율이 다양하기 때문에 식사 사이의 시간이 일정하지 않습니다. 이는 몇 시간에서 몇 분까지 지속될 수 있으며, 쉬림프가 오랫동안 무언가를 먹지 않으면 매우 포악해지며 따라다니던 사람을 쫒습니다.\r\n\r\n버려진 건물에 사는 것으로 알려진 쉬림프는 버려진 공장이나 사무실에서 폐철물을 찾아다니는 것으로 발견할 수 있습니다. 그렇다고 다른 곳에서 그를 찾을 수 없다는 말은 아닙니다. 그는 일반적으로 고독한 사냥꾼이며, 때로는 전문적인 추적자가 되기도 합니다.\r\n\r\n시구르드의 노트: 이 녀석이 으르렁거리는 소리를 듣게 된다면, 먹이를 줄 수 있는 무언가를 가지고 있기를 바라세요. 아니면 당신이 이 녀석의 식사가 될 거예요.\r\n맹세컨대... 마치 당신의 영혼을 들여다보는 것 같아요. 다시는 내 뒤에서 이 녀석을 보고 싶지 않아요.\r\n\r\n\r\nIK: <i>손님, 슬퍼하지 마세요! 쉬림프는 당신을 싫어하지 않는답니다.\r\n걔는 그냥... 배고플 뿐이에요.</i>\r\n\r\n";
				shrimpTerminalNode.creatureName = "쉬림프";
				shrimpTerminalKeyword.word = "쉬림프";
			}
			Enemies.RegisterEnemy(shrimpEnemy, shrimpSpawnWeight.Value, (LevelTypes)(-1), (SpawnType)0, shrimpTerminalNode, shrimpTerminalKeyword);
			socketInteractPrefab.AddComponent<ElevatorSystem>();
			shrimpPrefab.AddComponent<ShrimpAI>();
			elevatorManager.AddComponent<ElevatorSystem>();
			officeRoundSystem.AddComponent<OfficeRoundSystem>();
			insideCollider.AddComponent<ElevatorSystem>();
			insideCollider.AddComponent<ElevatorCollider>();
			NetworkPrefabs.RegisterNetworkPrefab(shrimpPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(elevatorManager);
			NetworkPrefabs.RegisterNetworkPrefab(storagePrefab);
			NetworkPrefabs.RegisterNetworkPrefab(socketInteractPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(officeRoundSystem);
			NetworkPrefabs.RegisterNetworkPrefab(insideCollider);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[LC_Office] Successfully loaded assets!");
			harmony.PatchAll(typeof(Plugin));
			harmony.PatchAll(typeof(PlayerControllerBPatch));
			harmony.PatchAll(typeof(GrabbableObjectPatch));
			harmony.PatchAll(typeof(TerminalPatch));
			harmony.PatchAll(typeof(StartOfRoundPatch));
			harmony.PatchAll(typeof(GameNetworkManagerPatch));
		}
	}
}
namespace LCOffice.Patches
{
	public class PlaceableLungProp : MonoBehaviour
	{
	}
	public class SetPosOfNetworkObject : MonoBehaviour
	{
		public Transform originPos;

		private void Start()
		{
		}

		private void LateUpdate()
		{
		}
	}
	public class PlaceLung : NetworkBehaviour
	{
		public static bool emergencyPowerRequires;

		public static bool emergencyCheck;

		public static bool lungPlaced;
	}
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal class GameNetworkManagerPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Disconnect")]
		private static void Disconnect_Prefix()
		{
		}
	}
	public class OfficeRoundSystem : NetworkBehaviour
	{
		public bool isOffice;

		public bool isChecked;

		public bool isDungeonOfficeChecked;

		public static OfficeRoundSystem Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
		}

		private void Start()
		{
			SceneManager.sceneLoaded += ResetStaticVariable;
		}

		private void LateUpdate()
		{
			if (!isChecked && TimeOfDay.Instance.currentDayTimeStarted && (Object)(object)RoundManager.Instance.dungeonGenerator != (Object)null)
			{
				if (((Object)RoundManager.Instance.dungeonGenerator.Generator.DungeonFlow).name == "OfficeDungeonFlow")
				{
					isOffice = true;
				}
				else
				{
					isOffice = false;
				}
				if (!isDungeonOfficeChecked)
				{
					((MonoBehaviour)this).StartCoroutine(CheckOfficeElevator());
					if (isOffice && ((NetworkBehaviour)this).IsServer)
					{
						NetworkObject component = Object.Instantiate<GameObject>(Plugin.insideCollider).GetComponent<NetworkObject>();
						component.Spawn(false);
					}
					isDungeonOfficeChecked = true;
				}
			}
			if (isChecked && !TimeOfDay.Instance.currentDayTimeStarted)
			{
				if (!isOffice || ((NetworkBehaviour)this).IsServer)
				{
				}
				isOffice = false;
				isChecked = false;
				isDungeonOfficeChecked = false;
			}
		}

		private void ResetStaticVariable(Scene scene, LoadSceneMode mode)
		{
			PlaceLung.emergencyPowerRequires = false;
			PlaceLung.emergencyCheck = false;
			PlaceLung.lungPlaced = false;
			ElevatorSystem.elevatorFloor.Value = 1;
			ElevatorSystem.isElevatorClosed = false;
			ElevatorSystem.spawnShrimpBool.Value = false;
			ElevatorSystem.isSetupEnd = false;
		}

		private IEnumerator CheckOfficeElevator()
		{
			yield return (object)new WaitForSeconds(7f);
			isChecked = true;
			SetKorean();
		}

		private void SetKorean()
		{
			InteractTrigger[] array = Object.FindObjectsOfType<InteractTrigger>();
			InteractTrigger[] array2 = array;
			foreach (InteractTrigger val in array2)
			{
				if (Plugin.setKorean)
				{
					if (val.hoverTip == "Open : [LMB]")
					{
						val.hoverTip = "열기 : [LMB]";
					}
					else if (val.hoverTip == "Open : [E]")
					{
						val.hoverTip = "열기 : [E]";
					}
					if (val.hoverTip == "Use door : [LMB]")
					{
						val.hoverTip = "문 사용하기 : [LMB]";
					}
					else if (val.hoverTip == "Use door : [E]")
					{
						val.hoverTip = "문 사용하기 : [E]";
					}
					if (val.hoverTip == "Go up : [LMB]")
					{
						val.hoverTip = "상승하기 : [LMB]";
					}
					else if (val.hoverTip == "Go up : [E]")
					{
						val.hoverTip = "상승하기 : [E]";
					}
					if (val.hoverTip == "Go down : [LMB]")
					{
						val.hoverTip = "하강하기 : [LMB]";
					}
					else if (val.hoverTip == "Go down : [E]")
					{
						val.hoverTip = "하강하기 : [E]";
					}
					if (val.hoverTip == "Place Apparatus : [LMB]")
					{
						val.hoverTip = "장치 설치하기 : [LMB]";
					}
					else if (val.hoverTip == "Place Apparatus : [E]")
					{
						val.hoverTip = "장치 설치하기 : [E]";
					}
					if (val.hoverTip == "Store item : [LMB]")
					{
						val.hoverTip = "아이템 보관하기 : [LMB]";
					}
					else if (val.hoverTip == "Store item : [E]")
					{
						val.hoverTip = "아이템 보관하기 : [E]";
					}
					if (val.hoverTip == "Climb : [LMB]")
					{
						val.hoverTip = "오르기 : [LMB]";
					}
					else if (val.hoverTip == "Climb : [E]")
					{
						val.hoverTip = "오르기 : [E]";
					}
					if (val.hoverTip == "Flush: [LMB]")
					{
						val.hoverTip = "물 내리기: [LMB]";
					}
					else if (val.hoverTip == "Flush: [E]")
					{
						val.hoverTip = "물 내리기: [E]";
					}
					if (val.disabledHoverTip == "[Not holding Apparatus]")
					{
						val.disabledHoverTip = "[장치를 들고 있지 않음]";
					}
				}
			}
		}
	}
	public class ShrimpCollider : MonoBehaviour
	{
	}
	public class ShrimpAI : EnemyAI
	{
		public float networkPosDistance;

		public Vector3 prevPosition;

		public float stuckDetectionTimer;

		public float prevPositionDistance;

		public AISearchRoutine roamMap = new AISearchRoutine();

		private Vector3 spawnPosition;

		public PlayerControllerB hittedPlayer;

		[PublicNetworkVariable]
		public static LethalNetworkVariable<bool> KillingPlayerBool = new LethalNetworkVariable<bool>("KillingPlayerBool");

		[PublicNetworkVariable]
		public static LethalNetworkVariable<int> SelectNode = new LethalNetworkVariable<int>("SelectNode");

		[PublicNetworkVariable]
		public static LethalNetworkVariable<float> shrimpVelocity = new LethalNetworkVariable<float>("shrimpVelocity");

		[PublicNetworkVariable]
		public static LethalNetworkVariable<float> hungerValue = new LethalNetworkVariable<float>("hungerValue");

		[PublicNetworkVariable]
		public static LethalNetworkVariable<bool> isHitted = new LethalNetworkVariable<bool>("isHitted");

		[PublicNetworkVariable]
		public static LethalNetworkVariable<Vector3> networkPosition = new LethalNetworkVariable<Vector3>("networkPosition");

		[PublicNetworkVariable]
		public static LethalNetworkVariable<Vector3> networkRotation = new LethalNetworkVariable<Vector3>("networkRotation");

		[PublicNetworkVariable]
		public static LethalNetworkVariable<PlayerControllerB> networkTargetPlayer = new LethalNetworkVariable<PlayerControllerB>("networkTargetPlayer");

		public bool isKillingPlayer;

		public bool isSeenPlayer;

		public bool isEnraging;

		public bool isAngered;

		public bool canBeMoved;

		public bool isRunning;

		public bool dogRandomWalk;

		public float footStepTime;

		public float randomVal;

		public bool isTargetAvailable;

		public float networkTargetPlayerDistance;

		public float nearestItemDistance;

		public bool isNearestItem;

		public List<GameObject> droppedItems = new List<GameObject>();

		public GameObject nearestDroppedItem;

		public Transform dogHead;

		public Ray lookRay;

		public Transform lookTarget;

		public BoxCollider[] allBoxCollider;

		public Transform IdleTarget;

		public bool isIdleTargetAvailable;

		public bool forceChangeTarget;

		public Rig lookRig;

		public Light lungLight;

		public bool ateLung;

		public bool isSatisfied;

		public float satisfyValue;

		public Transform leftEye;

		public Transform rightEye;

		public Transform shrimpEye;

		public Transform mouth;

		public GameObject shrimpKillTrigger;

		public Transform bittenObjectHolder;

		public float searchingForObjectTimer;

		private Vector3 scaleOfEyesNormally;

		public AudioSource mainAudio;

		public AudioSource voiceAudio;

		public AudioSource voice2Audio;

		public AudioSource dogMusic;

		public AudioSource sprintAudio;

		public Vector3 originalMouthScale;

		public float scaredBackingAway;

		public Ray backAwayRay;

		private RaycastHit hitInfo;

		private RaycastHit hitInfoB;

		public float followTimer;

		public EnemyBehaviourState roamingState;

		public EnemyBehaviourState followingPlayer;

		public EnemyBehaviourState enragedState;

		public List<EnemyBehaviourState> tempEnemyBehaviourStates;

		public List<SkinnedMeshRenderer> skinnedMeshRendererList;

		public List<MeshRenderer> meshRendererList;

		private float timeSinceLookingAtNoise;

		private Vector3 lookAtNoise;

		private void Awake()
		{
			base.agent = ((Component)this).GetComponent<NavMeshAgent>();
		}

		public override void Start()
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: 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_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Expected O, but got Unknown
			KillingPlayerBool.Value = false;
			SelectNode.Value = 0;
			shrimpVelocity.Value = 0f;
			hungerValue.Value = 0f;
			isHitted.Value = false;
			networkTargetPlayer.Value = null;
			((Component)((Component)this).transform.GetChild(0)).GetComponent<EnemyAICollisionDetect>().mainScript = (EnemyAI)(object)this;
			base.enemyType = Plugin.shrimpEnemy;
			base.skinnedMeshRenderers = ((Component)this).gameObject.GetComponentsInChildren<SkinnedMeshRenderer>();
			base.meshRenderers = ((Component)this).gameObject.GetComponentsInChildren<MeshRenderer>();
			base.thisNetworkObject = ((Component)this).gameObject.GetComponentInChildren<NetworkObject>();
			base.serverPosition = ((Component)this).transform.position;
			base.thisEnemyIndex = RoundManager.Instance.numberOfEnemiesInScene;
			RoundManager instance = RoundManager.Instance;
			instance.numberOfEnemiesInScene++;
			base.allAINodes = GameObject.FindGameObjectsWithTag("AINode");
			base.path1 = new NavMeshPath();
			mouth = GameObject.Find("ShrimpMouth").transform;
			leftEye = GameObject.Find("ShrimpLeftEye").transform;
			rightEye = GameObject.Find("ShrimpRightEye").transform;
			shrimpKillTrigger = GameObject.Find("ShrimpKillTrigger");
			base.creatureAnimator = ((Component)((Component)this).transform.GetChild(0).GetChild(1)).gameObject.GetComponent<Animator>();
			base.creatureAnimator.SetTrigger("Walk");
			mainAudio = GameObject.Find("ShrimpMainAudio").GetComponent<AudioSource>();
			voiceAudio = GameObject.Find("ShrimpGrowlAudio").GetComponent<AudioSource>();
			voice2Audio = GameObject.Find("ShrimpAngerAudio").GetComponent<AudioSource>();
			lookRig = GameObject.Find("ShrimpLookAtPlayer").GetComponent<Rig>();
			lungLight = GameObject.Find("LungFlash").GetComponent<Light>();
			lungLight.intensity = 0f;
			AudioSource[] componentsInChildren = ((Component)((Component)this).transform).GetComponentsInChildren<AudioSource>();
			AudioSource[] array = componentsInChildren;
			foreach (AudioSource val in array)
			{
				val.outputAudioMixerGroup = GameObject.Find("StatusEffectAudio").GetComponent<AudioSource>().outputAudioMixerGroup;
			}
			lookTarget = GameObject.Find("Shrimp_Look_target").transform;
			dogHead = GameObject.Find("ShrimpLookPoint").transform;
			bittenObjectHolder = GameObject.Find("BittenObjectHolder").transform;
			shrimpEye = GameObject.Find("ShrimpEye").transform;
			scaleOfEyesNormally = leftEye.localScale;
			originalMouthScale = mouth.localScale;
			voice2Audio.clip = Plugin.dogSprint;
			voice2Audio.Play();
			base.creatureVoice = voice2Audio;
			base.creatureSFX = voice2Audio;
			base.eye = shrimpEye;
			SetupBehaviour();
			tempEnemyBehaviourStates.Add(roamingState);
			tempEnemyBehaviourStates.Add(followingPlayer);
			tempEnemyBehaviourStates.Add(enragedState);
			base.enemyBehaviourStates = tempEnemyBehaviourStates.ToArray();
			spawnPosition = ((Component)this).transform.position;
			roamMap = new AISearchRoutine();
			ItemElevatorCheck[] array2 = Object.FindObjectsOfType<ItemElevatorCheck>();
			ItemElevatorCheck[] array3 = array2;
			foreach (ItemElevatorCheck itemElevatorCheck in array3)
			{
				itemElevatorCheck.shrimpAI = this;
			}
			if (Plugin.setKorean)
			{
				((Component)((Component)this).transform.GetChild(1)).GetComponent<ScanNodeProperties>().headerText = "쉬림프";
			}
			ShrimpAI[] array4 = Object.FindObjectsOfType<ShrimpAI>();
			ShrimpAI[] array5 = array4;
			foreach (ShrimpAI shrimpAI in array5)
			{
				if ((Object)(object)shrimpAI != (Object)(object)this)
				{
					Object.Destroy((Object)(object)((Component)shrimpAI).gameObject);
				}
			}
		}

		public IEnumerator stunnedTimer(PlayerControllerB playerWhoHit)
		{
			isHitted.Value = false;
			hittedPlayer = playerWhoHit;
			base.agent.speed = 0f;
			base.creatureAnimator.SetTrigger("Recoil");
			mainAudio.PlayOneShot(Plugin.cry1, 1f);
			yield return (object)new WaitForSeconds(0.5f);
			scaredBackingAway = 3f;
			yield return (object)new WaitForSeconds(2f);
			hittedPlayer = null;
		}

		private void StunTest()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			if (scaredBackingAway > 0f)
			{
				if (((Behaviour)base.agent).enabled && ((NetworkBehaviour)this).IsOwner)
				{
					lookRig.weight = Mathf.Lerp(lookRig.weight, 0f, Time.deltaTime);
					base.agent.SetDestination(((EnemyAI)this).ChooseFarthestNodeFromPosition(((Component)this).transform.position, true, 0, false).position);
				}
				scaredBackingAway -= Time.deltaTime;
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false)
		{
			((EnemyAI)this).HitEnemy(force, playerWhoHit, false);
			if (hungerValue.Value < 60f && scaredBackingAway <= 0f)
			{
				isHitted.Value = true;
			}
		}

		public void FootStepSound()
		{
			randomVal = Random.Range(0, 20);
			if (randomVal < 5f)
			{
				mainAudio.PlayOneShot(Plugin.footstep1, Random.Range(0.8f, 1f));
			}
			else if (randomVal < 10f)
			{
				mainAudio.PlayOneShot(Plugin.footstep2, Random.Range(0.8f, 1f));
			}
			else if (randomVal < 15f)
			{
				mainAudio.PlayOneShot(Plugin.footstep3, Random.Range(0.8f, 1f));
			}
			else if (randomVal < 20f)
			{
				mainAudio.PlayOneShot(Plugin.footstep4, Random.Range(0.8f, 1f));
			}
		}

		private IEnumerator DogSatisfied()
		{
			yield return (object)new WaitForSeconds(2f);
			canBeMoved = true;
			networkTargetPlayer.Value = null;
		}

		public override void Update()
		{
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: 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_04ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0504: Unknown result type (might be due to invalid IL or missing references)
			//IL_071e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0728: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0701: Unknown result type (might be due to invalid IL or missing references)
			//IL_0781: Unknown result type (might be due to invalid IL or missing references)
			//IL_078b: Unknown result type (might be due to invalid IL or missing references)
			//IL_079b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0756: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0579: Unknown result type (might be due to invalid IL or missing references)
			//IL_084f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0855: Unknown result type (might be due to invalid IL or missing references)
			//IL_0865: Unknown result type (might be due to invalid IL or missing references)
			//IL_087c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0882: Unknown result type (might be due to invalid IL or missing references)
			//IL_0892: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0904: Unknown result type (might be due to invalid IL or missing references)
			//IL_090e: Unknown result type (might be due to invalid IL or missing references)
			//IL_091e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05de: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0652: Unknown result type (might be due to invalid IL or missing references)
			//IL_0657: Unknown result type (might be due to invalid IL or missing references)
			timeSinceLookingAtNoise += Time.deltaTime;
			footStepTime += Time.deltaTime * shrimpVelocity.Value / 8f;
			if ((double)footStepTime > 0.5)
			{
				FootStepSound();
				footStepTime = 0f;
			}
			if (!isSatisfied)
			{
				CheckPlayer();
			}
			if ((Object)(object)networkTargetPlayer.Value != (Object)null)
			{
			}
			base.creatureAnimator.SetFloat("walkSpeed", Mathf.Clamp(shrimpVelocity.Value / 5f, 0f, 3f));
			base.creatureAnimator.SetFloat("runSpeed", Mathf.Clamp(shrimpVelocity.Value / 2.7f, 3f, 4f));
			SetByHunger();
			if ((Object)(object)networkTargetPlayer.Value != (Object)null)
			{
				EatItem();
			}
			CheckTargetAvailable();
			if (isHitted.Value)
			{
				((MonoBehaviour)this).StartCoroutine(stunnedTimer(networkTargetPlayer.Value));
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				((EnemyAI)this).SyncPositionToClients();
			}
			else
			{
				((EnemyAI)this).SetClientCalculatingAI(false);
			}
			if (ateLung)
			{
				lungLight.intensity = Mathf.Lerp(lungLight.intensity, 1500f, Time.deltaTime * 10f);
			}
			if (satisfyValue >= 21f && !isSatisfied)
			{
				mainAudio.PlayOneShot(Plugin.dogSneeze);
				canBeMoved = false;
				((MonoBehaviour)this).StartCoroutine(DogSatisfied());
				isSatisfied = true;
			}
			if (isSatisfied && satisfyValue > 0f)
			{
				satisfyValue -= Time.deltaTime;
				isSeenPlayer = false;
			}
			if (satisfyValue <= 0f && isSatisfied)
			{
				isSatisfied = false;
				satisfyValue = 0f;
			}
			if ((Object)(object)networkTargetPlayer.Value == (Object)null && !isNearestItem && (Object)(object)base.targetNode == (Object)null)
			{
				int num = Random.Range(1, base.allAINodes.Length);
				if (Vector3.Distance(((Component)this).transform.position, base.allAINodes[num].transform.position) > 5f && SelectNode.Value != num && ((NetworkBehaviour)this).IsOwner && ((NetworkBehaviour)this).IsOwner)
				{
					SelectNode.Value = num;
				}
			}
			else if ((Object)(object)networkTargetPlayer.Value == (Object)null && !isNearestItem && (Object)(object)base.targetNode != (Object)null)
			{
				int num2 = Random.Range(1, base.allAINodes.Length);
				if (Vector3.Distance(((Component)this).transform.position, base.allAINodes[SelectNode.Value].transform.position) < 1f && SelectNode.Value != num2 && ((NetworkBehaviour)this).IsOwner && ((NetworkBehaviour)this).IsOwner)
				{
					SelectNode.Value = num2;
				}
			}
			if (stuckDetectionTimer > 3.5f)
			{
				int num3 = Random.Range(1, base.allAINodes.Length);
				if (Vector3.Distance(((Component)this).transform.position, base.allAINodes[num3].transform.position) > 5f && SelectNode.Value != num3)
				{
					if (((NetworkBehaviour)this).IsOwner)
					{
						SelectNode.Value = num3;
					}
					stuckDetectionTimer = 0f;
				}
				else if (Vector3.Distance(((Component)this).transform.position, base.allAINodes[num3].transform.position) > 5f)
				{
					stuckDetectionTimer = 0f;
				}
			}
			Vector3 velocity;
			if (((Object)(object)networkTargetPlayer.Value == (Object)null && !isNearestItem) || isSatisfied)
			{
				if (timeSinceLookingAtNoise < 2f)
				{
					lookRig.weight = Mathf.Lerp(lookRig.weight, 1f, Time.deltaTime);
					lookTarget.position = Vector3.Lerp(lookTarget.position, lookAtNoise, 10f * Time.deltaTime);
				}
				else
				{
					lookRig.weight = Mathf.Lerp(lookRig.weight, 0f, Time.deltaTime);
				}
				if ((Object)(object)base.targetNode != (Object)null)
				{
					if (((Behaviour)base.agent).enabled && ((NetworkBehaviour)this).IsOwner)
					{
						base.agent.SetDestination(base.targetNode.position);
					}
					if (shrimpVelocity.Value < 0.5f)
					{
						stuckDetectionTimer += Time.deltaTime;
					}
					else
					{
						stuckDetectionTimer = 0f;
					}
					float num4 = 30f;
					Vector3 val = ((Component)this).transform.position - prevPosition;
					velocity = base.agent.velocity;
					float num5 = Vector3.Angle(val, ((Vector3)(ref velocity)).normalized);
					if (num5 > num4)
					{
						Plugin.mls.LogInfo((object)("angle diff: " + num5 + ", " + num4 + " rad."));
					}
					prevPosition = ((Component)this).transform.position;
				}
			}
			base.targetNode = base.allAINodes[SelectNode.Value].transform;
			if ((Object)(object)networkTargetPlayer.Value != (Object)null || isNearestItem)
			{
				dogRandomWalk = false;
				stuckDetectionTimer = 0f;
			}
			Quaternion rotation;
			if (((NetworkBehaviour)this).IsOwner)
			{
				networkPosition.Value = ((Component)this).transform.position;
				LethalNetworkVariable<Vector3> obj = networkRotation;
				rotation = ((Component)this).transform.rotation;
				obj.Value = ((Quaternion)(ref rotation)).eulerAngles;
				LethalNetworkVariable<float> obj2 = shrimpVelocity;
				velocity = base.agent.velocity;
				obj2.Value = ((Vector3)(ref velocity)).sqrMagnitude;
			}
			else
			{
				networkPosDistance = Vector3.Distance(((Component)this).transform.position, networkPosition.Value);
				if (networkPosDistance > 3f)
				{
					((Component)this).transform.position = networkPosition.Value;
					Plugin.mls.LogWarning((object)"Force the shrimp to change position.");
				}
				else
				{
					((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, networkPosition.Value, Time.deltaTime * 10f);
				}
				Transform transform = ((Component)this).transform;
				rotation = ((Component)this).transform.rotation;
				transform.rotation = Quaternion.Euler(Vector3.Lerp(((Quaternion)(ref rotation)).eulerAngles, networkRotation.Value, Time.deltaTime * 10f));
				if (networkPosDistance > 15f)
				{
					Plugin.mls.LogFatal((object)"Shrimp spawned successfully, but the current position is VERY far from the network position. This error typically occurs when network quality is low or the server is experiencing heavy traffic.");
				}
			}
			if ((Object)(object)networkTargetPlayer.Value != (Object)null)
			{
				isTargetAvailable = true;
			}
			if (hungerValue.Value < 55f)
			{
				leftEye.localScale = Vector3.Lerp(leftEye.localScale, scaleOfEyesNormally, 20f * Time.deltaTime);
				rightEye.localScale = Vector3.Lerp(rightEye.localScale, scaleOfEyesNormally, 20f * Time.deltaTime);
			}
			else if (hungerValue.Value > 55f)
			{
				leftEye.localScale = Vector3.Lerp(leftEye.localScale, scaleOfEyesNormally * 0.4f, 20f * Time.deltaTime);
				rightEye.localScale = Vector3.Lerp(rightEye.localScale, scaleOfEyesNormally * 0.4f, 20f * Time.deltaTime);
			}
			base.creatureAnimator.SetBool("DogRandomWalk", dogRandomWalk);
			if (canBeMoved && !isRunning)
			{
				base.creatureAnimator.SetBool("Running", false);
				base.agent.speed = 5.5f;
				base.agent.acceleration = 7f;
				base.agent.angularSpeed = 150f;
			}
			else if (!canBeMoved && !isRunning)
			{
				base.creatureAnimator.SetBool("Running", false);
				base.agent.speed = 0f;
				base.agent.angularSpeed = 0f;
			}
			if (isRunning)
			{
				base.creatureAnimator.SetBool("Running", true);
				base.agent.speed = Mathf.Lerp(base.agent.speed, 15f, Time.deltaTime * 2f);
				base.agent.angularSpeed = 10000f;
				base.agent.acceleration = 50f;
			}
			StunTest();
		}

		private IEnumerator SyncRotation()
		{
			Transform transform = ((Component)this).transform;
			Quaternion rotation = ((Component)this).transform.rotation;
			transform.rotation = Quaternion.Euler(Vector3.Lerp(((Quaternion)(ref rotation)).eulerAngles, networkRotation.Value, Time.deltaTime * 10f));
			yield return (object)new WaitForSeconds(1f);
		}

		private float CalculateRotationDifference(Vector3 rotation1, Vector3 rotation2)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Quaternion val = Quaternion.Euler(rotation1);
			Quaternion val2 = Quaternion.Euler(rotation2);
			return Quaternion.Angle(val, val2);
		}

		private void CheckPlayer()
		{
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: 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_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = ((EnemyAI)this).CheckLineOfSightForPlayer(40f, 40, 2);
			if ((Object)(object)val != (Object)null && (Object)(object)networkTargetPlayer.Value == (Object)null && !isKillingPlayer)
			{
				if (!isSeenPlayer)
				{
					mainAudio.PlayOneShot(Plugin.dogHowl);
					base.creatureAnimator.SetTrigger("Walk");
					isSeenPlayer = true;
				}
				networkTargetPlayer.Value = val;
			}
			if (droppedItems.Count > 0 && (Object)(object)nearestDroppedItem == (Object)null)
			{
				FindNearestItem();
			}
			if ((Object)(object)networkTargetPlayer.Value != (Object)null)
			{
				if (!isNearestItem && scaredBackingAway <= 0f)
				{
					if (hungerValue.Value > 55f)
					{
						lookRay = new Ray(dogHead.position, ((Component)networkTargetPlayer.Value).transform.position - dogHead.position);
						lookTarget.position = Vector3.Lerp(lookTarget.position, ((Ray)(ref lookRay)).GetPoint(3f), 30f * Time.deltaTime);
					}
					else
					{
						lookTarget.position = Vector3.Lerp(lookTarget.position, ((Component)networkTargetPlayer.Value.lowerSpine).transform.position, 6f * Time.deltaTime);
					}
				}
				base.agent.autoBraking = true;
				lookRig.weight = Mathf.Lerp(lookRig.weight, 0.5f, Time.deltaTime);
				dogRandomWalk = false;
				if (!isSeenPlayer)
				{
					mainAudio.PlayOneShot(Plugin.dogHowl, 1f);
				}
				isSeenPlayer = true;
			}
			if (!isRunning && !isNearestItem)
			{
				base.agent.stoppingDistance = 4.5f;
				lookRig.weight = Mathf.Lerp(lookRig.weight, 0f, Time.deltaTime);
			}
			else
			{
				base.agent.stoppingDistance = 0.5f;
			}
			if (!isNearestItem)
			{
			}
		}

		private void SetByHunger()
		{
			//IL_0550: Unknown result type (might be due to invalid IL or missing references)
			//IL_0556: Unknown result type (might be due to invalid IL or missing references)
			//IL_0566: Unknown result type (might be due to invalid IL or missing references)
			//IL_0478: 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_049c: Unknown result type (might be due to invalid IL or missing references)
			if (hungerValue.Value < 66f)
			{
				if (isSeenPlayer && !isTargetAvailable && ((NetworkBehaviour)this).IsOwner)
				{
					LethalNetworkVariable<float> obj = hungerValue;
					obj.Value += Time.deltaTime * 0.09f;
				}
				else if (isSeenPlayer && isTargetAvailable && ((NetworkBehaviour)this).IsOwner)
				{
					LethalNetworkVariable<float> obj2 = hungerValue;
					obj2.Value += Time.deltaTime;
				}
			}
			if (hungerValue.Value > 55f && hungerValue.Value < 60f)
			{
				voiceAudio.pitch = Mathf.Lerp(voiceAudio.pitch, 1f, 45f * Time.deltaTime);
				voiceAudio.volume = Mathf.Lerp(voiceAudio.volume, 1f, 125f * Time.deltaTime);
				voiceAudio.loop = true;
				voiceAudio.clip = Plugin.stomachGrowl;
				if (!voiceAudio.isPlaying)
				{
					voiceAudio.Play();
				}
			}
			else if (hungerValue.Value < 63f && hungerValue.Value >= 60f && !isEnraging)
			{
				voiceAudio.pitch = Mathf.Lerp(voiceAudio.pitch, 0.8f, 45f * Time.deltaTime);
				voiceAudio.volume = Mathf.Lerp(voiceAudio.volume, 1f, 125f * Time.deltaTime);
				isEnraging = true;
				voiceAudio.clip = Plugin.bigGrowl;
				if (!voiceAudio.isPlaying)
				{
					voiceAudio.Play();
				}
			}
			else if (hungerValue.Value < 63f && hungerValue.Value > 60f && isEnraging)
			{
				voiceAudio.pitch = Mathf.Lerp(voiceAudio.pitch, 1f, 45f * Time.deltaTime);
				voiceAudio.volume = Mathf.Lerp(voiceAudio.volume, 1f, 125f * Time.deltaTime);
				if (!isNearestItem)
				{
					canBeMoved = false;
				}
			}
			else if (hungerValue.Value < 55f)
			{
				voiceAudio.pitch = Mathf.Lerp(voiceAudio.pitch, 0f, 45f * Time.deltaTime);
				voiceAudio.volume = Mathf.Lerp(voiceAudio.volume, 0f, 125f * Time.deltaTime);
			}
			else if (hungerValue.Value > 63f && !isAngered)
			{
				if (!isNearestItem && !isKillingPlayer && base.stunNormalizedTimer <= 0f)
				{
					canBeMoved = true;
				}
				voiceAudio.clip = Plugin.enragedScream;
				voiceAudio.Play();
				isEnraging = false;
				isAngered = true;
			}
			else if (hungerValue.Value > 65f)
			{
				base.openDoorSpeedMultiplier = 1.5f;
				isRunning = true;
				voice2Audio.volume = Mathf.Lerp(voice2Audio.volume, 1f, 125f * Time.deltaTime);
			}
			else if (hungerValue.Value > 63f)
			{
				voiceAudio.pitch = Mathf.Lerp(voiceAudio.pitch, 0.8f, 45f * Time.deltaTime);
				mouth.localScale = Vector3.Lerp(mouth.localScale, new Vector3(0.005590725f, 0.01034348f, 0.02495567f), 30f * Time.deltaTime);
			}
			if (hungerValue.Value < 60f)
			{
				isEnraging = false;
				isAngered = false;
				if (!isNearestItem && !isKillingPlayer && base.stunNormalizedTimer <= 0f)
				{
					canBeMoved = true;
				}
			}
			if (hungerValue.Value < 66f)
			{
				isRunning = false;
				base.openDoorSpeedMultiplier = 0.3f;
			}
			if (hungerValue.Value < 63f)
			{
				mouth.localScale = Vector3.Lerp(mouth.localScale, originalMouthScale, 20f * Time.deltaTime);
				voice2Audio.volume = Mathf.Lerp(voice2Audio.volume, 0f, 125f * Time.deltaTime);
				isRunning = false;
			}
			if (hungerValue.Value > 64f && networkTargetPlayerDistance < 2f && !isKillingPlayer && (Object)(object)networkTargetPlayer.Value != (Object)null && !networkTargetPlayer.Value.isCameraDisabled)
			{
				KillingPlayerBool.Value = true;
			}
			if (KillingPlayerBool.Value)
			{
				if (!networkTargetPlayer.Value.isCameraDisabled)
				{
					((MonoBehaviour)this).StartCoroutine(KillPlayer(networkTargetPlayer.Value));
					KillingPlayerBool.Value = false;
				}
				else if (networkTargetPlayer.Value.isCameraDisabled)
				{
					((MonoBehaviour)this).StartCoroutine(KillPlayerInOtherClient(networkTargetPlayer.Value));
					KillingPlayerBool.Value = false;
				}
			}
			if (isKillingPlayer)
			{
				canBeMoved = false;
			}
		}

		private void EatItem()
		{
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: 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_0058: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)nearestDroppedItem != (Object)null)
			{
				if (isNearestItem && !nearestDroppedItem.GetComponent<GrabbableObject>().isHeld)
				{
					if (hungerValue.Value < 55f)
					{
						lookRay = new Ray(dogHead.position, nearestDroppedItem.transform.position - dogHead.position);
						lookTarget.position = Vector3.Lerp(lookTarget.position, ((Ray)(ref lookRay)).GetPoint(1.8f), 6f * Time.deltaTime);
					}
					else
					{
						lookTarget.position = Vector3.Lerp(lookTarget.position, nearestDroppedItem.transform.position, 6f * Time.deltaTime);
					}
					if (((Behaviour)base.agent).enabled && ((NetworkBehaviour)this).IsOwner)
					{
						base.agent.SetDestination(nearestDroppedItem.transform.position);
					}
					nearestItemDistance = Vector3.Distance(((Component)this).transform.position, nearestDroppedItem.transform.position);
					if (nearestItemDistance < 1.35f)
					{
						canBeMoved = false;
						isRunning = false;
						nearestDroppedItem.transform.SetParent(((Component)this).transform, true);
						if ((Object)(object)nearestDroppedItem.GetComponent<LungProp>() != (Object)null)
						{
							satisfyValue += 30f;
							if (((NetworkBehaviour)this).IsOwner)
							{
								LethalNetworkVariable<float> obj = hungerValue;
								obj.Value -= 50f;
							}
							ateLung = true;
							((Behaviour)nearestDroppedItem.GetComponentInChildren<Light>()).enabled = false;
						}
						else if ((Object)(object)nearestDroppedItem.GetComponent<StunGrenadeItem>() != (Object)null)
						{
							StunGrenadeItem component = nearestDroppedItem.GetComponent<StunGrenadeItem>();
							component.hasExploded = true;
							((MonoBehaviour)this).StartCoroutine(EatenFlashbang());
						}
						base.creatureAnimator.SetTrigger("eat");
						mainAudio.PlayOneShot(Plugin.dogEatItem);
						isNearestItem = false;
						nearestItemDistance = 500f;
						if (nearestDroppedItem.GetComponent<GrabbableObject>().itemProperties.weight > 1f)
						{
							satisfyValue += Mathf.Clamp(nearestDroppedItem.GetComponent<GrabbableObject>().itemProperties.weight - 1f, 0f, 100f) * 150f;
							if (((NetworkBehaviour)this).IsOwner)
							{
								LethalNetworkVariable<float> obj2 = hungerValue;
								obj2.Value -= Mathf.Clamp(nearestDroppedItem.GetComponent<GrabbableObject>().itemProperties.weight - 1f, 0f, 100f) * 230f;
							}
						}
						else
						{
							satisfyValue += 6f;
							if (((NetworkBehaviour)this).IsOwner)
							{
								LethalNetworkVariable<float> obj3 = hungerValue;
								obj3.Value -= 12f;
							}
						}
						GrabbableObject component2 = nearestDroppedItem.GetComponent<GrabbableObject>();
						component2.grabbable = false;
						component2.grabbableToEnemies = false;
						component2.deactivated = true;
						if ((Object)(object)component2.radarIcon != (Object)null)
						{
							Object.Destroy((Object)(object)((Component)component2.radarIcon).gameObject);
						}
						MeshRenderer[] componentsInChildren = ((Component)component2).gameObject.GetComponentsInChildren<MeshRenderer>();
						for (int i = 0; i < componentsInChildren.Length; i++)
						{
							Object.Destroy((Object)(object)componentsInChildren[i]);
						}
						Collider[] componentsInChildren2 = ((Component)component2).gameObject.GetComponentsInChildren<Collider>();
						for (int j = 0; j < componentsInChildren2.Length; j++)
						{
							Object.Destroy((Object)(object)componentsInChildren2[j]);
						}
						droppedItems.Remove(nearestDroppedItem);
						nearestDroppedItem = null;
					}
					else if (!isKillingPlayer && base.stunNormalizedTimer <= 0f)
					{
						canBeMoved = true;
					}
				}
				else if ((Object)(object)networkTargetPlayer.Value != (Object)null && !isSatisfied)
				{
					nearestDroppedItem = null;
					nearestItemDistance = 3000f;
					isNearestItem = false;
				}
			}
			if (base.stunNormalizedTimer > 0f)
			{
				canBeMoved = false;
				base.creatureAnimator.SetBool("Stun", true);
			}
			else
			{
				base.creatureAnimator.SetBool("Stun", false);
			}
		}

		private void CheckTargetAvailable()
		{
			//IL_007a: 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_013c: Unknown result type (might be due to invalid IL or missing references)
			if ((networkTargetPlayerDistance <= 12f || Object.op_Implicit((Object)(object)((EnemyAI)this).CheckLineOfSightForPlayer(40f, 40, -1))) && !isNearestItem && !isKillingPlayer && scaredBackingAway <= 0f)
			{
				followTimer = 10f;
				canBeMoved = true;
			}
			if ((Object)(object)networkTargetPlayer.Value != (Object)null)
			{
				networkTargetPlayerDistance = Vector3.Distance(((Component)this).transform.position, ((Component)networkTargetPlayer.Value).transform.position);
			}
			else
			{
				networkTargetPlayerDistance = 3000f;
			}
			if ((followTimer > 0f || networkTargetPlayerDistance < 10f) && !isSatisfied && isTargetAvailable && scaredBackingAway <= 0f && !isNearestItem && ((Behaviour)base.agent).enabled && ((NetworkBehaviour)this).IsOwner)
			{
				if (networkTargetPlayerDistance > 2.1f)
				{
					base.agent.SetDestination(((Component)networkTargetPlayer.Value).transform.position);
				}
				else if (hungerValue.Value < 55f)
				{
					BackAway();
				}
			}
			if ((((Object)(object)networkTargetPlayer.Value != (Object)null && networkTargetPlayerDistance > 12f) || !Object.op_Implicit((Object)(object)((EnemyAI)this).CheckLineOfSightForPlayer(40f, 30, -1))) && followTimer > 0f)
			{
				followTimer -= Time.deltaTime;
			}
			if ((Object)(object)networkTargetPlayer.Value == (Object)null)
			{
				followTimer = 10f;
			}
			if (followTimer <= 0f)
			{
				networkTargetPlayer.Value = null;
				isTargetAvailable = false;
			}
		}

		private bool IsPlayerVisible(PlayerControllerB player)
		{
			//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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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)
			Vector3 val = ((Component)player).transform.position - ((Component)this).transform.position;
			float num = Vector3.Angle(((Component)this).transform.forward, val);
			if (num < 35f && Physics.Raycast(((Component)this).transform.position, val, 120f, LayerMask.NameToLayer("Player")))
			{
				return true;
			}
			return false;
		}

		private void FindNearestItem()
		{
			//IL_001f: 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)
			foreach (GameObject droppedItem in droppedItems)
			{
				float num = Vector3.Distance(((Component)this).transform.position, droppedItem.transform.position);
				if (num < float.PositiveInfinity && num < 30f && !droppedItem.GetComponent<GrabbableObject>().isHeld)
				{
					nearestDroppedItem = droppedItem;
					isNearestItem = true;
					return;
				}
			}
			isNearestItem = false;
		}

		public override void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot = 0, int noiseID = 0)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DetectNoise(noisePosition, noiseLoudness, timesPlayedInOneSpot, noiseID);
			float num = Vector3.Distance(noisePosition, ((Component)this).transform.position);
			if (!(num > 15f))
			{
				if (Physics.Linecast(base.eye.position, noisePosition, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
				{
					noiseLoudness /= 2f;
				}
				if (!((double)(noiseLoudness / num) <= 0.045) && timeSinceLookingAtNoise > 5f)
				{
					timeSinceLookingAtNoise = 0f;
					lookAtNoise = noisePosition;
				}
			}
		}

		private void BackAway()
		{
			//IL_0016: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			base.agent.destination = ((Component)networkTargetPlayer.Value).transform.position;
			Vector3 position = ((Component)networkTargetPlayer.Value).transform.position;
			position.y = ((Component)this).transform.position.y;
			Vector3 val = position - ((Component)this).transform.position;
			backAwayRay = new Ray(((Component)this).transform.position, val * -1f);
			if (Physics.Raycast(backAwayRay, ref hitInfo, 60f, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
			{
				if (((RaycastHit)(ref hitInfo)).distance < 4f)
				{
					if (Physics.Linecast(((Component)this).transform.position, ((RaycastHit)(ref hitInfo)).point + Vector3.Cross(val, Vector3.up) * 25.5f, ref hitInfoB, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
					{
						float distance = ((RaycastHit)(ref hitInfoB)).distance;
						if (Physics.Linecast(((Component)this).transform.position, ((RaycastHit)(ref hitInfo)).point + Vector3.Cross(val, Vector3.up) * -25.5f, ref hitInfoB, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
						{
							float distance2 = ((RaycastHit)(ref hitInfoB)).distance;
							if (Mathf.Abs(distance - distance2) < 5f)
							{
								base.agent.destination = ((RaycastHit)(ref hitInfo)).point + Vector3.Cross(val, Vector3.up) * -4.5f;
							}
							else if (distance < distance2)
							{
								base.agent.destination = ((RaycastHit)(ref hitInfo)).point + Vector3.Cross(val, Vector3.up) * -4.5f;
							}
							else
							{
								base.agent.destination = ((RaycastHit)(ref hitInfo)).point + Vector3.Cross(val, Vector3.up) * 4.5f;
							}
						}
					}
				}
				else
				{
					base.agent.destination = ((RaycastHit)(ref hitInfo)).point;
				}
			}
			else
			{
				base.agent.destination = ((Ray)(ref backAwayRay)).GetPoint(2.3f);
			}
			base.agent.stoppingDistance = 0.2f;
			Quaternion val2 = Quaternion.Slerp(((Component)this).transform.rotation, Quaternion.LookRotation(val), 3f * Time.deltaTime);
			((Component)this).transform.eulerAngles = new Vector3(0f, ((Quaternion)(ref val2)).eulerAngles.y, 0f);
			base.agent.speed = 8f;
			base.creatureAnimator.SetFloat("walkSpeed", -2.2f);
		}

		private IEnumerator EatenFlashbang()
		{
			yield return (object)new WaitForSeconds(2f);
			mainAudio.PlayOneShot(Plugin.eatenExplode);
		}

		private void KillPlayerTrigger(PlayerControllerB killPlayer)
		{
			if (!killPlayer.isCameraDisabled)
			{
				((MonoBehaviour)this).StartCoroutine(KillPlayer(killPlayer));
			}
			else
			{
				((MonoBehaviour)this).StartCoroutine(KillPlayerInOtherClient(killPlayer));
			}
		}

		private IEnumerator KillPlayer(PlayerControllerB killPlayer)
		{
			hungerValue.Value = 0f;
			yield return (object)new WaitForSeconds(0.05f);
			isKillingPlayer = true;
			base.creatureAnimator.SetTrigger("RipObject");
			mainAudio.PlayOneShot(Plugin.ripPlayerApart);
			if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)killPlayer)
			{
				killPlayer.KillPlayer(Vector3.zero, true, (CauseOfDeath)6, 0);
			}
			yield return (object)new WaitForSeconds(0.1f);
			if ((Object)(object)killPlayer.deadBody == (Object)null)
			{
				Debug.Log((object)"Shrimp: Player body was not spawned or found within 0.5 seconds.");
				killPlayer.inAnimationWithEnemy = null;
				isKillingPlayer = false;
				KillingPlayerBool.Value = false;
			}
			else
			{
				TakeBodyInMouth(killPlayer.deadBody);
				yield return (object)new WaitForSeconds(4.4f);
				base.creatureAnimator.SetTrigger("eat");
				mainAudio.PlayOneShot(Plugin.dogEatItem);
				((Component)killPlayer.deadBody).gameObject.SetActive(false);
				yield return (object)new WaitForSeconds(2f);
				isKillingPlayer = false;
			}
		}

		private IEnumerator KillPlayerInOtherClient(PlayerControllerB killPlayer)
		{
			hungerValue.Value = 0f;
			yield return (object)new WaitForSeconds(0.05f);
			isKillingPlayer = true;
			base.creatureAnimator.SetTrigger("RipObject");
			mainAudio.PlayOneShot(Plugin.ripPlayerApart);
			yield return (object)new WaitForSeconds(0.1f);
			if ((Object)(object)killPlayer.deadBody == (Object)null)
			{
				Debug.Log((object)"Shrimp: Player body was not spawned or found within 0.5 seconds.");
				killPlayer.inAnimationWithEnemy = null;
				isKillingPlayer = false;
				KillingPlayerBool.Value = false;
			}
			else
			{
				TakeBodyInMouth(killPlayer.deadBody);
				yield return (object)new WaitForSeconds(4.4f);
				base.creatureAnimator.SetTrigger("eat");
				mainAudio.PlayOneShot(Plugin.dogEatItem);
				((Component)killPlayer.deadBody).gameObject.SetActive(false);
				yield return (object)new WaitForSeconds(2f);
				isKillingPlayer = false;
			}
		}

		private void TakeBodyInMouth(DeadBodyInfo body)
		{
			body.attachedTo = bittenObjectHolder;
			body.attachedLimb = body.bodyParts[5];
			body.matchPositionExactly = true;
		}

		private void SetupBehaviour()
		{
			roamingState.name = "Roaming";
			roamingState.boolValue = true;
			followingPlayer.name = "Following";
			followingPlayer.boolValue = true;
			enragedState.name = "Enraged";
			enragedState.boolValue = true;
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	internal class TerminalPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Start")]
		private static void Start_Prefix(Terminal __instance, ref List<TerminalNode> ___enemyFiles)
		{
			___enemyFiles.Add(Plugin.shrimpTerminalNode);
			TerminalKeyword defaultVerb = __instance.terminalNodes.allKeywords.First((TerminalKeyword x) => x.word == "info");
			TerminalKeyword shrimpTerminalKeyword = Plugin.shrimpTerminalKeyword;
			shrimpTerminalKeyword.defaultVerb = defaultVerb;
		}
	}
	public class AnotherInterior : MonoBehaviour
	{
		public RuntimeDungeon dungeonGenerator;

		private void Awake()
		{
			dungeonGenerator = ((Component)this).GetComponent<RuntimeDungeon>();
			dungeonGenerator.Generator.currentArchetype = Plugin.officeArchetype_A;
			dungeonGenerator.Generator.DungeonFlow = Plugin.officeDungeonFlow_A;
		}

		private void Start()
		{
			//IL_0016: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			RoundManager instance = RoundManager.Instance;
			Vector3 position = GameObject.Find("LevelGenerationRoot").transform.position;
			GameObject root = Object.Instantiate<GameObject>(new GameObject(), new Vector3(position.x - 130f, position.y, position.z - 130f), Quaternion.Euler(0f, 0f, 0f));
			dungeonGenerator.Root = root;
			dungeonGenerator.Generator.ShouldRandomizeSeed = false;
			dungeonGenerator.Generator.Seed = instance.LevelRandom.Next();
			Debug.Log((object)$"GenerateNewFloor(). Map generator's random seed: {dungeonGenerator.Generator.Seed}");
			float lengthMultiplier = instance.currentLevel.factorySizeMultiplier * instance.mapSizeMultiplier;
			dungeonGenerator.Generator.LengthMultiplier = lengthMultiplier;
			dungeonGenerator.Generator.currentArchetype = Plugin.officeArchetype_A;
			dungeonGenerator.Generator.DungeonFlow = Plugin.officeDungeonFlow_A;
			if ((Object)(object)dungeonGenerator.Generator.currentArchetype == (Object)(object)Plugin.officeArchetype_A && (Object)(object)dungeonGenerator.Generator.DungeonFlow == (Object)(object)Plugin.officeDungeonFlow_A)
			{
				dungeonGenerator.Generate();
			}
		}

		private void FixedUpdate()
		{
			dungeonGenerator.Generator.currentArchetype = Plugin.officeArchetype_A;
			dungeonGenerator.Generator.DungeonFlow = Plugin.officeDungeonFlow_A;
		}
	}
	public class CameraCulling : MonoBehaviour
	{
		public Transform player;

		public Camera camera;

		public Transform cullPos;

		public float fps = 25f;

		private float elapsed;

		private void Start()
		{
			player = ((Component)StartOfRound.Instance.localPlayerController).transform;
			camera = ((Component)this).GetComponent<Camera>();
			((Behaviour)camera).enabled = false;
			cullPos = GameObject.Find("FacilityCameraMonitor").transform;
			fps = 20f;
		}

		private void Update()
		{
			//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)
			if ((Object)(object)player == (Object)null)
			{
				return;
			}
			float num = Vector3.Distance(cullPos.position, player.position);
			if (num <= 10f)
			{
				elapsed += Time.deltaTime;
				if (elapsed > 1f / fps)
				{
					elapsed = 0f;
					camera.Render();
				}
			}
		}
	}
	public class TrapRoomTrigger : NetworkBehaviour
	{
		public LethalClientMessage<bool> SendTrapFloorTrigger = new LethalClientMessage<bool>("SendTrapFloorTrigger", (Action<bool>)null, (Action<bool, ulong>)null);

		public LethalClientMessage<bool> SendTrapDeactivate = new LethalClientMessage<bool>("SendTrapDeactivate", (Action<bool>)null, (Action<bool, ulong>)null);

		public AudioSource floorAudioSource;

		public AudioSource floorAudioSource2;

		public AudioSource doorAudioSource;

		public Animator roomAnimator;

		public bool isPlayed;

		public bool isPlayedOnce;

		public bool isDeactivated;

		public PlayerControllerB[] players;

		public float Timer;

		private void SendTrapFloorTriggerSync(bool value, ulong id)
		{
			if (value && !isPlayed)
			{
				isPlayed = true;
			}
			else if (!value && isPlayed)
			{
				isPlayed = false;
			}
		}

		private void SendTrapDeactivateSync(bool value, ulong id)
		{
			if (value && !isDeactivated)
			{
				isDeactivated = true;
			}
			else if (!value && isDeactivated)
			{
				isDeactivated = false;
			}
		}

		private void Start()
		{
			SendTrapFloorTrigger.OnReceivedFromClient += SendTrapFloorTriggerSync;
			SendTrapDeactivate.OnReceivedFromClient += SendTrapDeactivateSync;
			roomAnimator = GameObject.Find("TrapDoorAnimator").GetComponent<Animator>();
			floorAudioSource = GameObject.Find("Floor1").GetComponent<AudioSource>();
			floorAudioSource2 = GameObject.Find("Floor2").GetComponent<AudioSource>();
			doorAudioSource = GameObject.Find("DoorSlam").GetComponent<AudioSource>();
			((UnityEvent<PlayerControllerB>)(object)GameObject.Find("TrapTrigger").GetComponent<InteractTrigger>().onInteract).AddListener((UnityAction<PlayerControllerB>)TriggerTrap);
			((UnityEvent<PlayerControllerB>)(object)GameObject.Find("IgnoreFallDamagePlayer").GetComponent<InteractTrigger>().onInteract).AddListener((UnityAction<PlayerControllerB>)IgnoreFallDamage);
			((UnityEvent<PlayerControllerB>)(object)((Component)this).GetComponent<TerminalAccessibleObject>().terminalCodeEvent).AddListener((UnityAction<PlayerControllerB>)DeactivateTrap);
		}

		private void Update()
		{
			if (isPlayed && !isPlayedOnce && !isDeactivated)
			{
				((MonoBehaviour)this).StartCoroutine(ActivateTrap());
				isPlayed = false;
				isPlayedOnce = true;
			}
			if (!isPlayed && isDeactivated && isPlayedOnce)
			{
				((MonoBehaviour)this).StartCoroutine(DeactivateTrapCoroutine());
				isDeactivated = false;
			}
		}

		public void TriggerTrap(PlayerControllerB playerControllerB)
		{
			SendTrapFloorTrigger.SendAllClients(true, true, false);
		}

		public void IgnoreFallDamage(PlayerControllerB playerControllerB)
		{
			playerControllerB.fallValue -= 5f;
		}

		public void DeactivateTrap(PlayerControllerB playerControllerB)
		{
			SendTrapDeactivate.SendAllClients(true, true, false);
		}

		private IEnumerator ActivateTrap()
		{
			roomAnimator.SetBool("open", true);
			doorAudioSource.PlayOneShot(Plugin.garageDoorSlam);
			yield return (object)new WaitForSeconds(3f);
			doorAudioSource.PlayOneShot(Plugin.floorOpen);
		}

		private IEnumerator DeactivateTrapCoroutine()
		{
			roomAnimator.SetBool("unlock", true);
			doorAudioSource.PlayOneShot(Plugin.floorClose);
			yield return (object)new WaitForSeconds(1f);
			doorAudioSource.PlayOneShot(Plugin.garageSlide);
		}
	}
	public class ElevatorMusic : MonoBehaviour
	{
		public AudioSource audioSource;

		public int currentMusic;

		public float musicPlayTimer;

		private void Start()
		{
			audioSource = ((Component)this).GetComponent<AudioSource>();
			audioSource.PlayOneShot(Plugin.bossaLullaby);
			musicPlayTimer = 0f;
			currentMusic = 1;
			audioSource.volume = 0.4f * (Plugin.musicVolume / 100f);
		}

		private void Update()
		{
			if (audioSource.isPlaying)
			{
				return;
			}
			musicPlayTimer += Time.deltaTime;
			if (musicPlayTimer > 0.5f)
			{
				if (currentMusic == 0)
				{
					audioSource.PlayOneShot(Plugin.bossaLullaby);
					musicPlayTimer = 0f;
					currentMusic++;
				}
				else if (currentMusic == 1)
				{
					audioSource.PlayOneShot(Plugin.shopTheme);
					musicPlayTimer = 0f;
					currentMusic++;
				}
				else if (currentMusic == 2)
				{
					audioSource.PlayOneShot(Plugin.saferoomTheme);
					musicPlayTimer = 0f;
					currentMusic = 0;
				}
			}
		}
	}
	public class ElevatorCollider : NetworkBehaviour
	{
		public Bounds checkBounds;

		public LethalClientMessage<bool> SendInElevator = new LethalClientMessage<bool>("SendInElevator", (Action<bool>)null, (Action<bool, ulong>)IsInElevatorSync);

		public List<BoxCollider> allColliders = new List<BoxCollider>();

		public Transform storageParent;

		public Transform lungPlacement;

		public Transform colliderPos;

		public Transform elevatorTransform;

		public ConstraintSource constraintSource;

		public ElevatorSystem elevatorSystem;

		public Vector3 tempTargetFloorPosition;

		public Vector3 tempStartFallingPosition;

		private static void IsInElevatorSync(bool value, ulong id)
		{
			if (value)
			{
				((Component)LethalNetworkExtensions.GetPlayerController(id)).GetComponent<PlayerElevatorCheck>().wasInElevator = true;
				((Component)LethalNetworkExtensions.GetPlayerController(id)).GetComponent<PlayerElevatorCheck>().isInElevatorNotOwner = true;
			}
			else
			{
				((Component)LethalNetworkExtensions.GetPlayerController(id)).GetComponent<PlayerElevatorCheck>().isInElevatorNotOwner = false;
			}
		}

		private void Start()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			elevatorTransform = GameObject.Find("StartRoomElevator").transform;
			((Bounds)(ref checkBounds)).size = new Vector3(4.9f, 17f, 4.9f);
			GameObject[] allPlayerObjects = StartOfRound.Instance.allPlayerObjects;
			foreach (GameObject val in allPlayerObjects)
			{
				allColliders.Add(val.GetComponent<BoxCollider>());
			}
			colliderPos = GameObject.Find("InsideColliderPos").transform;
		}

		private void Update()
		{
			//IL_0035: 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)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: 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_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			if (!OfficeRoundSystem.Instance.isOffice)
			{
				return;
			}
			if ((Object)(object)colliderPos != (Object)null)
			{
				((Component)this).transform.position = colliderPos.position;
				((Component)this).transform.rotation = colliderPos.rotation;
				((Bounds)(ref checkBounds)).center = colliderPos.position;
			}
			else
			{
				colliderPos = GameObject.Find("InsideColliderPos").transform;
			}
			if ((Object)(object)storageParent == (Object)null && (Object)(object)GameObject.Find("ElevatorStorage(Clone)") != (Object)null)
			{
				storageParent = GameObject.Find("ElevatorStorage(Clone)").transform;
			}
			if ((Object)(object)elevatorSystem == (Object)null)
			{
				elevatorSystem = Object.FindObjectOfType<ElevatorSystem>();
				ItemElevatorCheck[] array = Object.FindObjectsOfType<ItemElevatorCheck>();
				foreach (ItemElevatorCheck itemElevatorCheck in array)
				{
					itemElevatorCheck.elevatorCollider = this;
				}
			}
			allColliders.RemoveAll((BoxCollider item) => (Object)(object)item == (Object)null || !((Component)item).gameObject.activeInHierarchy);
			foreach (BoxCollider allCollider in allColliders)
			{
				if (((Bounds)(ref checkBounds)).Intersects(((Collider)allCollider).bounds))
				{
					if (((Component)allCollider).gameObject.tag == "Player")
					{
						PlayerControllerB component = ((Component)allCollider).GetComponent<PlayerControllerB>();
						PlayerElevatorCheck component2 = ((Component)allCollider).GetComponent<PlayerElevatorCheck>();
						if ((Object)(object)component2.elevatorCollider == (Object)null)
						{
							component2.elevatorCollider = this;
						}
						if (!((Component)allCollider).GetComponent<PlayerElevatorCheck>().isInElevatorB && !component.isCameraDisabled)
						{
							((Component)allCollider).transform.SetParent(((Component)this).transform);
							SendInElevator.SendAllClients(true, true, false);
							component2.wasInElevator = true;
							component2.isInElevatorB = true;
						}
					}
					else if (((Component)allCollider).gameObject.tag == "PhysicsProp")
					{
						GrabbableObject component3 = ((Component)allCollider).GetComponent<GrabbableObject>();
						ItemElevatorCheck component4 = ((Component)allCollider).GetComponent<ItemElevatorCheck>();
						if ((Object)(object)component3.playerHeldBy != (Object)null && ((Component)component3.playerHeldBy).GetComponent<PlayerElevatorCheck>().isInElevatorB && component3.isHeld)
						{
							tempTargetFloorPosition = ((Component)component3.playerHeldBy).transform.localPosition;
							tempStartFallingPosition = ((Component)component3.playerHeldBy).transform.parent.InverseTransformPoint(((Component)component3).transform.position);
						}
						if (!component4.isInElevatorB && !component3.isHeld && (Object)(object)((Component)allCollider).transform.parent != (Object)(object)storageParent)
						{
							component4.isInElevatorB = true;
							((Component)allCollider).transform.SetParent(((Component)this).transform, true);
							component3.targetFloorPosition = tempTargetFloorPosition;
							component3.startFallingPosition = tempStartFallingPosition;
						}
					}
					continue;
				}
				if (((Component)allCollider).gameObject.tag == "Player")
				{
					if (((Component)allCollider).GetComponent<PlayerElevatorCheck>().isInElevatorB)
					{
						((Component)allCollider).transform.SetParent(StartOfRound.Instance.playersContainer, true);
						SendInElevator.SendAllClients(false, true, false);
						((Component)allCollider).GetComponent<PlayerElevatorCheck>().isInElevatorB = false;
					}
					else if (((Component)allCollider).GetComponent<PlayerElevatorCheck>().isInElevatorB && ((Component)allCollider).GetComponent<PlayerControllerB>().isCameraDisabled && !((Component)allCollider).GetComponent<PlayerElevatorCheck>().isInElevatorNotOwner)
					{
						((Component)allCollider).transform.SetParent((Transform)null, true);
						((Component)allCollider).GetComponent<PlayerElevatorCheck>().isInElevatorB = false;
					}
				}
				if ((Object)(object)((Component)allCollider).GetComponent<PlayerControllerB>() != (Object)null)
				{
					PlayerControllerB component5 = ((Component)allCollider).GetComponent<PlayerControllerB>();
					PlayerElevatorCheck component6 = ((Component)allCollider).GetComponent<PlayerElevatorCheck>();
					if (!component6.isInElevatorB && component5.isCameraDisabled && component6.isInElevatorNotOwner)
					{
						((Component)allCollider).transform.SetParent(((Component)this).transform, true);
						component6.isInElevatorB = true;
						component6.wasInElevator = true;
					}
					else if (component6.isInElevatorB && component5.isCameraDisabled && !component6.isInElevatorNotOwner)
					{
						((Component)allCollider).transform.SetParent((Transform)null, true);
						component6.isInElevatorB = false;
					}
				}
			}
		}
	}
	public class ElevatorSystem : NetworkBehaviour
	{
		public static LethalNetworkVariable<int> elevatorFloor = new LethalNetworkVariable<int>("elevatorFloor");

		public static bool isElevatorClosed;

		public float elevatorTimer;

		public static LethalNetworkVariable<bool> spawnShrimpBool = new LethalNetworkVariable<bool>("spawnShrimpBool");

		public static LethalClientEvent ElevatorUpTriggerEvent = new LethalClientEvent("elevatorUpTriggerEvent", (Action)null, (Action<ulong>)ElevatorTriggerUp);

		public static LethalClientEvent ElevatorDownTriggerEvent = new LethalClientEvent("elevatorDownTriggerEvent", (Action)null, (Action<ulong>)ElevatorTriggerDown);

		public static List<InteractTrigger> upButtons = new List<InteractTrigger>();

		public static List<InteractTrigger> downButtons = new List<InteractTrigger>();

		public static Animator doorAnimator;

		public Animator elevatorScreenDoorAnimator;

		public static Animator animator;

		public AudioSource audioSource;

		public static List<Animator> panelAnimators = new List<Animator>();

		public List<Animator> buttonLightAnimators = new List<Animator>();

		public bool performanceCheck;

		public GameObject storageObject;

		public Transform storagePos;

		public static bool isSetupEnd;

		private void Start()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			spawnShrimpBool.Value = false;
			((Component)this).transform.position = new Vector3(0f, 200f, 0f);
			isSetupEnd = false;
		}

		private void LateUpdate()
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_055d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0562: Unknown result type (might be due to invalid IL or missing references)
			//IL_0578: Unknown result type (might be due to invalid IL or missing references)
			//IL_057d: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0703: Unknown result type (might be due to invalid IL or missing references)
			//IL_076c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0771: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_07aa: Unknown result type (might be due to invalid IL or missing references)
			if (!TimeOfDay.Instance.currentDayTimeStarted && ((NetworkBehaviour)this).IsServer)
			{
				if (panelAnimators.Count != 0)
				{
					panelAnimators.Clear();
				}
				isSetupEnd = false;
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			else
			{
				Setup();
			}
			if (!OfficeRoundSystem.Instance.isOffice)
			{
				return;
			}
			if ((Object)(object)storageObject == (Object)null)
			{
				storageObject = GameObject.Find("ElevatorStorage(Clone)");
			}
			else
			{
				storageObject.transform.position = storagePos.position;
			}
			if ((Object)(object)storagePos == (Object)null)
			{
				storagePos = GameObject.Find("SpawnStorage").transform;
			}
			AnimatorStateInfo currentAnimatorStateInfo;
			if (isElevatorClosed)
			{
				if (doorAnimator.GetBool("closed"))
				{
					audioSource.PlayOneShot(Plugin.ElevatorClose);
				}
				elevatorScreenDoorAnimator.SetBool("open", false);
				doorAnimator.SetBool("closed", false);
			}
			else
			{
				if (!doorAnimator.GetBool("closed"))
				{
					audioSource.PlayOneShot(Plugin.ElevatorOpen);
				}
				if (elevatorFloor.Value == 1)
				{
					currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);
					if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime > 0.4f)
					{
						currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);
						if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime < 1f)
						{
							elevatorScreenDoorAnimator.SetBool("open", true);
						}
					}
				}
				currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);
				if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime > 1.2f && !doorAnimator.GetBool("closed"))
				{
					doorAnimator.SetBool("closed", true);
					audioSource.PlayOneShot(Plugin.ElevatorOpen);
				}
				doorAnimator.SetBool("closed", true);
			}
			if (elevatorFloor.Value < animator.GetInteger("floor"))
			{
				elevatorTimer += Time.deltaTime;
				if (elevatorTimer > 0f)
				{
					if (!isElevatorClosed)
					{
						isElevatorClosed = true;
					}
					if (elevatorTimer > 3f)
					{
						if (animator.GetInteger("floor") == 2)
						{
							animator.SetInteger("floor", 1);
							foreach (Animator buttonLightAnimator in buttonLightAnimators)
							{
								buttonLightAnimator.SetInteger("sta", 1);
							}
						}
						else
						{
							animator.SetInteger("floor", 0);
							foreach (Animator buttonLightAnimator2 in buttonLightAnimators)
							{
								buttonLightAnimator2.SetInteger("sta", 0);
							}
						}
						audioSource.PlayOneShot(Plugin.ElevatorDown);
						elevatorFloor.Value = animator.GetInteger("floor");
					}
				}
			}
			if (elevatorFloor.Value > animator.GetInteger("floor"))
			{
				foreach (Animator buttonLightAnimator3 in buttonLightAnimators)
				{
					buttonLightAnimator3.SetBool("up", true);
				}
				elevatorTimer += Time.deltaTime;
				if (elevatorTimer > 0f)
				{
					isElevatorClosed = true;
					if (elevatorTimer > 3f)
					{
						if (animator.GetInteger("floor") == 0)
						{
							animator.SetInteger("floor", 1);
							foreach (Animator buttonLightAnimator4 in buttonLightAnimators)
							{
								buttonLightAnimator4.SetInteger("sta", 1);
							}
						}
						else
						{
							animator.SetInteger("floor", 2);
							foreach (Animator buttonLightAnimator5 in buttonLightAnimators)
							{
								buttonLightAnimator5.SetInteger("sta", 2);
							}
						}
						audioSource.PlayOneShot(Plugin.ElevatorUp);
						animator.SetBool("goDown", false);
						elevatorFloor.Value = animator.GetInteger("floor");
					}
				}
			}
			if (isElevatorClosed)
			{
				currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);
				if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime < 1f)
				{
					currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);
					if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime >= 0.98f)
					{
						panelAnimators.RemoveAll((Animator item) => (Object)(object)item == (Object)null || !((Component)item).gameObject.activeInHierarchy);
						foreach (Animator panelAnimator in panelAnimators)
						{
							if ((Object)(object)((Component)((Component)panelAnimator).transform.GetChild(3).GetChild(1)).GetComponent<TMP_Text>() != (Object)null)
							{
								if (Plugin.setKorean)
								{
									((Component)((Component)panelAnimator).transform.GetChild(3).GetChild(1)).GetComponent<TMP_Text>().text = "대기 중";
								}
								else
								{
									((Component)((Component)panelAnimator).transform.GetChild(3).GetChild(1)).GetComponent<TMP_Text>().text = "Idle";
								}
							}
						}
						if (isElevatorClosed)
						{
							isElevatorClosed = false;
							elevatorTimer = 0f;
						}
					}
				}
			}
			foreach (InteractTrigger upButton in upButtons)
			{
				if (!upButton.interactable)
				{
					currentAnimatorS

plugins/LethalCompanyHarpGhost.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyHarpGhost.NetcodePatcher;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LethalCompanyHarpGhost")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Lethal Company Harp Ghost")]
[assembly: AssemblyFileVersion("1.2.2.0")]
[assembly: AssemblyInformationalVersion("1.2.2+ae8be2cc0ff31fb183a03c1c2a445950e09bb6f9")]
[assembly: AssemblyProduct("LethalCompanyHarpGhost")]
[assembly: AssemblyTitle("LethalCompanyHarpGhost")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LethalCompanyHarpGhost
{
	public class HarpBehaviour : PhysicsProp
	{
		[Serializable]
		public struct ItemOffset : INetworkSerializable
		{
			public Vector3 positionOffset;

			public Vector3 rotationOffset;

			public Vector3 restingRotation;

			public ItemOffset(Vector3 positionOffset = default(Vector3), Vector3 rotationOffset = default(Vector3), Vector3 restingRotation = default(Vector3))
			{
				//IL_0006: 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_001e: 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_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				this.positionOffset = default(Vector3);
				this.rotationOffset = default(Vector3);
				this.restingRotation = default(Vector3);
				this.positionOffset = positionOffset;
				this.rotationOffset = rotationOffset;
				this.restingRotation = restingRotation;
			}

			public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
			{
				serializer.SerializeValue(ref positionOffset);
				serializer.SerializeValue(ref rotationOffset);
				serializer.SerializeValue(ref restingRotation);
			}
		}

		private ManualLogSource mls;

		public AudioSource harpAudioSource;

		public List<AudioClip> harpAudioClips;

		private RoundManager roundManager;

		private int timesPlayedWithoutTurningOff;

		private float noiseInterval;

		private bool isPlayingMusic;

		[SerializeField]
		private ItemOffset playerHarpOffset;

		[SerializeField]
		private ItemOffset enemyHarpOffset;

		public void Awake()
		{
			//IL_0020: 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_003b: 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_005c: 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_0069: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			mls = Logger.CreateLogSource("Harp Behaviour");
			playerHarpOffset = new ItemOffset(new Vector3(-0.8f, 0.22f, 0.07f), new Vector3(3f, 12f, -100f));
			enemyHarpOffset = new ItemOffset(new Vector3(0f, -0.6f, 0.6f));
			isPlayingMusic = false;
		}

		public override void Start()
		{
			((GrabbableObject)this).Start();
			roundManager = Object.FindObjectOfType<RoundManager>();
			Random.InitState(Object.FindObjectOfType<StartOfRound>().randomMapSeed - 10);
			if ((Object)(object)harpAudioSource == (Object)null)
			{
				mls.LogError((object)"harpAudioSource is null!");
			}
			else if (harpAudioClips == null || harpAudioClips.Count == 0)
			{
				mls.LogError((object)"harpAudioClips is null or empty!");
			}
		}

		public override void Update()
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).Update();
			if (!((NetworkBehaviour)this).IsOwner)
			{
				return;
			}
			if (((GrabbableObject)this).isHeldByEnemy)
			{
				LogDebug("isHeldByEnemy");
				UpdateItemOffsetsServerRpc(enemyHarpOffset);
			}
			else if (((GrabbableObject)this).heldByPlayerOnServer)
			{
				LogDebug("heldByPlayerOnServer");
				UpdateItemOffsetsServerRpc(playerHarpOffset);
			}
			if (isPlayingMusic)
			{
				if ((double)noiseInterval <= 0.0)
				{
					noiseInterval = 1f;
					timesPlayedWithoutTurningOff++;
					roundManager.PlayAudibleNoise(((Component)this).transform.position, 16f, 3f, timesPlayedWithoutTurningOff, false, 540);
				}
				else
				{
					noiseInterval -= Time.deltaTime;
				}
			}
		}

		private void LogDebug(string logMessage)
		{
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			LogDebug("Harp ItemActivate() called");
			if (!isPlayingMusic)
			{
				StartMusicServerRpc();
			}
			else
			{
				StopMusicServerRpc();
			}
			((GrabbableObject)this).isBeingUsed = used;
		}

		private void StartMusic()
		{
			harpAudioSource.clip = harpAudioClips[Random.Range(0, harpAudioClips.Count)];
			harpAudioSource.pitch = 1f;
			harpAudioSource.volume = Mathf.Clamp(SyncedInstance<HarpGhostConfig>.Default.HarpMusicVolume.Value, 0f, 1f);
			harpAudioSource.Play();
			WalkieTalkie.TransmitOneShotAudio(harpAudioSource, harpAudioSource.clip, harpAudioSource.volume);
			isPlayingMusic = true;
		}

		private void StopMusic()
		{
			((MonoBehaviour)this).StartCoroutine(MusicPitchDown());
			timesPlayedWithoutTurningOff = 0;
			isPlayingMusic = false;
		}

		private IEnumerator MusicPitchDown()
		{
			int i = 0;
			while (i < 30)
			{
				yield return null;
				AudioSource obj = harpAudioSource;
				obj.pitch -= 0.033f;
				if ((double)harpAudioSource.pitch <= 0.0)
				{
					break;
				}
				int num = i + 1;
				i = num;
			}
			harpAudioSource.Stop();
		}

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

		public override void OnHitGround()
		{
			((GrabbableObject)this).OnHitGround();
			StopMusicServerRpc();
		}

		public override void GrabItemFromEnemy(EnemyAI enemy)
		{
			((GrabbableObject)this).GrabItemFromEnemy(enemy);
			((GrabbableObject)this).isHeldByEnemy = true;
		}

		public override void DiscardItemFromEnemy()
		{
			((GrabbableObject)this).DiscardItemFromEnemy();
			((GrabbableObject)this).isHeldByEnemy = false;
		}

		[ServerRpc(RequireOwnership = false)]
		public void UpdateItemOffsetsServerRpc(ItemOffset itemOffset)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(926255340u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<ItemOffset>(ref itemOffset, default(ForNetworkSerializable));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 926255340u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && (!(((GrabbableObject)this).itemProperties.positionOffset == itemOffset.positionOffset) || !(((GrabbableObject)this).itemProperties.rotationOffset == itemOffset.rotationOffset) || !(((GrabbableObject)this).itemProperties.restingRotation == itemOffset.restingRotation)))
				{
					LogDebug($"Owner: {((NetworkBehaviour)this).OwnerClientId}");
					UpdateItemOffsetsClientRpc(itemOffset);
				}
			}
		}

		[ClientRpc]
		public void UpdateItemOffsetsClientRpc(ItemOffset itemOffset)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: 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(3104675219u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<ItemOffset>(ref itemOffset, default(ForNetworkSerializable));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3104675219u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((GrabbableObject)this).itemProperties.positionOffset = itemOffset.positionOffset;
					((GrabbableObject)this).itemProperties.rotationOffset = itemOffset.rotationOffset;
					((GrabbableObject)this).itemProperties.restingRotation = itemOffset.restingRotation;
				}
			}
		}

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

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

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

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

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_HarpBehaviour()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(926255340u, new RpcReceiveHandler(__rpc_handler_926255340));
			NetworkManager.__rpc_func_table.Add(3104675219u, new RpcReceiveHandler(__rpc_handler_3104675219));
			NetworkManager.__rpc_func_table.Add(3434683095u, new RpcReceiveHandler(__rpc_handler_3434683095));
			NetworkManager.__rpc_func_table.Add(863547447u, new RpcReceiveHandler(__rpc_handler_863547447));
			NetworkManager.__rpc_func_table.Add(3785126865u, new RpcReceiveHandler(__rpc_handler_3785126865));
			NetworkManager.__rpc_func_table.Add(500983636u, new RpcReceiveHandler(__rpc_handler_500983636));
		}

		private static void __rpc_handler_926255340(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ItemOffset itemOffset = default(ItemOffset);
				((FastBufferReader)(ref reader)).ReadValueSafe<ItemOffset>(ref itemOffset, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((HarpBehaviour)(object)target).UpdateItemOffsetsServerRpc(itemOffset);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3104675219(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ItemOffset itemOffset = default(ItemOffset);
				((FastBufferReader)(ref reader)).ReadValueSafe<ItemOffset>(ref itemOffset, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((HarpBehaviour)(object)target).UpdateItemOffsetsClientRpc(itemOffset);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

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

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

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

		protected internal override string __getTypeName()
		{
			return "HarpBehaviour";
		}
	}
	[BepInPlugin("LethalCompanyHarpGhost", "LethalCompanyHarpGhost", "1.2.2")]
	public class HarpGhostPlugin : BaseUnityPlugin
	{
		private const string ModGuid = "LCM_HarpGhost|1.2.2";

		private const string ModName = "Lethal Company Harp Ghost Mod";

		private const string ModVersion = "1.2.2";

		private readonly Harmony _harmony = new Harmony("LCM_HarpGhost|1.2.2");

		private static readonly ManualLogSource _mls = Logger.CreateLogSource("LCM_HarpGhost|1.2.2");

		private static HarpGhostPlugin _instance;

		private static EnemyType _harpGhostEnemyType;

		public static Item HarpItem;

		public static HarpGhostConfig HarpGhostConfig { get; internal set; }

		private void Awake()
		{
			if ((Object)(object)_instance == (Object)null)
			{
				_instance = this;
			}
			Assets.PopulateAssets();
			if ((Object)(object)Assets.MainAssetBundle == (Object)null)
			{
				_mls.LogError((object)"MainAssetBundle is null");
				return;
			}
			_harmony.PatchAll();
			HarpGhostConfig = new HarpGhostConfig(((BaseUnityPlugin)this).Config);
			SetupHarpGhost();
			SetupHarp();
			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);
					}
				}
			}
			_mls.LogInfo((object)"Plugin Lethal Company Harp Ghost Mod is loaded!");
		}

		private static void SetupHarpGhost()
		{
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			_harpGhostEnemyType = Assets.MainAssetBundle.LoadAsset<EnemyType>("HarpGhost");
			_harpGhostEnemyType.canDie = SyncedInstance<HarpGhostConfig>.Instance.GhostIsKillable.Value;
			_harpGhostEnemyType.PowerLevel = SyncedInstance<HarpGhostConfig>.Instance.GhostPowerLevel.Value;
			_harpGhostEnemyType.canBeStunned = SyncedInstance<HarpGhostConfig>.Instance.GhostIsStunnable.Value;
			_harpGhostEnemyType.MaxCount = SyncedInstance<HarpGhostConfig>.Instance.MaxAmountOfGhosts.Value;
			_harpGhostEnemyType.stunTimeMultiplier = SyncedInstance<HarpGhostConfig>.Instance.GhostStunTimeMultiplier.Value;
			_harpGhostEnemyType.stunGameDifficultyMultiplier = SyncedInstance<HarpGhostConfig>.Instance.GhostStunGameDifficultyMultiplier.Value;
			_harpGhostEnemyType.canSeeThroughFog = SyncedInstance<HarpGhostConfig>.Instance.GhostCanSeeThroughFog.Value;
			TerminalNode val = Assets.MainAssetBundle.LoadAsset<TerminalNode>("HarpGhostTN");
			TerminalKeyword val2 = Assets.MainAssetBundle.LoadAsset<TerminalKeyword>("HarpGhostTK");
			NetworkPrefabs.RegisterNetworkPrefab(_harpGhostEnemyType.enemyPrefab);
			Utilities.FixMixerGroups(_harpGhostEnemyType.enemyPrefab);
			Enemies.RegisterEnemy(_harpGhostEnemyType, Mathf.Clamp(SyncedInstance<HarpGhostConfig>.Instance.GhostSpawnRate.Value, 0, 100), SyncedInstance<HarpGhostConfig>.Instance.GhostSpawnLevel.Value, (SpawnType)0, val, val2);
		}

		private static void SetupHarp()
		{
			HarpItem = Assets.MainAssetBundle.LoadAsset<Item>("HarpItemData");
			if ((Object)(object)HarpItem == (Object)null)
			{
				_mls.LogError((object)"Failed to load HarpItemData from AssetBundle.");
				return;
			}
			NetworkPrefabs.RegisterNetworkPrefab(HarpItem.spawnPrefab);
			Utilities.FixMixerGroups(HarpItem.spawnPrefab);
			Items.RegisterScrap(HarpItem, 0, (LevelTypes)(-1));
		}
	}
	public class HarpGhostConfig : SyncedInstance<HarpGhostConfig>
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__OnRequestSync;

			public static HandleNamedMessageDelegate <1>__OnReceiveSync;
		}

		public readonly ConfigEntry<int> GhostInitialHealth;

		public readonly ConfigEntry<int> GhostAttackDamage;

		public readonly ConfigEntry<float> GhostStunTimeMultiplier;

		public readonly ConfigEntry<float> GhostMaxDoorSpeedMultiplier;

		public readonly ConfigEntry<float> GhostStunGameDifficultyMultiplier;

		public readonly ConfigEntry<bool> GhostIsStunnable;

		public readonly ConfigEntry<bool> GhostIsKillable;

		public readonly ConfigEntry<bool> GhostCanSeeThroughFog;

		public readonly ConfigEntry<float> GhostAnnoyanceLevelDecayRate;

		public readonly ConfigEntry<float> GhostAnnoyanceThreshold;

		public readonly ConfigEntry<float> GhostMaxSearchRadius;

		public readonly ConfigEntry<float> GhostVoiceSfxVolume;

		public readonly ConfigEntry<float> HarpMusicVolume;

		public readonly ConfigEntry<int> GhostSpawnRate;

		public readonly ConfigEntry<int> MaxAmountOfGhosts;

		public readonly ConfigEntry<int> GhostPowerLevel;

		public readonly ConfigEntry<LevelTypes> GhostSpawnLevel;

		public readonly ConfigEntry<int> HarpMinValue;

		public readonly ConfigEntry<int> HarpMaxValue;

		public HarpGhostConfig(ConfigFile cfg)
		{
			InitInstance(this);
			GhostInitialHealth = cfg.Bind<int>("General", "Health", 3, "The health when spawned");
			GhostIsKillable = cfg.Bind<bool>("General", "Ghost Is Killable", true, "Whether a Harp Ghost can be killed or not");
			GhostAttackDamage = cfg.Bind<int>("General", "Attack Damage", 35, "The attack damage of the ghost");
			GhostStunTimeMultiplier = cfg.Bind<float>("General", "Stun Time Multiplier", 1f, "The multiplier for how long a Harp Ghost can be stunned");
			GhostMaxDoorSpeedMultiplier = cfg.Bind<float>("General", "Max Door Speed Multiplier", 6f, "The MAXIMUM multiplier for how long it takes a Harp Ghost to open a door (maximum because the value changes depending on how angry the ghost is, there is no global value)");
			GhostIsStunnable = cfg.Bind<bool>("General", "Ghost Is Stunnable", true, "Whether a Harp Ghost can be stunned or not");
			GhostStunTimeMultiplier = cfg.Bind<float>("General", "Stun Time Multiplier", 1f, "The multiplier for how long a Harp Ghost can be stunned");
			GhostStunGameDifficultyMultiplier = cfg.Bind<float>("General", "Stun Game Difficulty Multiplier", 0f, "Not sure what this does");
			GhostCanSeeThroughFog = cfg.Bind<bool>("General", "Ghost Can See Through Fog", false, "Whether a Harp Ghost can see through fog");
			GhostAnnoyanceLevelDecayRate = cfg.Bind<float>("General", "Annoyance Level Decay Rate", 0.3f, "The decay rate of the ghost's annoyance level (due to noises) over time");
			GhostAnnoyanceThreshold = cfg.Bind<float>("General", "Annoyance Level Threshold", 8f, "The threshold of how annoyed the ghost has to be (from noise) to get angry");
			GhostMaxSearchRadius = cfg.Bind<float>("General", "Max Search Radius", 100f, "The maximum distance the ghost will go to search for a player");
			GhostVoiceSfxVolume = cfg.Bind<float>("Audio", "Voice Sound Effects Volume", 1f, "The volume of the ghost's voice. Values are from 0-1");
			HarpMusicVolume = cfg.Bind<float>("Audio", "Harp Music Volume", 1f, "The volume of the music played from the harp. Values are from 0-1");
			GhostSpawnRate = cfg.Bind<int>("Spawn Values", "Harp Ghost Spawn Rates", 40, "The weighted spawn rarity of the harp ghost");
			MaxAmountOfGhosts = cfg.Bind<int>("Spawn Values", "Max Amount of Harp Ghosts", 2, "The maximum amount of harp ghosts that can spawn in a game");
			GhostPowerLevel = cfg.Bind<int>("Spawn Values", "Ghost Power Level", 1, "The power level of a Harp Ghost");
			GhostSpawnLevel = cfg.Bind<LevelTypes>("Spawn Values", "Ghost Spawn Level", (LevelTypes)256, "The LevelTypes that the ghost spawns in. Only single values are accepted.");
			HarpMinValue = cfg.Bind<int>("Spawn Values", "Harp Minimum value", 150, "The minimum value that the harp can be set to");
			HarpMaxValue = cfg.Bind<int>("Spawn Values", "Harp Maximum value", 300, "The maximum value that the harp can be set to");
		}

		private static void RequestSync()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (!SyncedInstance<HarpGhostConfig>.IsClient)
			{
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(SyncedInstance<HarpGhostConfig>.IntSize, (Allocator)2, -1);
			try
			{
				SyncedInstance<HarpGhostConfig>.MessageManager.SendNamedMessage("ModName_OnRequestConfigSync", 0uL, val, (NetworkDelivery)3);
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		private static void OnRequestSync(ulong clientId, FastBufferReader _)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			if (!SyncedInstance<HarpGhostConfig>.IsHost)
			{
				return;
			}
			Debug.Log((object)$"Config sync request received from client: {clientId}");
			byte[] array = SyncedInstance<HarpGhostConfig>.SerializeToBytes(SyncedInstance<HarpGhostConfig>.Instance);
			int num = array.Length;
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(num + SyncedInstance<HarpGhostConfig>.IntSize, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteBytesSafe(array, -1, 0);
				SyncedInstance<HarpGhostConfig>.MessageManager.SendNamedMessage("ModName_OnReceiveConfigSync", clientId, val, (NetworkDelivery)3);
			}
			catch (Exception arg)
			{
				Debug.Log((object)$"Error occurred syncing config with client: {clientId}\n{arg}");
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		private static void OnReceiveSync(ulong _, FastBufferReader reader)
		{
			//IL_001f: 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)
			if (!((FastBufferReader)(ref reader)).TryBeginRead(SyncedInstance<HarpGhostConfig>.IntSize))
			{
				Debug.LogError((object)"Config sync error: Could not begin reading buffer.");
				return;
			}
			int num = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
			if (!((FastBufferReader)(ref reader)).TryBeginRead(num))
			{
				Debug.LogError((object)"Config sync error: Host could not sync.");
				return;
			}
			byte[] data = new byte[num];
			((FastBufferReader)(ref reader)).ReadBytesSafe(ref data, num, 0);
			SyncedInstance<HarpGhostConfig>.SyncInstance(data);
			Debug.Log((object)"Successfully synced config with host.");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		public static void InitializeLocalPlayer()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			if (SyncedInstance<HarpGhostConfig>.IsHost)
			{
				CustomMessagingManager messageManager = SyncedInstance<HarpGhostConfig>.MessageManager;
				object obj = <>O.<0>__OnRequestSync;
				if (obj == null)
				{
					HandleNamedMessageDelegate val = OnRequestSync;
					<>O.<0>__OnRequestSync = val;
					obj = (object)val;
				}
				messageManager.RegisterNamedMessageHandler("HarpGhost_OnRequestConfigSync", (HandleNamedMessageDelegate)obj);
				SyncedInstance<HarpGhostConfig>.Synced = true;
				return;
			}
			SyncedInstance<HarpGhostConfig>.Synced = false;
			CustomMessagingManager messageManager2 = SyncedInstance<HarpGhostConfig>.MessageManager;
			object obj2 = <>O.<1>__OnReceiveSync;
			if (obj2 == null)
			{
				HandleNamedMessageDelegate val2 = OnReceiveSync;
				<>O.<1>__OnReceiveSync = val2;
				obj2 = (object)val2;
			}
			messageManager2.RegisterNamedMessageHandler("HarpGhost_OnReceiveConfigSync", (HandleNamedMessageDelegate)obj2);
			RequestSync();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")]
		public static void PlayerLeave()
		{
			SyncedInstance<HarpGhostConfig>.RevertSync();
		}
	}
	[Serializable]
	public class SyncedInstance<T>
	{
		[NonSerialized]
		protected static int IntSize = 4;

		internal static CustomMessagingManager MessageManager => NetworkManager.Singleton.CustomMessagingManager;

		internal static bool IsClient => NetworkManager.Singleton.IsClient;

		internal static bool IsHost => NetworkManager.Singleton.IsHost;

		public static T Default { get; private set; }

		public static T Instance { get; private set; }

		public static bool Synced { get; internal set; }

		protected void InitInstance(T instance)
		{
			Default = instance;
			Instance = instance;
			IntSize = 4;
		}

		internal static void SyncInstance(byte[] data)
		{
			Instance = DeserializeFromBytes(data);
			Synced = true;
		}

		internal static void RevertSync()
		{
			Instance = Default;
			Synced = false;
		}

		public static byte[] SerializeToBytes(T val)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream memoryStream = new MemoryStream();
			try
			{
				binaryFormatter.Serialize(memoryStream, val);
				return memoryStream.ToArray();
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"Error serializing instance: {arg}");
				return null;
			}
		}

		public static T DeserializeFromBytes(byte[] data)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream serializationStream = new MemoryStream(data);
			try
			{
				return (T)binaryFormatter.Deserialize(serializationStream);
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"Error deserializing instance: {arg}");
				return default(T);
			}
		}
	}
	public static class Assets
	{
		private const string MainAssetBundleName = "Assets.harpghostbundle";

		public static AssetBundle MainAssetBundle;

		private static string GetAssemblyName()
		{
			return Assembly.GetExecutingAssembly().FullName.Split(',')[0];
		}

		public static void PopulateAssets()
		{
			if ((Object)(object)MainAssetBundle != (Object)null)
			{
				return;
			}
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetAssemblyName() + ".Assets.harpghostbundle");
			MainAssetBundle = AssetBundle.LoadFromStream(stream);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "LethalCompanyHarpGhost";

		public const string PLUGIN_NAME = "LethalCompanyHarpGhost";

		public const string PLUGIN_VERSION = "1.2.2";
	}
}
namespace LethalCompanyHarpGhost.HarpGhost
{
	public class HarpGhostAIClient : MonoBehaviour
	{
		private readonly ManualLogSource _mls = Logger.CreateLogSource("Harp Ghost AI | Client");

		private NetworkObjectReference _harpObjectRef;

		private int _harpScrapValue;

		private HarpBehaviour _heldHarp;

		private PlayerControllerB _targetPlayer;

		public Transform grabTarget;

		public Transform eye;

		private void OnEnable()
		{
			HarpGhostNetcodeController.OnDropHarp += HandleDropHarp;
			HarpGhostNetcodeController.OnSpawnHarp += HandleSpawnHarp;
			HarpGhostNetcodeController.OnGrabHarp += HandleGrabHarp;
			HarpGhostNetcodeController.OnPlayHarpMusic += HandleOnPlayHarpMusic;
			HarpGhostNetcodeController.OnStopHarpMusic += HandleOnStopHarpMusic;
			HarpGhostNetcodeController.OnChangeTargetPlayer += HandleChangeTargetPlayer;
			HarpGhostNetcodeController.OnDamageTargetPlayer += HandleDamageTargetPlayer;
			HarpGhostNetcodeController.OnIncreaseTargetPlayerFearLevel += HandleIncreaseTargetPlayerFearLevel;
		}

		private void OnDestroy()
		{
			HarpGhostNetcodeController.OnDropHarp -= HandleDropHarp;
			HarpGhostNetcodeController.OnSpawnHarp -= HandleSpawnHarp;
			HarpGhostNetcodeController.OnGrabHarp -= HandleGrabHarp;
			HarpGhostNetcodeController.OnPlayHarpMusic -= HandleOnPlayHarpMusic;
			HarpGhostNetcodeController.OnStopHarpMusic -= HandleOnStopHarpMusic;
			HarpGhostNetcodeController.OnChangeTargetPlayer -= HandleChangeTargetPlayer;
			HarpGhostNetcodeController.OnDamageTargetPlayer -= HandleDamageTargetPlayer;
			HarpGhostNetcodeController.OnIncreaseTargetPlayerFearLevel -= HandleIncreaseTargetPlayerFearLevel;
		}

		private void LogDebug(string msg)
		{
		}

		private void HandleIncreaseTargetPlayerFearLevel()
		{
			//IL_0074: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			LogDebug("HandleIncreaseTargetPlayerFearLevel called");
			if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)(object)_targetPlayer)
			{
				return;
			}
			LogDebug("localplayercontroller is not target player");
			if ((Object)(object)_targetPlayer == (Object)null)
			{
				_mls.LogError((object)"Target player is null");
				return;
			}
			LogDebug("Increasing fear level for " + ((Object)_targetPlayer).name);
			if (_targetPlayer.HasLineOfSightToPosition(eye.position, 115f, 50, 3f))
			{
				LogDebug("Player to add fear to is looking at the ghost");
				_targetPlayer.JumpToFearLevel(1f, true);
				_targetPlayer.IncreaseFearLevelOverTime(0.8f, 1f);
			}
			else if (Vector3.Distance(((Component)eye).transform.position, ((Component)_targetPlayer).transform.position) < 3f)
			{
				LogDebug("Player to add fear to is not looking at the ghost, but is near");
				_targetPlayer.JumpToFearLevel(0.6f, true);
				_targetPlayer.IncreaseFearLevelOverTime(0.4f, 1f);
			}
		}

		private void HandleOnPlayHarpMusic()
		{
			if (!((Object)(object)_heldHarp == (Object)null))
			{
				_heldHarp.StartMusicServerRpc();
			}
		}

		private void HandleOnStopHarpMusic()
		{
			if (!((Object)(object)_heldHarp == (Object)null))
			{
				_heldHarp.StopMusicServerRpc();
			}
		}

		private void HandleDropHarp(Vector3 dropPosition)
		{
			//IL_0075: 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_007f: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_heldHarp == (Object)null))
			{
				((GrabbableObject)_heldHarp).parentObject = null;
				((Component)_heldHarp).transform.SetParent(StartOfRound.Instance.propsContainer, true);
				((GrabbableObject)_heldHarp).EnablePhysics(true);
				((GrabbableObject)_heldHarp).fallTime = 0f;
				Transform parent;
				((GrabbableObject)_heldHarp).startFallingPosition = (parent = ((Component)_heldHarp).transform.parent).InverseTransformPoint(((Component)_heldHarp).transform.position);
				((GrabbableObject)_heldHarp).targetFloorPosition = parent.InverseTransformPoint(dropPosition);
				((GrabbableObject)_heldHarp).floorYRot = -1;
				((GrabbableObject)_heldHarp).grabbable = true;
				((GrabbableObject)_heldHarp).grabbableToEnemies = true;
				((GrabbableObject)_heldHarp).isHeld = false;
				((GrabbableObject)_heldHarp).isHeldByEnemy = false;
				_heldHarp.StopMusicServerRpc();
				_heldHarp = null;
			}
		}

		private void HandleGrabHarp()
		{
			NetworkObject val = default(NetworkObject);
			if (!((Object)(object)_heldHarp != (Object)null) && ((NetworkObjectReference)(ref _harpObjectRef)).TryGet(ref val, (NetworkManager)null))
			{
				_heldHarp = ((Component)val).gameObject.GetComponent<HarpBehaviour>();
				((GrabbableObject)_heldHarp).SetScrapValue(_harpScrapValue);
				((GrabbableObject)_heldHarp).parentObject = grabTarget;
				((GrabbableObject)_heldHarp).isHeldByEnemy = true;
				((GrabbableObject)_heldHarp).grabbableToEnemies = false;
				((GrabbableObject)_heldHarp).grabbable = false;
			}
		}

		private void HandleSpawnHarp(NetworkObjectReference harpObject, int harpScrapValue)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			_harpObjectRef = harpObject;
			_harpScrapValue = harpScrapValue;
		}

		private void HandleChangeTargetPlayer(int targetPlayerObjectId)
		{
			if (targetPlayerObjectId == -69420)
			{
				_targetPlayer = null;
			}
			else
			{
				LogDebug("Target player is now: " + ((Object)(_targetPlayer = StartOfRound.Instance.allPlayerScripts[targetPlayerObjectId])).name);
			}
		}

		private void HandleDamageTargetPlayer(int damage, CauseOfDeath causeOfDeath = 0)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			_targetPlayer.DamagePlayer(damage, true, true, causeOfDeath, 0, false, default(Vector3));
		}
	}
	public class HarpGhostAIServer : EnemyAI
	{
		private enum States
		{
			PlayingMusic,
			SearchingForPlayers,
			InvestigatingTargetPosition,
			ChasingTargetPlayer,
			Dead
		}

		private readonly ManualLogSource _mls = Logger.CreateLogSource("Harp Ghost AI | Server");

		[Header("AI and Pathfinding")]
		[Space(5f)]
		public AISearchRoutine roamMap;

		public AISearchRoutine searchForPlayers;

		[SerializeField]
		private float agentMaxAcceleration = 50f;

		[SerializeField]
		private float agentMaxSpeed = 0.3f;

		[SerializeField]
		private float annoyanceLevel;

		[SerializeField]
		private float annoyanceDecayRate = 0.3f;

		[SerializeField]
		private float annoyanceThreshold = 8f;

		[SerializeField]
		private float maxSearchRadius = 100f;

		private float _agentCurrentSpeed;

		private float _timeSinceHittingLocalPlayer;

		private float _hearNoiseCooldown;

		private bool _hasBegunInvestigating;

		private bool _inStunAnimation;

		private Vector3 _targetPosition;

		private Vector3 _agentLastPosition;

		private RoundManager _roundManager;

		[Header("Transforms")]
		[Space(3f)]
		public BoxCollider attackArea;

		[Header("Controllers and Managers")]
		[Space(5f)]
		[SerializeField]
		private HarpGhostAudioManager audioManager;

		[SerializeField]
		private HarpGhostNetcodeController netcodeController;

		[SerializeField]
		private HarpGhostAnimationController animationController;

		public Vector3 TransformPosition => ((Component)this).transform.position;

		public RoundManager RoundManagerInstance => RoundManager.Instance;

		public HarpBehaviour HeldHarp { get; set; }

		public override void Start()
		{
			((EnemyAI)this).Start();
			if (((NetworkBehaviour)this).IsServer)
			{
				base.agent = ((Component)this).GetComponent<NavMeshAgent>();
				if ((Object)(object)base.agent == (Object)null)
				{
					_mls.LogError((object)("NavMeshAgent component not found on " + ((Object)this).name));
				}
				((Behaviour)base.agent).enabled = true;
				audioManager = ((Component)this).GetComponent<HarpGhostAudioManager>();
				if ((Object)(object)audioManager == (Object)null)
				{
					_mls.LogError((object)"Audio Manger is null");
				}
				netcodeController = ((Component)this).GetComponent<HarpGhostNetcodeController>();
				if ((Object)(object)netcodeController == (Object)null)
				{
					_mls.LogError((object)"Netcode Controller is null");
				}
				animationController = ((Component)this).GetComponent<HarpGhostAnimationController>();
				if ((Object)(object)animationController == (Object)null)
				{
					_mls.LogError((object)"Animation Controller is null");
				}
				_roundManager = Object.FindObjectOfType<RoundManager>();
				Random.InitState(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
				netcodeController.ChangeAnimationParameterBoolClientRpc(HarpGhostAnimationController.IsDead, value: false);
				netcodeController.ChangeAnimationParameterBoolClientRpc(HarpGhostAnimationController.IsStunned, value: false);
				netcodeController.ChangeAnimationParameterBoolClientRpc(HarpGhostAnimationController.IsRunning, value: false);
				InitializeConfigValues();
				netcodeController.SpawnHarpServerRpc();
				netcodeController.GrabHarpClientRpc();
				((MonoBehaviour)this).StartCoroutine(DelayedHarpMusicActivate());
				_mls.LogInfo((object)"Harp Ghost Spawned");
			}
		}

		public void OnEnable()
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				HarpGhostNetcodeController.OnChangeTargetPlayer += HandleChangeTargetPlayer;
				HarpGhostNetcodeController.OnChangeAgentMaxSpeed += HandleChangeAgentMaxSpeed;
				HarpGhostNetcodeController.OnFixAgentSpeedAfterAttack += HandleFixAgentSpeedAfterAttack;
			}
		}

		public override void OnDestroy()
		{
			((EnemyAI)this).OnDestroy();
			if (((NetworkBehaviour)this).IsServer)
			{
				HarpGhostNetcodeController.OnChangeTargetPlayer -= HandleChangeTargetPlayer;
				HarpGhostNetcodeController.OnChangeAgentMaxSpeed -= HandleChangeAgentMaxSpeed;
				HarpGhostNetcodeController.OnFixAgentSpeedAfterAttack -= HandleFixAgentSpeedAfterAttack;
			}
		}

		private void InitializeConfigValues()
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				netcodeController.InitializeConfigValuesClientRpc();
				base.enemyHP = SyncedInstance<HarpGhostConfig>.Instance.GhostInitialHealth.Value;
				annoyanceDecayRate = SyncedInstance<HarpGhostConfig>.Instance.GhostAnnoyanceLevelDecayRate.Value;
				annoyanceThreshold = SyncedInstance<HarpGhostConfig>.Instance.GhostAnnoyanceThreshold.Value;
				maxSearchRadius = SyncedInstance<HarpGhostConfig>.Instance.GhostMaxSearchRadius.Value;
			}
		}

		private IEnumerator DelayedHarpMusicActivate()
		{
			yield return (object)new WaitForSeconds(0.5f);
			netcodeController.PlayHarpMusicClientRpc();
		}

		private void FixedUpdate()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)this).IsServer)
			{
				Vector3 position = ((Component)this).transform.position;
				float agentCurrentSpeed = _agentCurrentSpeed;
				Vector3 val = position - _agentLastPosition;
				_agentCurrentSpeed = Mathf.Lerp(agentCurrentSpeed, ((Vector3)(ref val)).magnitude / Time.deltaTime, 0.75f);
				_agentLastPosition = position;
			}
		}

		public override void Update()
		{
			((EnemyAI)this).Update();
			if (!((NetworkBehaviour)this).IsServer)
			{
				return;
			}
			CalculateAgentSpeed();
			if ((double)base.stunNormalizedTimer <= 0.0 && _inStunAnimation && !base.isEnemyDead)
			{
				LogDebug("Doing stun recover animation");
				netcodeController.DoAnimationClientRpc(HarpGhostAnimationController.Recover);
				_inStunAnimation = false;
				netcodeController.ChangeAnimationParameterBoolClientRpc(HarpGhostAnimationController.IsStunned, value: false);
			}
			if (StartOfRound.Instance.allPlayersDead)
			{
				netcodeController.ChangeAnimationParameterBoolClientRpc(HarpGhostAnimationController.IsRunning, value: false);
				return;
			}
			_timeSinceHittingLocalPlayer += Time.deltaTime;
			_hearNoiseCooldown -= Time.deltaTime;
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				if (annoyanceLevel > 0f)
				{
					annoyanceLevel -= annoyanceDecayRate * Time.deltaTime;
					annoyanceLevel = Mathf.Clamp(annoyanceLevel, 0f, float.PositiveInfinity);
				}
				if (annoyanceLevel >= annoyanceThreshold)
				{
					netcodeController.PlayCreatureVoiceClientRpc(4, audioManager.upsetSfx.Length);
					SwitchBehaviourStateLocally(1);
				}
				break;
			case 1:
			{
				bool flag2 = _agentCurrentSpeed >= 3f;
				if (animationController.GetBool(HarpGhostAnimationController.IsRunning) != flag2 && !_inStunAnimation)
				{
					netcodeController.ChangeAnimationParameterBoolClientRpc(HarpGhostAnimationController.IsRunning, flag2);
				}
				break;
			}
			case 2:
			{
				bool flag3 = _agentCurrentSpeed >= 3f;
				if (animationController.GetBool(HarpGhostAnimationController.IsRunning) != flag3 && !_inStunAnimation)
				{
					netcodeController.ChangeAnimationParameterBoolClientRpc(HarpGhostAnimationController.IsRunning, flag3);
				}
				break;
			}
			case 3:
			{
				bool flag = _agentCurrentSpeed >= 3f;
				if (animationController.GetBool(HarpGhostAnimationController.IsRunning) != flag && !_inStunAnimation)
				{
					netcodeController.ChangeAnimationParameterBoolClientRpc(HarpGhostAnimationController.IsRunning, flag);
				}
				break;
			}
			case 4:
				break;
			}
		}

		public override void DoAIInterval()
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: 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_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			if (!((NetworkBehaviour)this).IsServer)
			{
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				if (searchForPlayers.inProgress)
				{
					((EnemyAI)this).StopSearch(searchForPlayers, true);
				}
				if (!roamMap.inProgress)
				{
					((EnemyAI)this).StartSearch(((Component)this).transform.position, roamMap);
				}
				break;
			case 1:
			{
				if (roamMap.inProgress)
				{
					((EnemyAI)this).StopSearch(roamMap, true);
				}
				PlayerControllerB val2 = ((EnemyAI)this).CheckLineOfSightForClosestPlayer(115f, 80, 2, 0f);
				LogDebug($"Temp player: {val2}");
				if ((Object)(object)val2 != (Object)null)
				{
					SwitchBehaviourStateLocally(3);
					break;
				}
				LogDebug($"Is searchforplayers in progress: {searchForPlayers.inProgress}");
				if (!searchForPlayers.inProgress)
				{
					if (_targetPosition != default(Vector3) && CheckForPath(_targetPosition))
					{
						searchForPlayers.searchWidth = 30f;
						((EnemyAI)this).StartSearch(_targetPosition, searchForPlayers);
					}
					else
					{
						searchForPlayers.searchWidth = 100f;
						((EnemyAI)this).StartSearch(((Component)this).transform.position, searchForPlayers);
					}
				}
				break;
			}
			case 2:
			{
				if (roamMap.inProgress)
				{
					((EnemyAI)this).StopSearch(roamMap, true);
				}
				if (searchForPlayers.inProgress)
				{
					((EnemyAI)this).StopSearch(searchForPlayers, true);
				}
				PlayerControllerB val = ((EnemyAI)this).CheckLineOfSightForClosestPlayer(135f, 80, 3, 0f);
				LogDebug($"Temp target player: {val}");
				if ((Object)(object)val != (Object)null)
				{
					SwitchBehaviourStateLocally(3);
					break;
				}
				if (!_hasBegunInvestigating)
				{
					if (_targetPosition == default(Vector3))
					{
						SwitchBehaviourStateLocally(1);
					}
					else
					{
						if (!((EnemyAI)this).SetDestinationToPosition(_targetPosition, true))
						{
							SwitchBehaviourStateLocally(1);
							break;
						}
						_hasBegunInvestigating = true;
					}
				}
				if (Vector3.Distance(((Component)this).transform.position, _targetPosition) <= 1f)
				{
					SwitchBehaviourStateLocally(1);
				}
				break;
			}
			case 3:
			{
				if (roamMap.inProgress)
				{
					((EnemyAI)this).StopSearch(roamMap, true);
				}
				if (searchForPlayers.inProgress)
				{
					((EnemyAI)this).StopSearch(searchForPlayers, true);
				}
				PlayerControllerB[] allPlayersInLineOfSight = ((EnemyAI)this).GetAllPlayersInLineOfSight(110f, 80, base.eye, 2f, StartOfRound.Instance.collidersAndRoomMaskAndDefault);
				bool flag = false;
				if (allPlayersInLineOfSight != null && allPlayersInLineOfSight.Length > 0)
				{
					LogDebug($"playersinlos: {allPlayersInLineOfSight.Length}");
					flag = (Object)(object)base.targetPlayer != (Object)null && allPlayersInLineOfSight.Any((PlayerControllerB playerControllerB) => (Object)(object)playerControllerB == (Object)(object)base.targetPlayer && (Object)(object)playerControllerB != (Object)null);
					LogDebug($"Our target found: {flag}");
					if (!flag)
					{
						PlayerControllerB val3 = ((EnemyAI)this).CheckLineOfSightForClosestPlayer(110f, 80, 3, 0f);
						if ((Object)(object)val3 == (Object)null)
						{
							LogDebug("No players found for second time, switching to state 2");
							SwitchBehaviourStateLocally(2);
							break;
						}
						LogDebug("New target found, beginning the chase");
						BeginChasingPlayer((int)val3.playerClientId);
					}
					_targetPosition = ((Component)base.targetPlayer).transform.position;
					if ((Object)(object)base.targetPlayer == (Object)null)
					{
						LogDebug("Target player is null");
						netcodeController.ChangeTargetPlayerClientRpc((int)base.targetPlayer.playerClientId);
					}
					netcodeController.IncreaseTargetPlayerFearLevelClientRpc();
					if (Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) < 8f)
					{
						AttackPlayerIfClose();
					}
				}
				else
				{
					LogDebug("No players found, switching to state 2");
					SwitchBehaviourStateLocally(2);
				}
				break;
			}
			case 4:
				if (roamMap.inProgress)
				{
					((EnemyAI)this).StopSearch(roamMap, true);
				}
				if (searchForPlayers.inProgress)
				{
					((EnemyAI)this).StopSearch(searchForPlayers, true);
				}
				break;
			}
		}

		private void SwitchBehaviourStateLocally(int state)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)this).IsServer)
			{
				switch (state)
				{
				case 0:
					LogDebug($"Switched to behaviour state {0}!");
					agentMaxSpeed = 0.3f;
					agentMaxAcceleration = 50f;
					base.movingTowardsTargetPlayer = false;
					_targetPosition = default(Vector3);
					_hasBegunInvestigating = false;
					base.openDoorSpeedMultiplier = Mathf.Clamp(6f, 0f, SyncedInstance<HarpGhostConfig>.Instance.GhostMaxDoorSpeedMultiplier.Value);
					netcodeController.ChangeTargetPlayerClientRpc(-69420);
					break;
				case 1:
					LogDebug($"Switched to behaviour state {1}!");
					agentMaxSpeed = 3f;
					agentMaxAcceleration = 100f;
					base.movingTowardsTargetPlayer = false;
					_hasBegunInvestigating = false;
					base.openDoorSpeedMultiplier = Mathf.Clamp(2f, 0f, SyncedInstance<HarpGhostConfig>.Instance.GhostMaxDoorSpeedMultiplier.Value);
					_targetPosition = default(Vector3);
					netcodeController.DropHarpClientRpc(((Component)this).transform.position);
					break;
				case 2:
					LogDebug($"Switched to behaviour state {2}!");
					agentMaxSpeed = 6f;
					agentMaxAcceleration = 100f;
					base.movingTowardsTargetPlayer = false;
					_hasBegunInvestigating = false;
					base.openDoorSpeedMultiplier = Mathf.Clamp(1f, 0f, SyncedInstance<HarpGhostConfig>.Instance.GhostMaxDoorSpeedMultiplier.Value);
					netcodeController.DropHarpClientRpc(((Component)this).transform.position);
					break;
				case 3:
					LogDebug($"Switched to behaviour state {3}!");
					agentMaxSpeed = 8f;
					agentMaxAcceleration = 75f;
					base.movingTowardsTargetPlayer = true;
					_hasBegunInvestigating = false;
					_targetPosition = default(Vector3);
					base.openDoorSpeedMultiplier = Mathf.Clamp(0.6f, 0f, SyncedInstance<HarpGhostConfig>.Instance.GhostMaxDoorSpeedMultiplier.Value);
					netcodeController.DropHarpClientRpc(((Component)this).transform.position);
					break;
				case 4:
					LogDebug($"Switched to behaviour state {4}!");
					agentMaxSpeed = 0f;
					agentMaxAcceleration = 0f;
					base.movingTowardsTargetPlayer = false;
					base.agent.speed = 0f;
					((Behaviour)base.agent).enabled = false;
					base.isEnemyDead = true;
					_hasBegunInvestigating = false;
					_targetPosition = default(Vector3);
					netcodeController.ChangeTargetPlayerClientRpc(-69420);
					netcodeController.DropHarpClientRpc(((Component)this).transform.position);
					netcodeController.ChangeAnimationParameterBoolClientRpc(HarpGhostAnimationController.IsDead, value: true);
					break;
				}
				if (base.currentBehaviourStateIndex != state)
				{
					base.previousBehaviourStateIndex = base.currentBehaviourStateIndex;
					base.currentBehaviourStateIndex = state;
				}
			}
		}

		private bool CheckForPath(Vector3 position)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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)
			position = RoundManager.Instance.GetNavMeshPosition(position, RoundManager.Instance.navHit, 1.75f, -1);
			base.path1 = new NavMeshPath();
			if (base.agent.CalculatePath(position, base.path1))
			{
				return !((double)Vector3.Distance(base.path1.corners[base.path1.corners.Length - 1], RoundManager.Instance.GetNavMeshPosition(position, RoundManager.Instance.navHit, 2.7f, -1)) > 1.5499999523162842);
			}
			return false;
		}

		private void CalculateAgentSpeed()
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				if (base.stunNormalizedTimer > 0f)
				{
					base.agent.speed = 0f;
					base.agent.acceleration = agentMaxAcceleration;
				}
				else if (base.currentBehaviourStateIndex != 5)
				{
					MoveWithAcceleration();
				}
			}
		}

		private void MoveWithAcceleration()
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				float num = Time.deltaTime / 2f;
				base.agent.speed = Mathf.Lerp(base.agent.speed, agentMaxSpeed, num);
				float deltaTime = Time.deltaTime;
				base.agent.acceleration = Mathf.Lerp(base.agent.acceleration, agentMaxAcceleration, deltaTime);
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false)
		{
			((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX);
			if (!((NetworkBehaviour)this).IsServer || base.isEnemyDead)
			{
				return;
			}
			base.enemyHP -= force;
			if (base.enemyHP > 0)
			{
				netcodeController.PlayCreatureVoiceClientRpc(1, audioManager.damageSfx.Length);
				if ((Object)(object)playerWhoHit != (Object)null)
				{
					LogDebug("Player " + ((Object)playerWhoHit).name + " hit ghost");
					netcodeController.ChangeTargetPlayerClientRpc((int)playerWhoHit.playerClientId);
					SwitchBehaviourStateLocally(3);
					return;
				}
				LogDebug("Unknown player hit ghost");
				if (base.currentBehaviourStateIndex == 0)
				{
					SwitchBehaviourStateLocally(1);
				}
			}
			else
			{
				LogDebug("Ghost is dead!");
				netcodeController.EnterDeathStateClientRpc();
				((EnemyAI)this).KillEnemyClientRpc(false);
				SwitchBehaviourStateLocally(4);
			}
		}

		public override void SetEnemyStunned(bool setToStunned, float setToStunTime = 1f, PlayerControllerB setStunnedByPlayer = null)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).SetEnemyStunned(setToStunned, setToStunTime, setStunnedByPlayer);
			if (!((NetworkBehaviour)this).IsServer)
			{
				return;
			}
			LogDebug("SetEnemyStunned called");
			netcodeController.PlayCreatureVoiceClientRpc(3, audioManager.stunSfx.Length);
			netcodeController.DropHarpClientRpc(((Component)this).transform.position);
			netcodeController.ChangeAnimationParameterBoolClientRpc(HarpGhostAnimationController.IsStunned, value: true);
			netcodeController.DoAnimationClientRpc(HarpGhostAnimationController.Stunned);
			_inStunAnimation = true;
			if ((Object)(object)setStunnedByPlayer != (Object)null)
			{
				LogDebug("Player " + ((Object)setStunnedByPlayer).name + " stunned ghost");
				netcodeController.ChangeTargetPlayerClientRpc((int)setStunnedByPlayer.playerClientId);
				SwitchBehaviourStateLocally(3);
				return;
			}
			LogDebug("Unknown player stunned ghost");
			if (base.currentBehaviourStateIndex == 0)
			{
				SwitchBehaviourStateLocally(1);
			}
		}

		private void AttackPlayerIfClose()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)this).IsServer || base.currentBehaviourStateIndex != 3 || _timeSinceHittingLocalPlayer < 2f || _inStunAnimation)
			{
				return;
			}
			Collider[] array = Physics.OverlapBox(((Component)attackArea).transform.position, attackArea.size * 0.5f, Quaternion.identity, 8);
			if (array.Length == 0)
			{
				return;
			}
			Collider[] array2 = array;
			foreach (Collider collider in array2)
			{
				PlayerControllerB val = PlayerMeetsStandardCollisionConditions(collider);
				if (!((Object)(object)val == (Object)null))
				{
					LogDebug("Attacking player " + ((Object)val).name);
					netcodeController.ChangeTargetPlayerClientRpc((int)val.playerClientId);
					_timeSinceHittingLocalPlayer = 0f;
					netcodeController.DoAnimationClientRpc(HarpGhostAnimationController.Attack);
					break;
				}
			}
		}

		private void HandleChangeTargetPlayer(int targetPlayerObjectId)
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				if (targetPlayerObjectId == -69420)
				{
					base.targetPlayer = null;
				}
				else
				{
					LogDebug("Target player is now: " + ((Object)(base.targetPlayer = StartOfRound.Instance.allPlayerScripts[targetPlayerObjectId])).name);
				}
			}
		}

		private void HandleChangeAgentMaxSpeed(float newMaxSpeed, float newMaxSpeed2)
		{
			base.agent.speed = newMaxSpeed;
			agentMaxSpeed = newMaxSpeed2;
		}

		private void HandleFixAgentSpeedAfterAttack()
		{
			LogDebug("FixAgentSpeedAfterAttackServerRpc called");
			float speed;
			float num;
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				speed = 0.3f;
				num = 0.3f;
				break;
			case 1:
				speed = 3f;
				num = 1f;
				break;
			case 2:
				speed = 6f;
				num = 1f;
				break;
			case 3:
				speed = 8f;
				num = 1f;
				break;
			case 4:
				speed = 0f;
				num = 0f;
				break;
			default:
				speed = 3f;
				num = 1f;
				break;
			}
			base.agent.speed = speed;
			agentMaxSpeed = num;
		}

		private void BeginChasingPlayer(int targetPlayerObjectId)
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				PlayerControllerB val = (base.targetPlayer = StartOfRound.Instance.allPlayerScripts[targetPlayerObjectId]);
				((EnemyAI)this).SetMovingTowardsTargetPlayer(val);
				LogDebug("Now chasing " + ((Object)val).name);
			}
		}

		private PlayerControllerB PlayerMeetsStandardCollisionConditions(Collider collider)
		{
			if (!((NetworkBehaviour)this).IsServer)
			{
				return null;
			}
			if (base.isEnemyDead || base.currentBehaviourStateIndex == 4)
			{
				return null;
			}
			PlayerControllerB component = ((Component)collider).gameObject.GetComponent<PlayerControllerB>();
			if ((Object)(object)component == (Object)null)
			{
				return null;
			}
			if (component.isInsideFactory && !component.isInHangarShipRoom && !component.isPlayerDead && (double)component.sinkingValue < 0.7300000190734863)
			{
				return component;
			}
			return null;
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			((EnemyAI)this).OnCollideWithPlayer(other);
			if (!((NetworkBehaviour)this).IsServer)
			{
				return;
			}
			int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
			bool flag = ((currentBehaviourStateIndex == 0 || currentBehaviourStateIndex == 4) ? true : false);
			if (flag || _timeSinceHittingLocalPlayer < 2f || _inStunAnimation)
			{
				return;
			}
			LogDebug("Collided with player!");
			PlayerControllerB val = PlayerMeetsStandardCollisionConditions(other);
			if (!((Object)(object)val == (Object)null))
			{
				_timeSinceHittingLocalPlayer = 0f;
				if (base.currentBehaviourStateIndex != 3)
				{
					SwitchBehaviourStateLocally(3);
				}
				netcodeController.ChangeTargetPlayerClientRpc((int)val.playerClientId);
				netcodeController.DoAnimationClientRpc(HarpGhostAnimationController.Attack);
				LogDebug("Attacking player " + ((Object)val).name);
			}
		}

		public override void FinishedCurrentSearchRoutine()
		{
			((EnemyAI)this).FinishedCurrentSearchRoutine();
			if (((NetworkBehaviour)this).IsServer && searchForPlayers.inProgress)
			{
				searchForPlayers.searchWidth = Mathf.Clamp(searchForPlayers.searchWidth + 10f, 1f, maxSearchRadius);
			}
		}

		public override void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesNoisePlayedInOneSpot = 0, int noiseID = 0)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DetectNoise(noisePosition, noiseLoudness, timesNoisePlayedInOneSpot, noiseID);
			if (!((NetworkBehaviour)this).IsServer || (double)base.stunNormalizedTimer > 0.0 || (double)_hearNoiseCooldown > 0.0 || Enum.IsDefined(typeof(HarpGhostAudioManager.NoiseIDToIgnore), noiseID))
			{
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
			{
				_hearNoiseCooldown = 0.02f;
				float num3 = Vector3.Distance(((Component)this).transform.position, noisePosition);
				float num4 = 8f * noiseLoudness;
				LogDebug($"Harp Ghost '{((Object)((Component)this).gameObject).name}': Heard Noise | Distance: {num3} meters away | Noise loudness: {noiseLoudness}");
				if (Physics.Linecast(((Component)this).transform.position, noisePosition, 256))
				{
					noiseLoudness /= 2f;
					num4 /= 2f;
				}
				if (!((double)noiseLoudness < 0.25) && !(num3 >= num4))
				{
					if ((noiseID == 5 || noiseID == 75 || noiseID == 1015) ? true : false)
					{
						noiseLoudness *= 2f;
					}
					annoyanceLevel += noiseLoudness;
					LogDebug($"Harp Ghost annoyance level: {annoyanceLevel}");
				}
				break;
			}
			case 1:
				if (timesNoisePlayedInOneSpot <= 5)
				{
					_hearNoiseCooldown = 0.1f;
					float num = Vector3.Distance(((Component)this).transform.position, noisePosition);
					float num2 = 8f * noiseLoudness;
					LogDebug($"Harp Ghost '{((Object)((Component)this).gameObject).name}': Heard Noise | Distance: {num} meters away | Noise loudness: {noiseLoudness}");
					if (Physics.Linecast(((Component)this).transform.position, noisePosition, 256))
					{
						noiseLoudness /= 2f;
						num2 /= 2f;
					}
					if (!((double)noiseLoudness < 0.25) && !(num >= num2))
					{
						_targetPosition = _roundManager.GetRandomNavMeshPositionInRadius(noisePosition, num / 14f, default(NavMeshHit));
						SwitchBehaviourStateLocally(2);
					}
				}
				break;
			}
		}

		private void LogDebug(string msg)
		{
		}

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

		protected internal override string __getTypeName()
		{
			return "HarpGhostAIServer";
		}
	}
	public class HarpGhostAnimationController : MonoBehaviour
	{
		private readonly ManualLogSource _mls = Logger.CreateLogSource("Harp Ghost Animation Controller");

		[SerializeField]
		private Animator animator;

		[SerializeField]
		private HarpGhostNetcodeController netcodeController;

		[SerializeField]
		private HarpGhostAudioManager audioManager;

		public static readonly int IsRunning = Animator.StringToHash("isRunning");

		public static readonly int IsStunned = Animator.StringToHash("isStunned");

		public static readonly int IsDead = Animator.StringToHash("isDead");

		public static readonly int Death = Animator.StringToHash("death");

		public static readonly int Stunned = Animator.StringToHash("stunned");

		public static readonly int Recover = Animator.StringToHash("recover");

		public static readonly int Attack = Animator.StringToHash("attack");

		private int attackDamage = 35;

		private void Start()
		{
			animator = ((Component)this).GetComponent<Animator>();
			if ((Object)(object)animator == (Object)null)
			{
				_mls.LogError((object)"Animator is null");
			}
			netcodeController = ((Component)this).GetComponent<HarpGhostNetcodeController>();
			if ((Object)(object)netcodeController == (Object)null)
			{
				_mls.LogError((object)"netcodeController is null");
			}
			audioManager = ((Component)this).GetComponent<HarpGhostAudioManager>();
			if ((Object)(object)audioManager == (Object)null)
			{
				_mls.LogError((object)"audioManager is null");
			}
		}

		private void LogDebug(string msg)
		{
		}

		private void OnEnable()
		{
			netcodeController.OnDoAnimation += SetTrigger;
			netcodeController.OnChangeAnimationParameterBool += SetBool;
			HarpGhostNetcodeController.OnEnterDeathState += HandleOnEnterDeathState;
			HarpGhostNetcodeController.OnInitializeConfigValues += HandleInitializeConfigValues;
		}

		private void OnDestroy()
		{
			if (!((Object)(object)netcodeController == (Object)null))
			{
				netcodeController.OnDoAnimation -= SetTrigger;
				netcodeController.OnChangeAnimationParameterBool -= SetBool;
				HarpGhostNetcodeController.OnEnterDeathState -= HandleOnEnterDeathState;
				HarpGhostNetcodeController.OnInitializeConfigValues -= HandleInitializeConfigValues;
			}
		}

		private void HandleOnEnterDeathState()
		{
			SetTrigger(Death);
			SetBool(IsDead, value: true);
			SetBool(IsRunning, value: false);
			SetBool(IsStunned, value: false);
			Object.Destroy((Object)(object)this);
		}

		private void HandleInitializeConfigValues()
		{
			attackDamage = SyncedInstance<HarpGhostConfig>.Instance.GhostAttackDamage.Value;
		}

		private void SetBool(int parameter, bool value)
		{
			LogDebug($"SetBoolCalled: {parameter}, {value}");
			animator.SetBool(parameter, value);
		}

		public bool GetBool(int parameter)
		{
			return animator.GetBool(parameter);
		}

		private void SetTrigger(int parameter)
		{
			LogDebug($"SetTriggerCalled: {parameter}");
			animator.SetTrigger(parameter);
		}

		public void OnAnimationEventFixAgentSpeedAfterAttack()
		{
			if (NetworkManager.Singleton.IsClient && ((NetworkBehaviour)netcodeController).IsOwner)
			{
				netcodeController.FixAgentSpeedAfterAttackServerRpc();
			}
		}

		public void OnAnimationEventAttackShiftComplete()
		{
			if (NetworkManager.Singleton.IsClient && ((NetworkBehaviour)netcodeController).IsOwner)
			{
				netcodeController.ChangeAgentMaxSpeedServerRpc(0f, 0f);
				netcodeController.PlayCreatureVoiceClientRpc(2, audioManager.laughSfx.Length);
				LogDebug("OnAnimationEventAttackShiftComplete() called");
				((MonoBehaviour)this).StartCoroutine(DamageTargetPlayerAfterDelay(0.05f, attackDamage, (CauseOfDeath)4));
			}
		}

		private IEnumerator DamageTargetPlayerAfterDelay(float delay, int damage, CauseOfDeath causeOfDeath = 0)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			yield return (object)new WaitForSeconds(delay);
			LogDebug("Damaging player in anim controller");
			netcodeController.DamageTargetPlayerServerRpc(damage, causeOfDeath);
		}
	}
	public class HarpGhostAudioManager : MonoBehaviour
	{
		public enum AudioClipTypes
		{
			Death,
			Damage,
			Laugh,
			Stun,
			Upset
		}

		public enum NoiseIds
		{
			PlayerFootstepsLocal = 6,
			PlayerFootstepsServer = 7,
			Lightning = 11,
			PlayersTalking = 75,
			Harp = 540,
			BaboonHawkCaw = 1105,
			ShipHorn = 14155,
			WhoopieCushionFart = 101158,
			DropSoundEffect = 941,
			Boombox = 5,
			ItemDropship = 94,
			DoubleWing = 911,
			RadarBoosterPing = 1015,
			Jetpack = 41,
			DocileLocustBees = 14152
		}

		public enum NoiseIDToIgnore
		{
			Harp = 540,
			DoubleWing = 911,
			Lightning = 11,
			DocileLocustBees = 14152,
			BaboonHawkCaw = 1105
		}

		private readonly ManualLogSource _mls = Logger.CreateLogSource("Harp Ghost Audio Manager");

		[SerializeField]
		private AudioSource creatureVoiceSource;

		[SerializeField]
		private AudioSource creatureSfxSource;

		[Header("Audio")]
		[Space(5f)]
		public AudioClip[] damageSfx;

		public AudioClip[] laughSfx;

		public AudioClip[] stunSfx;

		public AudioClip[] upsetSfx;

		public AudioClip dieSfx;

		private void Start()
		{
			if ((Object)(object)creatureSfxSource == (Object)null)
			{
				_mls.LogError((object)"creatureSfxSource is null");
			}
			if ((Object)(object)creatureVoiceSource == (Object)null)
			{
				_mls.LogError((object)"creatureVoiceSource is null");
			}
			if (damageSfx == null || damageSfx.Length == 0)
			{
				_mls.LogError((object)"DamageSfx is null or empty");
			}
			if (laughSfx == null || laughSfx.Length == 0)
			{
				_mls.LogError((object)"LaughSfx is null or empty");
			}
			if (stunSfx == null || stunSfx.Length == 0)
			{
				_mls.LogError((object)"StunSfx is null or empty");
			}
			if (upsetSfx == null || upsetSfx.Length == 0)
			{
				_mls.LogError((object)"UpsetSfx is null or empty");
			}
			if ((Object)(object)dieSfx == (Object)null)
			{
				_mls.LogError((object)"DieSfx is null");
			}
		}

		private void LogDebug(string msg)
		{
		}

		private void OnEnable()
		{
			HarpGhostNetcodeController.OnInitializeConfigValues += HandleOnInitializeConfigValues;
			HarpGhostNetcodeController.OnPlayCreatureVoice += PlayVoice;
			HarpGhostNetcodeController.OnEnterDeathState += HandleOnEnterDeathState;
		}

		private void OnDestroy()
		{
			HarpGhostNetcodeController.OnInitializeConfigValues -= HandleOnInitializeConfigValues;
			HarpGhostNetcodeController.OnPlayCreatureVoice -= PlayVoice;
			HarpGhostNetcodeController.OnEnterDeathState -= HandleOnEnterDeathState;
		}

		private void HandleOnInitializeConfigValues()
		{
			creatureVoiceSource.volume = SyncedInstance<HarpGhostConfig>.Default.GhostVoiceSfxVolume.Value;
		}

		private void HandleOnEnterDeathState()
		{
			creatureVoiceSource.Stop(true);
			creatureSfxSource.Stop(true);
			PlayVoice(0, 1);
			Object.Destroy((Object)(object)this);
		}

		private void PlayVoice(int typeIndex, int randomNum, bool interrupt = true)
		{
			creatureVoiceSource.pitch = Random.Range(0.8f, 1.1f);
			LogDebug($"Audio clip index: {typeIndex}, audio clip random number: {randomNum}");
			AudioClip val = (AudioClip)(typeIndex switch
			{
				0 => dieSfx, 
				1 => damageSfx[randomNum], 
				2 => laughSfx[randomNum], 
				3 => stunSfx[randomNum], 
				4 => upsetSfx[randomNum], 
				_ => null, 
			});
			if ((Object)(object)val == (Object)null)
			{
				_mls.LogError((object)$"Harp ghost voice audio clip index '{typeIndex}' and randomNum: '{randomNum}' is null");
				return;
			}
			LogDebug("Playing audio clip: " + ((Object)val).name);
			if (interrupt)
			{
				creatureVoiceSource.Stop(true);
			}
			creatureVoiceSource.PlayOneShot(val);
			WalkieTalkie.TransmitOneShotAudio(creatureVoiceSource, val, creatureVoiceSource.volume);
		}

		private void PlaySfx(AudioClip clip, float volume = 1f)
		{
			creatureSfxSource.volume = volume;
			creatureSfxSource.PlayOneShot(clip);
			WalkieTalkie.TransmitOneShotAudio(creatureSfxSource, clip, volume);
		}
	}
	public class HarpGhostNetcodeController : NetworkBehaviour
	{
		[SerializeField]
		private HarpGhostAIServer harpGhostAIServer;

		private readonly ManualLogSource _mls = Logger.CreateLogSource("Harp Ghost Netcode Controller");

		public event Action<int> OnDoAnimation;

		public event Action<int, bool> OnChangeAnimationParameterBool;

		public static event Action<int, int, bool> OnPlayCreatureVoice;

		public static event Action OnEnterDeathState;

		public static event Action OnGrabHarp;

		public static event Action<NetworkObjectReference, int> OnSpawnHarp;

		public static event Action<Vector3> OnDropHarp;

		public static event Action OnPlayHarpMusic;

		public static event Action OnStopHarpMusic;

		public static event Action<int> OnChangeTargetPlayer;

		public static event Action<int, CauseOfDeath> OnDamageTargetPlayer;

		public static event Action<float, float> OnChangeAgentMaxSpeed;

		public static event Action OnFixAgentSpeedAfterAttack;

		public static event Action OnIncreaseTargetPlayerFearLevel;

		public static event Action OnInitializeConfigValues;

		private void Start()
		{
			harpGhostAIServer = ((Component)this).GetComponent<HarpGhostAIServer>();
			if ((Object)(object)harpGhostAIServer == (Object)null)
			{
				_mls.LogError((object)"harpGhostAI is null");
			}
		}

		private void LogDebug(string msg)
		{
		}

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

		[ServerRpc(RequireOwnership = false)]
		public void ChangeAgentMaxSpeedServerRpc(float newMaxSpeed, float newMaxSpeed2)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_0098: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(433999943u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref newMaxSpeed, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref newMaxSpeed2, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 433999943u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					HarpGhostNetcodeController.OnChangeAgentMaxSpeed?.Invoke(newMaxSpeed, newMaxSpeed2);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void DamageTargetPlayerServerRpc(int damage, CauseOfDeath causeOfDeath = 0)
		{
			//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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3883552754u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, damage);
					((FastBufferWriter)(ref val2)).WriteValueSafe<CauseOfDeath>(ref causeOfDeath, default(ForEnums));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3883552754u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					LogDebug("DamageTargetPlayerServerRpc called");
					DamageTargetPlayerClientRpc(damage, causeOfDeath);
				}
			}
		}

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

		[ClientRpc]
		public void DamageTargetPlayerClientRpc(int damage, CauseOfDeath causeOfDeath = 0)
		{
			//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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(889049487u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, damage);
					((FastBufferWriter)(ref val2)).WriteValueSafe<CauseOfDeath>(ref causeOfDeath, default(ForEnums));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 889049487u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					LogDebug("DamageTargetPlayerClientRpc called");
					HarpGhostNetcodeController.OnDamageTargetPlayer?.Invoke(damage, causeOfDeath);
				}
			}
		}

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

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

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

		[ClientRpc]
		public void ChangeAnimationParameterBoolClientRpc(int animationId, bool value)
		{
			//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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(477427697u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, animationId);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref value, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 477427697u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					this.OnChangeAnimationParameterBool?.Invoke(animationId, value);
				}
			}
		}

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

		[ClientRpc]
		public void GrabHarpClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || net

plugins/LethalCompanyInputUtils/LethalCompanyInputUtils.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using LethalCompanyInputUtils.Components;
using LethalCompanyInputUtils.Components.Section;
using LethalCompanyInputUtils.Data;
using LethalCompanyInputUtils.Glyphs;
using LethalCompanyInputUtils.Utils;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LethalCompanyInputUtils")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+913017c58a6ad55b5050a44817920ad9c63ce200")]
[assembly: AssemblyProduct("LethalCompanyInputUtils")]
[assembly: AssemblyTitle("LethalCompanyInputUtils")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.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 LethalCompanyInputUtils
{
	public static class LcInputActionApi
	{
		private static readonly Dictionary<string, LcInputActions> InputActionsMap = new Dictionary<string, LcInputActions>();

		internal static bool PrefabLoaded;

		internal static RemapContainerController? ContainerInstance;

		internal static IReadOnlyCollection<LcInputActions> InputActions => InputActionsMap.Values;

		internal static void LoadIntoUI(KepRemapPanel panel)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			AdjustSizeAndPos(panel);
			LayoutElement val = EnsureLayoutElement(panel);
			panel.LoadKeybindsUI();
			float horizontalOffset = panel.horizontalOffset;
			Rect rect = ((Component)((Transform)panel.keyRemapContainer).parent).GetComponent<RectTransform>().rect;
			float num = Mathf.Floor(((Rect)(ref rect)).width / horizontalOffset);
			int count = panel.keySlots.Count;
			int num2 = NumberOfActualKeys(panel.keySlots);
			int num3 = count - num2;
			panel.maxVertical = (float)num2 / num + (float)num3;
			if (ContainerInstance != null && ContainerInstance.legacyButton != null)
			{
				((TMP_Text)((Component)ContainerInstance.legacyButton).GetComponentInChildren<TextMeshProUGUI>()).SetText($"> Show Legacy Controls ({num2} present)", true);
			}
			if (count == 0)
			{
				return;
			}
			val.minHeight = (panel.maxVertical + 1f) * panel.verticalOffset;
			int num4 = 0;
			int num5 = 0;
			foreach (GameObject keySlot in panel.keySlots)
			{
				if ((float)num5 > num)
				{
					num4++;
					num5 = 0;
				}
				keySlot.GetComponent<RectTransform>().anchoredPosition = new Vector2((float)num5 * panel.horizontalOffset, (float)num4 * (0f - panel.verticalOffset));
				if (keySlot.GetComponentInChildren<SettingsOption>() == null)
				{
					num5 = 0;
					num4++;
				}
				else
				{
					num5++;
				}
			}
		}

		public static bool RemapContainerVisible()
		{
			if (ContainerInstance == null)
			{
				return false;
			}
			return ContainerInstance.LayerShown > 0;
		}

		private static int NumberOfActualKeys(List<GameObject> keySlots)
		{
			int num = 0;
			foreach (GameObject keySlot in keySlots)
			{
				if (keySlot.GetComponentInChildren<SettingsOption>() != null)
				{
					num++;
				}
			}
			return num;
		}

		internal static void CloseContainerLayer()
		{
			if (ContainerInstance != null)
			{
				ContainerInstance.HideHighestLayer();
			}
		}

		private static void AdjustSizeAndPos(KepRemapPanel panel)
		{
			GameObject gameObject = ((Component)((Transform)panel.keyRemapContainer).parent).gameObject;
			if (gameObject.GetComponent<ContentSizeFitter>() == null)
			{
				panel.keyRemapContainer.SetPivotY(1f);
				panel.keyRemapContainer.SetAnchorMinY(1f);
				panel.keyRemapContainer.SetAnchorMaxY(1f);
				panel.keyRemapContainer.SetAnchoredPosY(0f);
				panel.keyRemapContainer.SetLocalPosY(0f);
				ContentSizeFitter obj = gameObject.AddComponent<ContentSizeFitter>();
				obj.horizontalFit = (FitMode)0;
				obj.verticalFit = (FitMode)1;
			}
		}

		private static LayoutElement EnsureLayoutElement(KepRemapPanel panel)
		{
			GameObject gameObject = ((Component)((Transform)panel.keyRemapContainer).parent).gameObject;
			LayoutElement component = gameObject.GetComponent<LayoutElement>();
			if (component != null)
			{
				return component;
			}
			return gameObject.AddComponent<LayoutElement>();
		}

		internal static void CalculateVerticalMaxForGamepad(KepRemapPanel panel)
		{
			//IL_0042: 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)
			int num = panel.remappableKeys.Count((RemappableKey key) => key.gamepadOnly);
			float horizontalOffset = panel.horizontalOffset;
			Rect rect = ((Component)((Transform)panel.keyRemapContainer).parent).GetComponent<RectTransform>().rect;
			float num2 = Mathf.Floor(((Rect)(ref rect)).width / horizontalOffset);
			panel.maxVertical = (float)num / num2;
			LayoutElement obj = EnsureLayoutElement(panel);
			obj.minHeight += (panel.maxVertical + 3f) * panel.verticalOffset;
		}

		internal static void ResetLoadedInputActions()
		{
			PrefabLoaded = false;
			foreach (LcInputActions inputAction in InputActions)
			{
				inputAction.Loaded = false;
			}
		}

		internal static void RegisterInputActions(LcInputActions lcInputActions, InputActionMapBuilder builder)
		{
			if (!InputActionsMap.TryAdd(lcInputActions.Id, lcInputActions))
			{
				Logging.Warn("The mod [" + lcInputActions.Plugin.GUID + "] instantiated an Actions class [" + lcInputActions.GetType().Name + "] more than once!\n\t These classes should be treated as singletons!, do not instantiate more than once!");
			}
			else
			{
				lcInputActions.CreateInputActions(in builder);
				InputActionSetupExtensions.AddActionMap(lcInputActions.GetAsset(), builder.Build());
				lcInputActions.GetAsset().Enable();
				lcInputActions.OnAssetLoaded();
				lcInputActions.Load();
				lcInputActions.BuildActionRefs();
			}
		}

		internal static void DisableForRebind()
		{
			foreach (LcInputActions inputAction in InputActions)
			{
				if (inputAction.Enabled)
				{
					inputAction.Disable();
				}
			}
		}

		internal static void ReEnableFromRebind()
		{
			foreach (LcInputActions inputAction in InputActions)
			{
				if (inputAction.WasEnabled)
				{
					inputAction.Enable();
				}
			}
		}

		internal static void SaveOverrides()
		{
			foreach (LcInputActions inputAction in InputActions)
			{
				inputAction.Save();
			}
		}

		internal static void LoadOverrides()
		{
			foreach (LcInputActions inputAction in InputActions)
			{
				inputAction.Load();
			}
		}
	}
	[BepInPlugin("com.rune580.LethalCompanyInputUtils", "Lethal Company Input Utils", "0.6.3")]
	public class LethalCompanyInputUtilsPlugin : BaseUnityPlugin
	{
		public const string ModId = "com.rune580.LethalCompanyInputUtils";

		public const string ModName = "Lethal Company Input Utils";

		public const string ModVersion = "0.6.3";

		private Harmony? _harmony;

		private void Awake()
		{
			Logging.SetLogSource(((BaseUnityPlugin)this).Logger);
			_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.rune580.LethalCompanyInputUtils");
			SceneManager.activeSceneChanged += OnSceneChanged;
			InputSystem.onDeviceChange += OnDeviceChanged;
			LoadAssetBundles();
			ControllerGlyph.LoadGlyphs();
			FsUtils.EnsureControlsDir();
			RegisterExtendedMouseLayout();
			Logging.Info("InputUtils 0.6.3 has finished loading!");
		}

		private void LoadAssetBundles()
		{
			Assets.AddBundle("ui-assets");
		}

		private static void OnSceneChanged(Scene current, Scene next)
		{
			LcInputActionApi.ResetLoadedInputActions();
			CameraUtils.ClearUiCameraReference();
			BindsListController.OffsetCompensation = ((((Scene)(ref next)).name != "MainMenu") ? 20 : 0);
		}

		private static void OnDeviceChanged(InputDevice device, InputDeviceChange state)
		{
			RebindButton.ReloadGlyphs();
		}

		private static void RegisterExtendedMouseLayout()
		{
			InputSystem.RegisterLayoutOverride("{\n   \"name\": \"InputUtilsExtendedMouse\",\n   \"extend\": \"Mouse\",\n   \"controls\": [\n       {\n           \"name\": \"scroll/up\",\n           \"layout\": \"Button\",\n           \"useStateFrom\": \"scroll/up\",\n           \"format\": \"BIT\",\n           \"synthetic\": true\n       },\n       {\n           \"name\": \"scroll/down\",\n           \"layout\": \"Button\",\n           \"useStateFrom\": \"scroll/down\",\n           \"format\": \"BIT\",\n           \"synthetic\": true\n       },\n       {\n           \"name\": \"scroll/left\",\n           \"layout\": \"Button\",\n           \"useStateFrom\": \"scroll/left\",\n           \"format\": \"BIT\",\n           \"synthetic\": true\n       },\n       {\n           \"name\": \"scroll/right\",\n           \"layout\": \"Button\",\n           \"useStateFrom\": \"scroll/right\",\n           \"format\": \"BIT\",\n           \"synthetic\": true\n       }\n   ]\n}", (string)null);
			Logging.Info("Registered InputUtilsExtendedMouse Layout Override!");
		}
	}
}
namespace LethalCompanyInputUtils.Utils
{
	internal static class AssemblyUtils
	{
		public static BepInPlugin? GetBepInPlugin(this Assembly assembly)
		{
			foreach (Type validType in assembly.GetValidTypes())
			{
				BepInPlugin customAttribute = ((MemberInfo)validType).GetCustomAttribute<BepInPlugin>();
				if (customAttribute != null)
				{
					return customAttribute;
				}
			}
			return null;
		}

		public static IEnumerable<Type> GetValidTypes(this Assembly assembly)
		{
			try
			{
				return assembly.GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				return ex.Types.Where((Type type) => (object)type != null);
			}
		}
	}
	internal static class Assets
	{
		private static readonly List<AssetBundle> AssetBundles = new List<AssetBundle>();

		private static readonly Dictionary<string, int> AssetIndices = new Dictionary<string, int>();

		public static void AddBundle(string bundleName)
		{
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(FsUtils.AssetBundlesDir, bundleName));
			int count = AssetBundles.Count;
			AssetBundles.Add(val);
			string[] allAssetNames = val.GetAllAssetNames();
			for (int i = 0; i < allAssetNames.Length; i++)
			{
				string text = allAssetNames[i].ToLowerInvariant();
				if (text.StartsWith("assets/"))
				{
					string text2 = text;
					int length = "assets/".Length;
					text = text2.Substring(length, text2.Length - length);
				}
				AssetIndices[text] = count;
			}
		}

		public static T? Load<T>(string assetName) where T : Object
		{
			try
			{
				assetName = assetName.ToLowerInvariant();
				if (assetName.StartsWith("assets/"))
				{
					string text = assetName;
					int length = "assets/".Length;
					assetName = text.Substring(length, text.Length - length);
				}
				int index = AssetIndices[assetName];
				return AssetBundles[index].LoadAsset<T>("assets/" + assetName);
			}
			catch (Exception arg)
			{
				Logging.Error($"Couldn't load asset [{assetName}] exception: {arg}");
				return default(T);
			}
		}
	}
	internal static class CameraUtils
	{
		private static Camera? _uiCamera;

		public static Camera GetBestUiCamera()
		{
			//IL_001f: 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)
			if (_uiCamera != null && Object.op_Implicit((Object)(object)_uiCamera))
			{
				return _uiCamera;
			}
			_uiCamera = null;
			Scene activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name == "MainMenu")
			{
				GameObject val = ((IEnumerable<GameObject>)((Scene)(ref activeScene)).GetRootGameObjects()).FirstOrDefault((Func<GameObject, bool>)((GameObject go) => ((Object)go).name == "UICamera"));
				if (val == null)
				{
					Logging.Warn("Failed to find UICamera at MainMenu, falling back to Camera.current!");
					return Camera.current;
				}
				Camera component = val.GetComponent<Camera>();
				if (component == null)
				{
					Logging.Warn("Failed to find Camera component on UICamera, falling back to Camera.current!");
					return Camera.current;
				}
				_uiCamera = component;
			}
			else
			{
				GameObject val2 = ((IEnumerable<GameObject>)((Scene)(ref activeScene)).GetRootGameObjects()).FirstOrDefault((Func<GameObject, bool>)((GameObject go) => ((Object)go).name == "Systems"));
				if (val2 == null)
				{
					Logging.Warn("Failed to find UICamera in active scene, falling back to Camera.current!");
					return Camera.current;
				}
				Transform val3 = val2.transform.Find("UI/UICamera");
				if (val3 == null)
				{
					Logging.Warn("Failed to find UICamera at MainMenu, falling back to Camera.current!");
					return Camera.current;
				}
				Camera component2 = ((Component)val3).GetComponent<Camera>();
				if (component2 == null)
				{
					Logging.Warn("Failed to find Camera component on UICamera, falling back to Camera.current!");
					return Camera.current;
				}
				_uiCamera = component2;
			}
			return _uiCamera;
		}

		public static void ClearUiCameraReference()
		{
			_uiCamera = null;
		}
	}
	internal static class DebugUtils
	{
		public static string ToPrettyString<TKey, TValue>(this IDictionary<TKey, TValue> dictionary)
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("{");
			using (IEnumerator<KeyValuePair<TKey, TValue>> enumerator = dictionary.GetEnumerator())
			{
				string[] obj;
				object obj3;
				for (; enumerator.MoveNext(); obj[3] = (string)obj3, obj[4] = "\",", stringBuilder.AppendLine(string.Concat(obj)))
				{
					enumerator.Current.Deconstruct(out var key, out var value);
					TKey val = key;
					TValue val2 = value;
					obj = new string[5] { "\t\"", null, null, null, null };
					ref TKey reference = ref val;
					key = default(TKey);
					object obj2;
					if (key == null)
					{
						key = reference;
						reference = ref key;
						if (key == null)
						{
							obj2 = null;
							goto IL_007c;
						}
					}
					obj2 = reference.ToString();
					goto IL_007c;
					IL_007c:
					obj[1] = (string)obj2;
					obj[2] = "\": \"";
					ref TValue reference2 = ref val2;
					value = default(TValue);
					if (value == null)
					{
						value = reference2;
						reference2 = ref value;
						if (value == null)
						{
							obj3 = null;
							continue;
						}
					}
					obj3 = reference2.ToString();
				}
			}
			stringBuilder.Remove(stringBuilder.Length - 1, 1);
			stringBuilder.AppendLine("}");
			return stringBuilder.ToString();
		}

		public static void DrawGizmoUiRectWorld(this RectTransform rectTransform)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			float z = ((Transform)rectTransform).position.z;
			Rect val = rectTransform.UiBoundsWorld();
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(((Rect)(ref val)).min.x, ((Rect)(ref val)).min.y, z);
			Vector3 val3 = default(Vector3);
			((Vector3)(ref val3))..ctor(((Rect)(ref val)).min.x, ((Rect)(ref val)).max.y, z);
			Vector3 val4 = default(Vector3);
			((Vector3)(ref val4))..ctor(((Rect)(ref val)).max.x, ((Rect)(ref val)).max.y, z);
			Vector3 val5 = default(Vector3);
			((Vector3)(ref val5))..ctor(((Rect)(ref val)).max.x, ((Rect)(ref val)).min.y, z);
			Gizmos.DrawLine(val2, val3);
			Gizmos.DrawLine(val3, val4);
			Gizmos.DrawLine(val4, val5);
			Gizmos.DrawLine(val5, val2);
		}

		public static void DrawGizmoUiRect(this RectTransform rectTransform, Vector3 position)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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_0097: 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_00a0: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			float z = position.z;
			Rect val = rectTransform.UiBounds(position);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(((Rect)(ref val)).min.x, ((Rect)(ref val)).min.y, z);
			Vector3 val3 = default(Vector3);
			((Vector3)(ref val3))..ctor(((Rect)(ref val)).min.x, ((Rect)(ref val)).max.y, z);
			Vector3 val4 = default(Vector3);
			((Vector3)(ref val4))..ctor(((Rect)(ref val)).max.x, ((Rect)(ref val)).max.y, z);
			Vector3 val5 = default(Vector3);
			((Vector3)(ref val5))..ctor(((Rect)(ref val)).max.x, ((Rect)(ref val)).min.y, z);
			Gizmos.DrawLine(val2, val3);
			Gizmos.DrawLine(val3, val4);
			Gizmos.DrawLine(val4, val5);
			Gizmos.DrawLine(val5, val2);
		}

		public static void DrawGizmoRect(this Rect rect, Vector3 position)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			float z = position.z;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(((Rect)(ref rect)).min.x + position.x, ((Rect)(ref rect)).min.y + position.y, z);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(((Rect)(ref rect)).min.x + position.x, ((Rect)(ref rect)).max.y + position.y, z);
			Vector3 val3 = default(Vector3);
			((Vector3)(ref val3))..ctor(((Rect)(ref rect)).max.x + position.x, ((Rect)(ref rect)).max.y + position.y, z);
			Vector3 val4 = default(Vector3);
			((Vector3)(ref val4))..ctor(((Rect)(ref rect)).max.x + position.x, ((Rect)(ref rect)).min.y + position.y, z);
			Gizmos.DrawLine(val, val2);
			Gizmos.DrawLine(val2, val3);
			Gizmos.DrawLine(val3, val4);
			Gizmos.DrawLine(val4, val);
		}
	}
	internal static class DeconstructUtils
	{
		public static void Deconstruct(this Rect rect, out Vector2 min, out Vector2 max)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			min = new Vector2(((Rect)(ref rect)).xMin, ((Rect)(ref rect)).yMin);
			max = new Vector2(((Rect)(ref rect)).xMax, ((Rect)(ref rect)).yMax);
		}

		public static void Deconstruct(this Vector3 vector, out float x, out float y, out float z)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			x = vector.x;
			y = vector.y;
			z = vector.z;
		}
	}
	internal static class FsUtils
	{
		private static string? _assetBundlesDir;

		public static string SaveDir { get; } = GetSaveDir();


		public static string Pre041ControlsDir { get; } = Path.Combine(Paths.BepInExRootPath, "controls");


		public static string ControlsDir { get; } = Path.Combine(Paths.ConfigPath, "controls");


		public static string AssetBundlesDir
		{
			get
			{
				if (_assetBundlesDir == null)
				{
					_assetBundlesDir = GetAssetBundlesDir();
				}
				if (string.IsNullOrEmpty(_assetBundlesDir))
				{
					string text = Chainloader.PluginInfos.ToPrettyString();
					Logging.Warn("InputUtils is loading in an invalid state!\n\tOne of the following mods may be the culprit:\n" + text);
					return "";
				}
				return _assetBundlesDir;
			}
		}

		private static string GetSaveDir()
		{
			string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
			return Path.Combine(folderPath, "AppData", "LocalLow", "ZeekerssRBLX", "Lethal Company");
		}

		public static void EnsureControlsDir()
		{
			if (!Directory.Exists(ControlsDir))
			{
				Directory.CreateDirectory(ControlsDir);
			}
		}

		private static string? GetAssetBundlesDir()
		{
			if (!Chainloader.PluginInfos.TryGetValue("com.rune580.LethalCompanyInputUtils", out var value))
			{
				return null;
			}
			string text = Path.Combine((Directory.GetParent(value.Location) ?? throw new NotSupportedException(BadInstallError())).FullName, "AssetBundles");
			if (!Directory.Exists(text))
			{
				throw new NotSupportedException(BadInstallError());
			}
			return text;
			static string BadInstallError()
			{
				Logging.Error("InputUtils can't find it's required AssetBundles! This will cause many issues!\nThis either means your mod manager incorrectly installed InputUtilsor if you've manually installed InputUtils, you've done so incorrectly. If you manually installed don't bother reporting the issue, I only provide support to people who use mod managers.");
				return "InputUtils can't find it's required AssetBundles! This will cause many issues!\nThis either means your mod manager incorrectly installed InputUtilsor if you've manually installed InputUtils, you've done so incorrectly. If you manually installed don't bother reporting the issue, I only provide support to people who use mod managers.";
			}
		}
	}
	internal static class InputSystemUtils
	{
		public static bool IsGamepadOnly(this InputAction action)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return ((IEnumerable<InputBinding>)(object)action.bindings).All((InputBinding binding) => !binding.IsKbmBind());
		}

		public static bool IsKbmBind(this InputBinding binding)
		{
			string path = ((InputBinding)(ref binding)).path;
			if (string.Equals(path, "<InputUtils-Kbm-Not-Bound>"))
			{
				return true;
			}
			if (path.StartsWith("<Keyboard>", StringComparison.InvariantCultureIgnoreCase))
			{
				return true;
			}
			if (path.StartsWith("<Mouse>", StringComparison.InvariantCultureIgnoreCase))
			{
				return true;
			}
			return false;
		}
	}
	internal static class Logging
	{
		private static ManualLogSource? _logSource;

		internal static void SetLogSource(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		public static void Error(object data)
		{
			Error(data.ToString());
		}

		public static void Warn(object data)
		{
			Warn(data.ToString());
		}

		public static void Info(object data)
		{
			Info(data.ToString());
		}

		public static void Error(string msg)
		{
			if (_logSource == null)
			{
				Debug.LogError((object)("[Lethal Company Input Utils] [Error] " + msg));
			}
			else
			{
				_logSource.LogError((object)msg);
			}
		}

		public static void Warn(string msg)
		{
			if (_logSource == null)
			{
				Debug.LogWarning((object)("[Lethal Company Input Utils] [Warning] " + msg));
			}
			else
			{
				_logSource.LogWarning((object)msg);
			}
		}

		public static void Info(string msg)
		{
			if (_logSource == null)
			{
				Debug.Log((object)("[Lethal Company Input Utils] [Info] " + msg));
			}
			else
			{
				_logSource.LogInfo((object)msg);
			}
		}
	}
	internal static class RectTransformExtensions
	{
		public static void SetLocalPosX(this RectTransform rectTransform, float x)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			Vector3 localPosition = ((Transform)rectTransform).localPosition;
			((Transform)rectTransform).localPosition = new Vector3(x, localPosition.y, localPosition.z);
		}

		public static void SetLocalPosY(this RectTransform rectTransform, float y)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			Vector3 localPosition = ((Transform)rectTransform).localPosition;
			((Transform)rectTransform).localPosition = new Vector3(localPosition.x, y, localPosition.z);
		}

		public static void SetPivotY(this RectTransform rectTransform, float y)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.pivot = new Vector2(rectTransform.pivot.x, y);
		}

		public static void SetAnchorMinY(this RectTransform rectTransform, float y)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchorMin = new Vector2(rectTransform.anchorMin.x, y);
		}

		public static void SetAnchorMaxY(this RectTransform rectTransform, float y)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchorMax = new Vector2(rectTransform.anchorMax.x, y);
		}

		public static void SetAnchoredPosX(this RectTransform rectTransform, float x)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchoredPosition = new Vector2(x, rectTransform.anchoredPosition.y);
		}

		public static void SetAnchoredPosY(this RectTransform rectTransform, float y)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchoredPosition = new Vector2(rectTransform.anchoredPosition.x, y);
		}

		public static void SetSizeDeltaX(this RectTransform rectTransform, float x)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.sizeDelta = new Vector2(x, rectTransform.sizeDelta.y);
		}

		public static Rect UiBoundsWorld(this RectTransform rectTransform)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_0038: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Transform)rectTransform).position;
			Rect rect = rectTransform.rect;
			Vector3 lossyScale = ((Transform)rectTransform).lossyScale;
			return new Rect(((Rect)(ref rect)).x * lossyScale.x + position.x, ((Rect)(ref rect)).y * lossyScale.y + position.y, ((Rect)(ref rect)).width * lossyScale.x, ((Rect)(ref rect)).height * lossyScale.y);
		}

		[Obsolete("Use GetRelativeRect")]
		public static Rect UiBounds(this RectTransform rectTransform, Vector3 position)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = rectTransform.rect;
			Vector3 lossyScale = ((Transform)rectTransform).lossyScale;
			return new Rect(((Rect)(ref rect)).x * lossyScale.x + position.x, ((Rect)(ref rect)).y * lossyScale.y + position.y, ((Rect)(ref rect)).width * lossyScale.x, ((Rect)(ref rect)).height * lossyScale.y);
		}

		public static Rect GetRelativeRect(this RectTransform rectTransform, RectTransform worldRectTransform)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			Camera bestUiCamera = CameraUtils.GetBestUiCamera();
			Vector3[] array = (Vector3[])(object)new Vector3[4];
			worldRectTransform.GetWorldCorners(array);
			Vector2[] array2 = (Vector2[])(object)new Vector2[4];
			for (int i = 0; i < array.Length; i++)
			{
				array2[i] = RectTransformUtility.WorldToScreenPoint(bestUiCamera, array[i]);
			}
			Vector2[] array3 = (Vector2[])(object)new Vector2[4];
			for (int j = 0; j < array2.Length; j++)
			{
				RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, array2[j], bestUiCamera, ref array3[j]);
			}
			Vector2 val = array3[0];
			Vector2 val2 = array3[0];
			Vector2[] array4 = array3;
			foreach (Vector2 val3 in array4)
			{
				val = Vector2.Min(val, val3);
				val2 = Vector2.Max(val2, val3);
			}
			Vector2 val4 = val2 - val;
			return new Rect(val.x, val.y, val4.x, val4.y);
		}

		public static Vector2 WorldToLocalPoint(this RectTransform rectTransform, Vector3 worldPoint)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			Camera bestUiCamera = CameraUtils.GetBestUiCamera();
			Vector2 val = RectTransformUtility.WorldToScreenPoint(bestUiCamera, worldPoint);
			Vector2 result = default(Vector2);
			RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, val, bestUiCamera, ref result);
			return result;
		}

		public static Vector2 WorldToLocalPoint(this RectTransform rectTransform, RectTransform other)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return rectTransform.WorldToLocalPoint(((Transform)other).position);
		}

		public static float WorldMaxY(this RectTransform rectTransform)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			Rect val = rectTransform.UiBoundsWorld();
			return ((Rect)(ref val)).max.y;
		}

		public static float WorldMinY(this RectTransform rectTransform)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			Rect val = rectTransform.UiBoundsWorld();
			return ((Rect)(ref val)).min.y;
		}
	}
	internal static class RectUtils
	{
		public static Vector2 CenteredPos(this Rect rect)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			return ((Rect)(ref rect)).min + ((Rect)(ref rect)).size / 2f;
		}
	}
	internal static class RuntimeHelper
	{
		public static Vector3 LocalPositionRelativeTo(this Transform transform, Transform parent)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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)
			Vector3 val = Vector3.zero;
			Transform val2 = transform;
			do
			{
				val += transform.localPosition;
				val2 = val2.parent;
			}
			while ((Object)(object)val2 != (Object)(object)parent);
			return val;
		}

		public static void DisableKeys(this IEnumerable<RemappableKey> keys)
		{
			foreach (RemappableKey key in keys)
			{
				key.currentInput.action.Disable();
			}
		}

		public static void EnableKeys(this IEnumerable<RemappableKey> keys)
		{
			foreach (RemappableKey key in keys)
			{
				key.currentInput.action.Enable();
			}
		}
	}
	internal static class VectorUtils
	{
		public static Vector3 Mul(this Vector3 left, Vector3 right)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(left.x * right.x, left.y * right.y, left.z * right.z);
		}
	}
}
namespace LethalCompanyInputUtils.Utils.Anim
{
	public interface ITweenValue
	{
		bool IgnoreTimeScale { get; }

		float Duration { get; }

		void TweenValue(float percentage);

		bool ValidTarget();
	}
	public class TweenRunner<T> where T : struct, ITweenValue
	{
		protected MonoBehaviour? CoroutineContainer;

		protected IEnumerator? Tween;

		private static IEnumerator Start(T tweenValue)
		{
			if (tweenValue.ValidTarget())
			{
				float elapsedTime = 0f;
				while (elapsedTime < tweenValue.Duration)
				{
					elapsedTime += (tweenValue.IgnoreTimeScale ? Time.unscaledDeltaTime : Time.deltaTime);
					float percentage = Mathf.Clamp01(elapsedTime / tweenValue.Duration);
					tweenValue.TweenValue(percentage);
					yield return null;
				}
				tweenValue.TweenValue(1f);
			}
		}

		public void Init(MonoBehaviour coroutineContainer)
		{
			CoroutineContainer = coroutineContainer;
		}

		public void StartTween(T tweenValue)
		{
			if (CoroutineContainer != null)
			{
				if (Tween != null)
				{
					CoroutineContainer.StopCoroutine(Tween);
					Tween = null;
				}
				if (!((Component)CoroutineContainer).gameObject.activeInHierarchy)
				{
					tweenValue.TweenValue(1f);
					return;
				}
				Tween = Start(tweenValue);
				CoroutineContainer.StartCoroutine(Tween);
			}
		}

		public void StopTween()
		{
			if (Tween != null && CoroutineContainer != null)
			{
				CoroutineContainer.StopCoroutine(Tween);
				Tween = null;
			}
		}
	}
}
namespace LethalCompanyInputUtils.Utils.Anim.TweenValues
{
	public struct Vector3Tween : ITweenValue
	{
		private class Vector3TweenCallback : UnityEvent<Vector3>
		{
		}

		private Vector3TweenCallback? _target;

		public float Duration { get; set; }

		public Vector3 StartValue { get; set; }

		public Vector3 TargetValue { get; set; }

		public bool IgnoreTimeScale { get; set; }

		public void TweenValue(float percentage)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			if (ValidTarget())
			{
				Vector3 val = Vector3.Lerp(StartValue, TargetValue, percentage);
				((UnityEvent<Vector3>)_target).Invoke(val);
			}
		}

		public void AddOnChangedCallback(UnityAction<Vector3> callback)
		{
			if (_target == null)
			{
				_target = new Vector3TweenCallback();
			}
			((UnityEvent<Vector3>)_target).AddListener(callback);
		}

		public bool ValidTarget()
		{
			return _target != null;
		}
	}
}
namespace LethalCompanyInputUtils.Patches
{
	public static class InGamePlayerSettingsPatches
	{
		[HarmonyPatch(typeof(IngamePlayerSettings), "SaveChangedSettings")]
		public static class SaveChangedSettingsPatch
		{
			public static void Prefix()
			{
				LcInputActionApi.SaveOverrides();
			}
		}

		[HarmonyPatch(typeof(IngamePlayerSettings), "DiscardChangedSettings")]
		public static class DiscardChangedSettingsPatch
		{
			public static void Prefix()
			{
				LcInputActionApi.LoadOverrides();
			}
		}
	}
	public static class InputControlPathPatches
	{
		[HarmonyPatch]
		public static class ToHumanReadableStringPatch
		{
			public static IEnumerable<MethodBase> TargetMethods()
			{
				return from method in AccessTools.GetDeclaredMethods(typeof(InputControlPath))
					where method.Name == "ToHumanReadableString" && method.ReturnType == typeof(string)
					select method;
			}

			public static void Postfix(ref string __result)
			{
				string text = __result;
				if ((text == "<InputUtils-Gamepad-Not-Bound>" || text == "<InputUtils-Kbm-Not-Bound>") ? true : false)
				{
					__result = "";
				}
			}
		}
	}
	public static class KeyRemapPanelPatches
	{
		[HarmonyPatch(typeof(KepRemapPanel), "OnEnable")]
		public static class LoadKeybindsUIPatch
		{
			[CompilerGenerated]
			private static class <>O
			{
				public static UnityAction <0>__CloseContainerLayer;
			}

			public static void Prefix(KepRemapPanel __instance)
			{
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d5: Expected O, but got Unknown
				//IL_011f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0129: Expected O, but got Unknown
				//IL_0130: Unknown result type (might be due to invalid IL or missing references)
				//IL_0147: Unknown result type (might be due to invalid IL or missing references)
				//IL_0182: Unknown result type (might be due to invalid IL or missing references)
				//IL_018c: Unknown result type (might be due to invalid IL or missing references)
				//IL_019f: 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_01f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0202: Expected O, but got Unknown
				//IL_023b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0245: Expected O, but got Unknown
				//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f5: Expected O, but got Unknown
				LcInputActionApi.DisableForRebind();
				if (LcInputActionApi.PrefabLoaded && LcInputActionApi.ContainerInstance != null)
				{
					LcInputActionApi.ContainerInstance.baseGameKeys.DisableKeys();
					return;
				}
				GameObject val = Object.Instantiate<GameObject>(Assets.Load<GameObject>("Prefabs/InputUtilsRemapContainer.prefab"), ((Component)__instance).transform);
				GameObject val2 = Object.Instantiate<GameObject>(Assets.Load<GameObject>("Prefabs/Legacy Holder.prefab"), ((Component)__instance).transform);
				if (val == null || val2 == null)
				{
					return;
				}
				Transform val3 = ((Component)__instance).transform.Find("Scroll View");
				if (val3 != null)
				{
					val3.SetParent(val2.transform);
					List<RemappableKey> remappableKeys = __instance.remappableKeys;
					__instance.remappableKeys = new List<RemappableKey>();
					val2.SetActive(false);
					GameObject gameObject = ((Component)((Component)__instance).transform.Find("Back")).gameObject;
					Button component = gameObject.GetComponent<Button>();
					GameObject obj = Object.Instantiate<GameObject>(gameObject, val2.transform, true);
					Object.DestroyImmediate((Object)(object)obj.GetComponentInChildren<SettingsOption>());
					Button component2 = obj.GetComponent<Button>();
					component2.onClick = new ButtonClickedEvent();
					ButtonClickedEvent onClick = component2.onClick;
					object obj2 = <>O.<0>__CloseContainerLayer;
					if (obj2 == null)
					{
						UnityAction val4 = LcInputActionApi.CloseContainerLayer;
						<>O.<0>__CloseContainerLayer = val4;
						obj2 = (object)val4;
					}
					((UnityEvent)onClick).AddListener((UnityAction)obj2);
					GameObject obj3 = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent);
					Object.DestroyImmediate((Object)(object)obj3.GetComponentInChildren<SettingsOption>());
					Button component3 = obj3.GetComponent<Button>();
					component3.onClick = new ButtonClickedEvent();
					RectTransform component4 = obj3.GetComponent<RectTransform>();
					component4.SetAnchoredPosY(component4.anchoredPosition.y + 25f);
					component4.SetSizeDeltaX(component4.sizeDelta.x + 180f);
					RectTransform component5 = ((Component)((Transform)component4).Find("SelectionHighlight")).GetComponent<RectTransform>();
					component5.SetSizeDeltaX(410f);
					component5.offsetMax = new Vector2(410f, component5.offsetMax.y);
					component5.offsetMin = new Vector2(0f, component5.offsetMin.y);
					RemapContainerController component6 = val.GetComponent<RemapContainerController>();
					component6.baseGameKeys = remappableKeys;
					component6.backButton = component;
					component6.legacyButton = component3;
					component6.legacyHolder = val2;
					component6.baseGameKeys.DisableKeys();
					((UnityEvent)component3.onClick).AddListener(new UnityAction(component6.ShowLegacyUi));
					component6.LoadUi();
					Button component7 = ((Component)((Component)__instance).transform.Find("SetDefault")).gameObject.GetComponent<Button>();
					((UnityEventBase)component7.onClick).RemoveAllListeners();
					((UnityEvent)component7.onClick).AddListener(new UnityAction(component6.OnSetToDefault));
					val2.transform.SetAsLastSibling();
					LcInputActionApi.PrefabLoaded = true;
				}
			}

			public static void Postfix(KepRemapPanel __instance)
			{
				LcInputActionApi.LoadIntoUI(__instance);
			}
		}

		[HarmonyPatch(typeof(KepRemapPanel), "OnDisable")]
		public static class UnloadKeybindsUIPatch
		{
			public static void Prefix()
			{
				if (LcInputActionApi.ContainerInstance != null)
				{
					LcInputActionApi.ContainerInstance.baseGameKeys.EnableKeys();
				}
			}
		}
	}
	public static class QuickMenuManagerPatches
	{
		[HarmonyPatch(typeof(QuickMenuManager), "CloseQuickMenu")]
		public static class OpenMenuPerformedPatch
		{
			public static bool Prefix(QuickMenuManager __instance)
			{
				if (LcInputActionApi.RemapContainerVisible() && __instance.isMenuOpen)
				{
					LcInputActionApi.CloseContainerLayer();
					return false;
				}
				return true;
			}
		}
	}
	public static class SettingsOptionPatches
	{
		[HarmonyPatch(typeof(SettingsOption), "SetBindingToCurrentSetting")]
		public static class SetBindingToCurrentSettingPatch
		{
			public static bool Prefix(SettingsOption __instance)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Invalid comparison between Unknown and I4
				//IL_0016: 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_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				if ((int)__instance.optionType != 6)
				{
					return true;
				}
				Enumerator<InputBinding> enumerator = __instance.rebindableAction.action.bindings.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						InputBinding current = enumerator.Current;
						if (__instance.gamepadOnlyRebinding)
						{
							if (!string.Equals(((InputBinding)(ref current)).effectivePath, "<InputUtils-Gamepad-Not-Bound>"))
							{
								continue;
							}
						}
						else if (!string.Equals(((InputBinding)(ref current)).effectivePath, "<InputUtils-Kbm-Not-Bound>"))
						{
							continue;
						}
						((TMP_Text)__instance.currentlyUsedKeyText).SetText("", true);
						return false;
					}
				}
				finally
				{
					((IDisposable)enumerator).Dispose();
				}
				return true;
			}
		}
	}
}
namespace LethalCompanyInputUtils.Glyphs
{
	[CreateAssetMenu]
	public class ControllerGlyph : ScriptableObject
	{
		public List<string> validGamepadTypes = new List<string>();

		public List<GlyphDef> glyphSet = new List<GlyphDef>();

		private readonly Dictionary<string, Sprite?> _glyphLut = new Dictionary<string, Sprite>();

		private static readonly List<ControllerGlyph> Instances = new List<ControllerGlyph>();

		private static bool _loaded;

		public static ControllerGlyph? MouseGlyphs { get; private set; }

		public bool IsCurrent
		{
			get
			{
				Gamepad current = Gamepad.current;
				if (current == null)
				{
					return false;
				}
				return validGamepadTypes.Any((string gamepadTypeName) => string.Equals(gamepadTypeName, ((object)current).GetType().Name));
			}
		}

		public Sprite this[string controlPath]
		{
			get
			{
				if (_glyphLut.Count == 0)
				{
					UpdateLut();
				}
				return _glyphLut.GetValueOrDefault(controlPath, null);
			}
		}

		public static ControllerGlyph? GetBestMatching()
		{
			if (Instances.Count == 0)
			{
				return null;
			}
			foreach (ControllerGlyph instance in Instances)
			{
				if (instance.IsCurrent)
				{
					return instance;
				}
			}
			return Instances[0];
		}

		internal static void LoadGlyphs()
		{
			if (!_loaded)
			{
				Assets.Load<ControllerGlyph>("controller glyphs/xbox series x glyphs.asset");
				Assets.Load<ControllerGlyph>("controller glyphs/dualsense glyphs.asset");
				MouseGlyphs = Assets.Load<ControllerGlyph>("controller glyphs/mouse glyphs.asset");
				_loaded = true;
			}
		}

		private void Awake()
		{
			if (!Instances.Contains(this))
			{
				Instances.Add(this);
			}
		}

		private void UpdateLut()
		{
			foreach (GlyphDef item in glyphSet)
			{
				_glyphLut[item.controlPath] = item.glyphSprite;
			}
		}

		private void OnDestroy()
		{
			if (Instances.Contains(this))
			{
				Instances.Remove(this);
			}
		}
	}
	[CreateAssetMenu]
	public class GlyphDef : ScriptableObject
	{
		public string controlPath = "";

		public Sprite? glyphSprite;
	}
}
namespace LethalCompanyInputUtils.Data
{
	[Serializable]
	public struct BindingOverride
	{
		public string? action;

		public string? origPath;

		public string? path;
	}
	[Serializable]
	public class BindingOverrides
	{
		public List<BindingOverride> overrides;

		private BindingOverrides()
		{
			overrides = new List<BindingOverride>();
		}

		public BindingOverrides(IEnumerable<InputBinding> bindings)
		{
			//IL_001b: 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)
			overrides = new List<BindingOverride>();
			foreach (InputBinding binding in bindings)
			{
				InputBinding current = binding;
				if (((InputBinding)(ref current)).hasOverrides)
				{
					BindingOverride item = new BindingOverride
					{
						action = ((InputBinding)(ref current)).action,
						origPath = ((InputBinding)(ref current)).path,
						path = ((InputBinding)(ref current)).overridePath
					};
					overrides.Add(item);
				}
			}
		}

		public void LoadInto(InputActionAsset asset)
		{
			foreach (BindingOverride @override in overrides)
			{
				InputAction obj = asset.FindAction(@override.action, false);
				if (obj != null)
				{
					InputActionRebindingExtensions.ApplyBindingOverride(obj, @override.path, (string)null, @override.origPath);
				}
			}
		}

		public static BindingOverrides FromJson(string json)
		{
			BindingOverrides bindingOverrides = new BindingOverrides();
			JToken value = JsonConvert.DeserializeObject<JObject>(json).GetValue("overrides");
			bindingOverrides.overrides = value.ToObject<List<BindingOverride>>();
			return bindingOverrides;
		}
	}
}
namespace LethalCompanyInputUtils.Components
{
	[RequireComponent(typeof(RectTransform))]
	public class BindsListController : MonoBehaviour
	{
		public GameObject? sectionHeaderPrefab;

		public GameObject? sectionAnchorPrefab;

		public GameObject? rebindItemPrefab;

		public GameObject? spacerPrefab;

		public ScrollRect? scrollRect;

		public RectTransform? headerContainer;

		public UnityEvent<int> OnSectionChanged = new UnityEvent<int>();

		public static float OffsetCompensation;

		private RectTransform? _rectTransform;

		private RectTransform? _scrollRectTransform;

		private RectTransform? _content;

		private VerticalLayoutGroup? _verticalLayoutGroup;

		private int _currentSection;

		private float _sectionHeight;

		private float _spacing;

		private readonly List<SectionHeaderAnchor> _anchors = new List<SectionHeaderAnchor>();

		private void Awake()
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			if (_rectTransform == null)
			{
				_rectTransform = ((Component)this).GetComponent<RectTransform>();
			}
			if (scrollRect == null)
			{
				scrollRect = ((Component)this).GetComponentInChildren<ScrollRect>();
			}
			if (_verticalLayoutGroup == null)
			{
				_verticalLayoutGroup = ((Component)scrollRect.content).GetComponent<VerticalLayoutGroup>();
			}
			_spacing = ((HorizontalOrVerticalLayoutGroup)_verticalLayoutGroup).spacing;
			if (sectionAnchorPrefab != null && rebindItemPrefab != null && spacerPrefab != null)
			{
				_sectionHeight = sectionAnchorPrefab.GetComponent<RectTransform>().sizeDelta.y;
				_scrollRectTransform = ((Component)scrollRect).GetComponent<RectTransform>();
				_content = scrollRect.content;
				if (headerContainer != null)
				{
					headerContainer.drivenByObject = (Object)(object)this;
					headerContainer.drivenProperties = (DrivenTransformProperties)3840;
					headerContainer.anchorMin = new Vector2(0f, 1f);
					headerContainer.anchorMax = Vector2.one;
					((UnityEvent<Vector2>)(object)scrollRect.onValueChanged).AddListener((UnityAction<Vector2>)OnScroll);
					OnScroll(Vector2.zero);
				}
			}
		}

		private void Start()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			OnScroll(Vector2.zero);
		}

		private void OnEnable()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			OnScroll(Vector2.zero);
		}

		public void JumpTo(int sectionIndex)
		{
			//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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			if (_content == null || scrollRect == null || _scrollRectTransform == null)
			{
				return;
			}
			int count = _anchors.Count;
			if (sectionIndex < count && sectionIndex >= 0)
			{
				Canvas.ForceUpdateCanvases();
				scrollRect.StopMovement();
				if (sectionIndex == 0)
				{
					scrollRect.verticalNormalizedPosition = 1f;
				}
				else
				{
					SectionHeaderAnchor sectionHeaderAnchor = _anchors[sectionIndex];
					float y = Vector2.op_Implicit(((Transform)_scrollRectTransform).InverseTransformPoint(((Transform)_content).position) - ((Transform)_scrollRectTransform).InverseTransformPoint(((Transform)sectionHeaderAnchor.RectTransform).position)).y + _sectionHeight / 2f - _spacing;
					_content.SetAnchoredPosY(y);
				}
				if (_currentSection != sectionIndex)
				{
					OnSectionChanged.Invoke(sectionIndex);
				}
				_currentSection = sectionIndex;
			}
		}

		public void AddSection(string sectionName)
		{
			//IL_0070: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			if (((Behaviour)this).isActiveAndEnabled && sectionHeaderPrefab != null && sectionAnchorPrefab != null && scrollRect != null)
			{
				SectionHeaderAnchor component = Object.Instantiate<GameObject>(sectionAnchorPrefab, (Transform)(object)_content).GetComponent<SectionHeaderAnchor>();
				SectionHeader component2 = Object.Instantiate<GameObject>(sectionHeaderPrefab, (Transform)(object)headerContainer).GetComponent<SectionHeader>();
				RectTransform rectTransform = component2.RectTransform;
				rectTransform.drivenByObject = (Object)(object)this;
				rectTransform.drivenProperties = (DrivenTransformProperties)1286;
				rectTransform.anchorMin = new Vector2(0f, rectTransform.anchorMin.y);
				rectTransform.anchorMax = new Vector2(1f, rectTransform.anchorMax.y);
				component2.anchor = component;
				component.sectionHeader = component2;
				component2.SetText(sectionName);
				OnScroll(Vector2.zero);
				if (_anchors.Count == 0)
				{
					component.RectTransform.sizeDelta = default(Vector2);
				}
				_currentSection = _anchors.Count;
				_anchors.Add(component);
			}
		}

		public void AddBinds(RemappableKey? kbmKey, RemappableKey? gamepadKey, bool isBaseGame = false, string controlName = "")
		{
			if (((Behaviour)this).isActiveAndEnabled && rebindItemPrefab != null && scrollRect != null)
			{
				if (kbmKey != null && string.IsNullOrEmpty(controlName))
				{
					controlName = kbmKey.ControlName;
				}
				else if (gamepadKey != null && string.IsNullOrEmpty(controlName))
				{
					controlName = gamepadKey.ControlName;
				}
				Object.Instantiate<GameObject>(rebindItemPrefab, (Transform)(object)_content).GetComponent<RebindItem>().SetBind(controlName, kbmKey, gamepadKey, isBaseGame);
			}
		}

		public void AddFooter()
		{
			if (((Behaviour)this).isActiveAndEnabled && spacerPrefab != null)
			{
				Object.Instantiate<GameObject>(spacerPrefab, (Transform)(object)_content);
			}
		}

		private void OnScroll(Vector2 delta)
		{
			//IL_00af: 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)
			if (_scrollRectTransform == null || headerContainer == null || _rectTransform == null)
			{
				return;
			}
			float maxY = GetMaxY(headerContainer);
			int num = -1;
			for (int i = 0; i < _anchors.Count; i++)
			{
				SectionHeaderAnchor sectionHeaderAnchor = _anchors[i];
				SectionHeader sectionHeader = sectionHeaderAnchor.sectionHeader;
				if (i == 0)
				{
					sectionHeader.RectTransform.SetLocalPosY(maxY - (_sectionHeight / 2f - _spacing));
					num = i;
					continue;
				}
				SectionHeader sectionHeader2 = _anchors[i - 1].sectionHeader;
				float num2 = CalculateHeaderRawYPos(sectionHeaderAnchor);
				sectionHeader.RectTransform.SetLocalPosY(num2);
				float num3 = GetMaxY(sectionHeader.RectTransform) + ((Transform)sectionHeader.RectTransform).localPosition.y;
				float num4 = GetMinY(sectionHeader2.RectTransform) + ((Transform)sectionHeader2.RectTransform).localPosition.y;
				if (num3 + _sectionHeight / 2f + _spacing >= num4)
				{
					sectionHeader2.RectTransform.SetLocalPosY(num2 + _sectionHeight);
				}
				if (num3 + _spacing / 2f >= maxY - _sectionHeight / 2f)
				{
					num = i;
					sectionHeader.RectTransform.SetLocalPosY(maxY - (_sectionHeight / 2f - _spacing));
				}
			}
			if (_currentSection != num)
			{
				OnSectionChanged.Invoke(num);
			}
			_currentSection = num;
		}

		private float CalculateHeaderRawYPos(SectionHeaderAnchor anchor)
		{
			//IL_0055: 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)
			if (_content == null || headerContainer == null || _scrollRectTransform == null)
			{
				return 0f;
			}
			float num = GetMaxY(headerContainer) - GetMaxY(_scrollRectTransform);
			num += _sectionHeight / 2f;
			num -= OffsetCompensation;
			return ((Transform)anchor.RectTransform).localPosition.y - (num + 50f) + ((Transform)_content).localPosition.y;
		}

		private void OnDrawGizmos()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (_rectTransform != null && headerContainer != null)
			{
				Color color = Gizmos.color;
				_rectTransform.DrawGizmoUiRectWorld();
				Gizmos.color = color;
			}
		}

		private float GetMaxY(RectTransform element)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//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_0022: Unknown result type (might be due to invalid IL or missing references)
			if (_rectTransform == null)
			{
				_rectTransform = ((Component)this).GetComponent<RectTransform>();
			}
			Rect val = element.UiBounds(Vector3.zero);
			return ((Rect)(ref val)).max.y;
		}

		private float GetMinY(RectTransform element)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//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_0022: Unknown result type (might be due to invalid IL or missing references)
			if (_rectTransform == null)
			{
				_rectTransform = ((Component)this).GetComponent<RectTransform>();
			}
			Rect val = element.UiBounds(Vector3.zero);
			return ((Rect)(ref val)).min.y;
		}
	}
	public class RebindButton : MonoBehaviour
	{
		public Selectable? button;

		public TextMeshProUGUI? bindLabel;

		public Image? glyphLabel;

		public Image? notSupportedImage;

		public RebindIndicator? rebindIndicator;

		public Button? resetButton;

		public Button? removeButton;

		public float timeout = 5f;

		private RemappableKey? _key;

		private bool _isBaseGame;

		private RebindingOperation? _rebindingOperation;

		private bool _rebinding;

		private float _timeoutTimer;

		private static MethodInfo? _setChangesNotAppliedMethodInfo;

		private static readonly List<RebindButton> Instances = new List<RebindButton>();

		public void SetKey(RemappableKey? key, bool isBaseGame)
		{
			_key = key;
			_isBaseGame = isBaseGame;
			UpdateState();
		}

		public void UpdateState()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			if (bindLabel == null || glyphLabel == null || button == null || notSupportedImage == null || resetButton == null || removeButton == null)
			{
				return;
			}
			if (_key == null)
			{
				SetAsUnsupported();
				return;
			}
			int rebindingIndex = GetRebindingIndex();
			InputAction action = _key.currentInput.action;
			if (rebindingIndex >= action.bindings.Count)
			{
				SetAsUnsupported();
				return;
			}
			GameObject gameObject = ((Component)resetButton).gameObject;
			InputBinding val = action.bindings[rebindingIndex];
			gameObject.SetActive(((InputBinding)(ref val)).hasOverrides);
			val = action.bindings[rebindingIndex];
			string effectivePath = ((InputBinding)(ref val)).effectivePath;
			string bindPath = InputControlPath.ToHumanReadableString(effectivePath, (HumanReadableStringOptions)2, (InputControl)null);
			if (_key.gamepadOnly)
			{
				((TMP_Text)bindLabel).SetText("", true);
				if (effectivePath == "<InputUtils-Gamepad-Not-Bound>")
				{
					((Component)removeButton).gameObject.SetActive(false);
					((Behaviour)glyphLabel).enabled = false;
					return;
				}
				((Component)removeButton).gameObject.SetActive(true);
				ControllerGlyph bestMatching = ControllerGlyph.GetBestMatching();
				if (bestMatching == null)
				{
					((TMP_Text)bindLabel).SetText(effectivePath, true);
					((Behaviour)glyphLabel).enabled = false;
					return;
				}
				Sprite val2 = bestMatching[effectivePath];
				if (val2 == null)
				{
					((TMP_Text)bindLabel).SetText(effectivePath, true);
					((Behaviour)glyphLabel).enabled = false;
				}
				else
				{
					glyphLabel.sprite = val2;
					((Behaviour)glyphLabel).enabled = true;
				}
			}
			else
			{
				((Component)removeButton).gameObject.SetActive(!string.Equals(effectivePath, "<InputUtils-Kbm-Not-Bound>"));
				HandleKbmGlyphOrLabel(effectivePath, bindPath);
			}
		}

		private void HandleKbmGlyphOrLabel(string effectivePath, string bindPath)
		{
			if (bindLabel == null || glyphLabel == null)
			{
				return;
			}
			if (ControllerGlyph.MouseGlyphs != null)
			{
				Sprite val = ControllerGlyph.MouseGlyphs[effectivePath];
				if (val != null)
				{
					((TMP_Text)bindLabel).SetText("", true);
					glyphLabel.sprite = val;
					((Behaviour)glyphLabel).enabled = true;
					return;
				}
			}
			((Behaviour)glyphLabel).enabled = false;
			((TMP_Text)bindLabel).SetText(bindPath, true);
		}

		private void SetAsUnsupported()
		{
			if (button != null && bindLabel != null && glyphLabel != null && notSupportedImage != null && resetButton != null && removeButton != null)
			{
				button.interactable = false;
				button.targetGraphic.raycastTarget = false;
				((Behaviour)button.targetGraphic).enabled = false;
				((TMP_Text)bindLabel).SetText("", true);
				((Behaviour)glyphLabel).enabled = false;
				((Component)notSupportedImage).gameObject.SetActive(true);
				((Component)resetButton).gameObject.SetActive(false);
				((Component)removeButton).gameObject.SetActive(false);
			}
		}

		private int GetRebindingIndex()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (_key == null)
			{
				return -1;
			}
			InputAction action = _key.currentInput.action;
			if (action.controls.Count == 0)
			{
				if (action.bindings.Count == 0)
				{
					return -1;
				}
				if (_key.gamepadOnly && action.bindings.Count > 1)
				{
					return 1;
				}
				return 0;
			}
			if (_key.rebindingIndex >= 0)
			{
				return _key.rebindingIndex;
			}
			return InputActionRebindingExtensions.GetBindingIndexForControl(action, action.controls[0]);
		}

		public void StartRebinding()
		{
			if (_key != null && bindLabel != null && glyphLabel != null && rebindIndicator != null && resetButton != null && removeButton != null)
			{
				int rebindingIndex = GetRebindingIndex();
				((Selectable)resetButton).interactable = false;
				((Selectable)removeButton).interactable = false;
				((Behaviour)glyphLabel).enabled = false;
				if (_key.gamepadOnly)
				{
					((Behaviour)rebindIndicator).enabled = true;
					RebindGamepad(_key.currentInput, rebindingIndex);
				}
				else
				{
					((TMP_Text)bindLabel).SetText("", true);
					((Behaviour)rebindIndicator).enabled = true;
					RebindKbm(_key.currentInput, rebindingIndex);
				}
				_timeoutTimer = timeout;
				_rebinding = true;
			}
		}

		private void FinishRebinding()
		{
			if (_key != null && rebindIndicator != null && resetButton != null && removeButton != null)
			{
				((Behaviour)rebindIndicator).enabled = false;
				_rebinding = false;
				if (_rebindingOperation != null)
				{
					_rebindingOperation = null;
				}
				((Selectable)resetButton).interactable = true;
				((Selectable)removeButton).interactable = true;
				UpdateState();
			}
		}

		public void ResetToDefault()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//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)
			FinishRebinding();
			if (_key == null)
			{
				return;
			}
			int rebindingIndex = GetRebindingIndex();
			InputAction action = _key.currentInput.action;
			InputBinding val = action.bindings[rebindingIndex];
			if (((InputBinding)(ref val)).hasOverrides)
			{
				InputActionRebindingExtensions.RemoveBindingOverride(action, rebindingIndex);
				if (_isBaseGame)
				{
					BaseGameUnsavedChanges();
				}
				MarkSettingsAsDirty();
				UpdateState();
			}
		}

		public void RemoveBind()
		{
			FinishRebinding();
			if (_key != null)
			{
				int rebindingIndex = GetRebindingIndex();
				InputActionRebindingExtensions.ApplyBindingOverride(_key.currentInput.action, rebindingIndex, _key.gamepadOnly ? "<InputUtils-Gamepad-Not-Bound>" : "<InputUtils-Kbm-Not-Bound>");
				if (_isBaseGame)
				{
					BaseGameUnsavedChanges();
				}
				MarkSettingsAsDirty();
				UpdateState();
			}
		}

		private void OnEnable()
		{
			Instances.Add(this);
			if (_key != null)
			{
				UpdateState();
			}
		}

		private void OnDisable()
		{
			FinishRebinding();
			Instances.Remove(this);
		}

		private void Update()
		{
			if (!_rebinding)
			{
				return;
			}
			_timeoutTimer -= Time.deltaTime;
			if (!(_timeoutTimer > 0f))
			{
				if (_rebindingOperation == null)
				{
					FinishRebinding();
					return;
				}
				_rebindingOperation.Cancel();
				FinishRebinding();
			}
		}

		private void RebindKbm(InputActionReference inputActionRef, int rebindIndex)
		{
			_rebindingOperation = InputActionRebindingExtensions.PerformInteractiveRebinding(inputActionRef.action, rebindIndex).OnMatchWaitForAnother(0.1f).WithControlsHavingToMatchPath("<Keyboard>")
				.WithControlsHavingToMatchPath("<Mouse>")
				.WithControlsHavingToMatchPath("<InputUtilsExtendedMouse>")
				.WithControlsExcluding("<Mouse>/scroll/y")
				.WithControlsExcluding("<Mouse>/scroll/x")
				.WithCancelingThrough("<Keyboard>/escape")
				.OnComplete((Action<RebindingOperation>)delegate(RebindingOperation operation)
				{
					OnRebindComplete(operation, this);
				})
				.OnCancel((Action<RebindingOperation>)delegate
				{
					FinishRebinding();
				})
				.Start();
		}

		private void RebindGamepad(InputActionReference inputActionRef, int rebindIndex)
		{
			_rebindingOperation = InputActionRebindingExtensions.PerformInteractiveRebinding(inputActionRef.action, rebindIndex).OnMatchWaitForAnother(0.1f).WithControlsHavingToMatchPath("<Gamepad>")
				.OnComplete((Action<RebindingOperation>)delegate(RebindingOperation operation)
				{
					OnRebindComplete(operation, this);
				})
				.Start();
		}

		private static void OnRebindComplete(RebindingOperation operation, RebindButton instance)
		{
			if (operation.completed)
			{
				if (instance._isBaseGame)
				{
					BaseGameUnsavedChanges();
				}
				MarkSettingsAsDirty();
				instance.FinishRebinding();
			}
		}

		private static void BaseGameUnsavedChanges()
		{
			IngamePlayerSettings.Instance.unsavedSettings.keyBindings = InputActionRebindingExtensions.SaveBindingOverridesAsJson((IInputActionCollection2)(object)IngamePlayerSettings.Instance.playerInput.actions);
		}

		private static void MarkSettingsAsDirty()
		{
			if ((object)_setChangesNotAppliedMethodInfo == null)
			{
				_setChangesNotAppliedMethodInfo = AccessTools.Method(typeof(IngamePlayerSettings), "SetChangesNotAppliedTextVisible", (Type[])null, (Type[])null);
			}
			_setChangesNotAppliedMethodInfo.Invoke(IngamePlayerSettings.Instance, new object[1] { true });
		}

		public static void ReloadGlyphs()
		{
			foreach (RebindButton instance in Instances)
			{
				instance.UpdateState();
			}
		}

		public static void ResetAllToDefaults()
		{
			foreach (RebindButton instance in Instances)
			{
				instance.ResetToDefault();
			}
		}
	}
	public class RebindIndicator : MonoBehaviour
	{
		public TextMeshProUGUI? label;

		public int maxTicks = 5;

		public float timeBetweenTicks = 1f;

		private int _ticks = 1;

		private float _timer;

		private void OnEnable()
		{
			_ticks = 1;
			_timer = timeBetweenTicks;
			((TMP_Text)label).SetText(GetText(), true);
		}

		private void OnDisable()
		{
			_ticks = 1;
			_timer = timeBetweenTicks;
			((TMP_Text)label).SetText("", true);
		}

		private void Update()
		{
			_timer -= Time.unscaledDeltaTime;
			if (!(_timer > 0f))
			{
				_ticks++;
				if (_ticks > maxTicks)
				{
					_ticks = 1;
				}
				((TMP_Text)label).SetText(GetText(), true);
				_timer = timeBetweenTicks;
			}
		}

		private string GetText()
		{
			string text = "";
			for (int i = 0; i < _ticks; i++)
			{
				text += ".";
			}
			return text;
		}
	}
	public class RebindItem : MonoBehaviour
	{
		public TextMeshProUGUI? controlNameLabel;

		public RebindButton? kbmButton;

		public RebindButton? gamepadButton;

		public void SetBind(string controlName, RemappableKey? kbmKey, RemappableKey? gamepadKey, bool isBaseGame = false)
		{
			if (controlNameLabel != null)
			{
				((TMP_Text)controlNameLabel).SetText(controlName, true);
				if (kbmButton != null)
				{
					kbmButton.SetKey(kbmKey, isBaseGame);
				}
				if (gamepadButton != null)
				{
					gamepadButton.SetKey(gamepadKey, isBaseGame);
				}
			}
		}
	}
	public class RemapContainerController : MonoBehaviour
	{
		public BindsListController? bindsList;

		public SectionListController? sectionList;

		public Button? backButton;

		public Button? legacyButton;

		public GameObject? legacyHolder;

		public List<RemappableKey> baseGameKeys = new List<RemappableKey>();

		internal int LayerShown;

		private void Awake()
		{
			if (bindsList == null)
			{
				bindsList = ((Component)this).GetComponentInChildren<BindsListController>();
			}
			if (sectionList == null)
			{
				sectionList = ((Component)this).GetComponentInChildren<SectionListController>();
			}
			bindsList.OnSectionChanged.AddListener((UnityAction<int>)HandleSectionChanged);
			LcInputActionApi.ContainerInstance = this;
		}

		public void JumpTo(int sectionIndex)
		{
			if (bindsList != null)
			{
				bindsList.JumpTo(sectionIndex);
			}
		}

		public void LoadUi()
		{
			GenerateBaseGameSection();
			GenerateApiSections();
			FinishUi();
		}

		private void GenerateBaseGameSection()
		{
			if (bindsList == null || sectionList == null)
			{
				return;
			}
			Dictionary<string, (RemappableKey, RemappableKey)> dictionary = new Dictionary<string, (RemappableKey, RemappableKey)>();
			string key;
			foreach (RemappableKey baseGameKey in baseGameKeys)
			{
				RemappableKey item = null;
				RemappableKey item2 = null;
				string text = baseGameKey.ControlName.ToLower();
				if (text.StartsWith("walk"))
				{
					key = text;
					text = "move" + key.Substring(4, key.Length - 4);
				}
				baseGameKey.ControlName = baseGameKey.ControlName.Replace("primary", "Primary");
				if (dictionary.TryGetValue(text, out var value))
				{
					if (baseGameKey.gamepadOnly)
					{
						(item, _) = value;
					}
					else
					{
						item2 = value.Item2;
					}
				}
				if (baseGameKey.gamepadOnly)
				{
					item2 = baseGameKey;
				}
				else
				{
					item = baseGameKey;
				}
				dictionary[text] = (item, item2);
			}
			bindsList.AddSection("Lethal Company");
			sectionList.AddSection("Lethal Company");
			foreach (KeyValuePair<string, (RemappableKey, RemappableKey)> item3 in dictionary)
			{
				item3.Deconstruct(out key, out var value2);
				var (kbmKey, gamepadKey) = value2;
				bindsList.AddBinds(kbmKey, gamepadKey, isBaseGame: true);
			}
		}

		public void OnSetToDefault()
		{
			RebindButton.ResetAllToDefaults();
		}

		public void HideHighestLayer()
		{
			if (backButton != null && legacyHolder != null)
			{
				if (LayerShown > 1)
				{
					legacyHolder.SetActive(false);
					LayerShown--;
				}
				else if (LayerShown > 0)
				{
					((UnityEvent)backButton.onClick).Invoke();
				}
			}
		}

		public void ShowLegacyUi()
		{
			if (((Behaviour)this).isActiveAndEnabled && legacyHolder != null)
			{
				legacyHolder.SetActive(true);
				LayerShown++;
			}
		}

		private void GenerateApiSections()
		{
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Expected O, but got Unknown
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Expected O, but got Unknown
			if (bindsList == null || sectionList == null)
			{
				return;
			}
			foreach (IGrouping<string, LcInputActions> item in from lc in LcInputActionApi.InputActions
				group lc by lc.Plugin.Name)
			{
				bindsList.AddSection(item.Key);
				sectionList.AddSection(item.Key);
				foreach (LcInputActions item2 in item)
				{
					if (item2.Loaded)
					{
						continue;
					}
					foreach (InputActionReference actionRef in item2.ActionRefs)
					{
						InputAction action = actionRef.action;
						InputBinding val = ((IEnumerable<InputBinding>)(object)action.bindings).First();
						string name = ((InputBinding)(ref val)).name;
						RemappableKey kbmKey = new RemappableKey
						{
							ControlName = name,
							currentInput = actionRef,
							rebindingIndex = 0,
							gamepadOnly = false
						};
						RemappableKey val2 = new RemappableKey
						{
							ControlName = name,
							currentInput = actionRef,
							rebindingIndex = 1,
							gamepadOnly = true
						};
						if (action.IsGamepadOnly())
						{
							val2.rebindingIndex = 0;
							bindsList.AddBinds(null, val2);
						}
						else
						{
							bindsList.AddBinds(kbmKey, val2);
						}
					}
					item2.Loaded = true;
				}
			}
		}

		private void FinishUi()
		{
			if (bindsList != null)
			{
				bindsList.AddFooter();
				JumpTo(0);
			}
		}

		private void HandleSectionChanged(int sectionIndex)
		{
			if (sectionList != null && bindsList != null)
			{
				sectionList.SelectSection(sectionIndex);
			}
		}

		private void OnEnable()
		{
			JumpTo(0);
			LayerShown = 1;
		}

		private void OnDisable()
		{
			LcInputActionApi.ReEnableFromRebind();
			LayerShown = 0;
		}

		private void OnDestroy()
		{
			LcInputActionApi.ContainerInstance = null;
			LayerShown = 0;
		}
	}
}
namespace LethalCompanyInputUtils.Components.Section
{
	[RequireComponent(typeof(Button), typeof(RectTransform))]
	public class SectionEntry : MonoBehaviour
	{
		public TextMeshProUGUI? indicator;

		public TextMeshProUGUI? label;

		public Button? button;

		public int sectionIndex;

		public UnityEvent<int> OnEntrySelected = new UnityEvent<int>();

		private RectTransform? _rectTransform;

		public RectTransform RectTransform
		{
			get
			{
				if (_rectTransform == null)
				{
					_rectTransform = ((Component)this).GetComponent<RectTransform>();
				}
				return _rectTransform;
			}
		}

		private void Awake()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			if (button == null)
			{
				button = ((Component)this).GetComponent<Button>();
			}
			((UnityEvent)button.onClick).AddListener(new UnityAction(SelectEntry));
		}

		public void SetText(string text)
		{
			if (label != null)
			{
				((TMP_Text)label).SetText(text, true);
			}
		}

		public void SetIndicator(bool indicated)
		{
			if (indicator != null)
			{
				((Behaviour)indicator).enabled = indicated;
			}
		}

		private void SelectEntry()
		{
			OnEntrySelected.Invoke(sectionIndex);
		}
	}
	[RequireComponent(typeof(RectTransform))]
	public class SectionHeader : MonoBehaviour
	{
		public SectionHeaderAnchor? anchor;

		public TextMeshProUGUI? label;

		private RectTransform? _rectTransform;

		public RectTransform RectTransform
		{
			get
			{
				if (_rectTransform == null)
				{
					_rectTransform = ((Component)this).GetComponent<RectTransform>();
				}
				return _rectTransform;
			}
		}

		public void SetText(string text)
		{
			if (label != null)
			{
				((TMP_Text)label).SetText(text, true);
			}
		}
	}
	[RequireComponent(typeof(RectTransform))]
	public class SectionHeaderAnchor : MonoBehaviour
	{
		public SectionHeader? sectionHeader;

		private RectTransform? _rectTransform;

		public RectTransform RectTransform
		{
			get
			{
				if (_rectTransform == null)
				{
					_rectTransform = ((Component)this).GetComponent<RectTransform>();
				}
				return _rectTransform;
			}
		}

		private void Awake()
		{
			if (_rectTransform == null)
			{
				_rectTransform = ((Component)this).GetComponent<RectTransform>();
			}
		}
	}
	public class SectionListController : MonoBehaviour
	{
		public GameObject? sectionEntryPrefab;

		public ScrollRect? scrollRect;

		public RemapContainerController? remapContainer;

		private RectTransform? _viewport;

		private RectTransform? _content;

		private readonly List<SectionEntry> _sectionEntries = new List<SectionEntry>();

		private void Awake()
		{
			if (remapContainer == null)
			{
				remapContainer = ((Component)this).GetComponentInParent<RemapContainerController>();
			}
			if (scrollRect == null)
			{
				scrollRect = ((Component)this).GetComponentInChildren<ScrollRect>();
			}
			_viewport = scrollRect.viewport;
			_content = scrollRect.content;
		}

		public void AddSection(string sectionName)
		{
			if (_content != null && sectionEntryPrefab != null)
			{
				SectionEntry component = Object.Instantiate<GameObject>(sectionEntryPrefab, (Transform)(object)_content).GetComponent<SectionEntry>();
				component.SetText(sectionName);
				component.sectionIndex = _sectionEntries.Count;
				component.OnEntrySelected.AddListener((UnityAction<int>)OnSectionEntryPressed);
				_sectionEntries.Add(component);
			}
		}

		public void SelectSection(int sectionIndex)
		{
			int count = _sectionEntries.Count;
			if (sectionIndex >= count || sectionIndex < 0)
			{
				return;
			}
			foreach (SectionEntry sectionEntry2 in _sectionEntries)
			{
				sectionEntry2.SetIndicator(indicated: false);
			}
			SectionEntry sectionEntry = _sectionEntries[sectionIndex];
			sectionEntry.SetIndicator(indicated: true);
			if (scrollRect != null)
			{
				UpdateScrollPosToFit(sectionEntry);
			}
		}

		private void UpdateScrollPosToFit(SectionEntry sectionEntry)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			if (_viewport == null || _content == null || scrollRect == null)
			{
				return;
			}
			RectTransform rectTransform = sectionEntry.RectTransform;
			float num = rectTransform.WorldMinY();
			float num2 = rectTransform.WorldMaxY();
			float num3 = _viewport.WorldMinY();
			float num4 = _viewport.WorldMaxY();
			if (!(num > num3) || !(num2 < num4))
			{
				scrollRect.StopMovement();
				float num5 = 0f;
				if (num2 > num4)
				{
					num5 = num4 - num2 - rectTransform.sizeDelta.y;
				}
				else if (num < num3)
				{
					num5 = num3 - num + rectTransform.sizeDelta.y;
				}
				float y = _content.anchoredPosition.y;
				_content.SetAnchoredPosY(y + num5);
			}
		}

		private void OnSectionEntryPressed(int sectionIndex)
		{
			if (remapContainer != null)
			{
				remapContainer.JumpTo(sectionIndex);
			}
		}
	}
}
namespace LethalCompanyInputUtils.Components.PopOvers
{
	[RequireComponent(typeof(RectTransform))]
	public class PopOver : MonoBehaviour
	{
		public enum Placement
		{
			Top,
			Bottom,
			Left,
			Right
		}

		public RectTransform? popOverLayer;

		public PopOverTextContainer? textContainer;

		public RectTransform? pivotPoint;

		public GameObject? background;

		public PopOverArrow? arrow;

		public CanvasGroup? canvasGroup;

		public float maxWidth = 300f;

		private RectTransform? _rectTransform;

		private RectTransform? _target;

		private Placement _placement;

		public void SetTarget(RectTransform target, Placement placement)
		{
			if (background != null && canvasGroup != null)
			{
				background.SetActive(true);
				_target = target;
				_placement = placement;
				SetPivot();
				SetArrow();
			}
		}

		public void ClearTarget()
		{
			if (background != null && canvasGroup != null)
			{
				canvasGroup.alpha = 0f;
				_target = null;
				background.SetActive(false);
			}
		}

		private void MoveTo(RectTransform target)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_0035: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			if (pivotPoint != null)
			{
				Vector3 val = Vector2.op_Implicit(GetTargetPosition(target));
				Vector3 val2 = Vector2.op_Implicit(GetTargetPivotOffset(target));
				Vector3 val3 = Vector2.op_Implicit(GetLabelPivotOffset());
				Vector3 targetPos = val + val2 + val3;
				MovePopOverToTarget(targetPos);
				AdjustArrowPosToTarget(target);
			}
		}

		private void SetPivot()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			if (pivotPoint != null)
			{
				RectTransform val = pivotPoint;
				val.pivot = (Vector2)(_placement switch
				{
					Placement.Top => new Vector2(0.5f, 0f), 
					Placement.Bottom => new Vector2(0.5f, 1f), 
					Placement.Left => new Vector2(1f, 0.5f), 
					Placement.Right => new Vector2(0f, 0.5f), 
					_ => throw new ArgumentOutOfRangeException(), 
				});
			}
		}

		private void SetArrow()
		{
			if (arrow != null)
			{
				switch (_placement)
				{
				case Placement.Top:
					arrow.PointToBottom();
					break;
				case Placement.Bottom:
					arrow.PointToTop();
					break;
				case Placement.Left:
					arrow.PointToRight();
					break;
				case Placement.Right:
					arrow.PointToLeft();
					break;
				default:
					throw new ArgumentOutOfRangeException();
				}
			}
		}

		private Vector2 GetTargetPosition(RectTransform target)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if (popOverLayer == null)
			{
				return Vector2.zero;
			}
			return popOverLayer.WorldToLocalPoint(target);
		}

		private Vector2 GetTargetPivotOffset(RectTransform target)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			if (popOverLayer == null)
			{
				return Vector2.zero;
			}
			Rect relativeRect = popOverLayer.GetRelativeRect(target);
			return (Vector2)(_placement switch
			{
				Placement.Top => new Vector2(0f, 2f + ((Rect)(ref relativeRect)).height / 2f), 
				Placement.Bottom => new Vector2(0f, -2f + (0f - ((Rect)(ref relativeRect)).height) / 2f), 
				Placement.Left => new Vector2(-2f + (0f - ((Rect)(ref relativeRect)).width) / 2f, 0f), 
				Placement.Right => new Vector2(2f + ((Rect)(ref relativeRect)).width / 2f, 0f), 
				_ => throw new ArgumentOutOfRangeException(), 
			});
		}

		private Vector2 GetLabelPivotOffset()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0053: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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)
			//IL_00da: 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_0106: Unknown result type (might be due to invalid IL or missing references)
			if (textContainer == null || textContainer.rectTransform == null || _rectTransform == null || popOverLayer == null)
			{
				return Vector2.zero;
			}
			Rect relativeRect = popOverLayer.GetRelativeRect(_rectTransform);
			Rect relativeRect2 = popOverLayer.GetRelativeRect(textContainer.rectTransform);
			return (Vector2)(_placement switch
			{
				Placement.Top => new Vector2(0f, 0f - (((Rect)(ref relativeRect)).height - ((Rect)(ref relativeRect2)).height) / 2f), 
				Placement.Bottom => new Vector2(0f, (((Rect)(ref relativeRect)).height - ((Rect)(ref relativeRect2)).height) / 2f), 
				Placement.Left => new Vector2((((Rect)(ref relativeRect)).width - ((Rect)(ref relativeRect2)).width) / 2f, 0f), 
				Placement.Right => new Vector2(0f - (((Rect)(ref relativeRect)).width - ((Rect)(ref relativeRect2)).width) / 2f, 0f), 
				_ => throw new ArgumentOutOfRangeException(), 
			});
		}

		private void MovePopOverToTarget(Vector3 targetPos)
		{
			//IL_001f: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//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_0039: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0064: Unknown result type (might be due to invalid 

plugins/LethalConfig/LethalConfig.dll

Decompiled 9 months ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalConfig.AutoConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using LethalConfig.Mods;
using LethalConfig.MonoBehaviours;
using LethalConfig.MonoBehaviours.Components;
using LethalConfig.MonoBehaviours.Managers;
using LethalConfig.Settings;
using LethalConfig.Utils;
using Newtonsoft.Json;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

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

		public byte[] TypesData;

		public int TotalTypes;

		public int TotalFiles;

		public bool IsEditorOnly;
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	private static MonoScriptData Get()
	{
		MonoScriptData result = default(MonoScriptData);
		result.FilePathsData = new byte[3641]
		{
			0, 0, 0, 2, 0, 0, 0, 49, 92, 65,
			115, 115, 101, 116, 115, 92, 83, 99, 114, 105,
			112, 116, 115, 92, 65, 117, 116, 111, 67, 111,
			110, 102, 105, 103, 92, 65, 117, 116, 111, 67,
			111, 110, 102, 105, 103, 71, 101, 110, 101, 114,
			97, 116, 111, 114, 46, 99, 115, 0, 0, 0,
			1, 0, 0, 0, 45, 92, 65, 115, 115, 101,
			116, 115, 92, 83, 99, 114, 105, 112, 116, 115,
			92, 65, 117, 116, 111, 67, 111, 110, 102, 105,
			103, 92, 67, 111, 110, 102, 105, 103, 69, 110,
			116, 114, 121, 80, 97, 116, 104, 46, 99, 115,
			0, 0, 0, 2, 0, 0, 0, 45, 92, 65,
			115, 115, 101, 116, 115, 92, 83, 99, 114, 105,
			112, 116, 115, 92, 67, 111, 110, 102, 105, 103,
			73, 116, 101, 109, 115, 92, 66, 97, 115, 101,
			67, 111, 110, 102, 105, 103, 73, 116, 101, 109,
			46, 99, 115, 0, 0, 0, 1, 0, 0, 0,
			53, 92, 65, 115, 115, 101, 116, 115, 92, 83,
			99, 114, 105, 112, 116, 115, 92, 67, 111, 110,
			102, 105, 103, 73, 116, 101, 109, 115, 92, 66,
			111, 111, 108, 67, 104, 101, 99, 107, 66, 111,
			120, 67, 111, 110, 102, 105, 103, 73, 116, 101,
			109, 46, 99, 115, 0, 0, 0, 1, 0, 0,
			0, 53, 92, 65, 115, 115, 101, 116, 115, 92,
			83, 99, 114, 105, 112, 116, 115, 92, 67, 111,
			110, 102, 105, 103, 73, 116, 101, 109, 115, 92,
			69, 110, 117, 109, 68, 114, 111, 112, 68, 111,
			119, 110, 67, 111, 110, 102, 105, 103, 73, 116,
			101, 109, 46, 99, 115, 0, 0, 0, 1, 0,
			0, 0, 56, 92, 65, 115, 115, 101, 116, 115,
			92, 83, 99, 114, 105, 112, 116, 115, 92, 67,
			111, 110, 102, 105, 103, 73, 116, 101, 109, 115,
			92, 70, 108, 111, 97, 116, 73, 110, 112, 117,
			116, 70, 105, 101, 108, 100, 67, 111, 110, 102,
			105, 103, 73, 116, 101, 109, 46, 99, 115, 0,
			0, 0, 1, 0, 0, 0, 52, 92, 65, 115,
			115, 101, 116, 115, 92, 83, 99, 114, 105, 112,
			116, 115, 92, 67, 111, 110, 102, 105, 103, 73,
			116, 101, 109, 115, 92, 70, 108, 111, 97, 116,
			83, 108, 105, 100, 101, 114, 67, 111, 110, 102,
			105, 103, 73, 116, 101, 109, 46, 99, 115, 0,
			0, 0, 1, 0, 0, 0, 56, 92, 65, 115,
			115, 101, 116, 115, 92, 83, 99, 114, 105, 112,
			116, 115, 92, 67, 111, 110, 102, 105, 103, 73,
			116, 101, 109, 115, 92, 70, 108, 111, 97, 116,
			83, 116, 101, 112, 83, 108, 105, 100, 101, 114,
			67, 111, 110, 102, 105, 103, 73, 116, 101, 109,
			46, 99, 115, 0, 0, 0, 1, 0, 0, 0,
			54, 92, 65, 115, 115, 101, 116, 115, 92, 83,
			99, 114, 105, 112, 116, 115, 92, 67, 111, 110,
			102, 105, 103, 73, 116, 101, 109, 115, 92, 71,
			101, 110, 101, 114, 105, 99, 66, 117, 116, 116,
			111, 110, 67, 111, 110, 102, 105, 103, 73, 116,
			101, 109, 46, 99, 115, 0, 0, 0, 1, 0,
			0, 0, 54, 92, 65, 115, 115, 101, 116, 115,
			92, 83, 99, 114, 105, 112, 116, 115, 92, 67,
			111, 110, 102, 105, 103, 73, 116, 101, 109, 115,
			92, 73, 110, 116, 73, 110, 112, 117, 116, 70,
			105, 101, 108, 100, 67, 111, 110, 102, 105, 103,
			73, 116, 101, 109, 46, 99, 115, 0, 0, 0,
			1, 0, 0, 0, 50, 92, 65, 115, 115, 101,
			116, 115, 92, 83, 99, 114, 105, 112, 116, 115,
			92, 67, 111, 110, 102, 105, 103, 73, 116, 101,
			109, 115, 92, 73, 110, 116, 83, 108, 105, 100,
			101, 114, 67, 111, 110, 102, 105, 103, 73, 116,
			101, 109, 46, 99, 115, 0, 0, 0, 1, 0,
			0, 0, 50, 92, 65, 115, 115, 101, 116, 115,
			92, 83, 99, 114, 105, 112, 116, 115, 92, 67,
			111, 110, 102, 105, 103, 73, 116, 101, 109, 115,
			92, 79, 112, 116, 105, 111, 110, 115, 92, 66,
			97, 115, 101, 79, 112, 116, 105, 111, 110, 115,
			46, 99, 115, 0, 0, 0, 1, 0, 0, 0,
			55, 92, 65, 115, 115, 101, 116, 115, 92, 83,
			99, 114, 105, 112, 116, 115, 92, 67, 111, 110,
			102, 105, 103, 73, 116, 101, 109, 115, 92, 79,
			112, 116, 105, 111, 110, 115, 92, 66, 97, 115,
			101, 82, 97, 110, 103, 101, 79, 112, 116, 105,
			111, 110, 115, 46, 99, 115, 0, 0, 0, 1,
			0, 0, 0, 58, 92, 65, 115, 115, 101, 116,
			115, 92, 83, 99, 114, 105, 112, 116, 115, 92,
			67, 111, 110, 102, 105, 103, 73, 116, 101, 109,
			115, 92, 79, 112, 116, 105, 111, 110, 115, 92,
			66, 111, 111, 108, 67, 104, 101, 99, 107, 66,
			111, 120, 79, 112, 116, 105, 111, 110, 115, 46,
			99, 115, 0, 0, 0, 1, 0, 0, 0, 54,
			92, 65, 115, 115, 101, 116, 115, 92, 83, 99,
			114, 105, 112, 116, 115, 92, 67, 111, 110, 102,
			105, 103, 73, 116, 101, 109, 115, 92, 79, 112,
			116, 105, 111, 110, 115, 92, 67, 97, 110, 77,
			111, 100, 105, 102, 121, 82, 101, 115, 117, 108,
			116, 46, 99, 115, 0, 0, 0, 1, 0, 0,
			0, 58, 92, 65, 115, 115, 101, 116, 115, 92,
			83, 99, 114, 105, 112, 116, 115, 92, 67, 111,
			110, 102, 105, 103, 73, 116, 101, 109, 115, 92,
			79, 112, 116, 105, 111, 110, 115, 92, 69, 110,
			117, 109, 68, 114, 111, 112, 68, 111, 119, 110,
			79, 112, 116, 105, 111, 110, 115, 46, 99, 115,
			0, 0, 0, 1, 0, 0, 0, 61, 92, 65,
			115, 115, 101, 116, 115, 92, 83, 99, 114, 105,
			112, 116, 115, 92, 67, 111, 110, 102, 105, 103,
			73, 116, 101, 109, 115, 92, 79, 112, 116, 105,
			111, 110, 115, 92, 70, 108, 111, 97, 116, 73,
			110, 112, 117, 116, 70, 105, 101, 108, 100, 79,
			112, 116, 105, 111, 110, 115, 46, 99, 115, 0,
			0, 0, 1, 0, 0, 0, 57, 92, 65, 115,
			115, 101, 116, 115, 92, 83, 99, 114, 105, 112,
			116, 115, 92, 67, 111, 110, 102, 105, 103, 73,
			116, 101, 109, 115, 92, 79, 112, 116, 105, 111,
			110, 115, 92, 70, 108, 111, 97, 116, 83, 108,
			105, 100, 101, 114, 79, 112, 116, 105, 111, 110,
			115, 46, 99, 115, 0, 0, 0, 1, 0, 0,
			0, 61, 92, 65, 115, 115, 101, 116, 115, 92,
			83, 99, 114, 105, 112, 116, 115, 92, 67, 111,
			110, 102, 105, 103, 73, 116, 101, 109, 115, 92,
			79, 112, 116, 105, 111, 110, 115, 92, 70, 108,
			111, 97, 116, 83, 116, 101, 112, 83, 108, 105,
			100, 101, 114, 79, 112, 116, 105, 111, 110, 115,
			46, 99, 115, 0, 0, 0, 1, 0, 0, 0,
			59, 92, 65, 115, 115, 101, 116, 115, 92, 83,
			99, 114, 105, 112, 116, 115, 92, 67, 111, 110,
			102, 105, 103, 73, 116, 101, 109, 115, 92, 79,
			112, 116, 105, 111, 110, 115, 92, 71, 101, 110,
			101, 114, 105, 99, 66, 117, 116, 116, 111, 110,
			79, 112, 116, 105, 111, 110, 115, 46, 99, 115,
			0, 0, 0, 1, 0, 0, 0, 59, 92, 65,
			115, 115, 101, 116, 115, 92, 83, 99, 114, 105,
			112, 116, 115, 92, 67, 111, 110, 102, 105, 103,
			73, 116, 101, 109, 115, 92, 79, 112, 116, 105,
			111, 110, 115, 92, 73, 110, 116, 73, 110, 112,
			117, 116, 70, 105, 101, 108, 100, 79, 112, 116,
			105, 111, 110, 115, 46, 99, 115, 0, 0, 0,
			1, 0, 0, 0, 55, 92, 65, 115, 115, 101,
			116, 115, 92, 83, 99, 114, 105, 112, 116, 115,
			92, 67, 111, 110, 102, 105, 103, 73, 116, 101,
			109, 115, 92, 79, 112, 116, 105, 111, 110, 115,
			92, 73, 110, 116, 83, 108, 105, 100, 101, 114,
			79, 112, 116, 105, 111, 110, 115, 46, 99, 115,
			0, 0, 0, 1, 0, 0, 0, 60, 92, 65,
			115, 115, 101, 116, 115, 92, 83, 99, 114, 105,
			112, 116, 115, 92, 67, 111, 110, 102, 105, 103,
			73, 116, 101, 109, 115, 92, 79, 112, 116, 105,
			111, 110, 115, 92, 84, 101, 120, 116, 73, 110,
			112, 117, 116, 70, 105, 101, 108, 100, 79, 112,
			116, 105, 111, 110, 115, 46, 99, 115, 0, 0,
			0, 1, 0, 0, 0, 55, 92, 65, 115, 115,
			101, 116, 115, 92, 83, 99, 114, 105, 112, 116,
			115, 92, 67, 111, 110, 102, 105, 103, 73, 116,
			101, 109, 115, 92, 84, 101, 120, 116, 73, 110,
			112, 117, 116, 70, 105, 101, 108, 100, 67, 111,
			110, 102, 105, 103, 73, 116, 101, 109, 46, 99,
			115, 0, 0, 0, 1, 0, 0, 0, 38, 92,
			65, 115, 115, 101, 116, 115, 92, 83, 99, 114,
			105, 112, 116, 115, 92, 76, 101, 116, 104, 97,
			108, 67, 111, 110, 102, 105, 103, 77, 97, 110,
			97, 103, 101, 114, 46, 99, 115, 0, 0, 0,
			2, 0, 0, 0, 37, 92, 65, 115, 115, 101,
			116, 115, 92, 83, 99, 114, 105, 112, 116, 115,
			92, 76, 101, 116, 104, 97, 108, 67, 111, 110,
			102, 105, 103, 80, 108, 117, 103, 105, 110, 46,
			99, 115, 0, 0, 0, 1, 0, 0, 0, 27,
			92, 65, 115, 115, 101, 116, 115, 92, 83, 99,
			114, 105, 112, 116, 115, 92, 77, 111, 100, 115,
			92, 77, 111, 100, 46, 99, 115, 0, 0, 0,
			1, 0, 0, 0, 31, 92, 65, 115, 115, 101,
			116, 115, 92, 83, 99, 114, 105, 112, 116, 115,
			92, 77, 111, 100, 115, 92, 77, 111, 100, 73,
			110, 102, 111, 46, 99, 115, 0, 0, 0, 1,
			0, 0, 0, 44, 92, 65, 115, 115, 101, 116,
			115, 92, 83, 99, 114, 105, 112, 116, 115, 92,
			77, 111, 100, 115, 92, 84, 104, 117, 110, 100,
			101, 114, 115, 116, 111, 114, 101, 77, 97, 110,
			105, 102, 101, 115, 116, 46, 99, 115, 0, 0,
			0, 1, 0, 0, 0, 67, 92, 65, 115, 115,
			101, 116, 115, 92, 83, 99, 114, 105, 112, 116,
			115, 92, 77, 111, 110, 111, 66, 101, 104, 97,
			118, 105, 111, 117, 114, 115, 92, 67, 111, 109,
			112, 111, 110, 101, 110, 116, 115, 92, 66, 111,
			111, 108, 67, 104, 101, 99, 107, 66, 111, 120,
			67, 111, 110, 116, 114, 111, 108, 108, 101, 114,
			46, 99, 115, 0, 0, 0, 1, 0, 0, 0,
			67, 92, 65, 115, 115, 101, 116, 115, 92, 83,
			99, 114, 105, 112, 116, 115, 92, 77, 111, 110,
			111, 66, 101, 104, 97, 118, 105, 111, 117, 114,
			115, 92, 67, 111, 109, 112, 111, 110, 101, 110,
			116, 115, 92, 69, 110, 117, 109, 68, 114, 111,
			112, 68, 111, 119, 110, 67, 111, 110, 116, 114,
			111, 108, 108, 101, 114, 46, 99, 115, 0, 0,
			0, 1, 0, 0, 0, 70, 92, 65, 115, 115,
			101, 116, 115, 92, 83, 99, 114, 105, 112, 116,
			115, 92, 77, 111, 110, 111, 66, 101, 104, 97,
			118, 105, 111, 117, 114, 115, 92, 67, 111, 109,
			112, 111, 110, 101, 110, 116, 115, 92, 70, 108,
			111, 97, 116, 73, 110, 112, 117, 116, 70, 105,
			101, 108, 100, 67, 111, 110, 116, 114, 111, 108,
			108, 101, 114, 46, 99, 115, 0, 0, 0, 1,
			0, 0, 0, 66, 92, 65, 115, 115, 101, 116,
			115, 92, 83, 99, 114, 105, 112, 116, 115, 92,
			77, 111, 110, 111, 66, 101, 104, 97, 118, 105,
			111, 117, 114, 115, 92, 67, 111, 109, 112, 111,
			110, 101, 110, 116, 115, 92, 70, 108, 111, 97,
			116, 83, 108, 105, 100, 101, 114, 67, 111, 110,
			116, 114, 111, 108, 108, 101, 114, 46, 99, 115,
			0, 0, 0, 1, 0, 0, 0, 70, 92, 65,
			115, 115, 101, 116, 115, 92, 83, 99, 114, 105,
			112, 116, 115, 92, 77, 111, 110, 111, 66, 101,
			104, 97, 118, 105, 111, 117, 114, 115, 92, 67,
			111, 109, 112, 111, 110, 101, 110, 116, 115, 92,
			70, 108, 111, 97, 116, 83, 116, 101, 112, 83,
			108, 105, 100, 101, 114, 67, 111, 110, 116, 114,
			111, 108, 108, 101, 114, 46, 99, 115, 0, 0,
			0, 1, 0, 0, 0, 68, 92, 65, 115, 115,
			101, 116, 115, 92, 83, 99, 114, 105, 112, 116,
			115, 92, 77, 111, 110, 111, 66, 101, 104, 97,
			118, 105, 111, 117, 114, 115, 92, 67, 111, 109,
			112, 111, 110, 101, 110, 116, 115, 92, 71, 101,
			110, 101, 114, 105, 99, 66, 117, 116, 116, 111,
			110, 67, 111, 110, 116, 114, 111, 108, 108, 101,
			114, 46, 99, 115, 0, 0, 0, 1, 0, 0,
			0, 68, 92, 65, 115, 115, 101, 116, 115, 92,
			83, 99, 114, 105, 112, 116, 115, 92, 77, 111,
			110, 111, 66, 101, 104, 97, 118, 105, 111, 117,
			114, 115, 92, 67, 111, 109, 112, 111, 110, 101,
			110, 116, 115, 92, 73, 110, 116, 73, 110, 112,
			117, 116, 70, 105, 101, 108, 100, 67, 111, 110,
			116, 114, 111, 108, 108, 101, 114, 46, 99, 115,
			0, 0, 0, 1, 0, 0, 0, 64, 92, 65,
			115, 115, 101, 116, 115, 92, 83, 99, 114, 105,
			112, 116, 115, 92, 77, 111, 110, 111, 66, 101,
			104, 97, 118, 105, 111, 117, 114, 115, 92, 67,
			111, 109, 112, 111, 110, 101, 110, 116, 115, 92,
			73, 110, 116, 83, 108, 105, 100, 101, 114, 67,
			111, 110, 116, 114, 111, 108, 108, 101, 114, 46,
			99, 115, 0, 0, 0, 2, 0, 0, 0, 64,
			92, 65, 115, 115, 101, 116, 115, 92, 83, 99,
			114, 105, 112, 116, 115, 92, 77, 111, 110, 111,
			66, 101, 104, 97, 118, 105, 111, 117, 114, 115,
			92, 67, 111, 109, 112, 111, 110, 101, 110, 116,
			115, 92, 77, 111, 100, 67, 111, 110, 102, 105,
			103, 67, 111, 110, 116, 114, 111, 108, 108, 101,
			114, 46, 99, 115, 0, 0, 0, 1, 0, 0,
			0, 69, 92, 65, 115, 115, 101, 116, 115, 92,
			83, 99, 114, 105, 112, 116, 115, 92, 77, 111,
			110, 111, 66, 101, 104, 97, 118, 105, 111, 117,
			114, 115, 92, 67, 111, 109, 112, 111, 110, 101,
			110, 116, 115, 92, 84, 101, 120, 116, 73, 110,
			112, 117, 116, 70, 105, 101, 108, 100, 67, 111,
			110, 116, 114, 111, 108, 108, 101, 114, 46, 99,
			115, 0, 0, 0, 1, 0, 0, 0, 47, 92,
			65, 115, 115, 101, 116, 115, 92, 83, 99, 114,
			105, 112, 116, 115, 92, 77, 111, 110, 111, 66,
			101, 104, 97, 118, 105, 111, 117, 114, 115, 92,
			67, 111, 110, 102, 105, 103, 73, 110, 102, 111,
			66, 111, 120, 46, 99, 115, 0, 0, 0, 1,
			0, 0, 0, 44, 92, 65, 115, 115, 101, 116,
			115, 92, 83, 99, 114, 105, 112, 116, 115, 92,
			77, 111, 110, 111, 66, 101, 104, 97, 118, 105,
			111, 117, 114, 115, 92, 67, 111, 110, 102, 105,
			103, 76, 105, 115, 116, 46, 99, 115, 0, 0,
			0, 1, 0, 0, 0, 44, 92, 65, 115, 115,
			101, 116, 115, 92, 83, 99, 114, 105, 112, 116,
			115, 92, 77, 111, 110, 111, 66, 101, 104, 97,
			118, 105, 111, 117, 114, 115, 92, 67, 111, 110,
			102, 105, 103, 77, 101, 110, 117, 46, 99, 115,
			0, 0, 0, 1, 0, 0, 0, 56, 92, 65,
			115, 115, 101, 116, 115, 92, 83, 99, 114, 105,
			112, 116, 115, 92, 77, 111, 110, 111, 66, 101,
			104, 97, 118, 105, 111, 117, 114, 115, 92, 67,
			111, 110, 102, 105, 103, 77, 101, 110, 117, 78,
			111, 116, 105, 102, 105, 99, 97, 116, 105, 111,
			110, 46, 99, 115, 0, 0, 0, 1, 0, 0,
			0, 48, 92, 65, 115, 115, 101, 116, 115, 92,
			83, 99, 114, 105, 112, 116, 115, 92, 77, 111,
			110, 111, 66, 101, 104, 97, 118, 105, 111, 117,
			114, 115, 92, 68, 101, 115, 99, 114, 105, 112,
			116, 105, 111, 110, 66, 111, 120, 46, 99, 115,
			0, 0, 0, 1, 0, 0, 0, 65, 92, 65,
			115, 115, 101, 116, 115, 92, 83, 99, 114, 105,
			112, 116, 115, 92, 77, 111, 110, 111, 66, 101,
			104, 97, 118, 105, 111, 117, 114, 115, 92, 77,
			97, 110, 97, 103, 101, 114, 115, 92, 67, 111,
			110, 102, 105, 103, 77, 101, 110, 117, 65, 117,
			100, 105, 111, 77, 97, 110, 97, 103, 101, 114,
			46, 99, 115, 0, 0, 0, 1, 0, 0, 0,
			60, 92, 65, 115, 115, 101, 116, 115, 92, 83,
			99, 114, 105, 112, 116, 115, 92, 77, 111, 110,
			111, 66, 101, 104, 97, 118, 105, 111, 117, 114,
			115, 92, 77, 97, 110, 97, 103, 101, 114, 115,
			92, 67, 111, 110, 102, 105, 103, 77, 101, 110,
			117, 77, 97, 110, 97, 103, 101, 114, 46, 99,
			115, 0, 0, 0, 1, 0, 0, 0, 44, 92,
			65, 115, 115, 101, 116, 115, 92, 83, 99, 114,
			105, 112, 116, 115, 92, 77, 111, 110, 111, 66,
			101, 104, 97, 118, 105, 111, 117, 114, 115, 92,
			77, 111, 100, 73, 110, 102, 111, 66, 111, 120,
			46, 99, 115, 0, 0, 0, 1, 0, 0, 0,
			41, 92, 65, 115, 115, 101, 116, 115, 92, 83,
			99, 114, 105, 112, 116, 115, 92, 77, 111, 110,
			111, 66, 101, 104, 97, 118, 105, 111, 117, 114,
			115, 92, 77, 111, 100, 76, 105, 115, 116, 46,
			99, 115, 0, 0, 0, 1, 0, 0, 0, 45,
			92, 65, 115, 115, 101, 116, 115, 92, 83, 99,
			114, 105, 112, 116, 115, 92, 77, 111, 110, 111,
			66, 101, 104, 97, 118, 105, 111, 117, 114, 115,
			92, 77, 111, 100, 76, 105, 115, 116, 73, 116,
			101, 109, 46, 99, 115, 0, 0, 0, 1, 0,
			0, 0, 47, 92, 65, 115, 115, 101, 116, 115,
			92, 83, 99, 114, 105, 112, 116, 115, 92, 77,
			111, 110, 111, 66, 101, 104, 97, 118, 105, 111,
			117, 114, 115, 92, 83, 101, 99, 116, 105, 111,
			110, 72, 101, 97, 100, 101, 114, 46, 99, 115,
			0, 0, 0, 1, 0, 0, 0, 41, 92, 65,
			115, 115, 101, 116, 115, 92, 83, 99, 114, 105,
			112, 116, 115, 92, 77, 111, 110, 111, 66, 101,
			104, 97, 118, 105, 111, 117, 114, 115, 92, 84,
			111, 111, 108, 116, 105, 112, 46, 99, 115, 0,
			0, 0, 1, 0, 0, 0, 47, 92, 65, 115,
			115, 101, 116, 115, 92, 83, 99, 114, 105, 112,
			116, 115, 92, 77, 111, 110, 111, 66, 101, 104,
			97, 118, 105, 111, 117, 114, 115, 92, 84, 111,
			111, 108, 116, 105, 112, 83, 121, 115, 116, 101,
			109, 46, 99, 115, 0, 0, 0, 1, 0, 0,
			0, 48, 92, 65, 115, 115, 101, 116, 115, 92,
			83, 99, 114, 105, 112, 116, 115, 92, 77, 111,
			110, 111, 66, 101, 104, 97, 118, 105, 111, 117,
			114, 115, 92, 84, 111, 111, 108, 116, 105, 112,
			84, 114, 105, 103, 103, 101, 114, 46, 99, 115,
			0, 0, 0, 1, 0, 0, 0, 46, 92, 65,
			115, 115, 101, 116, 115, 92, 83, 99, 114, 105,
			112, 116, 115, 92, 77, 111, 110, 111, 66, 101,
			104, 97, 118, 105, 111, 117, 114, 115, 92, 86,
			101, 114, 115, 105, 111, 110, 76, 97, 98, 101,
			108, 46, 99, 115, 0, 0, 0, 1, 0, 0,
			0, 45, 92, 65, 115, 115, 101, 116, 115, 92,
			83, 99, 114, 105, 112, 116, 115, 92, 80, 97,
			116, 99, 104, 101, 115, 92, 77, 101, 110, 117,
			77, 97, 110, 97, 103, 101, 114, 80, 97, 116,
			99, 104, 101, 115, 46, 99, 115, 0, 0, 0,
			1, 0, 0, 0, 50, 92, 65, 115, 115, 101,
			116, 115, 92, 83, 99, 114, 105, 112, 116, 115,
			92, 80, 97, 116, 99, 104, 101, 115, 92, 81,
			117, 105, 99, 107, 77, 101, 110, 117, 77, 97,
			110, 97, 103, 101, 114, 80, 97, 116, 99, 104,
			101, 115, 46, 99, 115, 0, 0, 0, 1, 0,
			0, 0, 43, 92, 65, 115, 115, 101, 116, 115,
			92, 83, 99, 114, 105, 112, 116, 115, 92, 85,
			116, 105, 108, 115, 92, 65, 115, 115, 101, 109,
			98, 108, 121, 69, 120, 116, 101, 110, 115, 105,
			111, 110, 115, 46, 99, 115, 0, 0, 0, 1,
			0, 0, 0, 31, 92, 65, 115, 115, 101, 116,
			115, 92, 83, 99, 114, 105, 112, 116, 115, 92,
			85, 116, 105, 108, 115, 92, 65, 115, 115, 101,
			116, 115, 46, 99, 115, 0, 0, 0, 1, 0,
			0, 0, 33, 92, 65, 115, 115, 101, 116, 115,
			92, 83, 99, 114, 105, 112, 116, 115, 92, 85,
			116, 105, 108, 115, 92, 76, 111, 103, 85, 116,
			105, 108, 115, 46, 99, 115, 0, 0, 0, 1,
			0, 0, 0, 35, 92, 65, 115, 115, 101, 116,
			115, 92, 83, 99, 114, 105, 112, 116, 115, 92,
			85, 116, 105, 108, 115, 92, 77, 101, 110, 117,
			115, 85, 116, 105, 108, 115, 46, 99, 115, 0,
			0, 0, 1, 0, 0, 0, 34, 92, 65, 115,
			115, 101, 116, 115, 92, 83, 99, 114, 105, 112,
			116, 115, 92, 85, 116, 105, 108, 115, 92, 80,
			97, 116, 104, 85, 116, 105, 108, 115, 46, 99,
			115
		};
		result.TypesData = new byte[3298]
		{
			0, 0, 0, 0, 43, 76, 101, 116, 104, 97,
			108, 67, 111, 110, 102, 105, 103, 46, 65, 117,
			116, 111, 67, 111, 110, 102, 105, 103, 124, 65,
			117, 116, 111, 67, 111, 110, 102, 105, 103, 71,
			101, 110, 101, 114, 97, 116, 111, 114, 0, 0,
			0, 0, 58, 76, 101, 116, 104, 97, 108, 67,
			111, 110, 102, 105, 103, 46, 65, 117, 116, 111,
			67, 111, 110, 102, 105, 103, 46, 65, 117, 116,
			111, 67, 111, 110, 102, 105, 103, 71, 101, 110,
			101, 114, 97, 116, 111, 114, 124, 65, 117, 116,
			111, 67, 111, 110, 102, 105, 103, 73, 116, 101,
			109, 0, 0, 0, 0, 39, 76, 101, 116, 104,
			97, 108, 67, 111, 110, 102, 105, 103, 46, 65,
			117, 116, 111, 67, 111, 110, 102, 105, 103, 124,
			67, 111, 110, 102, 105, 103, 69, 110, 116, 114,
			121, 80, 97, 116, 104, 0, 0, 0, 0, 39,
			76, 101, 116, 104, 97, 108, 67, 111, 110, 102,
			105, 103, 46, 67, 111, 110, 102, 105, 103, 73,
			116, 101, 109, 115, 124, 66, 97, 115, 101, 67,
			111, 110, 102, 105, 103, 73, 116, 101, 109, 0,
			0, 0, 0, 44, 76, 101, 116, 104, 97, 108,
			67, 111, 110, 102, 105, 103, 46, 67, 111, 110,
			102, 105, 103, 73, 116, 101, 109, 115, 124, 66,
			97, 115, 101, 86, 97, 108, 117, 101, 67, 111,
			110, 102, 105, 103, 73, 116, 101, 109, 0, 0,
			0, 0, 47, 76, 101, 116, 104, 97, 108, 67,
			111, 110, 102, 105, 103, 46, 67, 111, 110, 102,
			105, 103, 73, 116, 101, 109, 115, 124, 66, 111,
			111, 108, 67, 104, 101, 99, 107, 66, 111, 120,
			67, 111, 110, 102, 105, 103, 73, 116, 101, 109,
			0, 0, 0, 0, 47, 76, 101, 116, 104, 97,
			108, 67, 111, 110, 102, 105, 103, 46, 67, 111,
			110, 102, 105, 103, 73, 116, 101, 109, 115, 124,
			69, 110, 117, 109, 68, 114, 111, 112, 68, 111,
			119, 110, 67, 111, 110, 102, 105, 103, 73, 116,
			101, 109, 0, 0, 0, 0, 50, 76, 101, 116,
			104, 97, 108, 67, 111, 110, 102, 105, 103, 46,
			67, 111, 110, 102, 105, 103, 73, 116, 101, 109,
			115, 124, 70, 108, 111, 97, 116, 73, 110, 112,
			117, 116, 70, 105, 101, 108, 100, 67, 111, 110,
			102, 105, 103, 73, 116, 101, 109, 0, 0, 0,
			0, 46, 76, 101, 116, 104, 97, 108, 67, 111,
			110, 102, 105, 103, 46, 67, 111, 110, 102, 105,
			103, 73, 116, 101, 109, 115, 124, 70, 108, 111,
			97, 116, 83, 108, 105, 100, 101, 114, 67, 111,
			110, 102, 105, 103, 73, 116, 101, 109, 0, 0,
			0, 0, 50, 76, 101, 116, 104, 97, 108, 67,
			111, 110, 102, 105, 103, 46, 67, 111, 110, 102,
			105, 103, 73, 116, 101, 109, 115, 124, 70, 108,
			111, 97, 116, 83, 116, 101, 112, 83, 108, 105,
			100, 101, 114, 67, 111, 110, 102, 105, 103, 73,
			116, 101, 109, 0, 0, 0, 0, 48, 76, 101,
			116, 104, 97, 108, 67, 111, 110, 102, 105, 103,
			46, 67, 111, 110, 102, 105, 103, 73, 116, 101,
			109, 115, 124, 71, 101, 110, 101, 114, 105, 99,
			66, 117, 116, 116, 111, 110, 67, 111, 110, 102,
			105, 103, 73, 116, 101, 109, 0, 0, 0, 0,
			48, 76, 101, 116, 104, 97, 108, 67, 111, 110,
			102, 105, 103, 46, 67, 111, 110, 102, 105, 103,
			73, 116, 101, 109, 115, 124, 73, 110, 116, 73,
			110, 112, 117, 116, 70, 105, 101, 108, 100, 67,
			111, 110, 102, 105, 103, 73, 116, 101, 109, 0,
			0, 0, 0, 44, 76, 101, 116, 104, 97, 108,
			67, 111, 110, 102, 105, 103, 46, 67, 111, 110,
			102, 105, 103, 73, 116, 101, 109, 115, 124, 73,
			110, 116, 83, 108, 105, 100, 101, 114, 67, 111,
			110, 102, 105, 103, 73, 116, 101, 109, 0, 0,
			0, 0, 44, 76, 101, 116, 104, 97, 108, 67,
			111, 110, 102, 105, 103, 46, 67, 111, 110, 102,
			105, 103, 73, 116, 101, 109, 115, 46, 79, 112,
			116, 105, 111, 110, 115, 124, 66, 97, 115, 101,
			79, 112, 116, 105, 111, 110, 115, 0, 0, 0,
			0, 49, 76, 101, 116, 104, 97, 108, 67, 111,
			110, 102, 105, 103, 46, 67, 111, 110, 102, 105,
			103, 73, 116, 101, 109, 115, 46, 79, 112, 116,
			105, 111, 110, 115, 124, 66, 97, 115, 101, 82,
			97, 110, 103, 101, 79, 112, 116, 105, 111, 110,
			115, 0, 0, 0, 0, 52, 76, 101, 116, 104,
			97, 108, 67, 111, 110, 102, 105, 103, 46, 67,
			111, 110, 102, 105, 103, 73, 116, 101, 109, 115,
			46, 79, 112, 116, 105, 111, 110, 115, 124, 66,
			111, 111, 108, 67, 104, 101, 99, 107, 66, 111,
			120, 79, 112, 116, 105, 111, 110, 115, 0, 0,
			0, 0, 48, 76, 101, 116, 104, 97, 108, 67,
			111, 110, 102, 105, 103, 46, 67, 111, 110, 102,
			105, 103, 73, 116, 101, 109, 115, 46, 79, 112,
			116, 105, 111, 110, 115, 124, 67, 97, 110, 77,
			111, 100, 105, 102, 121, 82, 101, 115, 117, 108,
			116, 0, 0, 0, 0, 52, 76, 101, 116, 104,
			97, 108, 67, 111, 110, 102, 105, 103, 46, 67,
			111, 110, 102, 105, 103, 73, 116, 101, 109, 115,
			46, 79, 112, 116, 105, 111, 110, 115, 124, 69,
			110, 117, 109, 68, 114, 111, 112, 68, 111, 119,
			110, 79, 112, 116, 105, 111, 110, 115, 0, 0,
			0, 0, 55, 76, 101, 116, 104, 97, 108, 67,
			111, 110, 102, 105, 103, 46, 67, 111, 110, 102,
			105, 103, 73, 116, 101, 109, 115, 46, 79, 112,
			116, 105, 111, 110, 115, 124, 70, 108, 111, 97,
			116, 73, 110, 112, 117, 116, 70, 105, 101, 108,
			100, 79, 112, 116, 105, 111, 110, 115, 0, 0,
			0, 0, 51, 76, 101, 116, 104, 97, 108, 67,
			111, 110, 102, 105, 103, 46, 67, 111, 110, 102,
			105, 103, 73, 116, 101, 109, 115, 46, 79, 112,
			116, 105, 111, 110, 115, 124, 70, 108, 111, 97,
			116, 83, 108, 105, 100, 101, 114, 79, 112, 116,
			105, 111, 110, 115, 0, 0, 0, 0, 55, 76,
			101, 116, 104, 97, 108, 67, 111, 110, 102, 105,
			103, 46, 67, 111, 110, 102, 105, 103, 73, 116,
			101, 109, 115, 46, 79, 112, 116, 105, 111, 110,
			115, 124, 70, 108, 111, 97, 116, 83, 116, 101,
			112, 83, 108, 105, 100, 101, 114, 79, 112, 116,
			105, 111, 110, 115, 0, 0, 0, 0, 53, 76,
			101, 116, 104, 97, 108, 67, 111, 110, 102, 105,
			103, 46, 67, 111, 110, 102, 105, 103, 73, 116,
			101, 109, 115, 46, 79, 112, 116, 105, 111, 110,
			115, 124, 71, 101, 110, 101, 114, 105, 99, 66,
			117, 116, 116, 111, 110, 79, 112, 116, 105, 111,
			110, 115, 0, 0, 0, 0, 53, 76, 101, 116,
			104, 97, 108, 67, 111, 110, 102, 105, 103, 46,
			67, 111, 110, 102, 105, 103, 73, 116, 101, 109,
			115, 46, 79, 112, 116, 105, 111, 110, 115, 124,
			73, 110, 116, 73, 110, 112, 117, 116, 70, 105,
			101, 108, 100, 79, 112, 116, 105, 111, 110, 115,
			0, 0, 0, 0, 49, 76, 101, 116, 104, 97,
			108, 67, 111, 110, 102, 105, 103, 46, 67, 111,
			110, 102, 105, 103, 73, 116, 101, 109, 115, 46,
			79, 112, 116, 105, 111, 110, 115, 124, 73, 110,
			116, 83, 108, 105, 100, 101, 114, 79, 112, 116,
			105, 111, 110, 115, 0, 0, 0, 0, 54, 76,
			101, 116, 104, 97, 108, 67, 111, 110, 102, 105,
			103, 46, 67, 111, 110, 102, 105, 103, 73, 116,
			101, 109, 115, 46, 79, 112, 116, 105, 111, 110,
			115, 124, 84, 101, 120, 116, 73, 110, 112, 117,
			116, 70, 105, 101, 108, 100, 79, 112, 116, 105,
			111, 110, 115, 0, 0, 0, 0, 49, 76, 101,
			116, 104, 97, 108, 67, 111, 110, 102, 105, 103,
			46, 67, 111, 110, 102, 105, 103, 73, 116, 101,
			109, 115, 124, 84, 101, 120, 116, 73, 110, 112,
			117, 116, 70, 105, 101, 108, 100, 67, 111, 110,
			102, 105, 103, 73, 116, 101, 109, 0, 0, 0,
			0, 32, 76, 101, 116, 104, 97, 108, 67, 111,
			110, 102, 105, 103, 124, 76, 101, 116, 104, 97,
			108, 67, 111, 110, 102, 105, 103, 77, 97, 110,
			97, 103, 101, 114, 0, 0, 0, 0, 23, 76,
			101, 116, 104, 97, 108, 67, 111, 110, 102, 105,
			103, 124, 80, 108, 117, 103, 105, 110, 73, 110,
			102, 111, 0, 0, 0, 0, 31, 76, 101, 116,
			104, 97, 108, 67, 111, 110, 102, 105, 103, 124,
			76, 101, 116, 104, 97, 108, 67, 111, 110, 102,
			105, 103, 80, 108, 117, 103, 105, 110, 0, 0,
			0, 0, 21, 76, 101, 116, 104, 97, 108, 67,
			111, 110, 102, 105, 103, 46, 77, 111, 100, 115,
			124, 77, 111, 100, 0, 0, 0, 0, 25, 76,
			101, 116, 104, 97, 108, 67, 111, 110, 102, 105,
			103, 46, 77, 111, 100, 115, 124, 77, 111, 100,
			73, 110, 102, 111, 0, 0, 0, 0, 38, 76,
			101, 116, 104, 97, 108, 67, 111, 110, 102, 105,
			103, 46, 77, 111, 100, 115, 124, 84, 104, 117,
			110, 100, 101, 114, 115, 116, 111, 114, 101, 77,
			97, 110, 105, 102, 101, 115, 116, 0, 0, 0,
			0, 61, 76, 101, 116, 104, 97, 108, 67, 111,
			110, 102, 105, 103, 46, 77, 111, 110, 111, 66,
			101, 104, 97, 118, 105, 111, 117, 114, 115, 46,
			67, 111, 109, 112, 111, 110, 101, 110, 116, 115,
			124, 66, 111, 111, 108, 67, 104, 101, 99, 107,
			66, 111, 120, 67, 111, 110, 116, 114, 111, 108,
			108, 101, 114, 0, 0, 0, 0, 61, 76, 101,
			116, 104, 97, 108, 67, 111, 110, 102, 105, 103,
			46, 77, 111, 110, 111, 66, 101, 104, 97, 118,
			105, 111, 117, 114, 115, 46, 67, 111, 109, 112,
			111, 110, 101, 110, 116, 115, 124, 69, 110, 117,
			109, 68, 114, 111, 112, 68, 111, 119, 110, 67,
			111, 110, 116, 114, 111, 108, 108, 101, 114, 0,
			0, 0, 0, 64, 76, 101, 116, 104, 97, 108,
			67, 111, 110, 102, 105, 103, 46, 77, 111, 110,
			111, 66, 101, 104, 97, 118, 105, 111, 117, 114,
			115, 46, 67, 111, 109, 112, 111, 110, 101, 110,
			116, 115, 124, 70, 108, 111, 97, 116, 73, 110,
			112, 117, 116, 70, 105, 101, 108, 100, 67, 111,
			110, 116, 114, 111, 108, 108, 101, 114, 0, 0,
			0, 0, 60, 76, 101, 116, 104, 97, 108, 67,
			111, 110, 102, 105, 103, 46, 77, 111, 110, 111,
			66, 101, 104, 97, 118, 105, 111, 117, 114, 115,
			46, 67, 111, 109, 112, 111, 110, 101, 110, 116,
			115, 124, 70, 108, 111, 97, 116, 83, 108, 105,
			100, 101, 114, 67, 111, 110, 116, 114, 111, 108,
			108, 101, 114, 0, 0, 0, 0, 64, 76, 101,
			116, 104, 97, 108, 67, 111, 110, 102, 105, 103,
			46, 77, 111, 110, 111, 66, 101, 104, 97, 118,
			105, 111, 117, 114, 115, 46, 67, 111, 109, 112,
			111, 110, 101, 110, 116, 115, 124, 70, 108, 111,
			97, 116, 83, 116, 101, 112, 83, 108, 105, 100,
			101, 114, 67, 111, 110, 116, 114, 111, 108, 108,
			101, 114, 0, 0, 0, 0, 62, 76, 101, 116,
			104, 97, 108, 67, 111, 110, 102, 105, 103, 46,
			77, 111, 110, 111, 66, 101, 104, 97, 118, 105,
			111, 117, 114, 115, 46, 67, 111, 109, 112, 111,
			110, 101, 110, 116, 115, 124, 71, 101, 110, 101,
			114, 105, 99, 66, 117, 116, 116, 111, 110, 67,
			111, 110, 116, 114, 111, 108, 108, 101, 114, 0,
			0, 0, 0, 62, 76, 101, 116, 104, 97, 108,
			67, 111, 110, 102, 105, 103, 46, 77, 111, 110,
			111, 66, 101, 104, 97, 118, 105, 111, 117, 114,
			115, 46, 67, 111, 109, 112, 111, 110, 101, 110,
			116, 115, 124, 73, 110, 116, 73, 110, 112, 117,
			116, 70, 105, 101, 108, 100, 67, 111, 110, 116,
			114, 111, 108, 108, 101, 114, 0, 0, 0, 0,
			58, 76, 101, 116, 104, 97, 108, 67, 111, 110,
			102, 105, 103, 46, 77, 111, 110, 111, 66, 101,
			104, 97, 118, 105, 111, 117, 114, 115, 46, 67,
			111, 109, 112, 111, 110, 101, 110, 116, 115, 124,
			73, 110, 116, 83, 108, 105, 100, 101, 114, 67,
			111, 110, 116, 114, 111, 108, 108, 101, 114, 1,
			0, 0, 0, 58, 76, 101, 116, 104, 97, 108,
			67, 111, 110, 102, 105, 103, 46, 77, 111, 110,
			111, 66, 101, 104, 97, 118, 105, 111, 117, 114,
			115, 46, 67, 111, 109, 112, 111, 110, 101, 110,
			116, 115, 124, 77, 111, 100, 67, 111, 110, 102,
			105, 103, 67, 111, 110, 116, 114, 111, 108, 108,
			101, 114, 1, 0, 0, 0, 58, 76, 101, 116,
			104, 97, 108, 67, 111, 110, 102, 105, 103, 46,
			77, 111, 110, 111, 66, 101, 104, 97, 118, 105,
			111, 117, 114, 115, 46, 67, 111, 109, 112, 111,
			110, 101, 110, 116, 115, 124, 77, 111, 100, 67,
			111, 110, 102, 105, 103, 67, 111, 110, 116, 114,
			111, 108, 108, 101, 114, 0, 0, 0, 0, 63,
			76, 101, 116, 104, 97, 108, 67, 111, 110, 102,
			105, 103, 46, 77, 111, 110, 111, 66, 101, 104,
			97, 118, 105, 111, 117, 114, 115, 46, 67, 111,
			109, 112, 111, 110, 101, 110, 116, 115, 124, 84,
			101, 120, 116, 73, 110, 112, 117, 116, 70, 105,
			101, 108, 100, 67, 111, 110, 116, 114, 111, 108,
			108, 101, 114, 0, 0, 0, 0, 41, 76, 101,
			116, 104, 97, 108, 67, 111, 110, 102, 105, 103,
			46, 77, 111, 110, 111, 66, 101, 104, 97, 118,
			105, 111, 117, 114, 115, 124, 67, 111, 110, 102,
			105, 103, 73, 110, 102, 111, 66, 111, 120, 0,
			0, 0, 0, 38, 76, 101, 116, 104, 97, 108,
			67, 111, 110, 102, 105, 103, 46, 77, 111, 110,
			111, 66, 101, 104, 97, 118, 105, 111, 117, 114,
			115, 124, 67, 111, 110, 102, 105, 103, 76, 105,
			115, 116, 0, 0, 0, 0, 38, 76, 101, 116,
			104, 97, 108, 67, 111, 110, 102, 105, 103, 46,
			77, 111, 110, 111, 66, 101, 104, 97, 118, 105,
			111, 117, 114, 115, 124, 67, 111, 110, 102, 105,
			103, 77, 101, 110, 117, 0, 0, 0, 0, 50,
			76, 101, 116, 104, 97, 108, 67, 111, 110, 102,
			105, 103, 46, 77, 111, 110, 111, 66, 101, 104,
			97, 118, 105, 111, 117, 114, 115, 124, 67, 111,
			110, 102, 105, 103, 77, 101, 110, 117, 78, 111,
			116, 105, 102, 105, 99, 97, 116, 105, 111, 110,
			0, 0, 0, 0, 42, 76, 101, 116, 104, 97,
			108, 67, 111, 110, 102, 105, 103, 46, 77, 111,
			110, 111, 66, 101, 104, 97, 118, 105, 111, 117,
			114, 115, 124, 68, 101, 115, 99, 114, 105, 112,
			116, 105, 111, 110, 66, 111, 120, 0, 0, 0,
			0, 59, 76, 101, 116, 104, 97, 108, 67, 111,
			110, 102, 105, 103, 46, 77, 111, 110, 111, 66,
			101, 104, 97, 118, 105, 111, 117, 114, 115, 46,
			77, 97, 110, 97, 103, 101, 114, 115, 124, 67,
			111, 110, 102, 105, 103, 77, 101, 110, 117, 65,
			117, 100, 105, 111, 77, 97, 110, 97, 103, 101,
			114, 0, 0, 0, 0, 54, 76, 101, 116, 104,
			97, 108, 67, 111, 110, 102, 105, 103, 46, 77,
			111, 110, 111, 66, 101, 104, 97, 118, 105, 111,
			117, 114, 115, 46, 77, 97, 110, 97, 103, 101,
			114, 115, 124, 67, 111, 110, 102, 105, 103, 77,
			101, 110, 117, 77, 97, 110, 97, 103, 101, 114,
			0, 0, 0, 0, 38, 76, 101, 116, 104, 97,
			108, 67, 111, 110, 102, 105, 103, 46, 77, 111,
			110, 111, 66, 101, 104, 97, 118, 105, 111, 117,
			114, 115, 124, 77, 111, 100, 73, 110, 102, 111,
			66, 111, 120, 0, 0, 0, 0, 35, 76, 101,
			116, 104, 97, 108, 67, 111, 110, 102, 105, 103,
			46, 77, 111, 110, 111, 66, 101, 104, 97, 118,
			105, 111, 117, 114, 115, 124, 77, 111, 100, 76,
			105, 115, 116, 0, 0, 0, 0, 39, 76, 101,
			116, 104, 97, 108, 67, 111, 110, 102, 105, 103,
			46, 77, 111, 110, 111, 66, 101, 104, 97, 118,
			105, 111, 117, 114, 115, 124, 77, 111, 100, 76,
			105, 115, 116, 73, 116, 101, 109, 0, 0, 0,
			0, 41, 76, 101, 116, 104, 97, 108, 67, 111,
			110, 102, 105, 103, 46, 77, 111, 110, 111, 66,
			101, 104, 97, 118, 105, 111, 117, 114, 115, 124,
			83, 101, 99, 116, 105, 111, 110, 72, 101, 97,
			100, 101, 114, 0, 0, 0, 0, 35, 76, 101,
			116, 104, 97, 108, 67, 111, 110, 102, 105, 103,
			46, 77, 111, 110, 111, 66, 101, 104, 97, 118,
			105, 111, 117, 114, 115, 124, 84, 111, 111, 108,
			116, 105, 112, 0, 0, 0, 0, 41, 76, 101,
			116, 104, 97, 108, 67, 111, 110, 102, 105, 103,
			46, 77, 111, 110, 111, 66, 101, 104, 97, 118,
			105, 111, 117, 114, 115, 124, 84, 111, 111, 108,
			116, 105, 112, 83, 121, 115, 116, 101, 109, 0,
			0, 0, 0, 42, 76, 101, 116, 104, 97, 108,
			67, 111, 110, 102, 105, 103, 46, 77, 111, 110,
			111, 66, 101, 104, 97, 118, 105, 111, 117, 114,
			115, 124, 84, 111, 111, 108, 116, 105, 112, 84,
			114, 105, 103, 103, 101, 114, 0, 0, 0, 0,
			40, 76, 101, 116, 104, 97, 108, 67, 111, 110,
			102, 105, 103, 46, 77, 111, 110, 111, 66, 101,
			104, 97, 118, 105, 111, 117, 114, 115, 124, 86,
			101, 114, 115, 105, 111, 110, 76, 97, 98, 101,
			108, 0, 0, 0, 0, 39, 76, 101, 116, 104,
			97, 108, 67, 111, 110, 102, 105, 103, 46, 80,
			97, 116, 99, 104, 101, 115, 124, 77, 101, 110,
			117, 77, 97, 110, 97, 103, 101, 114, 80, 97,
			116, 99, 104, 101, 115, 0, 0, 0, 0, 44,
			76, 101, 116, 104, 97, 108, 67, 111, 110, 102,
			105, 103, 46, 80, 97, 116, 99, 104, 101, 115,
			124, 81, 117, 105, 99, 107, 77, 101, 110, 117,
			77, 97, 110, 97, 103, 101, 114, 80, 97, 116,
			99, 104, 101, 115, 0, 0, 0, 0, 37, 76,
			101, 116, 104, 97, 108, 67, 111, 110, 102, 105,
			103, 46, 85, 116, 105, 108, 115, 124, 65, 115,
			115, 101, 109, 98, 108, 121, 69, 120, 116, 101,
			110, 115, 105, 111, 110, 115, 0, 0, 0, 0,
			25, 76, 101, 116, 104, 97, 108, 67, 111, 110,
			102, 105, 103, 46, 85, 116, 105, 108, 115, 124,
			65, 115, 115, 101, 116, 115, 0, 0, 0, 0,
			27, 76, 101, 116, 104, 97, 108, 67, 111, 110,
			102, 105, 103, 46, 85, 116, 105, 108, 115, 124,
			76, 111, 103, 85, 116, 105, 108, 115, 0, 0,
			0, 0, 32, 76, 101, 116, 104, 97, 108, 67,
			111, 110, 102, 105, 103, 46, 83, 101, 116, 116,
			105, 110, 103, 115, 124, 77, 101, 110, 117, 115,
			85, 116, 105, 108, 115, 0, 0, 0, 0, 28,
			76, 101, 116, 104, 97, 108, 67, 111, 110, 102,
			105, 103, 46, 85, 116, 105, 108, 115, 124, 80,
			97, 116, 104, 85, 116, 105, 108, 115
		};
		result.TotalFiles = 61;
		result.TotalTypes = 65;
		result.IsEditorOnly = false;
		return result;
	}
}
namespace LethalConfig
{
	public static class LethalConfigManager
	{
		private static bool hasGeneratedMissingConfigs = false;

		internal static Dictionary<string, Mod> Mods { get; private set; } = new Dictionary<string, Mod>();


		private static Dictionary<Mod, Assembly> ModToAssemblyMap { get; set; } = new Dictionary<Mod, Assembly>();


		internal static void AutoGenerateMissingConfigsIfNeeded()
		{
			if (hasGeneratedMissingConfigs)
			{
				return;
			}
			Mod[] second = Mods.Values.ToArray();
			IEnumerable<BaseConfigItem> existingConfigsFlat = Mods.SelectMany((KeyValuePair<string, Mod> kv) => kv.Value.configItems);
			AutoConfigGenerator.AutoConfigItem[] array = AutoConfigGenerator.AutoGenerateConfigs();
			Dictionary<Mod, IEnumerable<BaseConfigItem>> dictionary = (from c in array
				group c.ConfigItem by ModForAssembly(c.Assembly) into kv
				where kv.Key != null
				select kv).SelectMany((IGrouping<Mod, BaseConfigItem> kv) => from c in kv.Select(delegate(BaseConfigItem c)
				{
					c.Owner = kv.Key;
					return c;
				})
				where !kv.Key.entriesToSkipAutoGen.Any((ConfigEntryPath path) => path.Matches(c))
				where existingConfigsFlat.FirstOrDefault((BaseConfigItem ec) => c.IsSameConfig(ec)) == null
				group c by c.Owner).ToDictionary((IGrouping<Mod, BaseConfigItem> kv) => kv.Key, (IGrouping<Mod, BaseConfigItem> kv) => kv.Select((BaseConfigItem c) => c));
			Mod[] array2 = dictionary.Keys.Except(second).ToArray();
			Mod[] array3 = array2;
			foreach (Mod obj in array3)
			{
				obj.IsAutoGenerated = true;
				obj.modInfo.Description += "\n*This mod entry was automatically generated as it does not use LethalConfig directly.";
			}
			foreach (KeyValuePair<Mod, IEnumerable<BaseConfigItem>> item in dictionary)
			{
				Assembly valueOrDefault = ModToAssemblyMap.GetValueOrDefault(item.Key);
				if (!(valueOrDefault != null))
				{
					continue;
				}
				foreach (BaseConfigItem item2 in item.Value)
				{
					AddConfigItemForAssembly(item2, valueOrDefault);
				}
			}
			LogUtils.LogInfo($"Generated {array2.Count()} mod entries.");
			LogUtils.LogInfo($"Generated {array.Length} configs, of which {dictionary.SelectMany((KeyValuePair<Mod, IEnumerable<BaseConfigItem>> kv) => kv.Value).Count()} were missing and registered.");
			hasGeneratedMissingConfigs = true;
		}

		public static void AddConfigItem(BaseConfigItem configItem)
		{
			if (AddConfigItemForAssembly(configItem, Assembly.GetCallingAssembly()))
			{
				LogUtils.LogInfo($"Registered config \"{configItem}\"");
			}
		}

		private static bool AddConfigItemForAssembly(BaseConfigItem configItem, Assembly assembly)
		{
			Mod mod = ModForAssembly(assembly);
			if (mod == null)
			{
				LogUtils.LogWarning("Mod for assembly not found.");
				return false;
			}
			configItem.Owner = mod;
			if (mod.configItems.Where((BaseConfigItem c) => c.IsSameConfig(configItem)).Count() > 0)
			{
				LogUtils.LogWarning($"Ignoring duplicated config \"{configItem}\"");
				return false;
			}
			mod.AddConfigItem(configItem);
			return true;
		}

		private static Mod ModForAssembly(Assembly assembly)
		{
			if (assembly.TryGetModInfo(out var modInfo))
			{
				if (Mods.TryGetValue(modInfo.GUID, out var value))
				{
					return value;
				}
				Mod mod = new Mod(modInfo);
				Mods.Add(modInfo.GUID, mod);
				ModToAssemblyMap.Add(mod, assembly);
				return mod;
			}
			return null;
		}

		public static void SetModIcon(Sprite sprite)
		{
			if (!((Object)(object)sprite == (Object)null))
			{
				Mod mod = ModForAssembly(Assembly.GetCallingAssembly());
				if (mod != null)
				{
					mod.modInfo.Icon = sprite;
				}
			}
		}

		public static void SetModDescription(string description)
		{
			if (description != null)
			{
				Mod mod = ModForAssembly(Assembly.GetCallingAssembly());
				if (mod != null)
				{
					mod.modInfo.Description = description;
				}
			}
		}

		public static void SkipAutoGenFor(string configSection)
		{
			ModForAssembly(Assembly.GetCallingAssembly())?.entriesToSkipAutoGen.Add(new ConfigEntryPath(configSection, "*"));
		}

		public static void SkipAutoGenFor(ConfigEntryBase configEntryBase)
		{
			ModForAssembly(Assembly.GetCallingAssembly())?.entriesToSkipAutoGen.Add(new ConfigEntryPath(configEntryBase.Definition.Section, configEntryBase.Definition.Key));
		}

		public static void SkipAutoGen()
		{
			ModForAssembly(Assembly.GetCallingAssembly())?.entriesToSkipAutoGen.Add(new ConfigEntryPath("*", "*"));
		}
	}
	internal static class PluginInfo
	{
		public const string Guid = "ainavt.lc.lethalconfig";

		public const string Name = "LethalConfig";

		public const string Version = "1.3.4";
	}
	[BepInPlugin("ainavt.lc.lethalconfig", "LethalConfig", "1.3.4")]
	internal class LethalConfigPlugin : BaseUnityPlugin
	{
		private enum TestEnum
		{
			None,
			First,
			Second
		}

		private static LethalConfigPlugin instance;

		private static Harmony harmony;

		private void Awake()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			LogUtils.Init("ainavt.lc.lethalconfig");
			Assets.Init();
			harmony = new Harmony("ainavt.lc.lethalconfig");
			harmony.PatchAll();
			CreateExampleConfigs();
			LogUtils.LogInfo("LethalConfig loaded!");
		}

		private void CreateExampleConfigs()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected O, but got Unknown
			ConfigEntry<int> configEntry = ((BaseUnityPlugin)this).Config.Bind<int>("Example", "Int Slider", 30, new ConfigDescription("This is an integer slider. You can also type a value in the input field to the right of the slider.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			ConfigEntry<float> configEntry2 = ((BaseUnityPlugin)this).Config.Bind<float>("Example", "Float Slider", 0f, new ConfigDescription("This is a float slider. You can also type a value in the input field to the right of the slider.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 1f), Array.Empty<object>()));
			ConfigEntry<float> configEntry3 = ((BaseUnityPlugin)this).Config.Bind<float>("Example", "Float Step Slider", 0f, new ConfigDescription("This is a float step slider. It set values in increments. You can also type a value in the input field to the right of the slider.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 1f), Array.Empty<object>()));
			ConfigEntry<bool> configEntry4 = ((BaseUnityPlugin)this).Config.Bind<bool>("Example", "Bool Checkbox", false, new ConfigDescription("This is a bool checkbox.", (AcceptableValueBase)null, Array.Empty<object>()));
			ConfigEntry<TestEnum> configEntry5 = ((BaseUnityPlugin)this).Config.Bind<TestEnum>("Example", "Enum Dropdown", TestEnum.None, new ConfigDescription("This is a enum dropdown.", (AcceptableValueBase)null, Array.Empty<object>()));
			ConfigEntry<string> configEntry6 = ((BaseUnityPlugin)this).Config.Bind<string>("Example", "Text Input", "Example", "This is a text input field. It can have a limit of characters too.");
			ConfigEntry<int> configEntry7 = ((BaseUnityPlugin)this).Config.Bind<int>("Example", "Int Input", 50, "This is an integer input field.");
			ConfigEntry<float> configEntry8 = ((BaseUnityPlugin)this).Config.Bind<float>("Example", "Float Input", 0.5f, "This is a float input field.");
			LethalConfigManager.AddConfigItem(new IntSliderConfigItem(configEntry, requiresRestart: false));
			LethalConfigManager.AddConfigItem(new FloatSliderConfigItem(configEntry2, requiresRestart: false));
			LethalConfigManager.AddConfigItem(new FloatStepSliderConfigItem(configEntry3, new FloatStepSliderOptions
			{
				Step = 0.1f,
				RequiresRestart = false,
				Min = -1f,
				Max = 1f
			}));
			LethalConfigManager.AddConfigItem(new BoolCheckBoxConfigItem(configEntry4, requiresRestart: false));
			LethalConfigManager.AddConfigItem(new EnumDropDownConfigItem<TestEnum>(configEntry5, requiresRestart: false));
			LethalConfigManager.AddConfigItem(new TextInputFieldConfigItem(configEntry6, requiresRestart: false));
			LethalConfigManager.AddConfigItem(new GenericButtonConfigItem("Example", "Button", "This is a test button with a callback", "Open", delegate
			{
				ConfigMenuManager.Instance?.DisplayNotification("Buttons can be used to open custom menus or other things.", "OK");
			}));
			LethalConfigManager.AddConfigItem(new IntInputFieldConfigItem(configEntry7, new IntInputFieldOptions
			{
				Max = 150
			}));
			LethalConfigManager.AddConfigItem(new FloatInputFieldConfigItem(configEntry8, new FloatInputFieldOptions
			{
				Max = 2.5f
			}));
		}
	}
}
namespace LethalConfig.Settings
{
	internal static class MenusUtils
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__0_0;

			public static UnityAction <>9__0_1;

			public static Func<Button, GameObject> <>9__0_2;

			public static Func<GameObject, RectTransform> <>9__0_4;

			public static Func<RectTransform, float> <>9__0_5;

			public static Func<float, float, float> <>9__0_6;

			internal void <InjectMenu>b__0_0()
			{
				ConfigMenuManager.Instance.ShowConfigMenu();
			}

			internal void <InjectMenu>b__0_1()
			{
				ConfigMenuManager.Instance.menuAudio.PlayConfirmSFX();
			}

			internal GameObject <InjectMenu>b__0_2(Button b)
			{
				return ((Component)b).gameObject;
			}

			internal RectTransform <InjectMenu>b__0_4(GameObject b)
			{
				Transform transform = b.transform;
				return (RectTransform)(object)((transform is RectTransform) ? transform : null);
			}

			internal float <InjectMenu>b__0_5(RectTransform t)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				return t.anchoredPosition.y;
			}

			internal float <InjectMenu>b__0_6(float y1, float y2)
			{
				return Mathf.Abs(y2 - y1);
			}
		}

		internal static void InjectMenu(Transform parentTransform, Transform mainButtonsTransform, GameObject quitButton)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: 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)
			//IL_0108: Expected O, but got Unknown
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Expected O, but got Unknown
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = Object.Instantiate<GameObject>(Assets.ConfigMenuManagerPrefab);
			obj.transform.SetParent(parentTransform);
			obj.transform.localPosition = Vector3.zero;
			GameObject obj2 = Object.Instantiate<GameObject>(Assets.ConfigMenuPrefab);
			obj2.transform.SetParent(parentTransform, false);
			obj2.transform.localPosition = Vector3.zero;
			obj2.transform.localScale = Vector3.one;
			obj2.transform.localRotation = Quaternion.identity;
			obj2.SetActive(false);
			GameObject obj3 = Object.Instantiate<GameObject>(Assets.ConfigMenuNotificationPrefab);
			obj3.transform.SetParent(parentTransform, false);
			obj3.transform.localPosition = Vector3.zero;
			obj3.transform.localScale = Vector3.one;
			obj3.transform.localRotation = Quaternion.identity;
			obj3.SetActive(false);
			GameObject clonedButton = Object.Instantiate<GameObject>(quitButton, mainButtonsTransform);
			((UnityEventBase)clonedButton.GetComponent<Button>().onClick).RemoveAllListeners();
			clonedButton.GetComponent<Button>().onClick = new ButtonClickedEvent();
			ButtonClickedEvent onClick = clonedButton.GetComponent<Button>().onClick;
			object obj4 = <>c.<>9__0_0;
			if (obj4 == null)
			{
				UnityAction val = delegate
				{
					ConfigMenuManager.Instance.ShowConfigMenu();
				};
				<>c.<>9__0_0 = val;
				obj4 = (object)val;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj4);
			ButtonClickedEvent onClick2 = clonedButton.GetComponent<Button>().onClick;
			object obj5 = <>c.<>9__0_1;
			if (obj5 == null)
			{
				UnityAction val2 = delegate
				{
					ConfigMenuManager.Instance.menuAudio.PlayConfirmSFX();
				};
				<>c.<>9__0_1 = val2;
				obj5 = (object)val2;
			}
			((UnityEvent)onClick2).AddListener((UnityAction)obj5);
			((TMP_Text)clonedButton.GetComponentInChildren<TextMeshProUGUI>()).text = "> LethalConfig";
			IEnumerable<GameObject> source = from b in ((Component)mainButtonsTransform).GetComponentsInChildren<Button>()
				select ((Component)b).gameObject;
			IEnumerable<float> enumerable = from t in source.Where((GameObject b) => (Object)(object)b != (Object)(object)clonedButton).Select(delegate(GameObject b)
				{
					Transform transform = b.transform;
					return (RectTransform)(object)((transform is RectTransform) ? transform : null);
				})
				select t.anchoredPosition.y;
			float num = enumerable.Zip(enumerable.Skip(1), (float y1, float y2) => Mathf.Abs(y2 - y1)).Min();
			foreach (GameObject item in source.Where((GameObject g) => (Object)(object)g != (Object)(object)quitButton))
			{
				RectTransform component = item.GetComponent<RectTransform>();
				component.anchoredPosition += new Vector2(0f, num);
			}
			clonedButton.GetComponent<RectTransform>().anchoredPosition = quitButton.GetComponent<RectTransform>().anchoredPosition + new Vector2(0f, num);
		}
	}
}
namespace LethalConfig.Utils
{
	internal static class AssemblyExtensions
	{
		internal static bool TryGetModInfo(this Assembly assembly, out ModInfo modInfo)
		{
			modInfo = new ModInfo();
			BepInPlugin val = assembly.FindPluginAttribute();
			if (val == null)
			{
				return false;
			}
			modInfo.Name = val.Name;
			modInfo.GUID = val.GUID;
			modInfo.Version = val.Version.ToString();
			return true;
		}

		internal static BepInPlugin FindPluginAttribute(this Assembly assembly)
		{
			Type[] array;
			try
			{
				array = assembly.GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				array = ex.Types.Where((Type t) => t != null).ToArray();
			}
			Type[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				BepInPlugin customAttribute = ((MemberInfo)array2[i]).GetCustomAttribute<BepInPlugin>();
				if (customAttribute != null)
				{
					return customAttribute;
				}
			}
			return null;
		}
	}
	internal static class Assets
	{
		private static AssetBundle assetBundle;

		internal static GameObject ConfigMenuManagerPrefab;

		internal static GameObject ConfigMenuNotificationPrefab;

		internal static GameObject ConfigMenuPrefab;

		internal static GameObject ModListItemPrefab;

		internal static GameObject SectionHeaderPrefab;

		internal static GameObject IntSliderPrefab;

		internal static GameObject FloatSliderPrefab;

		internal static GameObject FloatStepSliderPrefab;

		internal static GameObject BoolCheckBoxPrefab;

		internal static GameObject EnumDropDownPrefab;

		internal static GameObject TextInputFieldPrefab;

		internal static GameObject IntInputFieldPrefab;

		internal static GameObject FloatInputFieldPrefab;

		internal static GameObject GenericButtonPrefab;

		internal static Sprite DefaultModIcon;

		internal static Sprite LethalConfigModIcon;

		internal static void Init()
		{
			assetBundle = AssetBundle.LoadFromFile(PathUtils.PathForResourceInAssembly("ainavt_lethalconfig"));
			if ((Object)(object)assetBundle == (Object)null)
			{
				LogUtils.LogError("Failed to load LethalConfig bundle.");
				return;
			}
			LoadAsset<GameObject>("prefabs/ConfigMenuManager.prefab", out ConfigMenuManagerPrefab);
			LoadAsset<GameObject>("prefabs/ConfigMenuNotification.prefab", out ConfigMenuNotificationPrefab);
			LoadAsset<GameObject>("prefabs/ConfigMenu.prefab", out ConfigMenuPrefab);
			LoadAsset<GameObject>("prefabs/ModListItem.prefab", out ModListItemPrefab);
			LoadAsset<GameObject>("prefabs/components/SectionHeader.prefab", out SectionHeaderPrefab);
			LoadAsset<GameObject>("prefabs/components/IntSliderItem.prefab", out IntSliderPrefab);
			LoadAsset<GameObject>("prefabs/components/FloatSliderItem.prefab", out FloatSliderPrefab);
			LoadAsset<GameObject>("prefabs/components/FloatStepSliderItem.prefab", out FloatStepSliderPrefab);
			LoadAsset<GameObject>("prefabs/components/BoolCheckBoxItem.prefab", out BoolCheckBoxPrefab);
			LoadAsset<GameObject>("prefabs/components/EnumDropDownItem.prefab", out EnumDropDownPrefab);
			LoadAsset<GameObject>("prefabs/components/TextInputFieldItem.prefab", out TextInputFieldPrefab);
			LoadAsset<GameObject>("prefabs/components/IntInputFieldItem.prefab", out IntInputFieldPrefab);
			LoadAsset<GameObject>("prefabs/components/FloatInputFieldItem.prefab", out FloatInputFieldPrefab);
			LoadAsset<GameObject>("prefabs/components/GenericButtonItem.prefab", out GenericButtonPrefab);
			LoadAsset<Sprite>("sprite/unknown-icon.png", out DefaultModIcon);
			LoadAsset<Sprite>("icon.png", out LethalConfigModIcon);
			LogUtils.LogInfo("Finished loading assets.");
		}

		private static void LoadAsset<T>(string assetName, out T asset) where T : Object
		{
			string text = "Assets/" + assetName;
			asset = assetBundle.LoadAsset<T>(text);
			if ((Object)(object)asset == (Object)null)
			{
				LogUtils.LogError("Failed to load asset (" + text + ")");
			}
		}
	}
	internal static class LogUtils
	{
		private static Dictionary<Assembly, ManualLogSource> logSources = new Dictionary<Assembly, ManualLogSource>();

		public static void Init(string pluginGuid)
		{
			Assembly callingAssembly = Assembly.GetCallingAssembly();
			if (!logSources.ContainsKey(callingAssembly))
			{
				logSources.Add(callingAssembly, Logger.CreateLogSource(pluginGuid));
			}
		}

		public static void LogInfo(string message)
		{
			logSources[Assembly.GetCallingAssembly()].LogInfo((object)message);
		}

		public static void LogWarning(string message)
		{
			logSources[Assembly.GetCallingAssembly()].LogWarning((object)message);
		}

		public static void LogError(string message)
		{
			logSources[Assembly.GetCallingAssembly()].LogError((object)message);
		}

		public static void LogFatal(string message)
		{
			logSources[Assembly.GetCallingAssembly()].LogFatal((object)message);
		}
	}
	internal static class PathUtils
	{
		public static string PathForResourceInAssembly(string resourceName, Assembly assembly = null)
		{
			return Path.Combine(Path.GetDirectoryName((assembly ?? Assembly.GetCallingAssembly()).Location), resourceName);
		}
	}
}
namespace LethalConfig.Patches
{
	[HarmonyPatch(typeof(MenuManager))]
	internal class MenuManagerPatches
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void StartPostFix(MenuManager __instance)
		{
			((MonoBehaviour)__instance).StartCoroutine(DelayedMainMenuInjection());
		}

		private static IEnumerator DelayedMainMenuInjection()
		{
			yield return (object)new WaitForSeconds(0f);
			InjectToMainMenu();
		}

		private static void InjectToMainMenu()
		{
			LogUtils.LogInfo("Injecting mod config menu into main menu...");
			GameObject val = GameObject.Find("MenuContainer");
			Transform val2 = ((val != null) ? val.transform.Find("MainButtons") : null);
			object obj;
			if (val2 == null)
			{
				obj = null;
			}
			else
			{
				Transform obj2 = val2.Find("QuitButton");
				obj = ((obj2 != null) ? ((Component)obj2).gameObject : null);
			}
			GameObject val3 = (GameObject)obj;
			if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null) && !((Object)(object)val3 == (Object)null))
			{
				MenusUtils.InjectMenu(val.transform, val2, val3);
			}
		}
	}
	[HarmonyPatch(typeof(QuickMenuManager))]
	internal class QuickMenuManagerPatches
	{
		[HarmonyPatch("CloseQuickMenuPanels")]
		[HarmonyPostfix]
		public static void CloseQuickMenuPanelsPostFix(QuickMenuManager __instance)
		{
			ConfigMenu componentInChildren = ((Component)__instance.menuContainer.transform).GetComponentInChildren<ConfigMenu>(true);
			ConfigMenuNotification componentInChildren2 = ((Component)__instance.menuContainer.transform).GetComponentInChildren<ConfigMenuNotification>(true);
			componentInChildren?.Close(animated: false);
			componentInChildren2?.Close(animated: false);
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void StartPostFix(QuickMenuManager __instance)
		{
			LogUtils.LogInfo("Injecting mod config menu into quick menu...");
			GameObject menuContainer = __instance.menuContainer;
			Transform val = ((menuContainer != null) ? menuContainer.transform.Find("MainButtons") : null);
			GameObject val2 = ((val != null) ? ((Component)val.Find("Quit")).gameObject : null);
			if (!((Object)(object)menuContainer == (Object)null) && !((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null))
			{
				MenusUtils.InjectMenu(menuContainer.transform, val, val2);
			}
		}
	}
}
namespace LethalConfig.MonoBehaviours
{
	internal class ConfigInfoBox : MonoBehaviour
	{
		public TextMeshProUGUI configInfoText;

		public void SetConfigInfo(string configInfo)
		{
			((TMP_Text)configInfoText).text = configInfo;
		}
	}
	internal class ConfigList : MonoBehaviour
	{
		public GameObject listContainerObject;

		public DescriptionBox descriptionBox;

		internal void LoadConfigsForMod(Mod mod)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			ClearConfigList();
			foreach (IGrouping<string, BaseConfigItem> item in from c in mod.configItems
				group c by c.Section)
			{
				GameObject obj = Object.Instantiate<GameObject>(Assets.SectionHeaderPrefab);
				obj.GetComponent<SectionHeader>().SetSectionName(item.Key);
				obj.transform.SetParent(listContainerObject.transform);
				obj.transform.localPosition = Vector3.zero;
				obj.transform.localScale = Vector3.one;
				obj.transform.localRotation = Quaternion.identity;
				foreach (BaseConfigItem item2 in item)
				{
					GameObject val = item2.CreateGameObjectForConfig();
					ModConfigController controller = val.GetComponent<ModConfigController>();
					if (!controller.SetConfigItem(item2))
					{
						Object.DestroyImmediate((Object)(object)val.gameObject);
						return;
					}
					val.transform.SetParent(listContainerObject.transform);
					val.transform.localPosition = Vector3.zero;
					val.transform.localScale = Vector3.one;
					val.transform.localRotation = Quaternion.identity;
					controller.OnHoverEnter += delegate
					{
						descriptionBox.ShowConfigInfo(controller.GetDescription());
						ConfigMenuManager.Instance.menuAudio.PlayHoverSFX();
					};
				}
			}
		}

		private void ClearConfigList()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			foreach (Transform item in listContainerObject.transform)
			{
				Object.Destroy((Object)(object)((Component)item).gameObject);
			}
		}
	}
	internal class ConfigMenu : MonoBehaviour
	{
		public ConfigList configList;

		public Animator menuAnimator;

		private void Awake()
		{
			LethalConfigManager.AutoGenerateMissingConfigsIfNeeded();
		}

		public void Open()
		{
			//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)
			AnimatorStateInfo currentAnimatorStateInfo = menuAnimator.GetCurrentAnimatorStateInfo(0);
			if (!((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("ConfigMenuNormal") && !((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("ConfigMenuAppear"))
			{
				((Component)this).gameObject.SetActive(true);
				menuAnimator.SetTrigger("Open");
				((Component)this).transform.SetAsLastSibling();
			}
		}

		public void Close(bool animated = true)
		{
			//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)
			AnimatorStateInfo currentAnimatorStateInfo = menuAnimator.GetCurrentAnimatorStateInfo(0);
			if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("ConfigMenuClosed") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("ConfigMenuDisappear"))
			{
				return;
			}
			foreach (BaseConfigItem item in LethalConfigManager.Mods.SelectMany((KeyValuePair<string, Mod> m) => m.Value.configItems))
			{
				item.CancelChanges();
			}
			UpdateAppearanceOfCurrentComponents();
			if (!animated)
			{
				((Component)this).gameObject.SetActive(false);
				menuAnimator.SetTrigger("ForceClose");
			}
			else
			{
				menuAnimator.SetTrigger("Close");
			}
		}

		public void OnCloseAnimationEnd()
		{
			((Component)this).gameObject.SetActive(false);
		}

		public void OnCancelButtonClicked()
		{
			Close();
			ConfigMenuManager.Instance.menuAudio.PlayCancelSFX();
		}

		public void OnApplyButtonClicked()
		{
			List<BaseConfigItem> list = (from c in LethalConfigManager.Mods.SelectMany((KeyValuePair<string, Mod> m) => m.Value.configItems)
				where c.HasValueChanged
				select c).ToList();
			List<BaseConfigItem> list2 = list.Where((BaseConfigItem c) => c.RequiresRestart).ToList();
			foreach (BaseConfigItem item in list)
			{
				item.ApplyChanges();
			}
			UpdateAppearanceOfCurrentComponents();
			ConfigMenuManager.Instance.menuAudio.PlayConfirmSFX();
			LogUtils.LogInfo($"Saved config values for {list.Count} items.");
			LogUtils.LogInfo($"Modified {list2.Count} item(s) that requires a restart.");
			if (list2.Count > 0)
			{
				ConfigMenuManager.Instance.DisplayNotification("Some of the modified settings may require a restart to take effect.", "OK");
			}
		}

		private void UpdateAppearanceOfCurrentComponents()
		{
			ModConfigController[] componentsInChildren = ((Component)configList).GetComponentsInChildren<ModConfigController>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].UpdateAppearance();
			}
		}
	}
	internal class ConfigMenuNotification : MonoBehaviour
	{
		public TextMeshProUGUI messageTextComponent;

		public TextMeshProUGUI buttonTextComponent;

		public Animator notificationAnimator;

		public void SetNotificationContent(string text, string button)
		{
			((TMP_Text)messageTextComponent).text = text;
			((TMP_Text)buttonTextComponent).text = "[" + button + "]";
		}

		public void Open()
		{
			//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)
			AnimatorStateInfo currentAnimatorStateInfo = notificationAnimator.GetCurrentAnimatorStateInfo(0);
			if (!((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("NotificationNormal") && !((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("NotificationAppear"))
			{
				((Component)this).gameObject.SetActive(true);
				notificationAnimator.SetTrigger("Open");
				((Component)this).transform.SetAsLastSibling();
			}
		}

		public void Close(bool animated = true)
		{
			//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)
			AnimatorStateInfo currentAnimatorStateInfo = notificationAnimator.GetCurrentAnimatorStateInfo(0);
			if (!((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("NotificationClosed") && !((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("NotificationDisappear"))
			{
				if (!animated)
				{
					((Component)this).gameObject.SetActive(false);
					notificationAnimator.SetTrigger("ForceClose");
				}
				else
				{
					notificationAnimator.SetTrigger("Close");
				}
			}
		}

		public void OnButtonClick()
		{
			Close();
			ConfigMenuManager.Instance.menuAudio.PlayConfirmSFX();
		}

		public void OnCloseAnimationEnd()
		{
			((Component)this).gameObject.SetActive(false);
		}
	}
	internal class DescriptionBox : MonoBehaviour
	{
		public ModInfoBox modInfoBox;

		public ConfigInfoBox configInfoBox;

		private void Awake()
		{
			((Component)modInfoBox).gameObject.SetActive(false);
			((Component)configInfoBox).gameObject.SetActive(false);
		}

		public void ShowConfigInfo(string configInfo)
		{
			((Component)configInfoBox).gameObject.SetActive(true);
			configInfoBox.SetConfigInfo(configInfo);
			HideModInfo();
		}

		public void HideConfigInfo()
		{
			((Component)configInfoBox).gameObject.SetActive(false);
		}

		public void ShowModInfo(Mod mod)
		{
			((Component)modInfoBox).gameObject.SetActive(true);
			modInfoBox.SetModInfo(mod);
			HideConfigInfo();
		}

		public void HideModInfo()
		{
			((Component)modInfoBox).gameObject.SetActive(false);
		}
	}
	internal class ModInfoBox : MonoBehaviour
	{
		public Image modIconImage;

		public TextMeshProUGUI modInfoText;

		public void SetModInfo(Mod mod)
		{
			modIconImage.sprite = mod.modInfo.Icon;
			_ = $"{mod.modInfo}";
			((TMP_Text)modInfoText).text = $"{mod.modInfo}";
		}
	}
	internal class ModList : MonoBehaviour
	{
		public GameObject modItemPrefab;

		public GameObject listContainerObject;

		public ConfigList configList;

		public DescriptionBox descriptionBox;

		private List<ModListItem> _items;

		private void Awake()
		{
			_items = new List<ModListItem>();
			BuildModList();
		}

		private void BuildModList()
		{
			//IL_0024: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			_items.Clear();
			foreach (Transform item in listContainerObject.transform)
			{
				Object.Destroy((Object)(object)((Component)item).gameObject);
			}
			foreach (Mod mod in from m in LethalConfigManager.Mods.Values
				orderby m.modInfo.GUID != "ainavt.lc.lethalconfig", m.IsAutoGenerated, m.modInfo.Name
				select m)
			{
				GameObject val = Object.Instantiate<GameObject>(modItemPrefab, listContainerObject.transform);
				val.transform.localScale = Vector3.one;
				val.transform.localPosition = Vector3.zero;
				val.transform.localRotation = Quaternion.identity;
				ModListItem component = val.GetComponent<ModListItem>();
				component.mod = mod;
				component.modSelected += ModSelected;
				component.OnHoverEnter += delegate
				{
					descriptionBox.ShowModInfo(mod);
					ConfigMenuManager.Instance.menuAudio.PlayHoverSFX();
				};
				component.OnHoverExit += delegate
				{
					descriptionBox.HideModInfo();
				};
				_items.Add(val.GetComponent<ModListItem>());
			}
		}

		private void ModSelected(Mod mod)
		{
			ConfigMenuManager.Instance.menuAudio.PlayConfirmSFX();
			configList.LoadConfigsForMod(mod);
			_items.First((ModListItem i) => i.mod == mod).SetSelected(selected: true);
			foreach (ModListItem item in _items.Where((ModListItem i) => i.mod != mod))
			{
				item.SetSelected(selected: false);
			}
		}
	}
	internal class ModListItem : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
	{
		public delegate void OnHoverHandler();

		internal delegate void ModSelectedHandler(Mod mod);

		public TextMeshProUGUI textMesh;

		public GameObject selectedBorder;

		public Image modIcon;

		private Mod _mod;

		internal Mod mod
		{
			get
			{
				return _mod;
			}
			set
			{
				_mod = value;
				((TMP_Text)textMesh).text = _mod.modInfo.Name;
				modIcon.sprite = _mod.modInfo.Icon;
			}
		}

		public event OnHoverHandler OnHoverEnter;

		public event OnHoverHandler OnHoverExit;

		internal event ModSelectedHandler modSelected;

		public void OnClick()
		{
			this.modSelected(_mod);
		}

		public void SetSelected(bool selected)
		{
			selectedBorder.SetActive(selected);
		}

		public void OnPointerEnter(PointerEventData eventData)
		{
			this.OnHoverEnter?.Invoke();
		}

		public void OnPointerExit(PointerEventData eventData)
		{
			this.OnHoverExit?.Invoke();
		}

		public string GetDescription()
		{
			return _mod.modInfo.Name + "\n" + _mod.modInfo.GUID + "\n" + _mod.modInfo.Version;
		}
	}
	internal class SectionHeader : MonoBehaviour
	{
		public TextMeshProUGUI textMesh;

		public void SetSectionName(string sectionName)
		{
			((TMP_Text)textMesh).text = "[" + sectionName + "]";
		}
	}
	internal class Tooltip : MonoBehaviour
	{
		public TextMeshProUGUI textComponent;

		private RectTransform rectTransform;

		private Camera uiCamera;

		public void SetText(string text)
		{
			((TMP_Text)textComponent).text = text;
		}

		public void SetTarget(GameObject gameObject)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).transform.position = gameObject.transform.position;
		}
	}
	internal class TooltipSystem : MonoBehaviour
	{
		private static TooltipSystem instance;

		public Tooltip tooltip;

		private void Awake()
		{
			instance = this;
		}

		public static void Show(string content, GameObject target)
		{
			if (!((Object)(object)instance == (Object)null))
			{
				((Component)instance.tooltip).gameObject.SetActive(true);
				instance.tooltip.SetText(content);
				instance.tooltip.SetTarget(target);
			}
		}

		public static void Hide()
		{
			if (!((Object)(object)instance == (Object)null))
			{
				((Component)instance.tooltip).gameObject.SetActive(false);
			}
		}
	}
	internal class TooltipTrigger : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
	{
		public string tooltipText;

		public void OnPointerEnter(PointerEventData eventData)
		{
			TooltipSystem.Show(tooltipText, ((Component)this).gameObject);
		}

		public void OnPointerExit(PointerEventData eventData)
		{
			TooltipSystem.Hide();
		}
	}
	internal class VersionLabel : MonoBehaviour
	{
		private void Start()
		{
			((TMP_Text)((Component)this).GetComponent<TextMeshProUGUI>()).text = "LethalConfig v1.3.4";
		}
	}
}
namespace LethalConfig.MonoBehaviours.Managers
{
	internal class ConfigMenuAudioManager : MonoBehaviour
	{
		public AudioClip confirmSFX;

		public AudioClip cancelSFX;

		public AudioClip selectSFX;

		public AudioClip hoverSFX;

		public AudioClip changeValueSFX;

		public AudioSource audioSource;

		public void PlayConfirmSFX()
		{
			audioSource.PlayOneShot(confirmSFX);
		}

		public void PlayCancelSFX()
		{
			audioSource.PlayOneShot(cancelSFX);
		}

		public void PlayHoverSFX()
		{
			audioSource.PlayOneShot(hoverSFX);
		}

		public void PlaySelectSFX()
		{
			audioSource.PlayOneShot(selectSFX);
		}

		public void PlayChangeValueSFX()
		{
			audioSource.PlayOneShot(changeValueSFX);
		}
	}
	internal class ConfigMenuManager : MonoBehaviour
	{
		public ConfigMenuAudioManager menuAudio;

		public static ConfigMenuManager Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
		}

		private void OnDestroy()
		{
			Instance = null;
		}

		public void ShowConfigMenu()
		{
			Object.FindObjectOfType<ConfigMenu>(true)?.Open();
		}

		public void DisplayNotification(string message, string button)
		{
			ConfigMenuNotification configMenuNotification = Object.FindObjectOfType<ConfigMenuNotification>(true);
			if ((Object)(object)configMenuNotification == (Object)null)
			{
				LogUtils.LogWarning("Notification object not found");
				return;
			}
			configMenuNotification.SetNotificationContent(message, button);
			configMenuNotification.Open();
			EventSystem.current.SetSelectedGameObject(((Component)((Component)configMenuNotification).GetComponentInChildren<Button>()).gameObject);
		}
	}
}
namespace LethalConfig.MonoBehaviours.Components
{
	internal class BoolCheckBoxController : ModConfigController<BoolCheckBoxConfigItem, bool>
	{
		public Toggle toggleComponent;

		public override void UpdateAppearance()
		{
			base.UpdateAppearance();
			toggleComponent.SetIsOnWithoutNotify(base.ConfigItem.CurrentValue);
		}

		protected override void OnSetConfigItem()
		{
			toggleComponent.SetIsOnWithoutNotify(base.ConfigItem.CurrentValue);
			UpdateAppearance();
		}

		public void OnCheckBoxValueChanged(bool value)
		{
			base.ConfigItem.CurrentValue = value;
			UpdateAppearance();
			ConfigMenuManager.Instance.menuAudio.PlayChangeValueSFX();
		}
	}
	internal class EnumDropDownController : ModConfigController
	{
		public TMP_Dropdown dropdownComponent;

		private Type _enumType;

		private List<string> _enumNames = new List<string>();

		public override string GetDescription()
		{
			return base.GetDescription() + "\n\nDefault: " + Enum.GetName(_enumType, baseConfigItem.BoxedDefaultValue);
		}

		public override void UpdateAppearance()
		{
			base.UpdateAppearance();
			int valueWithoutNotify = _enumNames.FindIndex((string e) => e == Enum.GetName(_enumType, baseConfigItem.CurrentBoxedValue));
			dropdownComponent.SetValueWithoutNotify(valueWithoutNotify);
		}

		protected override void OnSetConfigItem()
		{
			_enumType = baseConfigItem.BaseConfigEntry.SettingType;
			_enumNames = Enum.GetNames(_enumType).ToList();
			dropdownComponent.ClearOptions();
			dropdownComponent.AddOptions(_enumNames);
			int valueWithoutNotify = _enumNames.FindIndex((string e) => e == Enum.GetName(_enumType, baseConfigItem.CurrentBoxedValue));
			dropdownComponent.SetValueWithoutNotify(valueWithoutNotify);
			UpdateAppearance();
		}

		public void OnDropDownValueChanged(int index)
		{
			baseConfigItem.CurrentBoxedValue = Enum.Parse(_enumType, _enumNames[index]);
			UpdateAppearance();
			ConfigMenuManager.Instance.menuAudio.PlayChangeValueSFX();
		}
	}
	internal class FloatInputFieldController : ModConfigController<FloatInputFieldConfigItem, float>
	{
		public TMP_InputField textInputField;

		public override string GetDescription()
		{
			string text = base.GetDescription();
			if (base.ConfigItem.MinValue != float.MinValue)
			{
				text += $"\nMin: {base.ConfigItem.MinValue:0.0#}";
			}
			if (base.ConfigItem.MaxValue != float.MaxValue)
			{
				text += $"\nMax: {base.ConfigItem.MaxValue:0.0#}";
			}
			return text;
		}

		protected override void OnSetConfigItem()
		{
			textInputField.SetTextWithoutNotify($"{base.ConfigItem.CurrentValue}");
			UpdateAppearance();
		}

		public void OnInputFieldEndEdit(string value)
		{
			if (float.TryParse(value, out var result))
			{
				base.ConfigItem.CurrentValue = Math.Clamp(result, base.ConfigItem.MinValue, base.ConfigItem.MaxValue);
			}
			UpdateAppearance();
			ConfigMenuManager.Instance.menuAudio.PlayChangeValueSFX();
		}

		public override void UpdateAppearance()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			base.UpdateAppearance();
			textInputField.SetTextWithoutNotify($"{base.ConfigItem.CurrentValue}");
			((Transform)textInputField.textComponent.rectTransform).localPosition = Vector3.zero;
		}
	}
	internal class FloatSliderController : ModConfigController<FloatSliderConfigItem, float>
	{
		public Slider sliderComponent;

		public TMP_InputField valueInputField;

		public override string GetDescription()
		{
			return $"{base.GetDescription()}\nMin: {base.ConfigItem.MinValue:0.0#}\nMax: {base.ConfigItem.MaxValue:0.0#}";
		}

		protected override void OnSetConfigItem()
		{
			sliderComponent.SetValueWithoutNotify(base.ConfigItem.CurrentValue);
			sliderComponent.maxValue = base.ConfigItem.MaxValue;
			sliderComponent.minValue = base.ConfigItem.MinValue;
			UpdateAppearance();
		}

		public void OnSliderValueChanged(float value)
		{
			base.ConfigItem.CurrentValue = value;
			UpdateAppearance();
			ConfigMenuManager.Instance.menuAudio.PlayChangeValueSFX();
		}

		public void OnInputFieldEndEdit(string value)
		{
			if (float.TryParse(value, out var result))
			{
				base.ConfigItem.CurrentValue = Math.Clamp(result, base.ConfigItem.MinValue, base.ConfigItem.MaxValue);
			}
			UpdateAppearance();
			ConfigMenuManager.Instance.menuAudio.PlayChangeValueSFX();
		}

		public override void UpdateAppearance()
		{
			base.UpdateAppearance();
			sliderComponent.SetValueWithoutNotify(base.ConfigItem.CurrentValue);
			valueInputField.SetTextWithoutNotify($"{base.ConfigItem.CurrentValue:0.0#}");
		}
	}
	internal class FloatStepSliderController : ModConfigController<FloatStepSliderConfigItem, float>
	{
		public Slider sliderComponent;

		public TMP_InputField valueInputField;

		public override string GetDescription()
		{
			return $"{base.GetDescription()}\nMin: {base.ConfigItem.MinValue:0.0#}\nMax: {base.ConfigItem.MaxValue:0.0#}";
		}

		protected override void OnSetConfigItem()
		{
			sliderComponent.SetValueWithoutNotify(base.ConfigItem.CurrentValue);
			int num = (int)MathF.Ceiling((base.ConfigItem.MaxValue - base.ConfigItem.MinValue) / MathF.Max(base.ConfigItem.Step, float.Epsilon));
			sliderComponent.maxValue = num;
			sliderComponent.minValue = 0f;
			sliderComponent.wholeNumbers = true;
			UpdateAppearance();
		}

		public void OnSliderValueChanged(float value)
		{
			base.ConfigItem.CurrentValue = MathF.Round(base.ConfigItem.MinValue + base.ConfigItem.Step * (float)(int)value, 4);
			UpdateAppearance();
			ConfigMenuManager.Instance.menuAudio.PlayChangeValueSFX();
		}

		public void OnInputFieldEndEdit(string value)
		{
			if (float.TryParse(value, out var result))
			{
				base.ConfigItem.CurrentValue = Math.Clamp(result, base.ConfigItem.MinValue, base.ConfigItem.MaxValue);
			}
			UpdateAppearance();
			ConfigMenuManager.Instance.menuAudio.PlayChangeValueSFX();
		}

		public override void UpdateAppearance()
		{
			base.UpdateAppearance();
			sliderComponent.SetValueWithoutNotify((base.ConfigItem.CurrentValue - base.ConfigItem.MinValue) / MathF.Max(base.ConfigItem.Step, float.Epsilon));
			valueInputField.SetTextWithoutNotify($"{base.ConfigItem.CurrentValue:0.0#}");
		}
	}
	internal class GenericButtonController : ModConfigController
	{
		public TextMeshProUGUI buttonTextComponent;

		private GenericButtonConfigItem ConfigItem => baseConfigItem as GenericButtonConfigItem;

		public override void UpdateAppearance()
		{
			base.UpdateAppearance();
			((TMP_Text)buttonTextComponent).text = ConfigItem?.ButtonOptions?.ButtonText ?? "Button";
		}

		protected override void OnSetConfigItem()
		{
			UpdateAppearance();
		}

		public void OnButtonClicked()
		{
			ConfigMenuManager.Instance.menuAudio.PlayConfirmSFX();
			ConfigItem?.ButtonOptions?.ButtonHandler?.Invoke();
		}
	}
	internal class IntInputFieldController : ModConfigController<IntInputFieldConfigItem, int>
	{
		public TMP_InputField textInputField;

		public override string GetDescription()
		{
			string text = base.GetDescription();
			if (base.ConfigItem.MinValue != int.MinValue)
			{
				text += $"\nMin: {base.ConfigItem.MinValue}";
			}
			if (base.ConfigItem.MaxValue != int.MaxValue)
			{
				text += $"\nMax: {base.ConfigItem.MaxValue}";
			}
			return text;
		}

		protected override void OnSetConfigItem()
		{
			textInputField.SetTextWithoutNotify($"{base.ConfigItem.CurrentValue}");
			UpdateAppearance();
		}

		public void OnInputFieldEndEdit(string value)
		{
			if (int.TryParse(value, out var result))
			{
				base.ConfigItem.CurrentValue = Math.Clamp(result, base.ConfigItem.MinValue, base.ConfigItem.MaxValue);
			}
			UpdateAppearance();
			ConfigMenuManager.Instance.menuAudio.PlayChangeValueSFX();
		}

		public override void UpdateAppearance()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			base.UpdateAppearance();
			textInputField.SetTextWithoutNotify($"{base.ConfigItem.CurrentValue}");
			((Transform)textInputField.textComponent.rectTransform).localPosition = Vector3.zero;
		}
	}
	internal class IntSliderController : ModConfigController<IntSliderConfigItem, int>
	{
		public Slider sliderComponent;

		public TMP_InputField valueInputField;

		public override string GetDescription()
		{
			return $"{base.GetDescription()}\nMin: {base.ConfigItem.MinValue}\nMax: {base.ConfigItem.MaxValue}";
		}

		protected override void OnSetConfigItem()
		{
			sliderComponent.SetValueWithoutNotify((float)base.ConfigItem.CurrentValue);
			sliderComponent.maxValue = base.ConfigItem.MaxValue;
			sliderComponent.minValue = base.ConfigItem.MinValue;
			UpdateAppearance();
		}

		public void OnSliderValueChanged(float value)
		{
			base.ConfigItem.CurrentValue = (int)value;
			UpdateAppearance();
			ConfigMenuManager.Instance.menuAudio.PlayChangeValueSFX();
		}

		public void OnInputFieldEndEdit(string value)
		{
			if (int.TryParse(value, out var result))
			{
				base.ConfigItem.CurrentValue = Math.Clamp(result, base.ConfigItem.MinValue, base.ConfigItem.MaxValue);
			}
			UpdateAppearance();
			ConfigMenuManager.Instance.menuAudio.PlayChangeValueSFX();
		}

		public override void UpdateAppearance()
		{
			base.UpdateAppearance();
			sliderComponent.SetValueWithoutNotify((float)base.ConfigItem.CurrentValue);
			valueInputField.SetTextWithoutNotify($"{base.ConfigItem.CurrentValue}");
		}
	}
	internal abstract class ModConfigController : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
	{
		public delegate void OnHoverHandler();

		private readonly List<Selectable> _selectables = new List<Selectable>();

		protected BaseConfigItem baseConfigItem;

		protected bool isOnSetup;

		public TextMeshProUGUI nameTextComponent;

		public TooltipTrigger tooltipTrigger;

		protected CanModifyResult CanModify
		{
			get
			{
				if (baseConfigItem.Options.CanModifyCallback == null)
				{
					return true;
				}
				return baseConfigItem.Options.CanModifyCallback();
			}
		}

		public event OnHoverHandler OnHoverEnter;

		public event OnHoverHandler OnHoverExit;

		protected virtual void Awake()
		{
			((Behaviour)tooltipTrigger).enabled = false;
			if (_selectables.Count <= 0)
			{
				_selectables.AddRange(((Component)this).GetComponentsInChildren<Selectable>());
			}
		}

		public virtual bool SetConfigItem(BaseConfigItem configItem)
		{
			baseConfigItem = configItem;
			isOnSetup = true;
			OnSetConfigItem();
			isOnSetup = false;
			if (baseConfigItem.Options.CanModifyCallback != null)
			{
				tooltipTrigger.tooltipText = "<b>Modifying this entry is currently disabled:</b>\n<b>" + CanModify.Reason + "</b>";
			}
			return true;
		}

		protected abstract void OnSetConfigItem();

		public virtual void UpdateAppearance()
		{
			((TMP_Text)nameTextComponent).text = (baseConfigItem.HasValueChanged ? "* " : "") + baseConfigItem.Name;
			CanModifyResult canModify = CanModify;
			foreach (Selectable selectable in _selectables)
			{
				selectable.interactable = canModify;
			}
			((Behaviour)tooltipTrigger).enabled = !canModify;
		}

		public virtual void ResetToDefault()
		{
			ConfigMenuManager.Instance.menuAudio.PlayConfirmSFX();
			baseConfigItem.ChangeToDefault();
			UpdateAppearance();
		}

		public virtual string GetDescription()
		{
			string text = "<b>" + baseConfigItem.Name + "</b>";
			if (baseConfigItem.IsAutoGenerated)
			{
				text += "\n\n<b>*This config entry was automatically generated and may require a restart*</b>";
			}
			else if (baseConfigItem.RequiresRestart)
			{
				text += "\n\n<b>*REQUIRES RESTART*</b>";
			}
			return text + "\n\n" + baseConfigItem.Description;
		}

		public void OnPointerEnter(PointerEventData eventData)
		{
			this.OnHoverEnter?.Invoke();
		}

		public void OnPointerExit(PointerEventData eventData)
		{
			this.OnHoverExit?.Invoke();
		}
	}
	internal abstract class ModConfigController<T, V> : ModConfigController where T : BaseValueConfigItem<V>
	{
		public T ConfigItem => (T)baseConfigItem;

		public override string GetDescription()
		{
			return $"{base.GetDescription()}\n\nDefault: {ConfigItem.Defaultvalue}";
		}

		public override bool SetConfigItem(BaseConfigItem configItem)
		{
			if (!(configItem is T))
			{
				LogUtils.LogError("Expected config item of type " + typeof(T).Name + ", but got " + configItem.GetType().Name + " instead.");
				return false;
			}
			return base.SetConfigItem(configItem);
		}
	}
	internal class TextInputFieldController : ModConfigController<TextInputFieldConfigItem, string>
	{
		public TMP_InputField textInputField;

		protected override void OnSetConfigItem()
		{
			textInputField.SetTextWithoutNotify(base.ConfigItem.CurrentValue);
			UpdateAppearance();
		}

		public void OnInputFieldEndEdit(string value)
		{
			base.ConfigItem.CurrentValue = value;
			UpdateAppearance();
			ConfigMenuManager.Instance.menuAudio.PlayChangeValueSFX();
		}

		public override void UpdateAppearance()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			base.UpdateAppearance();
			textInputField.SetTextWithoutNotify(base.ConfigItem.CurrentValue);
			((Transform)textInputField.textComponent.rectTransform).localPosition = Vector3.zero;
		}
	}
}
namespace LethalConfig.Mods
{
	internal class Mod
	{
		public ModInfo modInfo;

		public bool IsAutoGenerated;

		public List<BaseConfigItem> configItems;

		public List<ConfigEntryPath> entriesToSkipAutoGen;

		internal Mod(ModInfo modInfo)
		{
			configItems = new List<BaseConfigItem>();
			entriesToSkipAutoGen = new List<ConfigEntryPath>();
			this.modInfo = modInfo;
			TryResolveIconAndDesc();
		}

		internal void TryResolveIconAndDesc()
		{
			if (modInfo.TryGetPluginInfo(out var pluginInfo))
			{
				string text = Path.GetFullPath(pluginInfo.Location);
				DirectoryInfo parent = Directory.GetParent(text);
				while (parent != null && !string.Equals(parent.Name, "plugins", StringComparison.OrdinalIgnoreCase))
				{
					text = parent.FullName;
					parent = Directory.GetParent(text);
				}
				if (!text.EndsWith(".dll"))
				{
					string iconPath = Directory.EnumerateFiles(text, "icon.png", SearchOption.AllDirectories).FirstOrDefault();
					LoadIcon(iconPath);
					string manifestPath = Directory.EnumerateFiles(text, "manifest.json", SearchOption.AllDirectories).FirstOrDefault();
					LoadDesc(manifestPath);
				}
			}
		}

		private void LoadIcon(string iconPath)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (iconPath != null)
				{
					Texture2D val = new Texture2D(256, 256);
					if (ImageConversion.LoadImage(val, File.ReadAllBytes(iconPath)))
					{
						modInfo.Icon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
					}
				}
			}
			catch
			{
			}
		}

		private void LoadDesc(string manifestPath)
		{
			try
			{
				if (manifestPath != null)
				{
					ThunderstoreManifest thunderstoreManifest = JsonConvert.DeserializeObject<ThunderstoreManifest>(File.ReadAllText(manifestPath));
					if (thunderstoreManifest != null)
					{
						modInfo.Description = thunderstoreManifest.Description;
					}
				}
			}
			catch
			{
			}
		}

		internal void AddConfigItem(BaseConfigItem item)
		{
			configItems.Add(item);
		}
	}
	internal class ModInfo
	{
		internal string Name { get; set; }

		internal string GUID { get; set; }

		internal string Version { get; set; }

		internal string Description { get; set; } = "";


		internal Sprite Icon { get; set; } = Assets.DefaultModIcon;


		public override string ToString()
		{
			return "<b>" + Name + "</b>\n" + GUID + "\nv" + Version + "\n\n" + Description;
		}

		public bool TryGetPluginInfo(out PluginInfo pluginInfo)
		{
			return Chainloader.PluginInfos.TryGetValue(GUID, out pluginInfo);
		}
	}
	internal class ThunderstoreManifest
	{
		[JsonProperty("name")]
		public string Name { get; set; }

		[JsonProperty("version_number")]
		public string VersionNumber { get; set; }

		[JsonProperty("website_url")]
		public string WebsiteURL { get; set; }

		[JsonProperty("description")]
		public string Description { get; set; }

		[JsonProperty("dependencies")]
		public IList<string> Dependencies { get; set; }
	}
}
namespace LethalConfig.ConfigItems
{
	public abstract class BaseConfigItem
	{
		internal ConfigEntryBase BaseConfigEntry { get; private set; }

		internal BaseOptions Options { get; }

		internal bool RequiresRestart => Options.RequiresRestart;

		internal Mod Owner { get; set; }

		internal bool IsAutoGenerated { get; set; }

		private string UnderlyingSection
		{
			get
			{
				ConfigEntryBase baseConfigEntry = BaseConfigEntry;
				return ((baseConfigEntry != null) ? baseConfigEntry.Definition.Section : null) ?? string.Empty;
			}
		}

		private string UnderlyingName
		{
			get
			{
				ConfigEntryBase baseConfigEntry = BaseConfigEntry;
				return ((baseConfigEntry != null) ? baseConfigEntry.Definition.Key : null) ?? string.Empty;
			}
		}

		private string UnderlyingDescription
		{
			get
			{
				ConfigEntryBase baseConfigEntry = BaseConfigEntry;
				return ((baseConfigEntry != null) ? baseConfigEntry.Description.Description : null) ?? string.Empty;
			}
		}

		internal string Section => Options.Section ?? UnderlyingSection;

		internal string Name => Options.Name ?? UnderlyingName;

		internal string Description => Options.Description ?? UnderlyingDescription;

		internal object CurrentBoxedValue { get; set; }

		internal object OriginalBoxedValue
		{
			get
			{
				ConfigEntryBase baseConfigEntry = BaseConfigEntry;
				if (baseConfigEntry == null)
				{
					return null;
				}
				return baseConfigEntry.BoxedValue;
			}
		}

		internal object BoxedDefaultValue
		{
			get
			{
				ConfigEntryBase baseConfigEntry = BaseConfigEntry;
				if (baseConfigEntry == null)
				{
					return null;
				}
				return baseConfigEntry.DefaultValue;
			}
		}

		internal bool HasValueChanged
		{
			get
			{
				object currentBoxedValue = CurrentBoxedValue;
				if (currentBoxedValue == null)
				{
					return false;
				}
				return !currentBoxedValue.Equals(OriginalBoxedValue);
			}
		}

		internal abstract GameObject CreateGameObjectForConfig();

		internal void ApplyChanges()
		{
			if (BaseConfigEntry != null)
			{
				BaseConfigEntry.BoxedValue = CurrentBoxedValue;
			}
		}

		internal void CancelChanges()
		{
			CurrentBoxedValue = OriginalBoxedValue;
		}

		internal void ChangeToDefault()
		{
			CurrentBoxedValue = BoxedDefaultValue;
		}

		internal BaseConfigItem(BaseOptions options)
			: this(null, options)
		{
		}

		internal BaseConfigItem(ConfigEntryBase configEntry, BaseOptions options)
		{
			BaseConfigEntry = configEntry;
			Options = options;
			CurrentBoxedValue = OriginalBoxedValue;
		}

		internal bool IsSameConfig(BaseConfigItem configItem)
		{
			bool num = configItem.UnderlyingSection == UnderlyingSection;
			bool flag = configItem.UnderlyingName == UnderlyingName;
			bool flag2 = configItem.Owner.modInfo.GUID == Owner.modInfo.GUID;
			return num && flag && flag2;
		}
	}
	public abstract class BaseValueConfigItem<T> : BaseConfigItem
	{
		internal ConfigEntry<T> ConfigEntry => (ConfigEntry<T>)(object)base.BaseConfigEntry;

		internal T CurrentValue
		{
			get
			{
				return (T)base.CurrentBoxedValue;
			}
			set
			{
				base.CurrentBoxedValue = value;
			}
		}

		internal T OriginalValue => ConfigEntry.Value;

		internal T Defaultvalue => (T)((ConfigEntryBase)ConfigEntry).DefaultValue;

		internal BaseValueConfigItem(ConfigEntry<T> configEntry, BaseOptions options)
			: base((ConfigEntryBase)(object)configEntry, options)
		{
			CurrentValue = OriginalValue;
		}

		public override string ToString()
		{
			return base.Owner.modInfo.Name + "/" + ((ConfigEntryBase)ConfigEntry).Definition.Section + "/" + ((ConfigEntryBase)ConfigEntry).Definition.Key;
		}
	}
	public class BoolCheckBoxConfigItem : BaseValueConfigItem<bool>
	{
		public BoolCheckBoxConfigItem(ConfigEntry<bool> configEntry)
			: this(configEntry, requiresRestart: true)
		{
		}

		public BoolCheckBoxConfigItem(ConfigEntry<bool> configEntry, bool requiresRestart)
			: this(configEntry, new BoolCheckBoxOptions
			{
				RequiresRestart = requiresRestart
			})
		{
		}

		public BoolCheckBoxConfigItem(ConfigEntry<bool> configEntry, BoolCheckBoxOptions options)
			: base(configEntry, (BaseOptions)options)
		{
		}

		internal override GameObject CreateGameObjectForConfig()
		{
			return Object.Instantiate<GameObject>(Assets.BoolCheckBoxPrefab);
		}
	}
	public class EnumDropDownConfigItem<T> : BaseValueConfigItem<T> where T : Enum
	{
		public EnumDropDownConfigItem(ConfigEntry<T> configEntry)
			: this(configEntry, requiresRestart: true)
		{
		}

		public EnumDropDownConfigItem(ConfigEntry<T> configEntry, bool requiresRestart)
			: this(configEntry, new EnumDropDownOptions
			{
				RequiresRestart = requiresRestart
			})
		{
		}

		public EnumDropDownConfigItem(ConfigEntry<T> configEntry, EnumDropDownOptions options)
			: base(configEntry, (BaseOptions)options)
		{
		}

		internal override GameObject CreateGameObjectForConfig()
		{
			return Object.Instantiate<GameObject>(Assets.EnumDropDownPrefab);
		}
	}
	public sealed class FloatInputFieldConfigItem : BaseValueConfigItem<float>
	{
		internal float MaxValue { get; private set; }

		internal float MinValue { get; private set; }

		public FloatInputFieldConfigItem(ConfigEntry<float> configEntry)
			: this(configEntry, requiresRestart: true)
		{
		}

		public FloatInputFieldConfigItem(ConfigEntry<float> configEntry, bool requiresRestart)
			: this(configEntry, GetDefaultOptions(configEntry, requiresRestart))
		{
		}

		public FloatInputFieldConfigItem(ConfigEntry<float> configEntry, FloatInputFieldOptions options)
			: base(configEntry, (BaseOptions)options)
		{
			AcceptableValueBase acceptableValues = ((ConfigEntryBase)configEntry).Description.AcceptableValues;
			MinValue = (options.IsMinSet ? options.Min : ((acceptableValues as AcceptableValueRange<float>)?.MinValue ?? 0f));
			MaxValue = (options.IsMaxSet ? options.Max : ((acceptableValues as AcceptableValueRange<float>)?.MaxValue ?? 1f));
		}

		internal override GameObject CreateGameObjectForConfig()
		{
			return Object.Instantiate<GameObject>(Assets.FloatInputFieldPrefab);
		}

		private static FloatInputFieldOptions GetDefaultOptions(ConfigEntry<float> configEntry, bool requiresRestart = true)
		{
			AcceptableValueBase acceptableValues = ((ConfigEntryBase)configEntry).Description.AcceptableValues;
			return new FloatInputFieldOptions
			{
				Min = ((acceptableValues as AcceptableValueRange<float>)?.MinValue ?? float.MinValue),
				Max = ((acceptableValues as AcceptableValueRange<float>)?.MaxValue ?? float.MaxValue),
				RequiresRestart = requiresRestart
			};
		}
	}
	public sealed class FloatSliderConfigItem : BaseValueConfigItem<float>
	{
		internal float MaxValue { get; private set; }

		internal float MinValue { get; private set; }

		public FloatSliderConfigItem(ConfigEntry<float> configEntry)
			: this(configEntry, requiresRestart: true)
		{
		}

		public FloatSliderConfigItem(ConfigEntry<float> configEntry, bool requiresRestart)
			: this(configEntry, GetDefaultOptions(configEntry, requiresRestart))
		{
		}

		public FloatSliderConfigItem(ConfigEntry<float> configEntry, FloatSliderOptions options)
			: base(configEntry, (BaseOptions)options)
		{
			AcceptableValueBase acceptableValues = ((ConfigEntryBase)configEntry).Description.AcceptableValues;
			MinValue = (options.IsMinSet ? options.Min : ((acceptableValues as AcceptableValueRange<float>)?.MinValue ?? 0f));
			MaxValue = (options.IsMaxSet ? options.Max : ((acceptableValues as AcceptableValueRange<float>)?.MaxValue ?? 1f));
		}

		internal override GameObject CreateGameObjectForConfig()
		{
			return Object.Instantiate<GameObject>(Assets.FloatSliderPrefab);
		}

		private static FloatSliderOptions GetDefaultOptions(ConfigEntry<float> configEntry, bool requiresRestart = true)
		{
			AcceptableValueBase acceptableValues = ((ConfigEntryBase)configEntry).Description.AcceptableValues;
			return new FloatSliderOptions
			{
				Min = ((acceptableValues as AcceptableValueRange<float>)?.MinValue ?? 0f),
				Max = ((acceptableValues as AcceptableValueRange<float>)?.MaxValue ?? 1f),
				RequiresRestart = requiresRestart
			};
		}
	}
	public sealed class FloatStepSliderConfigItem : BaseValueConfigItem<float>
	{
		internal float MaxValue { get; private set; }

		internal float MinValue { get; private set; }

		internal float Step { get; private set; }

		public FloatStepSliderConfigItem(ConfigEntry<float> configEntry)
			: this(configEntry, requiresRestart: true)
		{
		}

		public FloatStepSliderConfigItem(ConfigEntry<float> configEntry, bool requiresRestart)
			: this(configEntry, GetDefaultOptions(configEntry, requiresRestart))
		{
		}

		public FloatStepSliderConfigItem(ConfigEntry<float> configEntry, FloatStepSliderOptions options)
			: base(configEntry, (BaseOptions)options)
		{
			AcceptableValueBase acceptableValues = ((ConfigEntryBase)configEntry).Description.AcceptableValues;
			MinValue = (options.IsMinSet ? options.Min : ((acceptableValues as AcceptableValueRange<float>)?.MinValue ?? 0f));
			MaxValue = (options.IsMaxSet ? options.Max : ((acceptableValues as AcceptableValueRange<float>)?.MaxValue ?? 1f));
			Step = options.Step;
		}

		internal override GameObject CreateGameObjectForConfig()
		{
			return Object.Instantiate<GameObject>(Assets.FloatStepSliderPrefab);
		}

		private static FloatStepSliderOptions GetDefaultOptions(ConfigEntry<float> configEntry, bool requiresRestart = true)
		{
			AcceptableValueBase acceptableValues = ((ConfigEntryBase)configEntry).Description.AcceptableValues;
			return new FloatStepSliderOptions
			{
				Min = ((acceptableValues as AcceptableValueRange<float>)?.MinValue ?? 0f),
				Max = ((acceptableValues as AcceptableValueRange<float>)?.MaxValue ?? 1f),
				Step = 0.1f,
				RequiresRestart = requiresRestart
			};
		}
	}
	public class GenericButtonConfigItem : BaseConfigItem
	{
		public GenericButtonOptions ButtonOptions => base.Options as GenericButtonOptions;

		public GenericButtonConfigItem(string section, string name, string description, string buttonText, GenericButtonOptions.GenericButtonHandler buttonHandler)
			: base(new GenericButtonOptions
			{
				Section = section,
				Name = name,
				Description = description,
				ButtonText = buttonText,
				ButtonHandler = buttonHandler,
				RequiresRestart = false
			})
		{
		}

		internal override GameObject CreateGameObjectForConfig()
		{
			return Object.Instantiate<GameObject>(Assets.GenericButtonPrefab);
		}
	}
	public sealed class IntInputFieldConfigItem : BaseValueConfigItem<int>
	{
		internal int MaxValue { get; private set; }

		internal int MinValue { get; private set; }

		public IntInputFieldConfigItem(ConfigEntry<int> configEntry)
			: this(configEntry, requiresRestart: true)
		{
		}

		public IntInputFieldConfigItem(ConfigEntry<int> configEntry, bool requiresRestart)
			: this(configEntry, GetDefaultOptions(configEntry, requiresRestart))
		{
		}

		public IntInputFieldConfigItem(ConfigEntry<int> configEntry, IntInputFieldOptions options)
			: base(configEntry, (BaseOptions)options)
		{
			AcceptableValueBase acceptableValues = ((ConfigEntryBase)configEntry).Description.AcceptableValues;
			MinValue = (options.IsMinSet ? options.Min : ((acceptableValues as AcceptableValueRange<int>)?.MinValue ?? 0));
			MaxValue = (options.IsMaxSet ? options.Max : ((acceptableValues as AcceptableValueRange<int>)?.MaxValue ?? 100));
		}

		internal override GameObject CreateGameObjectForConfig()
		{
			return Object.Instantiate<GameObject>(Assets.IntInputFieldPrefab);
		}

		private static IntInputFieldOptions GetDefaultOptions(ConfigEntry<int> configEntry, bool requiresRestart = true)
		{
			AcceptableValueBase acceptableValues = ((ConfigEntryBase)configEntry).Description.AcceptableValues;
			return new IntInputFieldOptions
			{
				Min = ((acceptableValues as AcceptableValueRange<int>)?.MinValue ?? int.MinValue),
				Max = ((acceptableValues as AcceptableValueRange<int>)?.MaxValue ?? int.MaxValue),
				RequiresRestart = requiresRestart
			};
		}
	}
	public sealed class IntSliderConfigItem : BaseValueConfigItem<int>
	{
		internal int MaxValue { get; private set; }

		internal int MinValue { get; private set; }

		public IntSliderConfigItem(ConfigEntry<int> configEntry)
			: this(configEntry, requiresRestart: true)
		{
		}

		public IntSliderConfigItem(ConfigEntry<int> configEntry, bool requiresRestart)
			: this(configEntry, GetDefaultOptions(configEntry, requiresRestart))
		{
		}

		public IntSliderConfigItem(ConfigEntry<int> configEntry, IntSliderOptions options)
			: base(configEntry, (BaseOptions)options)
		{
			AcceptableValueBase acceptableValues = ((ConfigEntryBase)configEntry).Description.AcceptableValues;
			MinValue = (options.IsMinSet ? options.Min : ((acceptableValues as AcceptableValueRange<int>)?.MinValue ?? 0));
			MaxValue = (options.IsMaxSet ? options.Max : ((acceptableValues as AcceptableValueRange<int>)?.MaxValue ?? 100));
		}

		internal override GameObject CreateGameObjectForConfig()
		{
			return Object.Instantiate<GameObject>(A

plugins/LethalEscape/LethalEscape.dll

Decompiled 9 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("LethalEscape")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LethalEscape")]
[assembly: AssemblyTitle("LethalEscape")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LethalEscape
{
	internal class LETimerFunctions : MonoBehaviour
	{
		public static float MinuteEscapeTimerPuffer;

		public static float MinuteEscapeTimerBracken;

		public static float MinuteEscapeTimerHoardingBug;

		public static LETimerFunctions instance;

		private void Awake()
		{
			instance = this;
		}

		private void Update()
		{
			MinuteEscapeTimerBracken += Time.deltaTime;
			MinuteEscapeTimerHoardingBug += Time.deltaTime;
			MinuteEscapeTimerPuffer += Time.deltaTime;
		}
	}
	[BepInPlugin("xCeezy.LethalEscape", "Lethal Escape", "0.8.2")]
	public class Plugin : BaseUnityPlugin
	{
		public static GameObject ExtraValues;

		private const string modGUID = "xCeezy.LethalEscape";

		private const string modName = "Lethal Escape";

		private const string modVersion = "0.8.2";

		private Harmony _harmony = new Harmony("LethalEscape");

		public static ManualLogSource mls;

		public static float TimeStartTeleport;

		public static ConfigEntry<bool> CanThumperEscape;

		public static ConfigEntry<bool> CanBrackenEscape;

		public static ConfigEntry<bool> CanJesterEscape;

		public static ConfigEntry<bool> CanHoardingBugEscape;

		public static ConfigEntry<bool> CanCoilHeadEscape;

		public static ConfigEntry<bool> CanSpiderEscape;

		public static ConfigEntry<bool> CanNutCrackerEscape;

		public static ConfigEntry<bool> CanHygrodereEscape;

		public static ConfigEntry<bool> CanPufferEscape;

		public static float JesterSpeedWindup;

		public static ConfigEntry<float> BrackenChanceToEscapeEveryMinute;

		public static ConfigEntry<float> PufferChanceToEscapeEveryMinute;

		public static ConfigEntry<float> HoardingBugChanceToEscapeEveryMinute;

		public static ConfigEntry<float> HoardingBugChanceToNestNearShip;

		public static ConfigEntry<float> HoardingBugChanceToSpawnOutside;

		public static ConfigEntry<float> BrackenChanceToSpawnOutside;

		public static ConfigEntry<float> PufferChanceToSpawnOutside;

		public static ConfigEntry<float> JesterChanceToSpawnOutside;

		public static ConfigEntry<float> HygrodereChanceToSpawnOutside;

		public static ConfigEntry<float> NutCrackerChanceToSpawnOutside;

		public static ConfigEntry<float> ThumperChanceToSpawnOutside;

		public static ConfigEntry<float> SpiderChanceToSpawnOutside;

		public static ConfigEntry<float> JesterSpeedIncreasePerSecond;

		public static ConfigEntry<float> MaxJesterOutsideSpeed;

		public static ConfigEntry<float> BrackenEscapeDelay;

		public static ConfigEntry<float> ThumperEscapeDelay;

		public static ConfigEntry<int> SpiderMinWebsOutside;

		public static ConfigEntry<int> SpiderMaxWebsOutside;

		private void Awake()
		{
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Expected O, but got Unknown
			CanThumperEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "ThumperEscape", true, "Whether or not the Thumper can escape");
			CanBrackenEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "BrackenEscape", true, "Whether or not the Bracken can escape");
			CanJesterEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "JesterEscape", true, "Whether or not the Jester can escape");
			CanHoardingBugEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "HoardingBugEscape", true, "Whether or not the Hoarding Bugs can escape");
			CanCoilHeadEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "CoilHeadEscape", true, "Whether or not Coil Head can escape");
			CanSpiderEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "SpiderEscape", true, "Whether or not the Spider can escape");
			CanNutCrackerEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "NutCrackerEscape", true, "Whether or not the Nut Cracker can escape");
			CanHygrodereEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "HygrodereEscape", false, "Whether or not the Hygrodere/Slime can escape");
			CanPufferEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "CanPufferEscape", true, "Whether or not the Puffer/Spore Lizard can escape");
			ThumperChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "ThumperSpawnOutsideChance", 5f, "The chance that the Thumper will spawn outside");
			BrackenChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "BrackenSpawnOutsideChance", 10f, "The chance that the Bracken will spawn outside");
			JesterChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "JesterSpawnOutsideChance", 0f, "The chance that the Jester will spawn outside");
			HoardingBugChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "HoardingBugSpawnOutsideChance", 30f, "The chance that the Hoarding Bug will spawn outside");
			SpiderChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "SpiderSpawnOutsideChance", 5f, "The chance that the Spider will spawn outside");
			NutCrackerChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "NutCrackerSpawnOutsideChance", 5f, "The chance that the NutCracker will spawn outside");
			HygrodereChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "HygrodereSpawnOutsideChance", 0f, "The chance that the Hygrodere will spawn outside");
			PufferChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "PufferSpawnOutsideChance", 5f, "The chance that the Puffer will spawn outside");
			PufferChanceToEscapeEveryMinute = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "Puffer Escape Chance", 10f, "The chance that the Puffer/Spore Lizard will escape randomly every minute");
			BrackenChanceToEscapeEveryMinute = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "Bracken Escape Chance", 10f, "The chance that the Bracken will escape randomly every minute");
			HoardingBugChanceToEscapeEveryMinute = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "HoardingBug Escape Chance", 15f, "The chance that the Hoarding Bug will escape randomly every minute");
			HoardingBugChanceToNestNearShip = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "HoardingBugShipNestChance", 50f, "The chance that the Hoarding Bug will make their nest at/near the ship");
			BrackenEscapeDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "Bracken Escape Delay", 5f, "Time it takes for the Bracken to follow a player outside");
			ThumperEscapeDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "Thumper Escape Delay", -5f, "Time it takes for the Thumper to follow a player outside which is based on how long the player was seen minus this value (Might break when under -15 and will force thumper outside when it sees someone when above 0)");
			SpiderMaxWebsOutside = ((BaseUnityPlugin)this).Config.Bind<int>("Escape Settings", "Max Spider Webs Outside", 28, "The maximum amount of spider webs the game will allow the spider to create webs outside (Vanilla game is 7 or 9 if update 47)");
			SpiderMinWebsOutside = ((BaseUnityPlugin)this).Config.Bind<int>("Escape Settings", "Min Spider Webs Outside", 20, "The minimum amount of spider webs the game will allow the spider to create webs outside (Vanilla game is 4 or 6 if update 47)");
			JesterSpeedIncreasePerSecond = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "Jester Speed Increase", 1.35f, "How much speed the jester gets per second");
			MaxJesterOutsideSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "Jester Outside Speed", 10f, "The max speed the Jester moves while outside (5 is the speed its at while in the box and 18 is jesters max speed inside the facility)");
			if ((Object)(object)ExtraValues == (Object)null)
			{
				ExtraValues = new GameObject();
				Object.DontDestroyOnLoad((Object)(object)ExtraValues);
				((Object)ExtraValues).hideFlags = (HideFlags)61;
				ExtraValues.AddComponent<LETimerFunctions>();
			}
			mls = Logger.CreateLogSource("GameMaster");
			mls.LogInfo((object)"Loaded xCeezy.LethalEscape. Patching.");
			_harmony.PatchAll(typeof(Plugin));
		}

		[HarmonyPatch(typeof(CrawlerAI), "Update")]
		[HarmonyPrefix]
		private static void CrawlerLEPrefixAI(CrawlerAI __instance)
		{
			if (((EnemyAI)__instance).isEnemyDead || !CanThumperEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				return;
			}
			if (!((EnemyAI)__instance).isOutside)
			{
				if (((EnemyAI)__instance).currentBehaviourStateIndex != 0 && __instance.noticePlayerTimer < ThumperEscapeDelay.Value && (Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory)
				{
					SendEnemyOutside((EnemyAI)(object)__instance);
				}
			}
			else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(CrawlerAI), "OnCollideWithPlayer")]
		[HarmonyPostfix]
		public static void ThumperAILEOutsideAttack(CrawlerAI __instance, ref Collider other)
		{
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			if (!((EnemyAI)__instance).isEnemyDead && ((EnemyAI)__instance).isOutside && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && !((double)__instance.timeSinceHittingPlayer <= 0.65) && !(((EnemyAI)__instance).stunNormalizedTimer > 0f))
				{
					__instance.timeSinceHittingPlayer = 0f;
					((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
					component.DamagePlayer(40, true, true, (CauseOfDeath)6, 0, false, default(Vector3));
					component.DamagePlayerFromOtherClientServerRpc(40, Vector3.zero, -1);
					((EnemyAI)__instance).agent.speed = 0f;
					__instance.HitPlayerServerRpc((int)component.playerClientId);
					component.JumpToFearLevel(1f, true);
				}
			}
		}

		[HarmonyPatch(typeof(CrawlerAI), "Start")]
		[HarmonyPostfix]
		private static void CrawlerAILEPostfixStart(CrawlerAI __instance)
		{
			if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && ThumperChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= ThumperChanceToSpawnOutside.Value)
			{
				SendEnemyOutside((EnemyAI)(object)__instance);
			}
		}

		[HarmonyPatch(typeof(JesterAI), "Update")]
		[HarmonyPrefix]
		private static void JesterLEPrefixAI(JesterAI __instance)
		{
			if (((EnemyAI)__instance).isEnemyDead || !CanJesterEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				return;
			}
			if (!((EnemyAI)__instance).isOutside)
			{
				if (((EnemyAI)__instance).currentBehaviourStateIndex == 2 && (Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory)
				{
					JesterSpeedWindup = 0f;
					SendEnemyOutside((EnemyAI)(object)__instance, SpawnOnDoor: false);
				}
			}
			else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(JesterAI), "Update")]
		[HarmonyPostfix]
		private static void JesterLEPostfixAI(JesterAI __instance)
		{
			if (!CanJesterEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost || !((EnemyAI)__instance).isOutside)
			{
				return;
			}
			if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
			bool flag = false;
			for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
			{
				if (StartOfRound.Instance.allPlayerScripts[i].isPlayerControlled && !StartOfRound.Instance.allPlayerScripts[i].isInsideFactory)
				{
					flag = true;
				}
			}
			if (flag)
			{
				((EnemyAI)__instance).SwitchToBehaviourState(2);
				((EnemyAI)__instance).agent.stoppingDistance = 0f;
			}
			JesterSpeedWindup = Mathf.Clamp(JesterSpeedWindup + Time.deltaTime * JesterSpeedIncreasePerSecond.Value, 0f, MaxJesterOutsideSpeed.Value);
			((EnemyAI)__instance).agent.speed = JesterSpeedWindup;
		}

		[HarmonyPatch(typeof(JesterAI), "OnCollideWithPlayer")]
		[HarmonyPostfix]
		public static void JesterAILEOutsideAttack(JesterAI __instance, ref Collider other)
		{
			if (!((EnemyAI)__instance).isEnemyDead && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && ((EnemyAI)__instance).isOutside)
			{
				if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
				{
					((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
				}
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && Object.op_Implicit((Object)(object)((Component)other).gameObject.GetComponent<PlayerControllerB>()) && ((EnemyAI)__instance).currentBehaviourStateIndex == 2)
				{
					__instance.KillPlayerServerRpc((int)component.playerClientId);
				}
			}
		}

		[HarmonyPatch(typeof(JesterAI), "Start")]
		[HarmonyPostfix]
		private static void JesterAILEPostfixStart(JesterAI __instance)
		{
			if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && JesterChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= JesterChanceToSpawnOutside.Value)
			{
				SendEnemyOutside((EnemyAI)(object)__instance);
			}
		}

		[HarmonyPatch(typeof(FlowermanAI), "Update")]
		[HarmonyPrefix]
		private static void FlowermanAILEPrefixAI(FlowermanAI __instance)
		{
			if (((EnemyAI)__instance).isEnemyDead || !CanBrackenEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				return;
			}
			if (!((EnemyAI)__instance).isOutside)
			{
				if ((Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory && (((EnemyAI)__instance).currentBehaviourStateIndex == 1 || __instance.evadeStealthTimer > 0f) && Time.time - TimeStartTeleport >= BrackenEscapeDelay.Value + 5f)
				{
					TimeStartTeleport = Time.time;
				}
				if (Time.time - TimeStartTeleport > BrackenEscapeDelay.Value && Time.time - TimeStartTeleport < BrackenEscapeDelay.Value + 5f)
				{
					SendEnemyOutside((EnemyAI)(object)__instance);
				}
				else if (LETimerFunctions.MinuteEscapeTimerBracken >= 60f && (Object)(object)((EnemyAI)__instance).targetPlayer == (Object)null)
				{
					LETimerFunctions.MinuteEscapeTimerBracken = 0f;
					if (BrackenChanceToEscapeEveryMinute.Value != 0f && (float)Random.Range(1, 100) <= BrackenChanceToEscapeEveryMinute.Value)
					{
						SendEnemyOutside((EnemyAI)(object)__instance, SpawnOnDoor: false);
					}
				}
			}
			else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(FlowermanAI), "Update")]
		[HarmonyPostfix]
		private static void FlowermanAILEPostfixAI(FlowermanAI __instance)
		{
			if (!((EnemyAI)__instance).isEnemyDead && CanBrackenEscape.Value && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && ((EnemyAI)__instance).isOutside && ((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(FlowermanAI), "OnCollideWithPlayer")]
		[HarmonyPostfix]
		public static void FlowerManAILEOutsideAttack(FlowermanAI __instance, ref Collider other, bool ___startingKillAnimationLocalClient)
		{
			if (!((EnemyAI)__instance).isEnemyDead && ((EnemyAI)__instance).isOutside && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && !__instance.inKillAnimation && !___startingKillAnimationLocalClient)
				{
					__instance.KillPlayerAnimationServerRpc((int)component.playerClientId);
					___startingKillAnimationLocalClient = true;
				}
			}
		}

		[HarmonyPatch(typeof(FlowermanAI), "Start")]
		[HarmonyPostfix]
		private static void FlowermanAILEPostfixStart(FlowermanAI __instance)
		{
			TimeStartTeleport = 0f;
			if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && BrackenChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= BrackenChanceToSpawnOutside.Value)
			{
				SendEnemyOutside((EnemyAI)(object)__instance);
			}
		}

		[HarmonyPatch(typeof(HoarderBugAI), "Update")]
		[HarmonyPrefix]
		private static void HoardingBugAILEPrefixAI(HoarderBugAI __instance)
		{
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			if (((EnemyAI)__instance).isEnemyDead || !CanHoardingBugEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				return;
			}
			if (!((EnemyAI)__instance).isOutside)
			{
				if ((Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory && __instance.searchForPlayer.inProgress)
				{
					SendEnemyOutside((EnemyAI)(object)__instance);
				}
				else
				{
					if (!(LETimerFunctions.MinuteEscapeTimerHoardingBug >= 60f) || !((Object)(object)((EnemyAI)__instance).targetPlayer == (Object)null))
					{
						return;
					}
					LETimerFunctions.MinuteEscapeTimerHoardingBug = 0f;
					if ((float)Random.Range(1, 100) <= HoardingBugChanceToEscapeEveryMinute.Value / (float)Object.FindObjectsOfType(typeof(HoarderBugAI)).Length)
					{
						SendEnemyOutside((EnemyAI)(object)__instance, SpawnOnDoor: false);
						if (HoardingBugChanceToNestNearShip.Value != 0f && (float)Random.Range(1, 100) <= HoardingBugChanceToNestNearShip.Value)
						{
							StartOfRound val = (StartOfRound)Object.FindObjectOfType(typeof(StartOfRound));
							Transform val2 = ((EnemyAI)__instance).ChooseClosestNodeToPosition(val.elevatorTransform.position, false, 0);
							__instance.nestPosition = val2.position;
						}
					}
				}
			}
			else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(HoarderBugAI), "OnCollideWithPlayer")]
		[HarmonyPostfix]
		public static void HoardingBugAILEOutsideAttack(HoarderBugAI __instance, ref Collider other)
		{
			//IL_00cf: 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)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			if (!((EnemyAI)__instance).isEnemyDead && ((EnemyAI)__instance).isOutside && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && !((double)__instance.timeSinceHittingPlayer <= 0.5) && !(((EnemyAI)__instance).stunNormalizedTimer > 0f) && __instance.inChase)
				{
					__instance.timeSinceHittingPlayer = 0f;
					component.DamagePlayer(30, true, true, (CauseOfDeath)6, 0, false, default(Vector3));
					component.DamagePlayerFromOtherClientServerRpc(30, Vector3.zero, -1);
					__instance.HitPlayerServerRpc();
				}
			}
		}

		[HarmonyPatch(typeof(HoarderBugAI), "Start")]
		[HarmonyPostfix]
		private static void HoardingBugAILEPostfixStart(HoarderBugAI __instance)
		{
			if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && HoardingBugChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= HoardingBugChanceToSpawnOutside.Value)
			{
				SendEnemyOutside((EnemyAI)(object)__instance);
			}
		}

		[HarmonyPatch(typeof(SpringManAI), "Update")]
		[HarmonyPrefix]
		private static void CoilHeadAILEPrefixAI(SpringManAI __instance)
		{
			if (((EnemyAI)__instance).isEnemyDead || !CanCoilHeadEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				return;
			}
			if (!((EnemyAI)__instance).isOutside)
			{
				if ((Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory)
				{
					SendEnemyOutside((EnemyAI)(object)__instance, SpawnOnDoor: false);
				}
			}
			else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(SpringManAI), "OnCollideWithPlayer")]
		[HarmonyPostfix]
		public static void CoilHeadAILEOutsideAttack(SpringManAI __instance, ref Collider other)
		{
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			if (!((EnemyAI)__instance).isEnemyDead && ((EnemyAI)__instance).isOutside && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && !__instance.stoppingMovement && ((EnemyAI)__instance).currentBehaviourStateIndex == 1 && !(__instance.timeSinceHittingPlayer >= 0f) && !(((EnemyAI)__instance).stunNormalizedTimer > 0f))
				{
					__instance.timeSinceHittingPlayer = 0.2f;
					component.DamagePlayer(90, true, true, (CauseOfDeath)6, 2, false, default(Vector3));
					component.DamagePlayerFromOtherClientServerRpc(90, Vector3.zero, -1);
					component.JumpToFearLevel(1f, true);
				}
			}
		}

		[HarmonyPatch(typeof(SandSpiderAI), "Update")]
		[HarmonyPrefix]
		private static void SpiderAILEPrefixAI(SandSpiderAI __instance)
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			if (((EnemyAI)__instance).isEnemyDead || !CanSpiderEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				return;
			}
			if (!((EnemyAI)__instance).isOutside)
			{
				if ((Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory)
				{
					SendEnemyOutside((EnemyAI)(object)__instance, SpawnOnDoor: false);
					__instance.meshContainerPosition = ((EnemyAI)__instance).serverPosition;
					__instance.meshContainerTarget = ((EnemyAI)__instance).serverPosition;
					__instance.maxWebTrapsToPlace += Random.Range(SpiderMinWebsOutside.Value, SpiderMaxWebsOutside.Value);
				}
			}
			else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(SandSpiderAI), "OnCollideWithPlayer")]
		[HarmonyPostfix]
		public static void SpiderAILEOutsideAttack(SandSpiderAI __instance, ref Collider other)
		{
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: 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)
			if (!((EnemyAI)__instance).isEnemyDead && ((EnemyAI)__instance).isOutside && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && !__instance.onWall && !(__instance.timeSinceHittingPlayer <= 1f) && !(((EnemyAI)__instance).stunNormalizedTimer > 0f))
				{
					__instance.timeSinceHittingPlayer = 0f;
					component.DamagePlayer(90, true, true, (CauseOfDeath)6, 0, false, default(Vector3));
					component.DamagePlayerFromOtherClientServerRpc(90, Vector3.zero, -1);
					__instance.HitPlayerServerRpc((int)component.playerClientId);
				}
			}
		}

		[HarmonyPatch(typeof(SandSpiderAI), "Start")]
		[HarmonyPostfix]
		private static void SpiderAILEPostfixStart(SandSpiderAI __instance)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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)
			if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && SpiderChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= SpiderChanceToSpawnOutside.Value)
			{
				SendEnemyOutside((EnemyAI)(object)__instance);
				__instance.meshContainerPosition = ((EnemyAI)__instance).serverPosition;
				__instance.meshContainerTarget = ((EnemyAI)__instance).serverPosition;
				__instance.maxWebTrapsToPlace = Random.Range(SpiderMinWebsOutside.Value, SpiderMaxWebsOutside.Value);
			}
		}

		[HarmonyPatch(typeof(NutcrackerEnemyAI), "Update")]
		[HarmonyPrefix]
		private static void NutCrackerAILEPrefixAI(NutcrackerEnemyAI __instance)
		{
			if (((EnemyAI)__instance).isEnemyDead || !CanNutCrackerEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				return;
			}
			if (!((EnemyAI)__instance).isOutside)
			{
				if ((Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory)
				{
					SendEnemyOutside((EnemyAI)(object)__instance);
				}
			}
			else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(NutcrackerEnemyAI), "OnCollideWithPlayer")]
		[HarmonyPostfix]
		public static void NutCrackerAILEOutsideAttack(NutcrackerEnemyAI __instance, ref Collider other)
		{
			if (!((EnemyAI)__instance).isEnemyDead && ((EnemyAI)__instance).isOutside && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && !(((EnemyAI)__instance).stunNormalizedTimer >= 0f) && !(__instance.timeSinceHittingPlayer < 1f))
				{
					__instance.timeSinceHittingPlayer = 0f;
					__instance.LegKickPlayerServerRpc((int)component.playerClientId);
				}
			}
		}

		[HarmonyPatch(typeof(NutcrackerEnemyAI), "Start")]
		[HarmonyPostfix]
		private static void NutCrackerAILEPostfixStart(NutcrackerEnemyAI __instance)
		{
			if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && NutCrackerChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= NutCrackerChanceToSpawnOutside.Value)
			{
				SendEnemyOutside((EnemyAI)(object)__instance);
			}
		}

		[HarmonyPatch(typeof(BlobAI), "Update")]
		[HarmonyPrefix]
		private static void BlobAILEPrefixAI(BlobAI __instance)
		{
			if (((EnemyAI)__instance).isEnemyDead || !CanHygrodereEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				return;
			}
			if (!((EnemyAI)__instance).isOutside)
			{
				if ((Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory)
				{
					SendEnemyOutside((EnemyAI)(object)__instance, SpawnOnDoor: false);
					__instance.centerPoint = ((Component)__instance).transform;
				}
			}
			else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(BlobAI), "OnCollideWithPlayer")]
		[HarmonyPostfix]
		public static void BlobAILEOutsideAttack(BlobAI __instance, ref Collider other)
		{
			//IL_00be: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			if (((EnemyAI)__instance).isEnemyDead || !((EnemyAI)__instance).isOutside || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				return;
			}
			PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
			if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && !(__instance.timeSinceHittingLocalPlayer < 0.25f) && (!(__instance.tamedTimer > 0f) || !(__instance.angeredTimer < 0f)))
			{
				__instance.timeSinceHittingLocalPlayer = 0f;
				component.DamagePlayerFromOtherClientServerRpc(35, Vector3.zero, -1);
				component.DamagePlayer(35, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				if (component.isPlayerDead)
				{
					__instance.SlimeKillPlayerEffectServerRpc((int)component.playerClientId);
				}
			}
		}

		[HarmonyPatch(typeof(BlobAI), "Start")]
		[HarmonyPostfix]
		private static void HygrodereAILEPostfixStart(BlobAI __instance)
		{
			if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && HygrodereChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= HygrodereChanceToSpawnOutside.Value)
			{
				SendEnemyOutside((EnemyAI)(object)__instance);
				__instance.centerPoint = ((Component)__instance).transform;
			}
		}

		[HarmonyPatch(typeof(PufferAI), "Update")]
		[HarmonyPrefix]
		private static void PufferAILEPrefixAI(PufferAI __instance)
		{
			if (((EnemyAI)__instance).isEnemyDead || !CanPufferEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				return;
			}
			if (!((EnemyAI)__instance).isOutside)
			{
				if ((Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory)
				{
					SendEnemyOutside((EnemyAI)(object)__instance, SpawnOnDoor: false);
				}
				else if (LETimerFunctions.MinuteEscapeTimerPuffer >= 60f && (Object)(object)((EnemyAI)__instance).targetPlayer == (Object)null)
				{
					LETimerFunctions.MinuteEscapeTimerPuffer = 0f;
					if (PufferChanceToEscapeEveryMinute.Value != 0f && (float)Random.Range(1, 100) <= PufferChanceToEscapeEveryMinute.Value)
					{
						SendEnemyOutside((EnemyAI)(object)__instance, SpawnOnDoor: false);
					}
				}
			}
			else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(PufferAI), "OnCollideWithPlayer")]
		[HarmonyPostfix]
		public static void PufferAILEOutsideAttack(PufferAI __instance, ref Collider other)
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			if (!((EnemyAI)__instance).isEnemyDead && ((EnemyAI)__instance).isOutside && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && !(__instance.timeSinceHittingPlayer <= 1f))
				{
					__instance.timeSinceHittingPlayer = 0f;
					component.DamagePlayer(20, true, true, (CauseOfDeath)6, 0, false, default(Vector3));
					component.DamagePlayerFromOtherClientServerRpc(20, Vector3.zero, -1);
					__instance.BitePlayerServerRpc((int)component.playerClientId);
				}
			}
		}

		[HarmonyPatch(typeof(PufferAI), "Start")]
		[HarmonyPostfix]
		private static void PufferAILEPostfixStart(PufferAI __instance)
		{
			if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && PufferChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= PufferChanceToSpawnOutside.Value)
			{
				SendEnemyOutside((EnemyAI)(object)__instance);
			}
		}

		public static void SendEnemyInside(EnemyAI __instance)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			__instance.isOutside = false;
			__instance.allAINodes = GameObject.FindGameObjectsWithTag("AINode");
			EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>(false);
			for (int i = 0; i < array.Length; i++)
			{
				if (array[i].entranceId == 0 && !array[i].isEntranceToBuilding)
				{
					__instance.serverPosition = array[i].entrancePoint.position;
					break;
				}
			}
			Transform val = __instance.ChooseClosestNodeToPosition(__instance.serverPosition, false, 0);
			if (Vector3.Magnitude(val.position - __instance.serverPosition) > 10f)
			{
				__instance.serverPosition = val.position;
				((Component)__instance).transform.position = __instance.serverPosition;
			}
			((Component)__instance).transform.position = __instance.serverPosition;
			__instance.agent.Warp(__instance.serverPosition);
			__instance.SyncPositionToClients();
		}

		public static void SendEnemyOutside(EnemyAI __instance, bool SpawnOnDoor = true)
		{
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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_00ba: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			__instance.isOutside = true;
			__instance.allAINodes = GameObject.FindGameObjectsWithTag("OutsideAINode");
			EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>(false);
			float num = 999f;
			for (int i = 0; i < array.Length; i++)
			{
				if (!array[i].isEntranceToBuilding)
				{
					continue;
				}
				for (int j = 0; j < StartOfRound.Instance.connectedPlayersAmount + 1; j++)
				{
					if (!StartOfRound.Instance.allPlayerScripts[j].isInsideFactory & (Vector3.Magnitude(((Component)StartOfRound.Instance.allPlayerScripts[j]).transform.position - array[i].entrancePoint.position) < num))
					{
						num = Vector3.Magnitude(((Component)StartOfRound.Instance.allPlayerScripts[j]).transform.position - array[i].entrancePoint.position);
						__instance.serverPosition = array[i].entrancePoint.position;
					}
				}
			}
			if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				__instance.ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
			Transform val = __instance.ChooseClosestNodeToPosition(__instance.serverPosition, false, 0);
			if (Vector3.Magnitude(val.position - __instance.serverPosition) > 10f || !SpawnOnDoor)
			{
				__instance.serverPosition = val.position;
			}
			((Component)__instance).transform.position = __instance.serverPosition;
			__instance.agent.Warp(__instance.serverPosition);
			__instance.SyncPositionToClients();
			if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
			{
				__instance.EnableEnemyMesh(!StartOfRound.Instance.hangarDoorsClosed || !GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom, false);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

plugins/LethalLevelLoader.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DunGen;
using DunGen.Graph;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLevelLoader.NetcodePatcher;
using LethalLevelLoader.Tools;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using On;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("LethalLevelLoader")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A Custom API to support the manual and dynamic integration of custom levels and dungeons in Lethal Company.")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+99e1e0f233232ae52ea829f2f29e91ba47ab5680")]
[assembly: AssemblyProduct("LethalLevelLoader")]
[assembly: AssemblyTitle("LethalLevelLoader")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public enum ContentType
{
	Vanilla,
	Custom,
	Any
}
internal static class HookHelper
{
	public class DisposableHookCollection
	{
		private List<ILHook> ilHooks = new List<ILHook>();

		private List<Hook> hooks = new List<Hook>();

		public void Clear()
		{
			foreach (Hook hook in hooks)
			{
				hook.Dispose();
			}
			hooks.Clear();
			foreach (ILHook ilHook in ilHooks)
			{
				ilHook.Dispose();
			}
			ilHooks.Clear();
		}

		public void ILHook<T>(string methodName, Manipulator to, Type[] parameters = null)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			ilHooks.Add(new ILHook((MethodBase)EzGetMethod<T>(methodName, parameters), to));
		}

		public void Hook<T>(string methodName, Delegate to, Type[] parameters = null)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			hooks.Add(new Hook((MethodBase)EzGetMethod<T>(methodName, parameters), to));
		}
	}

	public static MethodInfo methodof(Delegate method)
	{
		return method.Method;
	}

	public static MethodInfo EzGetMethod(Type type, string name, Type[] parameters = null)
	{
		BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
		if (parameters == null)
		{
			return type.GetMethod(name, bindingAttr);
		}
		return type.GetMethod(name, bindingAttr, null, parameters, null);
	}

	public static MethodInfo EzGetMethod<T>(string name, Type[] parameters = null)
	{
		return EzGetMethod(typeof(T), name, parameters);
	}
}
public static class NetworkScenePatcher
{
	[CompilerGenerated]
	private static class <>O
	{
		public static Action<Action<NetworkSceneManager>, NetworkSceneManager> <0>__GenerateScenesInBuild_Hook;

		public static Func<Func<NetworkSceneManager, uint, string>, NetworkSceneManager, uint, string> <1>__SceneNameFromHash_Hook;

		public static Func<Func<NetworkSceneManager, int, string, LoadSceneMode, bool>, NetworkSceneManager, int, string, LoadSceneMode, bool> <2>__ValidateSceneBeforeLoading_Hook;

		public static Manipulator <3>__ReplaceBuildIndexByScenePath;

		public static Manipulator <4>__ReplaceScenePathByBuildIndex;

		public static Func<int, string> <5>__GetScenePathByBuildIndex;

		public static Func<string, int> <6>__GetBuildIndexByScenePath;
	}

	private static List<string> scenePaths = new List<string>();

	private static Dictionary<string, int> scenePathToBuildIndex = new Dictionary<string, int>();

	private static Dictionary<int, string> buildIndexToScenePath = new Dictionary<int, string>();

	private static Dictionary<uint, string> sceneHashToScenePath = new Dictionary<uint, string>();

	private static HookHelper.DisposableHookCollection hooks = new HookHelper.DisposableHookCollection();

	internal static bool patched { get; private set; }

	public static void AddScenePath(string scenePath)
	{
		if (scenePaths.Contains(scenePath))
		{
			Debug.LogError((object)("Can not add scene path " + scenePath + " to the network scene patcher! (already exists in scene paths list)"));
		}
		else
		{
			scenePaths.Add(scenePath);
		}
	}

	internal static void Patch()
	{
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Expected O, but got Unknown
		//IL_010c: 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: Expected O, but got Unknown
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Expected O, but got Unknown
		if (!patched)
		{
			patched = true;
			hooks.Hook<NetworkSceneManager>("GenerateScenesInBuild", new Action<Action<NetworkSceneManager>, NetworkSceneManager>(GenerateScenesInBuild_Hook));
			hooks.Hook<NetworkSceneManager>("SceneNameFromHash", new Func<Func<NetworkSceneManager, uint, string>, NetworkSceneManager, uint, string>(SceneNameFromHash_Hook));
			hooks.Hook<NetworkSceneManager>("ValidateSceneBeforeLoading", new Func<Func<NetworkSceneManager, int, string, LoadSceneMode, bool>, NetworkSceneManager, int, string, LoadSceneMode, bool>(ValidateSceneBeforeLoading_Hook), new Type[3]
			{
				typeof(int),
				typeof(string),
				typeof(LoadSceneMode)
			});
			HookHelper.DisposableHookCollection disposableHookCollection = hooks;
			object obj = <>O.<3>__ReplaceBuildIndexByScenePath;
			if (obj == null)
			{
				Manipulator val = ReplaceBuildIndexByScenePath;
				<>O.<3>__ReplaceBuildIndexByScenePath = val;
				obj = (object)val;
			}
			disposableHookCollection.ILHook<NetworkSceneManager>("SceneHashFromNameOrPath", (Manipulator)obj);
			HookHelper.DisposableHookCollection disposableHookCollection2 = hooks;
			object obj2 = <>O.<3>__ReplaceBuildIndexByScenePath;
			if (obj2 == null)
			{
				Manipulator val2 = ReplaceBuildIndexByScenePath;
				<>O.<3>__ReplaceBuildIndexByScenePath = val2;
				obj2 = (object)val2;
			}
			disposableHookCollection2.ILHook<NetworkSceneManager>("ValidateSceneEvent", (Manipulator)obj2);
			HookHelper.DisposableHookCollection disposableHookCollection3 = hooks;
			object obj3 = <>O.<4>__ReplaceScenePathByBuildIndex;
			if (obj3 == null)
			{
				Manipulator val3 = ReplaceScenePathByBuildIndex;
				<>O.<4>__ReplaceScenePathByBuildIndex = val3;
				obj3 = (object)val3;
			}
			disposableHookCollection3.ILHook<NetworkSceneManager>("ScenePathFromHash", (Manipulator)obj3);
		}
	}

	internal static void Unpatch()
	{
		if (patched)
		{
			patched = false;
			hooks.Clear();
		}
	}

	private static void ReplaceScenePathByBuildIndex(ILContext il)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		ILCursor val = new ILCursor(il);
		MethodInfo methodInfo = HookHelper.methodof(new Func<int, string>(GetScenePathByBuildIndex));
		while (val.TryGotoNext(new Func<Instruction, bool>[1]
		{
			(Instruction instr) => ILPatternMatchingExt.MatchCall(instr, typeof(SceneUtility), "GetScenePathByBuildIndex")
		}))
		{
			val.Remove();
			val.Emit(OpCodes.Call, (MethodBase)methodInfo);
		}
	}

	private static void ReplaceBuildIndexByScenePath(ILContext il)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		ILCursor val = new ILCursor(il);
		MethodInfo methodInfo = HookHelper.methodof(new Func<string, int>(GetBuildIndexByScenePath));
		while (val.TryGotoNext(new Func<Instruction, bool>[1]
		{
			(Instruction instr) => ILPatternMatchingExt.MatchCall(instr, typeof(SceneUtility), "GetBuildIndexByScenePath")
		}))
		{
			val.Remove();
			val.Emit(OpCodes.Call, (MethodBase)methodInfo);
		}
	}

	private static string GetScenePathByBuildIndex(int buildIndex)
	{
		if (buildIndexToScenePath.ContainsKey(buildIndex))
		{
			return buildIndexToScenePath[buildIndex];
		}
		return SceneUtility.GetScenePathByBuildIndex(buildIndex);
	}

	private static int GetBuildIndexByScenePath(string scenePath)
	{
		int num = SceneUtility.GetBuildIndexByScenePath(scenePath);
		if (num == -1 && scenePathToBuildIndex.ContainsKey(scenePath))
		{
			num = scenePathToBuildIndex[scenePath];
		}
		return num;
	}

	private static void GenerateScenesInBuild_Hook(Action<NetworkSceneManager> orig, NetworkSceneManager self)
	{
		scenePathToBuildIndex.Clear();
		buildIndexToScenePath.Clear();
		sceneHashToScenePath.Clear();
		orig(self);
		int sceneCountInBuildSettings = SceneManager.sceneCountInBuildSettings;
		for (int i = 0; i < scenePaths.Count; i++)
		{
			int num = sceneCountInBuildSettings + i;
			string text = scenePaths[i];
			uint num2 = XXHash.Hash32(text);
			self.HashToBuildIndex.Add(num2, num);
			self.BuildIndexToHash.Add(num, num2);
			scenePathToBuildIndex.Add(text, num);
			buildIndexToScenePath.Add(num, text);
			sceneHashToScenePath.Add(num2, text);
			Debug.Log((object)("Added modded scene path: " + text));
		}
	}

	private static string SceneNameFromHash_Hook(Func<NetworkSceneManager, uint, string> orig, NetworkSceneManager self, uint sceneHash)
	{
		if (sceneHash == 0)
		{
			return "No Scene";
		}
		if (sceneHashToScenePath.ContainsKey(sceneHash))
		{
			return sceneHashToScenePath[sceneHash];
		}
		return orig(self, sceneHash);
	}

	private static bool ValidateSceneBeforeLoading_Hook(Func<NetworkSceneManager, int, string, LoadSceneMode, bool> orig, NetworkSceneManager self, int sceneIndex, string sceneName, LoadSceneMode loadSceneMode)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		Debug.LogWarning((object)(orig(self, sceneIndex, sceneName, loadSceneMode) ? ("Validation check success for scene: " + sceneName) : ("Bypassed validation check for scene " + sceneName)));
		return true;
	}
}
namespace LethalLevelLoader
{
	[CreateAssetMenu(menuName = "LethalLevelLoader/ExtendedDungeonFlow")]
	public class ExtendedDungeonFlow : ScriptableObject
	{
		[Header("Extended DungeonFlow Settings")]
		public string contentSourceName = string.Empty;

		[Space(5f)]
		public string dungeonDisplayName = string.Empty;

		[Space(5f)]
		public DungeonFlow dungeonFlow;

		[Space(5f)]
		public AudioClip dungeonFirstTimeAudio;

		[Space(10f)]
		[Header("Dynamic DungeonFlow Injections Settings")]
		public List<StringWithRarity> dynamicLevelTagsList = new List<StringWithRarity>();

		[Space(5f)]
		public List<Vector2WithRarity> dynamicRoutePricesList = new List<Vector2WithRarity>();

		[Space(5f)]
		public List<StringWithRarity> dynamicCurrentWeatherList = new List<StringWithRarity>();

		[Space(5f)]
		public List<StringWithRarity> manualPlanetNameReferenceList = new List<StringWithRarity>();

		[Space(5f)]
		public List<StringWithRarity> manualContentSourceNameReferenceList = new List<StringWithRarity>();

		[Space(10f)]
		[Header("Dynamic Dungeon Size Multiplier Lerp Settings")]
		public bool enableDynamicDungeonSizeRestriction = false;

		public float dungeonSizeMin = 1f;

		public float dungeonSizeMax = 1f;

		[Range(0f, 1f)]
		public float dungeonSizeLerpPercentage = 1f;

		[Space(10f)]
		[Header("Dynamic DungeonFlow Modification Settings")]
		public List<GlobalPropCountOverride> globalPropCountOverridesList = new List<GlobalPropCountOverride>();

		[Space(10f)]
		[Header("Misc. Settings")]
		public bool generateAutomaticConfigurationOptions = true;

		[Space(10f)]
		[Header("Experimental Settings (Currently Unused As Of LethalLevelLoader 1.1.0")]
		public GameObject mainEntrancePropPrefab;

		[Space(5f)]
		public GameObject fireExitPropPrefab;

		[Space(5f)]
		public Animator mainEntrancePropAnimator;

		[Space(5f)]
		public Animator fireExitPropAnimator;

		[HideInInspector]
		public ContentType dungeonType;

		[HideInInspector]
		public int dungeonID;

		[HideInInspector]
		public int dungeonDefaultRarity;

		[HideInInspector]
		public DungeonEvents dungeonEvents = new DungeonEvents();

		internal static ExtendedDungeonFlow Create(DungeonFlow newDungeonFlow, AudioClip newFirstTimeDungeonAudio, string contentSourceName)
		{
			ExtendedDungeonFlow extendedDungeonFlow = ScriptableObject.CreateInstance<ExtendedDungeonFlow>();
			extendedDungeonFlow.dungeonFlow = newDungeonFlow;
			extendedDungeonFlow.dungeonFirstTimeAudio = newFirstTimeDungeonAudio;
			extendedDungeonFlow.contentSourceName = contentSourceName;
			return extendedDungeonFlow;
		}

		internal void Initialize(ContentType newDungeonType)
		{
			dungeonType = newDungeonType;
			GetDungeonFlowID();
			if (dungeonDisplayName == null || dungeonDisplayName == string.Empty)
			{
				dungeonDisplayName = ((Object)dungeonFlow).name;
			}
			((Object)this).name = ((Object)dungeonFlow).name.Replace("Flow", "") + "ExtendedDungeonFlow";
			if ((Object)(object)dungeonFirstTimeAudio == (Object)null)
			{
				DebugHelper.LogWarning("Custom Dungeon: " + dungeonDisplayName + " Is Missing A DungeonFirstTimeAudio Reference! Assigning Facility Audio To Prevent Errors.");
				dungeonFirstTimeAudio = RoundManager.Instance.firstTimeDungeonAudios[0];
			}
		}

		private void GetDungeonFlowID()
		{
			if (dungeonType == ContentType.Custom)
			{
				dungeonID = PatchedContent.ExtendedDungeonFlows.Count;
			}
			if (dungeonType == ContentType.Vanilla)
			{
				dungeonID = RoundManager.Instance.dungeonFlowTypes.ToList().IndexOf(dungeonFlow);
			}
		}
	}
	[Serializable]
	public class StringWithRarity
	{
		[SerializeField]
		private string _name;

		[SerializeField]
		[Range(0f, 300f)]
		private int _rarity;

		[HideInInspector]
		public string Name
		{
			get
			{
				return _name;
			}
			set
			{
				_name = value;
			}
		}

		[HideInInspector]
		public int Rarity
		{
			get
			{
				return _rarity;
			}
			set
			{
				_rarity = value;
			}
		}

		[HideInInspector]
		public StringWithRarity(string newName, int newRarity)
		{
			_name = newName;
			_rarity = newRarity;
		}
	}
	[Serializable]
	public class Vector2WithRarity
	{
		[SerializeField]
		private Vector2 _minMax;

		[SerializeField]
		private int _rarity;

		[HideInInspector]
		public float Min
		{
			get
			{
				return _minMax.x;
			}
			set
			{
				_minMax.x = value;
			}
		}

		[HideInInspector]
		public float Max
		{
			get
			{
				return _minMax.y;
			}
			set
			{
				_minMax.y = value;
			}
		}

		[HideInInspector]
		public int Rarity
		{
			get
			{
				return _rarity;
			}
			set
			{
				_rarity = value;
			}
		}

		public Vector2WithRarity(Vector2 vector2, int newRarity)
		{
			//IL_000e: 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)
			_minMax.x = vector2.x;
			_minMax.y = vector2.y;
			_rarity = newRarity;
		}

		public Vector2WithRarity(float newMin, float newMax, int newRarity)
		{
			_minMax.x = newMin;
			_minMax.y = newMax;
			_rarity = newRarity;
		}
	}
	[Serializable]
	public class GlobalPropCountOverride
	{
		public int globalPropID;

		[Range(0f, 1f)]
		public float globalPropCountScaleRate = 0f;
	}
	[Serializable]
	public class DungeonEvents
	{
		public ExtendedEvent<RoundManager> onBeforeDungeonGenerate = new ExtendedEvent<RoundManager>();

		public ExtendedEvent<List<GameObject>> onSpawnedSyncedObjects = new ExtendedEvent<List<GameObject>>();

		public ExtendedEvent<List<GameObject>> onSpawnedMapObjects = new ExtendedEvent<List<GameObject>>();

		public ExtendedEvent<List<GrabbableObject>> onSpawnedScrapObjects = new ExtendedEvent<List<GrabbableObject>>();

		public ExtendedEvent<(EnemyVent, EnemyAI)> onEnemySpawnedFromVent = new ExtendedEvent<(EnemyVent, EnemyAI)>();

		public ExtendedEvent<(EntranceTeleport, PlayerControllerB)> onPlayerEnterDungeon = new ExtendedEvent<(EntranceTeleport, PlayerControllerB)>();

		public ExtendedEvent<(EntranceTeleport, PlayerControllerB)> onPlayerExitDungeon = new ExtendedEvent<(EntranceTeleport, PlayerControllerB)>();

		public ExtendedEvent<bool> onPowerSwitchToggle = new ExtendedEvent<bool>();

		public ExtendedEvent<LungProp> onApparatusTaken = new ExtendedEvent<LungProp>();
	}
	[CreateAssetMenu(menuName = "LethalLevelLoader/ExtendedLevel")]
	public class ExtendedLevel : ScriptableObject
	{
		[Header("Extended Level Settings")]
		[Space(5f)]
		public string contentSourceName = string.Empty;

		[Space(5f)]
		public SelectableLevel selectableLevel;

		[Space(5f)]
		[SerializeField]
		private int routePrice = 0;

		[Space(5f)]
		public bool isHidden = false;

		[Space(5f)]
		public bool isLocked = false;

		[Space(5f)]
		public string lockedNodeText = string.Empty;

		[Space(10f)]
		public List<StoryLogData> storyLogs = new List<StoryLogData>();

		[Space(10f)]
		[Header("Dynamic DungeonFlow Injections Settings")]
		[Space(5f)]
		public ContentType allowedDungeonContentTypes = ContentType.Any;

		[Space(5f)]
		public List<string> levelTags = new List<string>();

		[HideInInspector]
		public ContentType levelType;

		[SerializeField]
		[TextArea]
		public string infoNodeDescripton = string.Empty;

		[HideInInspector]
		public TerminalNode routeNode;

		[HideInInspector]
		public TerminalNode routeConfirmNode;

		[HideInInspector]
		public TerminalNode infoNode;

		[Space(10f)]
		[Header("Misc. Settings")]
		[Space(5f)]
		public bool generateAutomaticConfigurationOptions = true;

		[HideInInspector]
		public LevelEvents levelEvents = new LevelEvents();

		internal bool isLethalExpansion = false;

		public int RoutePrice
		{
			get
			{
				if ((Object)(object)routeNode != (Object)null)
				{
					routePrice = routeNode.itemCost;
					routeConfirmNode.itemCost = routePrice;
					return routeNode.itemCost;
				}
				DebugHelper.LogWarning("routeNode Is Missing! Using internal value!");
				return routePrice;
			}
			set
			{
				routeNode.itemCost = value;
				routeConfirmNode.itemCost = value;
				routePrice = value;
			}
		}

		[HideInInspector]
		public string NumberlessPlanetName => GetNumberlessPlanetName(selectableLevel);

		public bool IsLoaded
		{
			get
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				Scene sceneByName = SceneManager.GetSceneByName(selectableLevel.sceneName);
				return ((Scene)(ref sceneByName)).isLoaded;
			}
		}

		internal static ExtendedLevel Create(SelectableLevel newSelectableLevel, ContentType newContentType)
		{
			ExtendedLevel extendedLevel = ScriptableObject.CreateInstance<ExtendedLevel>();
			extendedLevel.levelType = newContentType;
			extendedLevel.selectableLevel = newSelectableLevel;
			return extendedLevel;
		}

		internal void Initialize(string newContentSourceName, bool generateTerminalAssets)
		{
			if (levelType == ContentType.Vanilla && selectableLevel.levelID > 8)
			{
				DebugHelper.LogWarning("LethalExpansion SelectableLevel " + NumberlessPlanetName + " Found, Setting To LevelType: Custom.");
				levelType = ContentType.Custom;
				contentSourceName = "Lethal Expansion";
				levelTags.Clear();
				isLethalExpansion = true;
			}
			if (contentSourceName == string.Empty)
			{
				contentSourceName = newContentSourceName;
			}
			if (levelType == ContentType.Custom)
			{
				levelTags.Add("Custom");
			}
			if (!isLethalExpansion)
			{
				SetLevelID();
			}
			if (generateTerminalAssets)
			{
				TerminalManager.CreateLevelTerminalData(this, routePrice);
			}
			if (levelType == ContentType.Custom)
			{
				((Object)this).name = NumberlessPlanetName.StripSpecialCharacters() + "ExtendedLevel";
				((Object)selectableLevel).name = NumberlessPlanetName.StripSpecialCharacters() + "Level";
			}
		}

		internal static string GetNumberlessPlanetName(SelectableLevel selectableLevel)
		{
			if ((Object)(object)selectableLevel != (Object)null)
			{
				return new string(selectableLevel.PlanetName.SkipWhile((char c) => !char.IsLetter(c)).ToArray());
			}
			return string.Empty;
		}

		internal void SetLevelID()
		{
			if (levelType == ContentType.Custom)
			{
				selectableLevel.levelID = PatchedContent.ExtendedLevels.IndexOf(this);
				if ((Object)(object)routeNode != (Object)null)
				{
					routeNode.displayPlanetInfo = selectableLevel.levelID;
				}
				if ((Object)(object)routeConfirmNode != (Object)null)
				{
					routeConfirmNode.buyRerouteToMoon = selectableLevel.levelID;
				}
			}
		}
	}
	[Serializable]
	public class LevelEvents
	{
		public ExtendedEvent onLevelLoaded = new ExtendedEvent();

		public ExtendedEvent onNighttime = new ExtendedEvent();

		public ExtendedEvent<EnemyAI> onDaytimeEnemySpawn = new ExtendedEvent<EnemyAI>();

		public ExtendedEvent<EnemyAI> onNighttimeEnemySpawn = new ExtendedEvent<EnemyAI>();

		public ExtendedEvent<StoryLog> onStoryLogCollected = new ExtendedEvent<StoryLog>();

		public ExtendedEvent<LungProp> onApparatusTaken = new ExtendedEvent<LungProp>();

		public ExtendedEvent<(EntranceTeleport, PlayerControllerB)> onPlayerEnterDungeon = new ExtendedEvent<(EntranceTeleport, PlayerControllerB)>();

		public ExtendedEvent<(EntranceTeleport, PlayerControllerB)> onPlayerExitDungeon = new ExtendedEvent<(EntranceTeleport, PlayerControllerB)>();

		public ExtendedEvent<bool> onPowerSwitchToggle = new ExtendedEvent<bool>();
	}
	[Serializable]
	public class StoryLogData
	{
		public int storyLogID;

		public string terminalWord = string.Empty;

		public string storyLogTitle = string.Empty;

		[TextArea]
		public string storyLogDescription = string.Empty;

		[HideInInspector]
		internal int newStoryLogID;
	}
	public class MoonsCataloguePage
	{
		private List<ExtendedLevelGroup> extendedLevelGroups;

		public List<ExtendedLevelGroup> ExtendedLevelGroups => extendedLevelGroups;

		public List<ExtendedLevel> ExtendedLevels
		{
			get
			{
				List<ExtendedLevel> list = new List<ExtendedLevel>();
				foreach (ExtendedLevelGroup extendedLevelGroup in extendedLevelGroups)
				{
					foreach (ExtendedLevel extendedLevels in extendedLevelGroup.extendedLevelsList)
					{
						list.Add(extendedLevels);
					}
				}
				return list;
			}
		}

		public MoonsCataloguePage(List<ExtendedLevelGroup> newExtendedLevelGroupList)
		{
			extendedLevelGroups = new List<ExtendedLevelGroup>();
			extendedLevelGroups.Clear();
			foreach (ExtendedLevelGroup newExtendedLevelGroup in newExtendedLevelGroupList)
			{
				extendedLevelGroups.Add(new ExtendedLevelGroup(newExtendedLevelGroup.extendedLevelsList));
			}
		}

		public void RebuildLevelGroups(List<ExtendedLevelGroup> newExtendedLevelGroups, int splitCount)
		{
			List<ExtendedLevel> list = new List<ExtendedLevel>();
			foreach (ExtendedLevelGroup extendedLevelGroup in extendedLevelGroups)
			{
				foreach (ExtendedLevel extendedLevels in extendedLevelGroup.extendedLevelsList)
				{
					list.Add(extendedLevels);
				}
			}
			RebuildLevelGroups(list.ToArray(), splitCount);
		}

		public void RebuildLevelGroups(List<ExtendedLevel> newExtendedLevels, int splitCount)
		{
			RebuildLevelGroups(newExtendedLevels.ToArray(), splitCount);
		}

		public void RebuildLevelGroups(IOrderedEnumerable<ExtendedLevel> orderedExtendedLevels, int splitCount)
		{
			RebuildLevelGroups(orderedExtendedLevels.ToArray(), splitCount);
		}

		public void RebuildLevelGroups(ExtendedLevel[] newExtendedLevels, int splitCount)
		{
			List<ExtendedLevelGroup> list = new List<ExtendedLevelGroup>();
			int num = 0;
			int num2 = 0;
			List<ExtendedLevel> list2 = new List<ExtendedLevel>();
			foreach (ExtendedLevel item in new List<ExtendedLevel>(newExtendedLevels))
			{
				list2.Add(item);
				num2++;
				num++;
				if (num == splitCount || num2 == newExtendedLevels.Length)
				{
					list.Add(new ExtendedLevelGroup(list2));
					list2.Clear();
					num = 0;
				}
			}
			extendedLevelGroups = list;
		}

		public void RefreshLevelGroups(List<ExtendedLevelGroup> newLevelGroups)
		{
			extendedLevelGroups.Clear();
			foreach (ExtendedLevelGroup newLevelGroup in newLevelGroups)
			{
				if (newLevelGroup.extendedLevelsList.Count != 0)
				{
					extendedLevelGroups.Add(new ExtendedLevelGroup(newLevelGroup.extendedLevelsList));
				}
			}
		}
	}
	[Serializable]
	public class ExtendedLevelGroup
	{
		public List<ExtendedLevel> extendedLevelsList;

		public ExtendedLevelGroup(List<ExtendedLevel> newExtendedLevelsList)
		{
			extendedLevelsList = new List<ExtendedLevel>(newExtendedLevelsList);
		}

		public ExtendedLevelGroup(List<SelectableLevel> newSelectableLevelsList)
		{
			extendedLevelsList = new List<ExtendedLevel>();
			foreach (SelectableLevel newSelectableLevels in newSelectableLevelsList)
			{
				extendedLevelsList.Add(LevelManager.GetExtendedLevel(newSelectableLevels));
			}
		}
	}
	public static class PatchedContent
	{
		public static List<ExtendedLevel> ExtendedLevels { get; internal set; } = new List<ExtendedLevel>();


		public static List<ExtendedLevel> VanillaExtendedLevels
		{
			get
			{
				List<ExtendedLevel> list = new List<ExtendedLevel>();
				foreach (ExtendedLevel extendedLevel in ExtendedLevels)
				{
					if (extendedLevel.levelType == ContentType.Vanilla)
					{
						list.Add(extendedLevel);
					}
				}
				return list;
			}
		}

		public static List<ExtendedLevel> CustomExtendedLevels
		{
			get
			{
				List<ExtendedLevel> list = new List<ExtendedLevel>();
				foreach (ExtendedLevel extendedLevel in ExtendedLevels)
				{
					if (extendedLevel.levelType == ContentType.Custom)
					{
						list.Add(extendedLevel);
					}
				}
				return list;
			}
		}

		public static List<SelectableLevel> SeletectableLevels
		{
			get
			{
				List<SelectableLevel> list = new List<SelectableLevel>();
				foreach (ExtendedLevel extendedLevel in ExtendedLevels)
				{
					list.Add(extendedLevel.selectableLevel);
				}
				return list;
			}
		}

		public static List<SelectableLevel> MoonsCatalogue
		{
			get
			{
				List<SelectableLevel> list = new List<SelectableLevel>();
				foreach (SelectableLevel item in OriginalContent.MoonsCatalogue)
				{
					list.Add(item);
				}
				foreach (ExtendedLevel extendedLevel in ExtendedLevels)
				{
					if (extendedLevel.levelType == ContentType.Custom)
					{
						list.Add(extendedLevel.selectableLevel);
					}
				}
				return list;
			}
		}

		public static List<ExtendedDungeonFlow> ExtendedDungeonFlows { get; internal set; } = new List<ExtendedDungeonFlow>();


		public static List<ExtendedDungeonFlow> VanillaExtendedDungeonFlows
		{
			get
			{
				List<ExtendedDungeonFlow> list = new List<ExtendedDungeonFlow>();
				foreach (ExtendedDungeonFlow extendedDungeonFlow in ExtendedDungeonFlows)
				{
					if (extendedDungeonFlow.dungeonType == ContentType.Vanilla)
					{
						list.Add(extendedDungeonFlow);
					}
				}
				return list;
			}
		}

		public static List<ExtendedDungeonFlow> CustomExtendedDungeonFlows
		{
			get
			{
				List<ExtendedDungeonFlow> list = new List<ExtendedDungeonFlow>();
				foreach (ExtendedDungeonFlow extendedDungeonFlow in ExtendedDungeonFlows)
				{
					if (extendedDungeonFlow.dungeonType == ContentType.Custom)
					{
						list.Add(extendedDungeonFlow);
					}
				}
				return list;
			}
		}

		public static List<string> AllExtendedLevelTags
		{
			get
			{
				List<string> list = new List<string>();
				foreach (ExtendedLevel extendedLevel in ExtendedLevels)
				{
					foreach (string levelTag in extendedLevel.levelTags)
					{
						if (!list.Contains(levelTag))
						{
							list.Add(levelTag);
						}
					}
				}
				return list;
			}
		}

		public static List<AudioMixer> AudioMixers { get; internal set; } = new List<AudioMixer>();


		public static List<AudioMixerGroup> AudioMixerGroups { get; internal set; } = new List<AudioMixerGroup>();


		public static List<AudioMixerSnapshot> AudioMixerSnapshots { get; internal set; } = new List<AudioMixerSnapshot>();


		public static List<Item> Items { get; internal set; } = new List<Item>();


		public static List<EnemyType> Enemies { get; internal set; } = new List<EnemyType>();


		public static void RegisterExtendedDungeonFlow(ExtendedDungeonFlow extendedDungeonFlow)
		{
			AssetBundleLoader.obtainedExtendedDungeonFlowsList.Add(extendedDungeonFlow);
		}

		public static void RegisterExtendedLevel(ExtendedLevel extendedLevel)
		{
			AssetBundleLoader.obtainedExtendedLevelsList.Add(extendedLevel);
		}
	}
	public static class OriginalContent
	{
		public static List<SelectableLevel> SelectableLevels { get; internal set; } = new List<SelectableLevel>();


		public static List<SelectableLevel> MoonsCatalogue { get; internal set; } = new List<SelectableLevel>();


		public static List<DungeonFlow> DungeonFlows { get; internal set; } = new List<DungeonFlow>();


		public static List<Item> Items { get; internal set; } = new List<Item>();


		public static List<ItemGroup> ItemGroups { get; internal set; } = new List<ItemGroup>();


		public static List<EnemyType> Enemies { get; internal set; } = new List<EnemyType>();


		public static List<SpawnableOutsideObject> SpawnableOutsideObjects { get; internal set; } = new List<SpawnableOutsideObject>();


		public static List<GameObject> SpawnableMapObjects { get; internal set; } = new List<GameObject>();


		public static List<AudioMixer> AudioMixers { get; internal set; } = new List<AudioMixer>();


		public static List<AudioMixerGroup> AudioMixerGroups { get; internal set; } = new List<AudioMixerGroup>();


		public static List<AudioMixerSnapshot> AudioMixerSnapshots { get; internal set; } = new List<AudioMixerSnapshot>();


		public static List<LevelAmbienceLibrary> LevelAmbienceLibraries { get; internal set; } = new List<LevelAmbienceLibrary>();


		public static List<ReverbPreset> ReverbPresets { get; internal set; } = new List<ReverbPreset>();


		public static List<TerminalKeyword> TerminalKeywords { get; internal set; } = new List<TerminalKeyword>();


		public static List<TerminalNode> TerminalNodes { get; internal set; } = new List<TerminalNode>();

	}
	internal class EventPatches
	{
		private static EnemyVent cachedSelectedVent;

		internal static void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
		{
			if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null && LevelManager.CurrentExtendedLevel.IsLoaded)
			{
				LevelManager.CurrentExtendedLevel.levelEvents.onLevelLoaded.Invoke();
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(StoryLog), "CollectLog")]
		[HarmonyPrefix]
		internal static void StoryLogCollectLog_Prefix(StoryLog __instance)
		{
			if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null && ((NetworkBehaviour)__instance).IsServer)
			{
				LevelManager.CurrentExtendedLevel.levelEvents.onStoryLogCollected.Invoke(__instance);
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(RoundManager), "SpawnRandomDaytimeEnemy")]
		[HarmonyPostfix]
		internal static void RoundManagerSpawnRandomDaytimeEnemy_Postfix(RoundManager __instance, GameObject __result)
		{
			EnemyAI param = default(EnemyAI);
			if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null && ((NetworkBehaviour)__instance).IsServer && (Object)(object)__result != (Object)null && __result.TryGetComponent<EnemyAI>(ref param))
			{
				LevelManager.CurrentExtendedLevel.levelEvents.onDaytimeEnemySpawn.Invoke(param);
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(RoundManager), "SpawnRandomOutsideEnemy")]
		[HarmonyPostfix]
		internal static void RoundManagerSpawnRandomOutsideEnemy_Postfix(RoundManager __instance, GameObject __result)
		{
			EnemyAI param = default(EnemyAI);
			if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null && ((NetworkBehaviour)__instance).IsServer && (Object)(object)__result != (Object)null && __result.TryGetComponent<EnemyAI>(ref param))
			{
				LevelManager.CurrentExtendedLevel.levelEvents.onNighttimeEnemySpawn.Invoke(param);
			}
		}

		[HarmonyPriority(201)]
		[HarmonyPatch(typeof(DungeonGenerator), "Generate")]
		[HarmonyPrefix]
		internal static void DungeonGeneratorGenerate_Prefix()
		{
			if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null)
			{
				DungeonManager.CurrentExtendedDungeonFlow.dungeonEvents.onBeforeDungeonGenerate.Invoke(RoundManager.Instance);
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(RoundManager), "SwitchPower")]
		[HarmonyPrefix]
		internal static void RoundManagerSwitchPower_Prefix(bool on)
		{
			if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null)
			{
				DungeonManager.CurrentExtendedDungeonFlow.dungeonEvents.onPowerSwitchToggle.Invoke(on);
			}
			if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null)
			{
				LevelManager.CurrentExtendedLevel.levelEvents.onPowerSwitchToggle.Invoke(on);
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")]
		[HarmonyPostfix]
		internal static void RoundManagerSpawnScrapInLevel_Postfix()
		{
			if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null && DungeonManager.CurrentExtendedDungeonFlow.dungeonEvents.onSpawnedScrapObjects.HasListeners)
			{
				DungeonManager.CurrentExtendedDungeonFlow.dungeonEvents.onSpawnedScrapObjects.Invoke(Object.FindObjectsOfType<GrabbableObject>().ToList());
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(RoundManager), "SpawnSyncedProps")]
		[HarmonyPostfix]
		internal static void RoundManagerSpawnSyncedProps_Postfix()
		{
			if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null && DungeonManager.CurrentExtendedDungeonFlow.dungeonEvents.onSpawnedSyncedObjects.HasListeners)
			{
				DungeonManager.CurrentExtendedDungeonFlow.dungeonEvents.onSpawnedSyncedObjects.Invoke(RoundManager.Instance.spawnedSyncedObjects);
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(RoundManager), "SpawnEnemyFromVent")]
		[HarmonyPrefix]
		internal static void RoundManagerSpawnEventFromVent_Prefix(EnemyVent vent)
		{
			if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null)
			{
				cachedSelectedVent = vent;
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(RoundManager), "SpawnEnemyGameObject")]
		[HarmonyPostfix]
		internal static void RoundManagerSpawnEventFromVent_Postfix()
		{
			if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null && (Object)(object)cachedSelectedVent != (Object)null)
			{
				DungeonManager.CurrentExtendedDungeonFlow.dungeonEvents.onEnemySpawnedFromVent.Invoke((cachedSelectedVent, RoundManager.Instance.SpawnedEnemies.Last()));
				cachedSelectedVent = null;
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(RoundManager), "SpawnMapObjects")]
		[HarmonyPostfix]
		internal static void RoundManagerSpawnMapObjects_Postfix()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null))
			{
				return;
			}
			List<GameObject> list = new List<GameObject>();
			Scene sceneByName = SceneManager.GetSceneByName(LevelManager.CurrentExtendedLevel.selectableLevel.sceneName);
			GameObject[] rootGameObjects = ((Scene)(ref sceneByName)).GetRootGameObjects();
			foreach (GameObject val in rootGameObjects)
			{
				SpawnableMapObject[] spawnableMapObjects = LevelManager.CurrentExtendedLevel.selectableLevel.spawnableMapObjects;
				foreach (SpawnableMapObject val2 in spawnableMapObjects)
				{
					if (((Object)val).name.Sanitized().Contains(((Object)val2.prefabToSpawn).name.Sanitized()))
					{
						list.Add(val);
					}
				}
			}
			DungeonManager.CurrentExtendedDungeonFlow.dungeonEvents.onSpawnedMapObjects.Invoke(list);
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(EntranceTeleport), "TeleportPlayerServerRpc")]
		[HarmonyPrefix]
		internal static void EntranceTeleportTeleportPlayerServerRpc_Prefix(EntranceTeleport __instance)
		{
			if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null)
			{
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				if (__instance.isEntranceToBuilding)
				{
					DungeonManager.CurrentExtendedDungeonFlow.dungeonEvents.onPlayerEnterDungeon.Invoke((__instance, localPlayerController));
				}
				else
				{
					DungeonManager.CurrentExtendedDungeonFlow.dungeonEvents.onPlayerExitDungeon.Invoke((__instance, localPlayerController));
				}
			}
			if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null)
			{
				PlayerControllerB localPlayerController2 = GameNetworkManager.Instance.localPlayerController;
				if (__instance.isEntranceToBuilding)
				{
					LevelManager.CurrentExtendedLevel.levelEvents.onPlayerEnterDungeon.Invoke((__instance, localPlayerController2));
				}
				else
				{
					LevelManager.CurrentExtendedLevel.levelEvents.onPlayerExitDungeon.Invoke((__instance, localPlayerController2));
				}
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(LungProp), "EquipItem")]
		[HarmonyPrefix]
		internal static void LungPropEquipItem_Postfix(LungProp __instance)
		{
			if (((NetworkBehaviour)__instance).IsServer)
			{
				if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null)
				{
					DungeonManager.CurrentExtendedDungeonFlow.dungeonEvents.onApparatusTaken.Invoke(__instance);
				}
				if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null)
				{
					LevelManager.CurrentExtendedLevel.levelEvents.onApparatusTaken.Invoke(__instance);
				}
			}
		}
	}
	public class ExtendedEvent<T>
	{
		public delegate void ParameterEvent(T param);

		public bool HasListeners => Listeners != 0;

		public int Listeners { get; internal set; }

		private event ParameterEvent onParameterEvent;

		public void Invoke(T param)
		{
			this.onParameterEvent?.Invoke(param);
		}

		public void AddListener(ParameterEvent listener)
		{
			onParameterEvent += listener;
			Listeners++;
		}

		public void RemoveListener(ParameterEvent listener)
		{
			onParameterEvent -= listener;
			Listeners--;
		}
	}
	public class ExtendedEvent
	{
		public delegate void Event();

		public bool HasListeners => Listeners != 0;

		public int Listeners { get; internal set; }

		private event Event onEvent;

		public void Invoke()
		{
			this.onEvent?.Invoke();
		}

		public void AddListener(Event listener)
		{
			onEvent += listener;
			Listeners++;
		}

		public void RemoveListener(Event listener)
		{
			onEvent -= listener;
			Listeners--;
		}
	}
	public static class Extensions
	{
		public static List<Tile> GetTiles(this DungeonFlow dungeonFlow)
		{
			List<Tile> list = new List<Tile>();
			foreach (GraphNode node in dungeonFlow.Nodes)
			{
				foreach (TileSet tileSet in node.TileSets)
				{
					list.AddRange(GetTilesInTileSet(tileSet));
				}
			}
			foreach (GraphLine line in dungeonFlow.Lines)
			{
				foreach (DungeonArchetype dungeonArchetype in line.DungeonArchetypes)
				{
					foreach (TileSet branchCapTileSet in dungeonArchetype.BranchCapTileSets)
					{
						list.AddRange(GetTilesInTileSet(branchCapTileSet));
					}
					foreach (TileSet tileSet2 in dungeonArchetype.TileSets)
					{
						list.AddRange(GetTilesInTileSet(tileSet2));
					}
				}
			}
			foreach (Tile item in new List<Tile>(list))
			{
				if ((Object)(object)item == (Object)null)
				{
					list.Remove(item);
				}
			}
			return list;
		}

		public static List<Tile> GetTilesInTileSet(TileSet tileSet)
		{
			List<Tile> list = new List<Tile>();
			if (tileSet.TileWeights != null && tileSet.TileWeights.Weights != null)
			{
				foreach (GameObjectChance weight in tileSet.TileWeights.Weights)
				{
					Tile[] componentsInChildren = weight.Value.GetComponentsInChildren<Tile>();
					foreach (Tile item in componentsInChildren)
					{
						list.Add(item);
					}
				}
			}
			return list;
		}

		public static List<RandomMapObject> GetRandomMapObjects(this DungeonFlow dungeonFlow)
		{
			List<RandomMapObject> list = new List<RandomMapObject>();
			foreach (Tile tile in dungeonFlow.GetTiles())
			{
				RandomMapObject[] componentsInChildren = ((Component)tile).gameObject.GetComponentsInChildren<RandomMapObject>();
				foreach (RandomMapObject item in componentsInChildren)
				{
					list.Add(item);
				}
			}
			return list;
		}

		public static List<SpawnSyncedObject> GetSpawnSyncedObjects(this DungeonFlow dungeonFlow)
		{
			List<SpawnSyncedObject> list = new List<SpawnSyncedObject>();
			foreach (Tile tile in dungeonFlow.GetTiles())
			{
				Doorway[] componentsInChildren = ((Component)tile).gameObject.GetComponentsInChildren<Doorway>();
				foreach (Doorway val in componentsInChildren)
				{
					foreach (GameObjectWeight connectorPrefabWeight in val.ConnectorPrefabWeights)
					{
						SpawnSyncedObject[] componentsInChildren2 = connectorPrefabWeight.GameObject.GetComponentsInChildren<SpawnSyncedObject>();
						foreach (SpawnSyncedObject item in componentsInChildren2)
						{
							list.Add(item);
						}
					}
					foreach (GameObjectWeight blockerPrefabWeight in val.BlockerPrefabWeights)
					{
						SpawnSyncedObject[] componentsInChildren3 = blockerPrefabWeight.GameObject.GetComponentsInChildren<SpawnSyncedObject>();
						foreach (SpawnSyncedObject item2 in componentsInChildren3)
						{
							list.Add(item2);
						}
					}
				}
				SpawnSyncedObject[] componentsInChildren4 = ((Component)tile).gameObject.GetComponentsInChildren<SpawnSyncedObject>();
				foreach (SpawnSyncedObject item3 in componentsInChildren4)
				{
					list.Add(item3);
				}
			}
			return list;
		}

		public static void AddReferences(this CompatibleNoun compatibleNoun, TerminalKeyword firstNoun, TerminalNode firstResult)
		{
			compatibleNoun.noun = firstNoun;
			compatibleNoun.result = firstResult;
		}

		public static void AddCompatibleNoun(this TerminalKeyword terminalKeyword, TerminalKeyword newNoun, TerminalNode newResult)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			if (terminalKeyword.compatibleNouns == null)
			{
				terminalKeyword.compatibleNouns = (CompatibleNoun[])(object)new CompatibleNoun[0];
			}
			CompatibleNoun val = new CompatibleNoun();
			val.noun = newNoun;
			val.result = newResult;
			terminalKeyword.compatibleNouns = CollectionExtensions.AddItem<CompatibleNoun>((IEnumerable<CompatibleNoun>)terminalKeyword.compatibleNouns, val).ToArray();
		}

		public static void AddCompatibleNoun(this TerminalNode terminalNode, TerminalKeyword newNoun, TerminalNode newResult)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			if (terminalNode.terminalOptions == null)
			{
				terminalNode.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[0];
			}
			CompatibleNoun val = new CompatibleNoun();
			val.noun = newNoun;
			val.result = newResult;
			terminalNode.terminalOptions = CollectionExtensions.AddItem<CompatibleNoun>((IEnumerable<CompatibleNoun>)terminalNode.terminalOptions, val).ToArray();
		}

		public static void Add(this IntWithRarity intWithRarity, int id, int rarity)
		{
			intWithRarity.id = id;
			intWithRarity.rarity = rarity;
		}

		public static string Sanitized(this string currentString)
		{
			return new string(currentString.SkipToLetters().RemoveWhitespace().ToLowerInvariant());
		}

		public static string RemoveWhitespace(this string input)
		{
			return new string((from c in input.ToCharArray()
				where !char.IsWhiteSpace(c)
				select c).ToArray());
		}

		public static string SkipToLetters(this string input)
		{
			return new string(input.SkipWhile((char c) => !char.IsLetter(c)).ToArray());
		}

		public static string StripSpecialCharacters(this string input)
		{
			string text = string.Empty;
			for (int i = 0; i < input.Length; i++)
			{
				char c = input[i];
				if ((!".,?!@#$%^&*()_+-=';:'\"".ToCharArray().Contains(c) && char.IsLetterOrDigit(c)) || c.ToString() == " ")
				{
					text += c;
				}
			}
			return text;
		}
	}
	internal static class Patches
	{
		internal const int harmonyPriority = 200;

		internal static string delayedSceneLoadingName = string.Empty;

		internal static List<string> allSceneNamesCalledToLoad = new List<string>();

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(PreInitSceneScript), "Awake")]
		[HarmonyPrefix]
		internal static void PreInitSceneScriptAwake_Prefix(PreInitSceneScript __instance)
		{
			if (!Plugin.hasVanillaBeenPatched)
			{
				AssetBundleLoader.CreateLoadingBundlesHeaderText(__instance);
				AudioSource val = default(AudioSource);
				if (((Component)__instance).TryGetComponent<AudioSource>(ref val))
				{
					OriginalContent.AudioMixers.Add(val.outputAudioMixerGroup.audioMixer);
				}
				AssetBundleLoader.LoadBundles(__instance);
				AssetBundleLoader.onBundlesFinishedLoading += AssetBundleLoader.LoadContentInBundles;
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(PreInitSceneScript), "ChooseLaunchOption")]
		[HarmonyPrefix]
		internal static bool PreInitSceneScriptChooseLaunchOption_Prefix()
		{
			return true;
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(SceneManager), "LoadScene", new Type[] { typeof(string) })]
		[HarmonyPrefix]
		internal static bool SceneManagerLoadScene(string sceneName)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (allSceneNamesCalledToLoad.Count == 0)
			{
				List<string> list = allSceneNamesCalledToLoad;
				Scene activeScene = SceneManager.GetActiveScene();
				list.Add(((Scene)(ref activeScene)).name);
			}
			SceneManager.GetSceneByName(sceneName);
			if (true)
			{
				allSceneNamesCalledToLoad.Add(sceneName);
			}
			if (sceneName == "MainMenu" && !allSceneNamesCalledToLoad.Contains("InitSceneLaunchOptions"))
			{
				DebugHelper.LogError("SceneManager has been told to load Main Menu without ever loading InitSceneLaunchOptions. This will break LethalLevelLoader. This is likely due to a \"Skip to Main Menu\" mod.");
				return false;
			}
			if (AssetBundleLoader.loadingStatus == AssetBundleLoader.LoadingStatus.Loading)
			{
				DebugHelper.LogWarning("SceneManager has attempted to load " + sceneName + " Scene before AssetBundles have finished loading. Pausing request until LethalLeveLoader is ready to proceed.");
				delayedSceneLoadingName = sceneName;
				AssetBundleLoader.onBundlesFinishedLoading -= LoadMainMenu;
				AssetBundleLoader.onBundlesFinishedLoading += LoadMainMenu;
				return false;
			}
			return true;
		}

		internal static void LoadMainMenu()
		{
			DebugHelper.LogWarning("Proceeding with the loading of " + delayedSceneLoadingName + " Scene as LethalLevelLoader has finished loading AssetBundles.");
			if (delayedSceneLoadingName != string.Empty)
			{
				SceneManager.LoadScene(delayedSceneLoadingName);
			}
			delayedSceneLoadingName = string.Empty;
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		[HarmonyPrefix]
		internal static void GameNetworkManagerStart_Prefix(GameNetworkManager __instance)
		{
			if (Plugin.hasVanillaBeenPatched)
			{
				return;
			}
			foreach (NetworkPrefab prefab in ((Component)__instance).GetComponent<NetworkManager>().NetworkConfig.Prefabs.m_Prefabs)
			{
				if (((Object)prefab.Prefab).name.Contains("EntranceTeleport") && (Object)(object)prefab.Prefab.GetComponent<AudioSource>() != (Object)null)
				{
					OriginalContent.AudioMixers.Add(prefab.Prefab.GetComponent<AudioSource>().outputAudioMixerGroup.audioMixer);
				}
			}
			GameObject val = NetworkPrefabs.CreateNetworkPrefab("LethalLevelLoaderNetworkManagerTest");
			val.AddComponent<LethalLevelLoaderNetworkManager>();
			val.GetComponent<NetworkObject>().DontDestroyWithOwner = true;
			val.GetComponent<NetworkObject>().SceneMigrationSynchronization = true;
			val.GetComponent<NetworkObject>().DestroyWithScene = false;
			Object.DontDestroyOnLoad((Object)(object)val);
			LethalLevelLoaderNetworkManager.networkingManagerPrefab = val;
			AssetBundleLoader.RegisterCustomContent(((Component)__instance).GetComponent<NetworkManager>());
			LethalLevelLoaderNetworkManager.RegisterPrefabs(((Component)__instance).GetComponent<NetworkManager>());
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		[HarmonyPrefix]
		internal static void StartOfRoundAwake_Prefix(StartOfRound __instance)
		{
			if (!Plugin.hasVanillaBeenPatched)
			{
				ContentExtractor.TryScrapeVanillaItems(__instance);
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(RoundManager), "Awake")]
		[HarmonyPostfix]
		internal static void RoundManagerAwake_Postfix(RoundManager __instance)
		{
			if (((Component)GameNetworkManager.Instance).GetComponent<NetworkManager>().IsServer)
			{
				LethalLevelLoaderNetworkManager component = Object.Instantiate<GameObject>(LethalLevelLoaderNetworkManager.networkingManagerPrefab).GetComponent<LethalLevelLoaderNetworkManager>();
				((Component)component).GetComponent<NetworkObject>().Spawn(false);
			}
			RoundManager.Instance.firstTimeDungeonAudios = CollectionExtensions.AddItem<AudioClip>((IEnumerable<AudioClip>)RoundManager.Instance.firstTimeDungeonAudios.ToList(), RoundManager.Instance.firstTimeDungeonAudios[0]).ToArray();
			if (Plugin.hasVanillaBeenPatched)
			{
				return;
			}
			ContentExtractor.TryScrapeVanillaContent(__instance);
			TerminalManager.CacheTerminalReferences();
			AssetBundleLoader.CreateVanillaExtendedDungeonFlows();
			AssetBundleLoader.CreateVanillaExtendedLevels(StartOfRound.Instance);
			AssetBundleLoader.InitializeBundles();
			string text = "LethalLevelLoader Loaded The Following ExtendedLevels:\n";
			foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels)
			{
				text = text + (PatchedContent.ExtendedLevels.IndexOf(extendedLevel) + 1) + ". " + extendedLevel.selectableLevel.PlanetName + " (" + extendedLevel.levelType.ToString() + ")\n";
			}
			DebugHelper.Log(text);
			text = "LethalLevelLoader Loaded The Following ExtendedDungeonFlows:\n";
			foreach (ExtendedDungeonFlow extendedDungeonFlow in PatchedContent.ExtendedDungeonFlows)
			{
				text = text + (PatchedContent.ExtendedDungeonFlows.IndexOf(extendedDungeonFlow) + 1) + ". " + extendedDungeonFlow.dungeonDisplayName + " (" + ((Object)extendedDungeonFlow.dungeonFlow).name + ") (" + extendedDungeonFlow.dungeonType.ToString() + ")\n";
			}
			DebugHelper.Log(text);
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(RoundManager), "Start")]
		[HarmonyPrefix]
		internal static void RoundManagerStart_Prefix()
		{
			if (!Plugin.hasVanillaBeenPatched)
			{
				foreach (ExtendedLevel customExtendedLevel in PatchedContent.CustomExtendedLevels)
				{
					ContentRestorer.RestoreVanillaLevelAssetReferences(customExtendedLevel);
				}
				foreach (ExtendedDungeonFlow customExtendedDungeonFlow in PatchedContent.CustomExtendedDungeonFlows)
				{
					ContentRestorer.RestoreVanillaDungeonAssetReferences(customExtendedDungeonFlow);
				}
				TerminalManager.CreateMoonsFilterTerminalAssets();
				ConfigLoader.BindConfigs();
				SceneManager.sceneLoaded += OnSceneLoaded;
				SceneManager.sceneLoaded += EventPatches.OnSceneLoaded;
			}
			AudioSource[] array = Resources.FindObjectsOfTypeAll<AudioSource>();
			foreach (AudioSource val in array)
			{
				val.spatialize = false;
			}
			LevelManager.ValidateLevelLists();
			LevelManager.PatchVanillaLevelLists();
			DungeonManager.PatchVanillaDungeonLists();
			LevelManager.RefreshCustomExtendedLevelIDs();
			TerminalManager.CreateExtendedLevelGroups();
			if (LevelManager.invalidSaveLevelID != -1 && StartOfRound.Instance.levels.Length > LevelManager.invalidSaveLevelID)
			{
				DebugHelper.Log("Setting CurrentLevel to previously saved ID that was not loaded at the time of save loading.");
				DebugHelper.Log(LevelManager.invalidSaveLevelID + " / " + StartOfRound.Instance.levels.Length);
				StartOfRound.Instance.ChangeLevelServerRpc(LevelManager.invalidSaveLevelID, TerminalManager.Terminal.groupCredits);
				LevelManager.invalidSaveLevelID = -1;
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(RoundManager), "Start")]
		[HarmonyPostfix]
		internal static void RoundManagerStart_Postfix()
		{
			if (!Plugin.hasVanillaBeenPatched)
			{
				ContentExtractor.TryScrapeCustomContent();
				Plugin.hasVanillaBeenPatched = true;
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(StartOfRound), "ChangeLevel")]
		[HarmonyPrefix]
		internal static void StartOfRoundChangeLevel_Prefix(ref int levelID)
		{
			if (levelID >= StartOfRound.Instance.levels.Length)
			{
				DebugHelper.LogWarning("Lethal Company attempted to load a saved current level that has not yet been loaded");
				DebugHelper.LogWarning(levelID + " / " + StartOfRound.Instance.levels.Length);
				LevelManager.invalidSaveLevelID = levelID;
				levelID = 0;
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(Terminal), "Start")]
		[HarmonyPostfix]
		internal static void TerminalStart_Postfix()
		{
			LevelManager.RefreshLethalExpansionMoons();
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(Terminal), "ParseWord")]
		[HarmonyPostfix]
		internal static void TerminalParseWord_Postfix(Terminal __instance, ref TerminalKeyword __result, string playerWord)
		{
			if ((Object)(object)__result != (Object)null)
			{
				TerminalKeyword val = TerminalManager.TryFindAlternativeNoun(__instance, __result, playerWord);
				if ((Object)(object)val != (Object)null)
				{
					__result = val;
				}
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(Terminal), "RunTerminalEvents")]
		[HarmonyPrefix]
		internal static bool TerminalRunTerminalEvents_Prefix(TerminalNode node)
		{
			return TerminalManager.RunLethalLevelLoaderTerminalEvents(node);
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(Terminal), "LoadNewNode")]
		[HarmonyPrefix]
		internal static void TerminalLoadNewNode_Prefix(Terminal __instance, ref TerminalNode node)
		{
			if ((Object)(object)node == (Object)(object)TerminalManager.moonsKeyword.specialKeywordResult)
			{
				TerminalManager.RefreshExtendedLevelGroups();
				node.displayText = TerminalManager.GetMoonsTerminalText();
			}
			else
			{
				if (!((Object)(object)__instance.currentNode == (Object)(object)TerminalManager.moonsKeyword.specialKeywordResult))
				{
					return;
				}
				foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels)
				{
					if ((Object)(object)extendedLevel.routeNode == (Object)(object)node && extendedLevel.isLocked)
					{
						TerminalManager.SwapRouteNodeToLockedNode(extendedLevel, ref node);
					}
				}
			}
		}

		internal static void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null && LevelManager.CurrentExtendedLevel.IsLoaded && LevelManager.CurrentExtendedLevel.levelType == ContentType.Custom && !LevelManager.CurrentExtendedLevel.isLethalExpansion)
			{
				Scene sceneByName = SceneManager.GetSceneByName(LevelManager.CurrentExtendedLevel.selectableLevel.sceneName);
				GameObject[] rootGameObjects = ((Scene)(ref sceneByName)).GetRootGameObjects();
				foreach (GameObject val in rootGameObjects)
				{
					LevelLoader.UpdateStoryLogs(LevelManager.CurrentExtendedLevel, val);
					ContentRestorer.RestoreAudioAssetReferencesInParent(val);
				}
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(DungeonGenerator), "Generate")]
		[HarmonyPrefix]
		internal static void DungeonGeneratorGenerate_Prefix(DungeonGenerator __instance)
		{
			if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null)
			{
				DungeonLoader.PrepareDungeon();
			}
			LevelManager.LogDayHistory();
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(RoundManager), "Generator_OnGenerationStatusChanged")]
		[HarmonyPrefix]
		internal static bool OnGenerationStatusChanged_Prefix(RoundManager __instance, GenerationStatus status)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			DebugHelper.Log(((object)(GenerationStatus)(ref status)).ToString());
			if ((int)status == 6 && !__instance.dungeonCompletedGenerating)
			{
				__instance.FinishGeneratingLevel();
				__instance.dungeonGenerator.Generator.OnGenerationStatusChanged -= new GenerationStatusDelegate(__instance.Generator_OnGenerationStatusChanged);
				Debug.Log((object)"Dungeon has finished generating on this client after multiple frames");
			}
			return false;
		}

		[HarmonyPatch(typeof(RoundManager), "GenerateNewLevelClientRpc")]
		[HarmonyTranspiler]
		public static IEnumerable<CodeInstruction> GenerateNewLevelClientRpcTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: 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_0051: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).SearchForward((Func<CodeInstruction, bool>)((CodeInstruction instructions) => CodeInstructionExtensions.Calls(instructions, AccessTools.Method(typeof(RoundManager), "GenerateNewFloor", (Type[])null, (Type[])null)))).SetInstruction(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Patches), "InjectHostDungeonFlowSelection", (Type[])null, (Type[])null))).Advance(-1)
				.SetInstruction(new CodeInstruction(OpCodes.Nop, (object)null));
			return val.InstructionEnumeration();
		}

		[HarmonyPatch(typeof(RoundManager), "GenerateNewFloor")]
		[HarmonyTranspiler]
		public static IEnumerable<CodeInstruction> GenerateNewFloorTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: 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_0051: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).SearchForward((Func<CodeInstruction, bool>)((CodeInstruction instructions) => CodeInstructionExtensions.Calls(instructions, AccessTools.Method(typeof(RuntimeDungeon), "Generate", (Type[])null, (Type[])null)))).SetInstruction(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Patches), "InjectHostDungeonSizeSelection", (Type[])null, (Type[])null))).Advance(-1)
				.SetInstruction(new CodeInstruction(OpCodes.Nop, (object)null));
			return val.InstructionEnumeration();
		}

		public static void InjectHostDungeonSizeSelection(RoundManager roundManager)
		{
			if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null)
			{
				LethalLevelLoaderNetworkManager.Instance.GetDungeonFlowSizeServerRpc();
			}
			else
			{
				roundManager.dungeonGenerator.Generate();
			}
		}

		internal static void InjectHostDungeonFlowSelection()
		{
			if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null)
			{
				DungeonManager.TryAddCurrentVanillaLevelDungeonFlow(RoundManager.Instance.dungeonGenerator.Generator, LevelManager.CurrentExtendedLevel);
				DungeonLoader.SelectDungeon();
			}
			else
			{
				RoundManager.Instance.GenerateNewFloor();
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(Dungeon), "RoundManager_Start")]
		[HarmonyPrefix]
		internal static bool Dungeon_Start_Prefix(orig_Start orig, RoundManager self)
		{
			DebugHelper.LogWarning("Disabling LethalLib Dungeon.RoundManager_Start() Function To Prevent Conflicts");
			orig.Invoke(self);
			return false;
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(Dungeon), "RoundManager_GenerateNewFloor")]
		[HarmonyPrefix]
		internal static bool Dungeon_GenerateNewFloor_Prefix(orig_GenerateNewFloor orig, RoundManager self)
		{
			DebugHelper.LogWarning("Disabling LethalLib Dungeon.RoundManager_GenerateNewFloor() Function To Prevent Conflicts");
			orig.Invoke(self);
			return false;
		}
	}
	public enum PreviewInfoType
	{
		Price,
		Difficulty,
		Weather,
		History,
		All,
		None,
		Vanilla,
		Override
	}
	public enum SortInfoType
	{
		Price,
		Difficulty,
		Tag,
		LastTraveled,
		None
	}
	public enum FilterInfoType
	{
		Price,
		Weather,
		Tag,
		TraveledThisQuota,
		TraveledThisRun,
		None
	}
	public enum SimulateInfoType
	{
		Percentage,
		Rarity
	}
	public static class Settings
	{
		public static PreviewInfoType levelPreviewInfoType = PreviewInfoType.Weather;

		public static SortInfoType levelPreviewSortType = SortInfoType.None;

		public static FilterInfoType levelPreviewFilterType = FilterInfoType.None;

		public static SimulateInfoType levelSimulateInfoType = SimulateInfoType.Percentage;

		public static bool allDungeonFlowsRequireMatching = false;

		public static string GetOverridePreviewInfo(ExtendedLevel extendedLevel)
		{
			return string.Empty;
		}
	}
	[Serializable]
	public class ExtendedDungeonFlowWithRarity
	{
		public ExtendedDungeonFlow extendedDungeonFlow;

		public int rarity;

		public ExtendedDungeonFlowWithRarity(ExtendedDungeonFlow newExtendedDungeonFlow, int newRarity)
		{
			extendedDungeonFlow = newExtendedDungeonFlow;
			rarity = newRarity;
		}

		public bool UpdateRarity(int newRarity)
		{
			if (newRarity > rarity)
			{
				rarity = newRarity;
				return true;
			}
			return false;
		}
	}
	public static class DungeonLoader
	{
		internal static void SelectDungeon()
		{
			RoundManager.Instance.dungeonGenerator.Generator.DungeonFlow = null;
			if (((NetworkBehaviour)LethalLevelLoaderNetworkManager.Instance).IsServer)
			{
				LethalLevelLoaderNetworkManager.Instance.GetRandomExtendedDungeonFlowServerRpc();
			}
		}

		internal static void PrepareDungeon()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			DungeonGenerator generator = RoundManager.Instance.dungeonGenerator.Generator;
			ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel;
			ExtendedDungeonFlow currentExtendedDungeonFlow = DungeonManager.CurrentExtendedDungeonFlow;
			PatchFireEscapes(generator, currentExtendedLevel, SceneManager.GetSceneByName(currentExtendedLevel.selectableLevel.sceneName));
			PatchDynamicGlobalProps(generator, currentExtendedDungeonFlow);
		}

		public static float GetClampedDungeonSize()
		{
			float num = LevelManager.CurrentExtendedLevel.selectableLevel.factorySizeMultiplier * RoundManager.Instance.mapSizeMultiplier;
			if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null && DungeonManager.CurrentExtendedDungeonFlow.enableDynamicDungeonSizeRestriction)
			{
				ExtendedDungeonFlow currentExtendedDungeonFlow = DungeonManager.CurrentExtendedDungeonFlow;
				ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel;
				if (currentExtendedLevel.selectableLevel.factorySizeMultiplier > currentExtendedDungeonFlow.dungeonSizeMax)
				{
					num = Mathf.Lerp(currentExtendedLevel.selectableLevel.factorySizeMultiplier, currentExtendedDungeonFlow.dungeonSizeMax, currentExtendedDungeonFlow.dungeonSizeLerpPercentage) * RoundManager.Instance.mapSizeMultiplier;
				}
				else if (currentExtendedLevel.selectableLevel.factorySizeMultiplier < currentExtendedDungeonFlow.dungeonSizeMin)
				{
					num = Mathf.Lerp(currentExtendedLevel.selectableLevel.factorySizeMultiplier, currentExtendedDungeonFlow.dungeonSizeMin, currentExtendedDungeonFlow.dungeonSizeLerpPercentage) * RoundManager.Instance.mapSizeMultiplier;
				}
				DebugHelper.Log("CurrentLevel: " + LevelManager.CurrentExtendedLevel.NumberlessPlanetName + " DungeonSize Is: " + LevelManager.CurrentExtendedLevel.selectableLevel.factorySizeMultiplier + " | Overrriding DungeonSize To: " + num / RoundManager.Instance.mapSizeMultiplier + " (" + num + ")");
			}
			else
			{
				DebugHelper.Log("CurrentLevel: " + LevelManager.CurrentExtendedLevel.NumberlessPlanetName + " DungeonSize Is: " + LevelManager.CurrentExtendedLevel.selectableLevel.factorySizeMultiplier + " | Leaving DungeonSize As: " + num / RoundManager.Instance.mapSizeMultiplier + " (" + num + ")");
			}
			return num;
		}

		internal static void PatchDungeonSize(DungeonGenerator dungeonGenerator, ExtendedLevel extendedLevel, ExtendedDungeonFlow extendedDungeonFlow)
		{
		}

		internal static List<EntranceTeleport> GetEntranceTeleports(Scene scene)
		{
			List<EntranceTeleport> list = new List<EntranceTeleport>();
			GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects();
			foreach (GameObject val in rootGameObjects)
			{
				EntranceTeleport[] componentsInChildren = val.GetComponentsInChildren<EntranceTeleport>();
				foreach (EntranceTeleport item in componentsInChildren)
				{
					list.Add(item);
				}
			}
			return list;
		}

		internal static void PatchFireEscapes(DungeonGenerator dungeonGenerator, ExtendedLevel extendedLevel, Scene scene)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Expected O, but got Unknown
			string text = "Fire Exit Patch Report, Details Below;\n\n";
			if (!DungeonManager.TryGetExtendedDungeonFlow(dungeonGenerator.DungeonFlow, out var returnExtendedDungeonFlow))
			{
				return;
			}
			List<EntranceTeleport> list = (from o in GetEntranceTeleports(scene)
				orderby o.entranceId
				select o).ToList();
			foreach (EntranceTeleport item in list)
			{
				item.entranceId = list.IndexOf(item);
				item.dungeonFlowId = returnExtendedDungeonFlow.dungeonID;
			}
			text = text + "EntranceTeleport's Found, " + extendedLevel.NumberlessPlanetName + " Contains " + list.Count + " Entrances! ( " + (list.Count - 1) + " Fire Escapes) \n";
			text = text + "Main Entrance: " + ((Object)((Component)list[0]).gameObject).name + " (Entrance ID: " + list[0].entranceId + ") (Dungeon ID: " + list[0].dungeonFlowId + ")\n";
			foreach (EntranceTeleport item2 in list)
			{
				if (item2.entranceId != 0)
				{
					text = text + "Alternate Entrance: " + ((Object)((Component)item2).gameObject).name + " (Entrance ID: " + item2.entranceId + ") (Dungeon ID: " + item2.dungeonFlowId + ")\n";
				}
			}
			foreach (GlobalPropSettings globalProp in dungeonGenerator.DungeonFlow.GlobalProps)
			{
				if (globalProp.ID == 1231)
				{
					text = text + "Found Fire Escape GlobalProp: (ID: 1231), Modifying Spawnrate Count From (" + globalProp.Count.Min + "," + globalProp.Count.Max + ") To (" + (list.Count - 1) + "," + (list.Count - 1) + ")\n";
					globalProp.Count = new IntRange(list.Count - 1, list.Count - 1);
					break;
				}
			}
			DebugHelper.Log(text + "\n");
		}

		public static void PatchDynamicGlobalProps(DungeonGenerator dungeonGenerator, ExtendedDungeonFlow extendedDungeonFlow)
		{
			foreach (GlobalPropCountOverride globalPropCountOverrides in extendedDungeonFlow.globalPropCountOverridesList)
			{
				foreach (GlobalPropSettings globalProp in dungeonGenerator.DungeonFlow.GlobalProps)
				{
					if (globalPropCountOverrides.globalPropID == globalProp.ID)
					{
						globalProp.Count.Min = globalProp.Count.Min * Mathf.RoundToInt(Mathf.Lerp(1f, dungeonGenerator.LengthMultiplier / RoundManager.Instance.mapSizeMultiplier, globalPropCountOverrides.globalPropCountScaleRate));
						globalProp.Count.Max = globalProp.Count.Max * Mathf.RoundToInt(Mathf.Lerp(1f, dungeonGenerator.LengthMultiplier / RoundManager.Instance.mapSizeMultiplier, globalPropCountOverrides.globalPropCountScaleRate));
					}
				}
			}
		}
	}
	public class LevelLoader
	{
		internal static List<MeshCollider> customLevelMeshCollidersList = new List<MeshCollider>();

		internal static async void EnableMeshColliders()
		{
			List<MeshCollider> instansiatedCustomLevelMeshColliders = new List<MeshCollider>();
			int counter = 0;
			MeshCollider[] array = Object.FindObjectsOfType<MeshCollider>();
			foreach (MeshCollider meshCollider in array)
			{
				if (((Object)((Component)meshCollider).gameObject).name.Contains(" (LLL Tracked)"))
				{
					instansiatedCustomLevelMeshColliders.Add(meshCollider);
				}
			}
			Task[] meshColliderEnableTasks = new Task[instansiatedCustomLevelMeshColliders.Count];
			foreach (MeshCollider meshCollider2 in instansiatedCustomLevelMeshColliders)
			{
				meshColliderEnableTasks[counter] = EnableMeshCollider(meshCollider2);
				counter++;
			}
			await Task.WhenAll(meshColliderEnableTasks);
		}

		internal static async Task EnableMeshCollider(MeshCollider meshCollider)
		{
			((Collider)meshCollider).enabled = true;
			((Object)((Component)meshCollider).gameObject).name.Replace(" (LLL Tracked)", "");
			await Task.Yield();
		}

		internal static void UpdateStoryLogs(ExtendedLevel extendedLevel, GameObject sceneRootObject)
		{
			StoryLog[] componentsInChildren = sceneRootObject.GetComponentsInChildren<StoryLog>();
			foreach (StoryLog val in componentsInChildren)
			{
				foreach (StoryLogData storyLog in extendedLevel.storyLogs)
				{
					if (val.storyLogID == storyLog.storyLogID)
					{
						val.storyLogID = storyLog.newStoryLogID;
					}
				}
			}
		}
	}
	public class DungeonManager
	{
		public static ExtendedDungeonFlow CurrentExtendedDungeonFlow
		{
			get
			{
				ExtendedDungeonFlow result = null;
				if ((Object)(object)RoundManager.Instance != (Object)null && (Object)(object)RoundManager.Instance.dungeonGenerator != (Object)null && TryGetExtendedDungeonFlow(RoundManager.Instance.dungeonGenerator.Generator.DungeonFlow, out var returnExtendedDungeonFlow))
				{
					result = returnExtendedDungeonFlow;
				}
				return result;
			}
		}

		internal static void PatchVanillaDungeonLists()
		{
			foreach (ExtendedDungeonFlow customExtendedDungeonFlow in PatchedContent.CustomExtendedDungeonFlows)
			{
				customExtendedDungeonFlow.dungeonID = RoundManager.Instance.dungeonFlowTypes.Length;
				RoundManager.Instance.dungeonFlowTypes = CollectionExtensions.AddItem<DungeonFlow>((IEnumerable<DungeonFlow>)RoundManager.Instance.dungeonFlowTypes, customExtendedDungeonFlow.dungeonFlow).ToArray();
				if ((Object)(object)customExtendedDungeonFlow.dungeonFirstTimeAudio != (Object)null)
				{
					RoundManager.Instance.firstTimeDungeonAudios = CollectionExtensions.AddItem<AudioClip>((IEnumerable<AudioClip>)RoundManager.Instance.firstTimeDungeonAudios, customExtendedDungeonFlow.dungeonFirstTimeAudio).ToArray();
				}
			}
		}

		internal static void AddExtendedDungeonFlow(ExtendedDungeonFlow extendedDungeonFlow)
		{
			PatchedContent.ExtendedDungeonFlows.Add(extendedDungeonFlow);
		}

		internal static void TryAddCurrentVanillaLevelDungeonFlow(DungeonGenerator dungeonGenerator, ExtendedLevel currentExtendedLevel)
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			if ((Object)(object)dungeonGenerator.DungeonFlow != (Object)null && !RoundManager.Instance.dungeonFlowTypes.ToList().Contains(dungeonGenerator.DungeonFlow))
			{
				DebugHelper.Log("Level: " + currentExtendedLevel.selectableLevel.PlanetName + " Contains DungeonFlow: " + ((Object)dungeonGenerator.DungeonFlow).name + " In DungeonGenerator That Was Not Found In RoundManager, Adding!");
				AssetBundleLoader.CreateVanillaExtendedDungeonFlow(dungeonGenerator.DungeonFlow);
				if (TryGetExtendedDungeonFlow(dungeonGenerator.DungeonFlow, out var returnExtendedDungeonFlow))
				{
					IntWithRarity val = new IntWithRarity();
					val.id = returnExtendedDungeonFlow.dungeonID;
					val.rarity = 300;
					currentExtendedLevel.selectableLevel.dungeonFlowTypes = CollectionExtensions.AddItem<IntWithRarity>((IEnumerable<IntWithRarity>)currentExtendedLevel.selectableLevel.dungeonFlowTypes, val).ToArray();
				}
			}
		}

		internal static List<ExtendedDungeonFlowWithRarity> GetValidExtendedDungeonFlows(ExtendedLevel extendedLevel, bool debugResults)
		{
			string text = "Trying To Find All Matching DungeonFlows For Level: " + extendedLevel.NumberlessPlanetName + "\n";
			List<ExtendedDungeonFlowWithRarity> list = new List<ExtendedDungeonFlowWithRarity>();
			List<ExtendedDungeonFlowWithRarity> list2 = new List<ExtendedDungeonFlowWithRarity>();
			if (extendedLevel.allowedDungeonContentTypes == ContentType.Vanilla || extendedLevel.allowedDungeonContentTypes == ContentType.Any)
			{
				IntWithRarity[] dungeonFlowTypes = extendedLevel.selectableLevel.dungeonFlowTypes;
				foreach (IntWithRarity val in dungeonFlowTypes)
				{
					if (TryGetExtendedDungeonFlow(RoundManager.Instance.dungeonFlowTypes[val.id], out var returnExtendedDungeonFlow))
					{
						if (!Settings.allDungeonFlowsRequireMatching)
						{
							list.Add(new ExtendedDungeonFlowWithRarity(returnExtendedDungeonFlow, val.rarity));
						}
						else
						{
							list2.Add(new ExtendedDungeonFlowWithRarity(returnExtendedDungeonFlow, val.rarity));
						}
					}
				}
			}
			if (extendedLevel.allowedDungeonContentTypes == ContentType.Custom || extendedLevel.allowedDungeonContentTypes == ContentType.Any)
			{
				foreach (ExtendedDungeonFlow customExtendedDungeonFlow in PatchedContent.CustomExtendedDungeonFlows)
				{
					list2.Add(new ExtendedDungeonFlowWithRarity(customExtendedDungeonFlow, 0));
				}
			}
			text += "Potential DungeonFlows Collected, List Below: \n";
			foreach (ExtendedDungeonFlowWithRarity item in list.Concat(list2))
			{
				text = text + item.extendedDungeonFlow.dungeonDisplayName + " - " + item.rarity + ", ";
			}
			text = text + "\n\nSelectableLevel - " + extendedLevel.selectableLevel.PlanetName + " Level Tags: ";
			foreach (string levelTag in extendedLevel.levelTags)
			{
				text = text + levelTag + ", ";
			}
			text += "\n";
			foreach (ExtendedDungeonFlowWithRarity item2 in list)
			{
				text = text + "\nDungeonFlow " + (list.IndexOf(item2) + 1) + ". : " + ((Object)item2.extendedDungeonFlow.dungeonFlow).name + " - Matched " + extendedLevel.NumberlessPlanetName + " With A Rarity Of: " + item2.rarity + " Based On The Levels DungeonFlowTypes!\n";
			}
			foreach (ExtendedDungeonFlowWithRarity item3 in new List<ExtendedDungeonFlowWithRarity>(list2))
			{
				string text2 = string.Empty;
				ExtendedDungeonFlow extendedDungeonFlow = item3.extendedDungeonFlow;
				if (item3.UpdateRarity(GetHighestRarityViaMatchingNormalizedString(extendedLevel.contentSourceName, extendedDungeonFlow.manualContentSourceNameReferenceList)))
				{
					text2 = " Based On Content Source Name!";
				}
				if (item3.UpdateRarity(GetHighestRarityViaMatchingNormalizedString(extendedLevel.NumberlessPlanetName, extendedDungeonFlow.manualPlanetNameReferenceList)))
				{
					text2 = " Based On Planet Name!";
				}
				if (item3.UpdateRarity(GetHighestRarityViaMatchingWithinRanges(extendedLevel.RoutePrice, extendedDungeonFlow.dynamicRoutePricesList)))
				{
					text2 = " Based On Route Price!";
				}
				if (item3.UpdateRarity(GetHighestRarityViaMatchingNormalizedStrings(extendedLevel.levelTags, extendedDungeonFlow.dynamicLevelTagsList)))
				{
					text2 = " Based On Level Tags!";
				}
				if (item3.UpdateRarity(GetHighestRarityViaMatchingNormalizedString(((object)(LevelWeatherType)(ref extendedLevel.selectableLevel.currentWeather)).ToString(), extendedDungeonFlow.dynamicCurrentWeatherList)))
				{
					text2 = " Based On Current Weather!";
				}
				if (text2 != string.Empty)
				{
					text = text + "\nDungeonFlow " + (list2.IndexOf(item3) + 1) + ". : " + ((Object)extendedDungeonFlow.dungeonFlow).name + " - Matched " + extendedLevel.NumberlessPlanetName + " With A Rarity Of: " + item3.rarity + text2 + "\n";
				}
				if (item3.rarity != 0)
				{
					list.Add(item3);
				}
			}
			if (debugResults)
			{
				DebugHelper.Log(text + "\nMatching DungeonFlows Collected, Count Is: " + list.Count + "\n\n");
			}
			return list;
		}

		internal static void RefreshDungeonFlowIDs()
		{
			DebugHelper.Log("Re-Adjusting DungeonFlowTypes Array For Late Arriving Vanilla DungeonFlow");
			List<DungeonFlow> list = new List<DungeonFlow>();
			foreach (ExtendedDungeonFlow vanillaExtendedDungeonFlow in PatchedContent.VanillaExtendedDungeonFlows)
			{
				vanillaExtendedDungeonFlow.dungeonID = list.Count;
				list.Add(vanillaExtendedDungeonFlow.dungeonFlow);
			}
			foreach (ExtendedDungeonFlow customExtendedDungeonFlow in PatchedContent.CustomExtendedDungeonFlows)
			{
				customExtendedDungeonFlow.dungeonID = list.Count;
				list.Add(customExtendedDungeonFlow.dungeonFlow);
			}
			RoundManager.Instance.dungeonFlowTypes = list.ToArray();
		}

		internal static int GetHighestRarityViaMatchingWithinRanges(int comparingValue, List<Vector2WithRarity> matchingVectors)
		{
			int num = 0;
			foreach (Vector2WithRarity matchingVector in matchingVectors)
			{
				if (matchingVector.Rarity >= num && (float)comparingValue >= matchingVector.Min && (float)comparingValue <= matchingVector.Max)
				{
					num = matchingVector.Rarity;
				}
			}
			return num;
		}

		internal static int GetHighestRarityViaMatchingNormalizedString(string comparingString, List<StringWithRarity> matchingStrings)
		{
			return GetHighestRarityViaMatchingNormalizedStrings(new List<string> { comparingString }, matchingStrings);
		}

		internal static int GetHighestRarityViaMatchingNormalizedStrings(List<string> comparingStrings, List<StringWithRarity> matchingStrings)
		{
			int num = 0;
			foreach (StringWithRarity matchingString in matchingStrings)
			{
				foreach (string item in new List<string>(comparingStrings))
				{
					if (matchingString.Rarity >= num && (matchingString.Name.Sanitized().Contains(item.Sanitized()) || item.Sanitized().Contains(matchingString.Name.Sanitized())))
					{
						num = matchingString.Rarity;
					}
				}
			}
			return num;
		}

		internal static bool TryGetExtendedDungeonFlow(DungeonFlow dungeonFlow, out ExtendedDungeonFlow returnExtendedDungeonFlow, ContentType contentType = ContentType.Any)
		{
			returnExtendedDungeonFlow = null;
			List<ExtendedDungeonFlow> list = null;
			if ((Object)(object)dungeonFlow == (Object)null)
			{
				return false;
			}
			switch (contentType)
			{
			case ContentType.Any:
				list = PatchedContent.ExtendedDungeonFlows;
				break;
			case ContentType.Custom:
				list = PatchedContent.CustomExtendedDungeonFlows;
				break;
			case ContentType.Vanilla:
				list = PatchedContent.VanillaExtendedDungeonFlows;
				break;
			}
			foreach (ExtendedDungeonFlow item in list)
			{
				if ((Object)(object)item.dungeonFlow == (Object)(object)dungeonFlow)
				{
					returnExtendedDungeonFlow = item;
				}
			}
			return (Object)(object)returnExtendedDungeonFlow != (Object)null;
		}
	}
	public class LethalLevelLoaderNetworkManager : NetworkBehaviour
	{
		public static GameObject networkingManagerPrefab;

		private static LethalLevelLoaderNetworkManager _instance;

		private static List<GameObject> queuedNetworkPrefabs = new List<GameObject>();

		public static bool networkHasStarted;

		public static LethalLevelLoaderNetworkManager Instance
		{
			get
			{
				if ((Object)(object)_instance == (Object)null)
				{
					_instance = Object.FindObjectOfType<LethalLevelLoaderNetworkManager>();
				}
				if ((Object)(object)_instance == (Object)null)
				{
					DebugHelper.LogWarning("LethalLevelLoaderNetworkManager Could Not Be Found! Returning Null!");
				}
				return _instance;
			}
			set
			{
				_instance = value;
			}
		}

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			((Object)((Component)this).gameObject).name = "LethalLevelLoaderNetworkManager";
			Instance = this;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
		}

		[ServerRpc]
		public void GetRandomExtendedDungeonFlowServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(12573863u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 12573863u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			DebugHelper.Log("Getting Random DungeonFlows!");
			List<ExtendedDungeonFlowWithRarity> validExtendedDungeonFlows = DungeonManager.GetValidExtendedDungeonFlows(LevelManager.CurrentExtendedLevel, debugResults: true);
			List<int> list = new List<int>();
			List<int> list2 = new List<int>();
			if (validExtendedDungeonFlows.Count == 0)
			{
				DebugHelper.LogError("No ExtendedDungeonFlow's could be found! This should only happen if the Host's requireMatchesOnAllDungeonFlows is set to true!");
				DebugHelper.LogError("Loading Facility DungeonFlow to prevent infinite loading!");
				list.Add(0);
				list2.Add(300);
			}
			else
			{
				foreach (ExtendedDungeonFlowWithRarity item in validExtendedDungeonFlows)
				{
					list.Add(RoundManager.Instance.dungeonFlowTypes.ToList().IndexOf(item.extendedDungeonFlow.dungeonFlow));
					list2.Add(item.rarity);
				}
			}
			SetRandomExtendedDungeonFlowClientRpc(list.ToArray(), list2.ToArray());
		}

		[ClientRpc]
		public void SetRandomExtendedDungeonFlowClientRpc(int[] dungeonFlowIDs, int[] rarities)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Expected O, but got Unknown
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1934987400u, val, (RpcDelivery)0);
				bool flag = dungeonFlowIDs != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe<int>(dungeonFlowIDs, default(ForPrimitives));
				}
				bool flag2 = rarities != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives));
				if (flag2)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe<int>(rarities, default(ForPrimitives));
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1934987400u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				DebugHelper.Log("Setting Random DungeonFlows!");
				List<IntWithRarity> list = new List<IntWithRarity>();
				List<IntWithRarity> list2 = new List<IntWithRarity>();
				for (int i = 0; i < dungeonFlowIDs.Length; i++)
				{
					IntWithRarity val3 = new IntWithRarity();
					val3.Add(dungeonFlowIDs[i], rarities[i]);
					list.Add(val3);
				}
				list2 = new List<IntWithRarity>(LevelManager.CurrentExtendedLevel.selectableLevel.dungeonFlowTypes.ToList());
				LevelManager.CurrentExtendedLevel.selectableLevel.dungeonFlowTypes = list.ToArray();
				RoundManager.Instance.GenerateNewFloor();
				LevelManager.CurrentExtendedLevel.selectableLevel.dungeonFlowTypes = list2.ToArray();
			}
		}

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

		[ClientRpc]
		public void SetDungeonFlowSizeClientRpc(float hostSize)
		{
			//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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1778200789u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref hostSize, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1778200789u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					RoundManager.Instance.dungeonGenerator.Generator.LengthMultiplier = hostSize;
					RoundManager.Instance.dungeonGenerator.Generate();
				}
			}
		}

		public static void RegisterNetworkPrefab(GameObject prefab)
		{
			if (!networkHasStarted)
			{
				queuedNetworkPrefabs.Add(prefab);
			}
			else
			{
				DebugHelper.Log("Attempted To Register NetworkPrefab: " + ((object)prefab)?.ToString() + " After GameNetworkManager Has Started!");
			}
		}

		internal static void RegisterPrefabs(NetworkManager networkManager)
		{
			List<GameObject> list = new List<GameObject>();
			foreach (NetworkPrefab prefab in networkManager.NetworkConfig.Prefabs.m_Prefabs)
			{
				list.Add(prefab.Prefab);
			}
			int num = 0;
			foreach (GameObject queuedNetworkPrefab in queuedNetworkPrefabs)
			{
				if (!list.Contains(queuedNetworkPrefab))
				{
					networkManager.AddNetworkPrefab(queuedNetworkPrefab);
					list.Add(queuedNetworkPrefab);
				}
				else
				{
					num++;
				}
			}
			DebugHelper.Log("Skipped Registering " + num + " NetworkObjects As They Were Already Registered.");
			networkHasStarted = true;
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_LethalLevelLoaderNetworkManager()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(12573863u, new RpcReceiveHandler(__rpc_handler_12573863));
			NetworkManager.__rpc_func_table.Add(1934987400u, new RpcReceiveHandler(__rpc_handler_1934987400));
			NetworkManager.__rpc_func_table.Add(1367970965u, new RpcReceiveHandler(__rpc_handler_1367970965));
			NetworkManager.__rpc_func_table.Add(1778200789u, new RpcReceiveHandler(__rpc_handler_1778200789));
		}

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

		private static void __rpc_handler_1934987400(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_0074: 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_0058: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				int[] dungeonFlowIDs = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref dungeonFlowIDs, default(ForPrimitives));
				}
				bool flag2 = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
				int[] rarities = null;
				if (flag2)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref rarities, default(ForPrimitives));
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((LethalLevelLoaderNetworkManager)(object)target).SetRandomExtendedDungeonFlowClientRpc(dungeonFlowIDs, rarities);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		private static void __rpc_handler_1778200789(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float dungeonFlowSizeClientRpc = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref dungeonFlowSizeClientRpc, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((LethalLevelLoaderNetworkManager)(object)target).SetDungeonFlowSizeClientRpc(dungeonFlowSizeClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "LethalLevelLoaderNetworkManager";
		}
	}
	public class LevelManager
	{
		public static List<DayHistory> dayHistoryList = new List<DayHistory>();

		public static int daysTotal;

		public static int quotasTotal;

		public static int invalidSaveLevelID = -1;

		public static ExtendedLevel CurrentExtendedLevel
		{
			get
			{
				ExtendedLevel result = null;
				if ((Object)(object)StartOfRound.Instance != (Object)null && TryGetExtendedLevel(StartOfRound.Instance.currentLevel, out var returnExtendedLevel))
				{
					result = returnExtendedLevel;
				}
				return result;
			}
		}

		internal static void ValidateLevelLists()
		{
			List<SelectableLevel> list = new List<SelectableLevel>(OriginalContent.SelectableLevels);
			List<SelectableLevel> list2 = new List<SelectableLevel>(OriginalContent.MoonsCatalogue);
			List<SelectableLevel> list3 = new List<SelectableLevel>(StartOfRound.Instance.levels);
			foreach (SelectableLevel item in new List<SelectableLevel>(list))
			{
				if (item.levelID > 8)
				{
					list.Remove(item);
				}
			}
			foreach (SelectableLevel item2 in new List<SelectableLevel>(list2))
			{
				if (item2.levelID > 8)
				{
					list2.Remove(item2);
				}
			}
			foreach (SelectableLevel item3 in new List<SelectableLevel>(list3))
			{
				if (item3.levelID > 8)
				{
					list3.Remove(item3);
				}
			}
			OriginalContent.SelectableLevels = list;
			OriginalContent.MoonsCatalogue = list2;
			PatchVanillaLevelLists();
		}

		internal static void PatchVanillaLevelLists()
		{
			StartOfRound.Instance.levels = PatchedContent.SeletectableLevels.ToArray();
			TerminalManager.Terminal.moonsCatalogueList = PatchedContent.MoonsCatalogue.ToArray();
		}

		internal static void RefreshCustomExtendedLevelIDs()
		{
			foreach (ExtendedLevel item in new List<ExtendedLevel>(PatchedContent.CustomExtendedLevels))
			{
				if (!item.isLethalExpansion)
				{
					item.SetLevelID();
				}
			}
		}

		internal static void RefreshLethalExpansionMoons()
		{
			foreach (ExtendedLevel customExtendedLevel in PatchedContent.CustomExtendedLevels)
			{
				if (!customExtendedLevel.isLethalExpansion)
				{
					continue;
				}
				CompatibleNoun[] compatibleNouns = TerminalManager.routeKeyword.compatibleNouns;
				foreach (CompatibleNoun val in compatibleNouns)
				{
					if (((Object)val.noun).name.ToLower().Contains(customExtendedLevel.NumberlessPlanetName.ToLower()))
					{
						customExtendedLevel.routeNode = val.result;
						customExtendedLevel.routeConfirmNode = val.result.terminalOptions[1].result;
						customExtendedLevel.RoutePrice = customExtendedLevel.routeNode.itemCost;
						break;
					}
				}
			}
			RefreshCustomExtendedLevelIDs();
		}

		public static bool TryGetExtendedLevel(SelectableLevel selectableLevel, out ExtendedLevel returnExtendedLevel, ContentType levelType = ContentType.Any)
		{
			returnExtendedLevel = null;
			List<ExtendedLevel> list = null;
			if ((Object)(object)selectableLevel == (Object)null)
			{
				return false;
			}
			switch (levelType)
			{
			case ContentType.Any:
				list = PatchedContent

plugins/LethalLib.dll

Decompiled 9 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DunGen;
using DunGen.Graph;
using LethalLib.Extras;
using LethalLib.Modules;
using LethalLib.NetcodePatcher;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using On;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Audio;

[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("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("Evaisa")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Content-addition API for Lethal Company")]
[assembly: AssemblyFileVersion("0.14.2.0")]
[assembly: AssemblyInformationalVersion("0.14.2+553a3b4022b798db3343e7463a3d6d5d90b37d0e")]
[assembly: AssemblyProduct("LethalLib")]
[assembly: AssemblyTitle("LethalLib")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/EvaisaDev/LethalLib")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.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 LethalLib
{
	[BepInPlugin("evaisa.lethallib", "LethalLib", "0.14.2")]
	public class Plugin : BaseUnityPlugin
	{
		public const string ModGUID = "evaisa.lethallib";

		public const string ModName = "LethalLib";

		public const string ModVersion = "0.14.2";

		public static AssetBundle MainAssets;

		public static ManualLogSource logger;

		public static ConfigFile config;

		public static Plugin Instance;

		public static ConfigEntry<bool> extendedLogging;

		private void Awake()
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			config = ((BaseUnityPlugin)this).Config;
			logger = ((BaseUnityPlugin)this).Logger;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"LethalLib loaded!!");
			extendedLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ExtendedLogging", false, "Enable extended logging");
			MainAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "lethallib"));
			new ILHook((MethodBase)typeof(StackTrace).GetMethod("AddFrames", BindingFlags.Instance | BindingFlags.NonPublic), new Manipulator(IlHook));
			Enemies.Init();
			Items.Init();
			Unlockables.Init();
			MapObjects.Init();
			Dungeon.Init();
			Weathers.Init();
			Player.Init();
			Utilities.Init();
			NetworkPrefabs.Init();
		}

		private void IlHook(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, (MethodBase)typeof(StackFrame).GetMethod("GetFileLineNumber", BindingFlags.Instance | BindingFlags.Public))
			});
			val.RemoveRange(2);
			val.EmitDelegate<Func<StackFrame, string>>((Func<StackFrame, string>)GetLineOrIL);
		}

		private static string GetLineOrIL(StackFrame instance)
		{
			int fileLineNumber = instance.GetFileLineNumber();
			if (fileLineNumber == -1 || fileLineNumber == 0)
			{
				return "IL_" + instance.GetILOffset().ToString("X4");
			}
			return fileLineNumber.ToString();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LethalLib";

		public const string PLUGIN_NAME = "LethalLib";

		public const string PLUGIN_VERSION = "0.14.2";
	}
}
namespace LethalLib.Modules
{
	public class ContentLoader
	{
		public class CustomContent
		{
			private string id = "";

			public string ID => id;

			public CustomContent(string id)
			{
				this.id = id;
			}
		}

		public class CustomItem : CustomContent
		{
			public Action<Item> registryCallback = delegate
			{
			};

			public string contentPath = "";

			internal Item item;

			public Item Item => item;

			public CustomItem(string id, string contentPath, Action<Item> registryCallback = null)
				: base(id)
			{
				this.contentPath = contentPath;
				if (registryCallback != null)
				{
					this.registryCallback = registryCallback;
				}
			}
		}

		public class ShopItem : CustomItem
		{
			public int initPrice;

			public string buyNode1Path;

			public string buyNode2Path;

			public string itemInfoPath;

			public void RemoveFromShop()
			{
				Items.RemoveShopItem(base.Item);
			}

			public void SetPrice(int price)
			{
				Items.UpdateShopItemPrice(base.Item, price);
			}

			public ShopItem(string id, string contentPath, int price = 0, string buyNode1Path = null, string buyNode2Path = null, string itemInfoPath = null, Action<Item> registryCallback = null)
				: base(id, contentPath, registryCallback)
			{
				initPrice = price;
				this.buyNode1Path = buyNode1Path;
				this.buyNode2Path = buyNode2Path;
				this.itemInfoPath = itemInfoPath;
			}
		}

		public class ScrapItem : CustomItem
		{
			public Dictionary<Levels.LevelTypes, int> levelRarities = new Dictionary<Levels.LevelTypes, int>();

			public Dictionary<string, int> customLevelRarities = new Dictionary<string, int>();

			public int Rarity => 0;

			public void RemoveFromLevels(Levels.LevelTypes levelFlags)
			{
				Items.RemoveScrapFromLevels(base.Item, levelFlags);
			}

			public ScrapItem(string id, string contentPath, int rarity, Levels.LevelTypes levelFlags = Levels.LevelTypes.None, string[] levelOverrides = null, Action<Item> registryCallback = null)
				: base(id, contentPath, registryCallback)
			{
				if (levelFlags != Levels.LevelTypes.None)
				{
					levelRarities.Add(levelFlags, rarity);
				}
				else if (levelOverrides != null)
				{
					foreach (string key in levelOverrides)
					{
						customLevelRarities.Add(key, rarity);
					}
				}
			}

			public ScrapItem(string id, string contentPath, Dictionary<Levels.LevelTypes, int>? levelRarities = null, Dictionary<string, int>? customLevelRarities = null, Action<Item> registryCallback = null)
				: base(id, contentPath, registryCallback)
			{
				if (levelRarities != null)
				{
					this.levelRarities = levelRarities;
				}
				if (customLevelRarities != null)
				{
					this.customLevelRarities = customLevelRarities;
				}
			}
		}

		public class Unlockable : CustomContent
		{
			public Action<UnlockableItem> registryCallback = delegate
			{
			};

			internal UnlockableItem unlockable;

			public string contentPath = "";

			public int initPrice;

			public string buyNode1Path;

			public string buyNode2Path;

			public string itemInfoPath;

			public StoreType storeType;

			public UnlockableItem UnlockableItem => unlockable;

			public void RemoveFromShop()
			{
				Unlockables.DisableUnlockable(UnlockableItem);
			}

			public void SetPrice(int price)
			{
				Unlockables.UpdateUnlockablePrice(UnlockableItem, price);
			}

			public Unlockable(string id, string contentPath, int price = 0, string buyNode1Path = null, string buyNode2Path = null, string itemInfoPath = null, StoreType storeType = StoreType.None, Action<UnlockableItem> registryCallback = null)
				: base(id)
			{
				this.contentPath = contentPath;
				if (registryCallback != null)
				{
					this.registryCallback = registryCallback;
				}
				initPrice = price;
				this.buyNode1Path = buyNode1Path;
				this.buyNode2Path = buyNode2Path;
				this.itemInfoPath = itemInfoPath;
				this.storeType = storeType;
			}
		}

		public class CustomEnemy : CustomContent
		{
			public Action<EnemyType> registryCallback = delegate
			{
			};

			public string contentPath = "";

			internal EnemyType enemy;

			public string infoNodePath;

			public string infoKeywordPath;

			public int rarity;

			public Levels.LevelTypes LevelTypes = Levels.LevelTypes.None;

			public string[] levelOverrides;

			public Enemies.SpawnType spawnType = (Enemies.SpawnType)(-1);

			public EnemyType Enemy => enemy;

			public void RemoveFromLevels(Levels.LevelTypes levelFlags)
			{
				Enemies.RemoveEnemyFromLevels(Enemy, levelFlags);
			}

			public CustomEnemy(string id, string contentPath, int rarity = 0, Levels.LevelTypes levelFlags = Levels.LevelTypes.None, Enemies.SpawnType spawnType = (Enemies.SpawnType)(-1), string[] levelOverrides = null, string infoNodePath = null, string infoKeywordPath = null, Action<EnemyType> registryCallback = null)
				: base(id)
			{
				this.contentPath = contentPath;
				if (registryCallback != null)
				{
					this.registryCallback = registryCallback;
				}
				this.infoNodePath = infoNodePath;
				this.infoKeywordPath = infoKeywordPath;
				this.rarity = rarity;
				LevelTypes = levelFlags;
				this.levelOverrides = levelOverrides;
				this.spawnType = spawnType;
			}
		}

		public class MapHazard : CustomContent
		{
			public Action<SpawnableMapObjectDef> registryCallback = delegate
			{
			};

			public string contentPath = "";

			internal SpawnableMapObjectDef hazard;

			public Func<SelectableLevel, AnimationCurve> spawnRateFunction;

			public Levels.LevelTypes LevelTypes = Levels.LevelTypes.None;

			public string[] levelOverrides;

			public SpawnableMapObjectDef Hazard => hazard;

			public void RemoveFromLevels(Levels.LevelTypes levelFlags = Levels.LevelTypes.None, string[] levelOverrides = null)
			{
				MapObjects.RemoveMapObject(Hazard, levelFlags, levelOverrides);
			}

			public MapHazard(string id, string contentPath, Levels.LevelTypes levelFlags = Levels.LevelTypes.None, string[] levelOverrides = null, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null, Action<SpawnableMapObjectDef> registryCallback = null)
				: base(id)
			{
				this.contentPath = contentPath;
				if (registryCallback != null)
				{
					this.registryCallback = registryCallback;
				}
				LevelTypes = levelFlags;
				this.levelOverrides = levelOverrides;
				this.spawnRateFunction = spawnRateFunction;
			}
		}

		public class OutsideObject : CustomContent
		{
			public Action<SpawnableOutsideObjectDef> registryCallback = delegate
			{
			};

			public string contentPath = "";

			internal SpawnableOutsideObjectDef mapObject;

			public Func<SelectableLevel, AnimationCurve> spawnRateFunction;

			public Levels.LevelTypes LevelTypes = Levels.LevelTypes.None;

			public string[] levelOverrides;

			public SpawnableOutsideObjectDef MapObject => mapObject;

			public void RemoveFromLevels(Levels.LevelTypes levelFlags = Levels.LevelTypes.None, string[] levelOverrides = null)
			{
				MapObjects.RemoveOutsideObject(MapObject, levelFlags, levelOverrides);
			}

			public OutsideObject(string id, string contentPath, Levels.LevelTypes levelFlags = Levels.LevelTypes.None, string[] levelOverrides = null, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null, Action<SpawnableOutsideObjectDef> registryCallback = null)
				: base(id)
			{
				this.contentPath = contentPath;
				if (registryCallback != null)
				{
					this.registryCallback = registryCallback;
				}
				LevelTypes = levelFlags;
				this.levelOverrides = levelOverrides;
				this.spawnRateFunction = spawnRateFunction;
			}
		}

		public PluginInfo modInfo;

		private AssetBundle modBundle;

		public Action<CustomContent, GameObject> prefabCallback = delegate
		{
		};

		public Dictionary<string, CustomContent> LoadedContent { get; } = new Dictionary<string, CustomContent>();


		public string modName => modInfo.Metadata.Name;

		public string modVersion => modInfo.Metadata.Version.ToString();

		public string modGUID => modInfo.Metadata.GUID;

		public ContentLoader(PluginInfo modInfo, AssetBundle modBundle, Action<CustomContent, GameObject> prefabCallback = null)
		{
			this.modInfo = modInfo;
			this.modBundle = modBundle;
			if (prefabCallback != null)
			{
				this.prefabCallback = prefabCallback;
			}
		}

		public ContentLoader Create(PluginInfo modInfo, AssetBundle modBundle, Action<CustomContent, GameObject> prefabCallback = null)
		{
			return new ContentLoader(modInfo, modBundle, prefabCallback);
		}

		public void Register(CustomContent content)
		{
			if (LoadedContent.ContainsKey(content.ID))
			{
				Debug.LogError((object)("[LethalLib] " + modName + " tried to register content with ID " + content.ID + " but it already exists!"));
				return;
			}
			if (content is CustomItem customItem)
			{
				Item val = (customItem.item = modBundle.LoadAsset<Item>(customItem.contentPath));
				NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
				Utilities.FixMixerGroups(val.spawnPrefab);
				prefabCallback(customItem, val.spawnPrefab);
				customItem.registryCallback(val);
				if (content is ShopItem shopItem)
				{
					TerminalNode buyNode = null;
					TerminalNode buyNode2 = null;
					TerminalNode itemInfo = null;
					if (shopItem.buyNode1Path != null)
					{
						buyNode = modBundle.LoadAsset<TerminalNode>(shopItem.buyNode1Path);
					}
					if (shopItem.buyNode2Path != null)
					{
						buyNode2 = modBundle.LoadAsset<TerminalNode>(shopItem.buyNode2Path);
					}
					if (shopItem.itemInfoPath != null)
					{
						itemInfo = modBundle.LoadAsset<TerminalNode>(shopItem.itemInfoPath);
					}
					Items.RegisterShopItem(val, buyNode, buyNode2, itemInfo, shopItem.initPrice);
				}
				else if (content is ScrapItem scrapItem)
				{
					Items.RegisterScrap(val, scrapItem.levelRarities, scrapItem.customLevelRarities);
				}
				else
				{
					Items.RegisterItem(val);
				}
			}
			else if (content is Unlockable unlockable)
			{
				UnlockableItemDef unlockableItemDef = modBundle.LoadAsset<UnlockableItemDef>(unlockable.contentPath);
				if ((Object)(object)unlockableItemDef.unlockable.prefabObject != (Object)null)
				{
					NetworkPrefabs.RegisterNetworkPrefab(unlockableItemDef.unlockable.prefabObject);
					prefabCallback(content, unlockableItemDef.unlockable.prefabObject);
					Utilities.FixMixerGroups(unlockableItemDef.unlockable.prefabObject);
				}
				unlockable.unlockable = unlockableItemDef.unlockable;
				unlockable.registryCallback(unlockableItemDef.unlockable);
				TerminalNode buyNode3 = null;
				TerminalNode buyNode4 = null;
				TerminalNode itemInfo2 = null;
				if (unlockable.buyNode1Path != null)
				{
					buyNode3 = modBundle.LoadAsset<TerminalNode>(unlockable.buyNode1Path);
				}
				if (unlockable.buyNode2Path != null)
				{
					buyNode4 = modBundle.LoadAsset<TerminalNode>(unlockable.buyNode2Path);
				}
				if (unlockable.itemInfoPath != null)
				{
					itemInfo2 = modBundle.LoadAsset<TerminalNode>(unlockable.itemInfoPath);
				}
				Unlockables.RegisterUnlockable(unlockableItemDef, unlockable.storeType, buyNode3, buyNode4, itemInfo2, unlockable.initPrice);
			}
			else if (content is CustomEnemy customEnemy)
			{
				EnemyType val2 = modBundle.LoadAsset<EnemyType>(customEnemy.contentPath);
				NetworkPrefabs.RegisterNetworkPrefab(val2.enemyPrefab);
				Utilities.FixMixerGroups(val2.enemyPrefab);
				customEnemy.enemy = val2;
				prefabCallback(content, val2.enemyPrefab);
				customEnemy.registryCallback(val2);
				TerminalNode infoNode = null;
				TerminalKeyword infoKeyword = null;
				if (customEnemy.infoNodePath != null)
				{
					infoNode = modBundle.LoadAsset<TerminalNode>(customEnemy.infoNodePath);
				}
				if (customEnemy.infoKeywordPath != null)
				{
					infoKeyword = modBundle.LoadAsset<TerminalKeyword>(customEnemy.infoKeywordPath);
				}
				if (customEnemy.spawnType == (Enemies.SpawnType)(-1))
				{
					Enemies.RegisterEnemy(val2, customEnemy.rarity, customEnemy.LevelTypes, customEnemy.levelOverrides, infoNode, infoKeyword);
				}
				else
				{
					Enemies.RegisterEnemy(val2, customEnemy.rarity, customEnemy.LevelTypes, customEnemy.spawnType, customEnemy.levelOverrides, infoNode, infoKeyword);
				}
			}
			else if (content is MapHazard mapHazard)
			{
				SpawnableMapObjectDef spawnableMapObjectDef = (mapHazard.hazard = modBundle.LoadAsset<SpawnableMapObjectDef>(mapHazard.contentPath));
				NetworkPrefabs.RegisterNetworkPrefab(spawnableMapObjectDef.spawnableMapObject.prefabToSpawn);
				Utilities.FixMixerGroups(spawnableMapObjectDef.spawnableMapObject.prefabToSpawn);
				prefabCallback(content, spawnableMapObjectDef.spawnableMapObject.prefabToSpawn);
				mapHazard.registryCallback(spawnableMapObjectDef);
				MapObjects.RegisterMapObject(spawnableMapObjectDef, mapHazard.LevelTypes, mapHazard.levelOverrides, mapHazard.spawnRateFunction);
			}
			else if (content is OutsideObject outsideObject)
			{
				SpawnableOutsideObjectDef spawnableOutsideObjectDef = (outsideObject.mapObject = modBundle.LoadAsset<SpawnableOutsideObjectDef>(outsideObject.contentPath));
				NetworkPrefabs.RegisterNetworkPrefab(spawnableOutsideObjectDef.spawnableMapObject.spawnableObject.prefabToSpawn);
				Utilities.FixMixerGroups(spawnableOutsideObjectDef.spawnableMapObject.spawnableObject.prefabToSpawn);
				prefabCallback(content, spawnableOutsideObjectDef.spawnableMapObject.spawnableObject.prefabToSpawn);
				outsideObject.registryCallback(spawnableOutsideObjectDef);
				MapObjects.RegisterOutsideObject(spawnableOutsideObjectDef, outsideObject.LevelTypes, outsideObject.levelOverrides, outsideObject.spawnRateFunction);
			}
			LoadedContent.Add(content.ID, content);
		}

		public void RegisterAll(CustomContent[] content)
		{
			Plugin.logger.LogInfo((object)$"[LethalLib] {modName} is registering {content.Length} content items!");
			foreach (CustomContent content2 in content)
			{
				Register(content2);
			}
		}

		public void RegisterAll(List<CustomContent> content)
		{
			Plugin.logger.LogInfo((object)$"[LethalLib] {modName} is registering {content.Count} content items!");
			foreach (CustomContent item in content)
			{
				Register(item);
			}
		}
	}
	public class Dungeon
	{
		public class CustomDungeonArchetype
		{
			public DungeonArchetype archeType;

			public Levels.LevelTypes LevelTypes;

			public int lineIndex = -1;
		}

		public class CustomGraphLine
		{
			public GraphLine graphLine;

			public Levels.LevelTypes LevelTypes;
		}

		public class CustomDungeon
		{
			public int rarity;

			public DungeonFlow dungeonFlow;

			public Levels.LevelTypes LevelTypes;

			public string[] levelOverrides;

			public int dungeonIndex = -1;

			public AudioClip firstTimeDungeonAudio;
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static hook_GenerateNewFloor <0>__RoundManager_GenerateNewFloor;

			public static hook_Start <1>__RoundManager_Start;
		}

		public static List<CustomDungeonArchetype> customDungeonArchetypes = new List<CustomDungeonArchetype>();

		public static List<CustomGraphLine> customGraphLines = new List<CustomGraphLine>();

		public static Dictionary<string, TileSet> extraTileSets = new Dictionary<string, TileSet>();

		public static Dictionary<string, GameObjectChance> extraRooms = new Dictionary<string, GameObjectChance>();

		public static List<CustomDungeon> customDungeons = new List<CustomDungeon>();

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			object obj = <>O.<0>__RoundManager_GenerateNewFloor;
			if (obj == null)
			{
				hook_GenerateNewFloor val = RoundManager_GenerateNewFloor;
				<>O.<0>__RoundManager_GenerateNewFloor = val;
				obj = (object)val;
			}
			RoundManager.GenerateNewFloor += (hook_GenerateNewFloor)obj;
			object obj2 = <>O.<1>__RoundManager_Start;
			if (obj2 == null)
			{
				hook_Start val2 = RoundManager_Start;
				<>O.<1>__RoundManager_Start = val2;
				obj2 = (object)val2;
			}
			RoundManager.Start += (hook_Start)obj2;
		}

		private static void RoundManager_Start(orig_Start orig, RoundManager self)
		{
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Expected O, but got Unknown
			foreach (CustomDungeon customDungeon in customDungeons)
			{
				if (self.dungeonFlowTypes.Contains(customDungeon.dungeonFlow))
				{
					continue;
				}
				List<DungeonFlow> list = self.dungeonFlowTypes.ToList();
				list.Add(customDungeon.dungeonFlow);
				self.dungeonFlowTypes = list.ToArray();
				int dungeonIndex = self.dungeonFlowTypes.Length - 1;
				customDungeon.dungeonIndex = dungeonIndex;
				List<AudioClip> list2 = self.firstTimeDungeonAudios.ToList();
				if (list2.Count != self.dungeonFlowTypes.Length - 1)
				{
					while (list2.Count < self.dungeonFlowTypes.Length - 1)
					{
						list2.Add(null);
					}
				}
				list2.Add(customDungeon.firstTimeDungeonAudio);
				self.firstTimeDungeonAudios = list2.ToArray();
			}
			StartOfRound instance = StartOfRound.Instance;
			foreach (CustomDungeon dungeon in customDungeons)
			{
				SelectableLevel[] levels = instance.levels;
				foreach (SelectableLevel val in levels)
				{
					string name = ((Object)val).name;
					bool flag = dungeon.LevelTypes.HasFlag(Levels.LevelTypes.All) || (dungeon.levelOverrides != null && dungeon.levelOverrides.Any((string item) => item.ToLowerInvariant() == name.ToLowerInvariant()));
					if (dungeon.LevelTypes.HasFlag(Levels.LevelTypes.Modded) && !Enum.IsDefined(typeof(Levels.LevelTypes), name))
					{
						flag = true;
					}
					if (Enum.IsDefined(typeof(Levels.LevelTypes), name) || flag)
					{
						Levels.LevelTypes levelTypes = (flag ? Levels.LevelTypes.All : ((Levels.LevelTypes)Enum.Parse(typeof(Levels.LevelTypes), name)));
						if ((flag || dungeon.LevelTypes.HasFlag(levelTypes)) && !val.dungeonFlowTypes.Any((IntWithRarity rarityInt) => rarityInt.id == dungeon.dungeonIndex))
						{
							List<IntWithRarity> list3 = val.dungeonFlowTypes.ToList();
							list3.Add(new IntWithRarity
							{
								id = dungeon.dungeonIndex,
								rarity = dungeon.rarity
							});
							val.dungeonFlowTypes = list3.ToArray();
						}
					}
				}
			}
			orig.Invoke(self);
		}

		private static void RoundManager_GenerateNewFloor(orig_GenerateNewFloor orig, RoundManager self)
		{
			string name = ((Object)self.currentLevel).name;
			if (Enum.IsDefined(typeof(Levels.LevelTypes), name))
			{
				Levels.LevelTypes levelEnum = (Levels.LevelTypes)Enum.Parse(typeof(Levels.LevelTypes), name);
				int index = 0;
				self.dungeonGenerator.Generator.DungeonFlow.Lines.ForEach(delegate(GraphLine line)
				{
					foreach (CustomDungeonArchetype customDungeonArchetype in customDungeonArchetypes)
					{
						if (customDungeonArchetype.LevelTypes.HasFlag(levelEnum) && !line.DungeonArchetypes.Contains(customDungeonArchetype.archeType) && (customDungeonArchetype.lineIndex == -1 || customDungeonArchetype.lineIndex == index))
						{
							line.DungeonArchetypes.Add(customDungeonArchetype.archeType);
							if (Plugin.extendedLogging.Value)
							{
								Plugin.logger.LogInfo((object)("Added " + ((Object)customDungeonArchetype.archeType).name + " to " + name));
							}
						}
					}
					foreach (DungeonArchetype dungeonArchetype in line.DungeonArchetypes)
					{
						string name2 = ((Object)dungeonArchetype).name;
						if (extraTileSets.ContainsKey(name2))
						{
							TileSet val4 = extraTileSets[name2];
							if (!dungeonArchetype.TileSets.Contains(val4))
							{
								dungeonArchetype.TileSets.Add(val4);
								if (Plugin.extendedLogging.Value)
								{
									Plugin.logger.LogInfo((object)("Added " + ((Object)val4).name + " to " + name));
								}
							}
						}
						foreach (TileSet tileSet in dungeonArchetype.TileSets)
						{
							string name3 = ((Object)tileSet).name;
							if (extraRooms.ContainsKey(name3))
							{
								GameObjectChance item = extraRooms[name3];
								if (!tileSet.TileWeights.Weights.Contains(item))
								{
									tileSet.TileWeights.Weights.Add(item);
								}
							}
						}
					}
					index++;
				});
				foreach (CustomGraphLine customGraphLine in customGraphLines)
				{
					if (customGraphLine.LevelTypes.HasFlag(levelEnum) && !self.dungeonGenerator.Generator.DungeonFlow.Lines.Contains(customGraphLine.graphLine))
					{
						self.dungeonGenerator.Generator.DungeonFlow.Lines.Add(customGraphLine.graphLine);
					}
				}
			}
			orig.Invoke(self);
			NetworkManager val = Object.FindObjectOfType<NetworkManager>();
			RandomMapObject[] array = Object.FindObjectsOfType<RandomMapObject>();
			foreach (RandomMapObject val2 in array)
			{
				for (int j = 0; j < val2.spawnablePrefabs.Count; j++)
				{
					string prefabName = ((Object)val2.spawnablePrefabs[j]).name;
					NetworkPrefab val3 = ((IEnumerable<NetworkPrefab>)val.NetworkConfig.Prefabs.m_Prefabs).FirstOrDefault((Func<NetworkPrefab, bool>)((NetworkPrefab x) => ((Object)x.Prefab).name == prefabName));
					if (val3 != null && (Object)(object)val3.Prefab != (Object)(object)val2.spawnablePrefabs[j])
					{
						val2.spawnablePrefabs[j] = val3.Prefab;
					}
					else if (val3 == null)
					{
						Plugin.logger.LogError((object)("DungeonGeneration - Could not find network prefab (" + prefabName + ")! Make sure your assigned prefab is registered with the network manager, or named identically to the vanilla prefab you are referencing."));
					}
				}
			}
		}

		public static void AddArchetype(DungeonArchetype archetype, Levels.LevelTypes levelFlags, int lineIndex = -1)
		{
			CustomDungeonArchetype customDungeonArchetype = new CustomDungeonArchetype();
			customDungeonArchetype.archeType = archetype;
			customDungeonArchetype.LevelTypes = levelFlags;
			customDungeonArchetype.lineIndex = lineIndex;
			customDungeonArchetypes.Add(customDungeonArchetype);
		}

		public static void AddLine(GraphLine line, Levels.LevelTypes levelFlags)
		{
			CustomGraphLine customGraphLine = new CustomGraphLine();
			customGraphLine.graphLine = line;
			customGraphLine.LevelTypes = levelFlags;
			customGraphLines.Add(customGraphLine);
		}

		public static void AddLine(DungeonGraphLineDef line, Levels.LevelTypes levelFlags)
		{
			AddLine(line.graphLine, levelFlags);
		}

		public static void AddTileSet(TileSet set, string archetypeName)
		{
			extraTileSets.Add(archetypeName, set);
		}

		public static void AddRoom(GameObjectChance room, string tileSetName)
		{
			extraRooms.Add(tileSetName, room);
		}

		public static void AddRoom(GameObjectChanceDef room, string tileSetName)
		{
			AddRoom(room.gameObjectChance, tileSetName);
		}

		public static void AddDungeon(DungeonDef dungeon, Levels.LevelTypes levelFlags)
		{
			AddDungeon(dungeon.dungeonFlow, dungeon.rarity, levelFlags, dungeon.firstTimeDungeonAudio);
		}

		public static void AddDungeon(DungeonDef dungeon, Levels.LevelTypes levelFlags, string[] levelOverrides)
		{
			AddDungeon(dungeon.dungeonFlow, dungeon.rarity, levelFlags, levelOverrides, dungeon.firstTimeDungeonAudio);
		}

		public static void AddDungeon(DungeonFlow dungeon, int rarity, Levels.LevelTypes levelFlags, AudioClip firstTimeDungeonAudio = null)
		{
			customDungeons.Add(new CustomDungeon
			{
				dungeonFlow = dungeon,
				rarity = rarity,
				LevelTypes = levelFlags,
				firstTimeDungeonAudio = firstTimeDungeonAudio
			});
		}

		public static void AddDungeon(DungeonFlow dungeon, int rarity, Levels.LevelTypes levelFlags, string[] levelOverrides = null, AudioClip firstTimeDungeonAudio = null)
		{
			customDungeons.Add(new CustomDungeon
			{
				dungeonFlow = dungeon,
				rarity = rarity,
				LevelTypes = levelFlags,
				firstTimeDungeonAudio = firstTimeDungeonAudio,
				levelOverrides = levelOverrides
			});
		}
	}
	public class Enemies
	{
		public struct EnemyAssetInfo
		{
			public EnemyType EnemyAsset;

			public TerminalKeyword keyword;
		}

		public enum SpawnType
		{
			Default,
			Daytime,
			Outside
		}

		public class SpawnableEnemy
		{
			public EnemyType enemy;

			public SpawnType spawnType;

			public TerminalNode terminalNode;

			public TerminalKeyword infoKeyword;

			public string modName;

			public int rarity;

			public Levels.LevelTypes spawnLevels;

			public string[] spawnLevelOverrides;

			public Dictionary<string, int> customLevelRarities = new Dictionary<string, int>();

			public Dictionary<Levels.LevelTypes, int> levelRarities = new Dictionary<Levels.LevelTypes, int>();

			public SpawnableEnemy(EnemyType enemy, int rarity, Levels.LevelTypes spawnLevels, SpawnType spawnType, string[] spawnLevelOverrides = null)
			{
				this.enemy = enemy;
				this.spawnLevels = spawnLevels;
				this.spawnType = spawnType;
				if (spawnLevelOverrides != null)
				{
					foreach (string key in spawnLevelOverrides)
					{
						customLevelRarities.Add(key, rarity);
					}
				}
				if (spawnLevels == Levels.LevelTypes.None)
				{
					return;
				}
				foreach (Levels.LevelTypes value in Enum.GetValues(typeof(Levels.LevelTypes)))
				{
					if (spawnLevels.HasFlag(value))
					{
						levelRarities.Add(value, rarity);
					}
				}
			}

			public SpawnableEnemy(EnemyType enemy, SpawnType spawnType, Dictionary<Levels.LevelTypes, int>? levelRarities = null, Dictionary<string, int>? customLevelRarities = null)
			{
				this.enemy = enemy;
				this.spawnType = spawnType;
				if (levelRarities != null)
				{
					this.levelRarities = levelRarities;
				}
				if (customLevelRarities != null)
				{
					this.customLevelRarities = customLevelRarities;
				}
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Awake <0>__RegisterLevelEnemies;

			public static hook_Start <1>__Terminal_Start;

			public static hook_Start <2>__QuickMenuManager_Start;
		}

		private static bool addedToDebug = false;

		public static Terminal terminal;

		public static List<EnemyAssetInfo> enemyAssetInfos = new List<EnemyAssetInfo>();

		public static List<SpawnableEnemy> spawnableEnemies = new List<SpawnableEnemy>();

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			object obj = <>O.<0>__RegisterLevelEnemies;
			if (obj == null)
			{
				hook_Awake val = RegisterLevelEnemies;
				<>O.<0>__RegisterLevelEnemies = val;
				obj = (object)val;
			}
			StartOfRound.Awake += (hook_Awake)obj;
			object obj2 = <>O.<1>__Terminal_Start;
			if (obj2 == null)
			{
				hook_Start val2 = Terminal_Start;
				<>O.<1>__Terminal_Start = val2;
				obj2 = (object)val2;
			}
			Terminal.Start += (hook_Start)obj2;
			object obj3 = <>O.<2>__QuickMenuManager_Start;
			if (obj3 == null)
			{
				hook_Start val3 = QuickMenuManager_Start;
				<>O.<2>__QuickMenuManager_Start = val3;
				obj3 = (object)val3;
			}
			QuickMenuManager.Start += (hook_Start)obj3;
		}

		private static void QuickMenuManager_Start(orig_Start orig, QuickMenuManager self)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_0091: Expected O, but got Unknown
			if (addedToDebug)
			{
				orig.Invoke(self);
				return;
			}
			SelectableLevel testAllEnemiesLevel = self.testAllEnemiesLevel;
			List<SpawnableEnemyWithRarity> enemies = testAllEnemiesLevel.Enemies;
			List<SpawnableEnemyWithRarity> daytimeEnemies = testAllEnemiesLevel.DaytimeEnemies;
			List<SpawnableEnemyWithRarity> outsideEnemies = testAllEnemiesLevel.OutsideEnemies;
			foreach (SpawnableEnemy spawnableEnemy in spawnableEnemies)
			{
				if (enemies.All((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)spawnableEnemy.enemy))
				{
					continue;
				}
				SpawnableEnemyWithRarity item = new SpawnableEnemyWithRarity
				{
					enemyType = spawnableEnemy.enemy,
					rarity = spawnableEnemy.rarity
				};
				switch (spawnableEnemy.spawnType)
				{
				case SpawnType.Default:
					if (!enemies.Any((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)spawnableEnemy.enemy))
					{
						enemies.Add(item);
					}
					break;
				case SpawnType.Daytime:
					if (!daytimeEnemies.Any((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)spawnableEnemy.enemy))
					{
						daytimeEnemies.Add(item);
					}
					break;
				case SpawnType.Outside:
					if (!outsideEnemies.Any((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)spawnableEnemy.enemy))
					{
						outsideEnemies.Add(item);
					}
					break;
				}
				if (Plugin.extendedLogging.Value)
				{
					Plugin.logger.LogInfo((object)$"Added {spawnableEnemy.enemy.enemyName} to DebugList [{spawnableEnemy.spawnType}]");
				}
			}
			addedToDebug = true;
			orig.Invoke(self);
		}

		private static void Terminal_Start(orig_Start orig, Terminal self)
		{
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Expected O, but got Unknown
			terminal = self;
			TerminalKeyword val = self.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "info");
			List<string> list = new List<string>();
			foreach (SpawnableEnemy spawnableEnemy in spawnableEnemies)
			{
				if (list.Contains(spawnableEnemy.enemy.enemyName))
				{
					Plugin.logger.LogInfo((object)("Skipping " + spawnableEnemy.enemy.enemyName + " because it was already added"));
					continue;
				}
				if ((Object)(object)spawnableEnemy.terminalNode == (Object)null)
				{
					spawnableEnemy.terminalNode = ScriptableObject.CreateInstance<TerminalNode>();
					spawnableEnemy.terminalNode.displayText = spawnableEnemy.enemy.enemyName + "\n\nDanger level: Unknown\n\n[No information about this creature was found.]\n\n";
					spawnableEnemy.terminalNode.clearPreviousText = true;
					spawnableEnemy.terminalNode.maxCharactersToType = 35;
					spawnableEnemy.terminalNode.creatureName = spawnableEnemy.enemy.enemyName;
				}
				if (self.enemyFiles.Any((TerminalNode x) => x.creatureName == spawnableEnemy.terminalNode.creatureName))
				{
					Plugin.logger.LogInfo((object)("Skipping " + spawnableEnemy.enemy.enemyName + " because it was already added"));
					continue;
				}
				TerminalKeyword keyword2 = (((Object)(object)spawnableEnemy.infoKeyword != (Object)null) ? spawnableEnemy.infoKeyword : TerminalUtils.CreateTerminalKeyword(spawnableEnemy.terminalNode.creatureName.ToLowerInvariant().Replace(" ", "-"), isVerb: false, null, null, val));
				keyword2.defaultVerb = val;
				List<TerminalKeyword> list2 = self.terminalNodes.allKeywords.ToList();
				if (!list2.Any((TerminalKeyword x) => x.word == keyword2.word))
				{
					list2.Add(keyword2);
					self.terminalNodes.allKeywords = list2.ToArray();
				}
				List<CompatibleNoun> list3 = val.compatibleNouns.ToList();
				if (!list3.Any((CompatibleNoun x) => x.noun.word == keyword2.word))
				{
					list3.Add(new CompatibleNoun
					{
						noun = keyword2,
						result = spawnableEnemy.terminalNode
					});
				}
				val.compatibleNouns = list3.ToArray();
				spawnableEnemy.terminalNode.creatureFileID = self.enemyFiles.Count;
				self.enemyFiles.Add(spawnableEnemy.terminalNode);
				spawnableEnemy.enemy.enemyPrefab.GetComponentInChildren<ScanNodeProperties>().creatureScanID = spawnableEnemy.terminalNode.creatureFileID;
				EnemyAssetInfo enemyAssetInfo = default(EnemyAssetInfo);
				enemyAssetInfo.EnemyAsset = spawnableEnemy.enemy;
				enemyAssetInfo.keyword = keyword2;
				EnemyAssetInfo item = enemyAssetInfo;
				enemyAssetInfos.Add(item);
			}
			orig.Invoke(self);
		}

		private static void RegisterLevelEnemies(orig_Awake orig, StartOfRound self)
		{
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Expected O, but got Unknown
			orig.Invoke(self);
			foreach (SpawnableEnemy spawnableEnemy in spawnableEnemies)
			{
				SelectableLevel[] levels = self.levels;
				foreach (SelectableLevel val in levels)
				{
					string name = ((Object)val).name;
					bool flag = spawnableEnemy.levelRarities.ContainsKey(Levels.LevelTypes.All) || (spawnableEnemy.customLevelRarities != null && spawnableEnemy.customLevelRarities.ContainsKey(name));
					if (spawnableEnemy.levelRarities.ContainsKey(Levels.LevelTypes.Modded) && !Enum.IsDefined(typeof(Levels.LevelTypes), name))
					{
						flag = true;
					}
					if (!(Enum.IsDefined(typeof(Levels.LevelTypes), name) || flag))
					{
						continue;
					}
					Levels.LevelTypes levelEnum = (flag ? Levels.LevelTypes.All : ((Levels.LevelTypes)Enum.Parse(typeof(Levels.LevelTypes), name)));
					if (!flag && !spawnableEnemy.spawnLevels.HasFlag(levelEnum))
					{
						continue;
					}
					int rarity = 0;
					if (spawnableEnemy.levelRarities.Keys.Any((Levels.LevelTypes key) => key.HasFlag(levelEnum)))
					{
						rarity = spawnableEnemy.levelRarities.First((KeyValuePair<Levels.LevelTypes, int> x) => x.Key.HasFlag(levelEnum)).Value;
					}
					else if (spawnableEnemy.customLevelRarities != null && spawnableEnemy.customLevelRarities.ContainsKey(name))
					{
						rarity = spawnableEnemy.customLevelRarities[name];
					}
					SpawnableEnemyWithRarity item = new SpawnableEnemyWithRarity
					{
						enemyType = spawnableEnemy.enemy,
						rarity = rarity
					};
					switch (spawnableEnemy.spawnType)
					{
					case SpawnType.Default:
						if (!val.Enemies.Any((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)spawnableEnemy.enemy))
						{
							val.Enemies.Add(item);
							if (Plugin.extendedLogging.Value)
							{
								Plugin.logger.LogInfo((object)("Added " + ((Object)spawnableEnemy.enemy).name + " to " + name + " with SpawnType [Default]"));
							}
						}
						break;
					case SpawnType.Daytime:
						if (!val.DaytimeEnemies.Any((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)spawnableEnemy.enemy))
						{
							val.DaytimeEnemies.Add(item);
							if (Plugin.extendedLogging.Value)
							{
								Plugin.logger.LogInfo((object)("Added " + ((Object)spawnableEnemy.enemy).name + " to " + name + " with SpawnType [Daytime]"));
							}
						}
						break;
					case SpawnType.Outside:
						if (!val.OutsideEnemies.Any((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)spawnableEnemy.enemy))
						{
							val.OutsideEnemies.Add(item);
							if (Plugin.extendedLogging.Value)
							{
								Plugin.logger.LogInfo((object)("Added " + ((Object)spawnableEnemy.enemy).name + " to " + name + " with SpawnType [Outside]"));
							}
						}
						break;
					}
				}
			}
		}

		public static void RegisterEnemy(EnemyType enemy, int rarity, Levels.LevelTypes levelFlags, SpawnType spawnType, TerminalNode infoNode = null, TerminalKeyword infoKeyword = null)
		{
			RegisterEnemy(enemy, rarity, levelFlags, spawnType, null, infoNode, infoKeyword);
		}

		public static void RegisterEnemy(EnemyType enemy, int rarity, Levels.LevelTypes levelFlags, SpawnType spawnType, string[] spawnLevelOverrides = null, TerminalNode infoNode = null, TerminalKeyword infoKeyword = null)
		{
			EnemyType enemy2 = enemy;
			SpawnableEnemy spawnableEnemy = spawnableEnemies.FirstOrDefault((SpawnableEnemy x) => (Object)(object)x.enemy == (Object)(object)enemy2 && x.spawnType == spawnType);
			if (spawnableEnemy != null)
			{
				if (levelFlags != Levels.LevelTypes.None)
				{
					spawnableEnemy.levelRarities.Add(levelFlags, rarity);
				}
				if (spawnLevelOverrides != null)
				{
					foreach (string key in spawnLevelOverrides)
					{
						spawnableEnemy.customLevelRarities.Add(key, rarity);
					}
				}
			}
			else
			{
				spawnableEnemy = new SpawnableEnemy(enemy2, rarity, levelFlags, spawnType, spawnLevelOverrides);
				spawnableEnemy.terminalNode = infoNode;
				spawnableEnemy.infoKeyword = infoKeyword;
				string name = Assembly.GetCallingAssembly().GetName().Name;
				spawnableEnemy.modName = name;
				spawnableEnemies.Add(spawnableEnemy);
			}
		}

		public static void RegisterEnemy(EnemyType enemy, SpawnType spawnType, Dictionary<Levels.LevelTypes, int>? levelRarities = null, Dictionary<string, int>? customLevelRarities = null, TerminalNode infoNode = null, TerminalKeyword infoKeyword = null)
		{
			EnemyType enemy2 = enemy;
			SpawnableEnemy spawnableEnemy = spawnableEnemies.FirstOrDefault((SpawnableEnemy x) => (Object)(object)x.enemy == (Object)(object)enemy2 && x.spawnType == spawnType);
			if (spawnableEnemy != null)
			{
				if (levelRarities != null)
				{
					foreach (KeyValuePair<Levels.LevelTypes, int> levelRarity in levelRarities)
					{
						spawnableEnemy.levelRarities.Add(levelRarity.Key, levelRarity.Value);
					}
				}
				if (customLevelRarities == null)
				{
					return;
				}
				{
					foreach (KeyValuePair<string, int> customLevelRarity in customLevelRarities)
					{
						spawnableEnemy.customLevelRarities.Add(customLevelRarity.Key, customLevelRarity.Value);
					}
					return;
				}
			}
			spawnableEnemy = new SpawnableEnemy(enemy2, spawnType, levelRarities, customLevelRarities);
			spawnableEnemy.terminalNode = infoNode;
			spawnableEnemy.infoKeyword = infoKeyword;
			string name = Assembly.GetCallingAssembly().GetName().Name;
			spawnableEnemy.modName = name;
		}

		public static void RegisterEnemy(EnemyType enemy, int rarity, Levels.LevelTypes levelFlags, TerminalNode infoNode = null, TerminalKeyword infoKeyword = null)
		{
			SpawnType spawnType = (enemy.isDaytimeEnemy ? SpawnType.Daytime : (enemy.isOutsideEnemy ? SpawnType.Outside : SpawnType.Default));
			RegisterEnemy(enemy, rarity, levelFlags, spawnType, null, infoNode, infoKeyword);
		}

		public static void RegisterEnemy(EnemyType enemy, int rarity, Levels.LevelTypes levelFlags, string[] spawnLevelOverrides = null, TerminalNode infoNode = null, TerminalKeyword infoKeyword = null)
		{
			SpawnType spawnType = (enemy.isDaytimeEnemy ? SpawnType.Daytime : (enemy.isOutsideEnemy ? SpawnType.Outside : SpawnType.Default));
			RegisterEnemy(enemy, rarity, levelFlags, spawnType, spawnLevelOverrides, infoNode, infoKeyword);
		}

		public static void RegisterEnemy(EnemyType enemy, Dictionary<Levels.LevelTypes, int>? levelRarities = null, Dictionary<string, int>? customLevelRarities = null, TerminalNode infoNode = null, TerminalKeyword infoKeyword = null)
		{
			SpawnType spawnType = (enemy.isDaytimeEnemy ? SpawnType.Daytime : (enemy.isOutsideEnemy ? SpawnType.Outside : SpawnType.Default));
			RegisterEnemy(enemy, spawnType, levelRarities, customLevelRarities, infoNode, infoKeyword);
		}

		public static void RemoveEnemyFromLevels(EnemyType enemyType, Levels.LevelTypes levelFlags = Levels.LevelTypes.None, string[] levelOverrides = null)
		{
			EnemyType enemyType2 = enemyType;
			if (!((Object)(object)StartOfRound.Instance != (Object)null))
			{
				return;
			}
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			foreach (SelectableLevel val in levels)
			{
				string name = ((Object)val).name;
				bool flag = levelFlags.HasFlag(Levels.LevelTypes.All) || (levelOverrides?.Any((string item) => item.ToLowerInvariant() == name.ToLowerInvariant()) ?? false);
				if (levelFlags.HasFlag(Levels.LevelTypes.Modded) && !Enum.IsDefined(typeof(Levels.LevelTypes), name))
				{
					flag = true;
				}
				if (!(Enum.IsDefined(typeof(Levels.LevelTypes), name) || flag))
				{
					continue;
				}
				Levels.LevelTypes levelTypes = (flag ? Levels.LevelTypes.All : ((Levels.LevelTypes)Enum.Parse(typeof(Levels.LevelTypes), name)));
				if (flag || levelFlags.HasFlag(levelTypes))
				{
					List<SpawnableEnemyWithRarity> enemies = val.Enemies;
					List<SpawnableEnemyWithRarity> daytimeEnemies = val.DaytimeEnemies;
					List<SpawnableEnemyWithRarity> outsideEnemies = val.OutsideEnemies;
					enemies.RemoveAll((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)enemyType2);
					daytimeEnemies.RemoveAll((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)enemyType2);
					outsideEnemies.RemoveAll((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)enemyType2);
				}
			}
		}
	}
	public class Items
	{
		public struct ItemSaveOrderData
		{
			public int itemId;

			public string itemName;

			public string assetName;
		}

		public struct BuyableItemAssetInfo
		{
			public Item itemAsset;

			public TerminalKeyword keyword;
		}

		public class ScrapItem
		{
			public Item item;

			public Item origItem;

			public int rarity;

			public Levels.LevelTypes spawnLevels;

			public string[] spawnLevelOverrides;

			public string modName = "Unknown";

			public Dictionary<string, int> customLevelRarities = new Dictionary<string, int>();

			public Dictionary<Levels.LevelTypes, int> levelRarities = new Dictionary<Levels.LevelTypes, int>();

			public ScrapItem(Item item, int rarity, Levels.LevelTypes spawnLevels = Levels.LevelTypes.None, string[] spawnLevelOverrides = null)
			{
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				origItem = item;
				if (!item.isScrap)
				{
					item = item.Clone<Item>();
					item.isScrap = true;
					if (item.maxValue == 0 && item.minValue == 0)
					{
						item.minValue = 40;
						item.maxValue = 100;
					}
					else if (item.maxValue == 0)
					{
						item.maxValue = item.minValue * 2;
					}
					else if (item.minValue == 0)
					{
						item.minValue = item.maxValue / 2;
					}
					GameObject val = NetworkPrefabs.CloneNetworkPrefab(item.spawnPrefab);
					if ((Object)(object)val.GetComponent<GrabbableObject>() != (Object)null)
					{
						val.GetComponent<GrabbableObject>().itemProperties = item;
					}
					if ((Object)(object)val.GetComponentInChildren<ScanNodeProperties>() == (Object)null)
					{
						GameObject obj = Object.Instantiate<GameObject>(scanNodePrefab, val.transform);
						((Object)obj).name = "ScanNode";
						obj.transform.localPosition = new Vector3(0f, 0f, 0f);
						obj.GetComponent<ScanNodeProperties>().headerText = item.itemName;
					}
					item.spawnPrefab = val;
				}
				this.item = item;
				if (spawnLevelOverrides != null)
				{
					foreach (string key in spawnLevelOverrides)
					{
						customLevelRarities.Add(key, rarity);
					}
				}
				if (spawnLevels == Levels.LevelTypes.None)
				{
					return;
				}
				foreach (Levels.LevelTypes value in Enum.GetValues(typeof(Levels.LevelTypes)))
				{
					if (spawnLevels.HasFlag(value))
					{
						levelRarities.Add(value, rarity);
					}
				}
			}

			public ScrapItem(Item item, Dictionary<Levels.LevelTypes, int>? levelRarities = null, Dictionary<string, int>? customLevelRarities = null)
			{
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				origItem = item;
				if (!item.isScrap)
				{
					item = item.Clone<Item>();
					item.isScrap = true;
					if (item.maxValue == 0 && item.minValue == 0)
					{
						item.minValue = 40;
						item.maxValue = 100;
					}
					else if (item.maxValue == 0)
					{
						item.maxValue = item.minValue * 2;
					}
					else if (item.minValue == 0)
					{
						item.minValue = item.maxValue / 2;
					}
					GameObject val = NetworkPrefabs.CloneNetworkPrefab(item.spawnPrefab);
					if ((Object)(object)val.GetComponent<GrabbableObject>() != (Object)null)
					{
						val.GetComponent<GrabbableObject>().itemProperties = item;
					}
					if ((Object)(object)val.GetComponentInChildren<ScanNodeProperties>() == (Object)null)
					{
						GameObject obj = Object.Instantiate<GameObject>(scanNodePrefab, val.transform);
						((Object)obj).name = "ScanNode";
						obj.transform.localPosition = new Vector3(0f, 0f, 0f);
						obj.GetComponent<ScanNodeProperties>().headerText = item.itemName;
					}
					item.spawnPrefab = val;
				}
				this.item = item;
				if (customLevelRarities != null)
				{
					this.customLevelRarities = customLevelRarities;
				}
				if (levelRarities != null)
				{
					this.levelRarities = levelRarities;
				}
			}
		}

		public class PlainItem
		{
			public Item item;

			public string modName;

			public PlainItem(Item item)
			{
				this.item = item;
			}
		}

		public class ShopItem
		{
			public Item item;

			public Item origItem;

			public TerminalNode buyNode1;

			public TerminalNode buyNode2;

			public TerminalNode itemInfo;

			public bool wasRemoved;

			public int price;

			public string modName;

			public ShopItem(Item item, TerminalNode buyNode1 = null, TerminalNode buyNode2 = null, TerminalNode itemInfo = null, int price = 0)
			{
				origItem = item;
				this.item = item;
				this.price = price;
				if ((Object)(object)buyNode1 != (Object)null)
				{
					this.buyNode1 = buyNode1;
				}
				if ((Object)(object)buyNode2 != (Object)null)
				{
					this.buyNode2 = buyNode2;
				}
				if ((Object)(object)itemInfo != (Object)null)
				{
					this.itemInfo = itemInfo;
				}
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Start <0>__StartOfRound_Start;

			public static hook_Awake <1>__Terminal_Awake;

			public static hook_TextPostProcess <2>__Terminal_TextPostProcess;
		}

		public static ConfigEntry<bool> useSavedataFix;

		public static GameObject scanNodePrefab;

		public static List<Item> LethalLibItemList = new List<Item>();

		public static List<BuyableItemAssetInfo> buyableItemAssetInfos = new List<BuyableItemAssetInfo>();

		public static Terminal terminal;

		public static List<ScrapItem> scrapItems = new List<ScrapItem>();

		public static List<ShopItem> shopItems = new List<ShopItem>();

		public static List<PlainItem> plainItems = new List<PlainItem>();

		public static void Init()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//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)
			//IL_006e: Expected O, but got Unknown
			//IL_0083: 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: Expected O, but got Unknown
			useSavedataFix = Plugin.config.Bind<bool>("Items", "EnableItemSaveFix", false, "Allow for LethalLib to store/reorder the item list, which should fix issues where items get reshuffled when loading an old save. This is experimental and may cause save corruptions occasionally.");
			scanNodePrefab = Plugin.MainAssets.LoadAsset<GameObject>("Assets/Custom/ItemScanNode.prefab");
			object obj = <>O.<0>__StartOfRound_Start;
			if (obj == null)
			{
				hook_Start val = StartOfRound_Start;
				<>O.<0>__StartOfRound_Start = val;
				obj = (object)val;
			}
			StartOfRound.Start += (hook_Start)obj;
			object obj2 = <>O.<1>__Terminal_Awake;
			if (obj2 == null)
			{
				hook_Awake val2 = Terminal_Awake;
				<>O.<1>__Terminal_Awake = val2;
				obj2 = (object)val2;
			}
			Terminal.Awake += (hook_Awake)obj2;
			object obj3 = <>O.<2>__Terminal_TextPostProcess;
			if (obj3 == null)
			{
				hook_TextPostProcess val3 = Terminal_TextPostProcess;
				<>O.<2>__Terminal_TextPostProcess = val3;
				obj3 = (object)val3;
			}
			Terminal.TextPostProcess += (hook_TextPostProcess)obj3;
		}

		private static string Terminal_TextPostProcess(orig_TextPostProcess orig, Terminal self, string modifiedDisplayText, TerminalNode node)
		{
			List<Item> list = self.buyableItemsList.ToList();
			List<Item> list2 = self.buyableItemsList.ToList();
			list2.RemoveAll((Item x) => shopItems.FirstOrDefault((ShopItem item) => (Object)(object)item.origItem == (Object)(object)x || (Object)(object)item.item == (Object)(object)x)?.wasRemoved ?? false);
			self.buyableItemsList = list2.ToArray();
			string result = orig.Invoke(self, modifiedDisplayText, node);
			self.buyableItemsList = list.ToArray();
			return result;
		}

		private static void StartOfRound_Start(orig_Start orig, StartOfRound self)
		{
			if (useSavedataFix.Value && ((NetworkBehaviour)self).IsHost)
			{
				Plugin.logger.LogInfo((object)"Fixing Item savedata!!");
				List<ItemSaveOrderData> itemList = new List<ItemSaveOrderData>();
				StartOfRound.Instance.allItemsList.itemsList.ForEach(delegate(Item item)
				{
					itemList.Add(new ItemSaveOrderData
					{
						itemId = item.itemId,
						itemName = item.itemName,
						assetName = ((Object)item).name
					});
				});
				if (ES3.KeyExists("LethalLibAllItemsList", GameNetworkManager.Instance.currentSaveFileName))
				{
					itemList = ES3.Load<List<ItemSaveOrderData>>("LethalLibAllItemsList", GameNetworkManager.Instance.currentSaveFileName);
				}
				List<Item> itemsList = StartOfRound.Instance.allItemsList.itemsList;
				List<Item> list = new List<Item>();
				foreach (ItemSaveOrderData item2 in itemList)
				{
					Item val = ((IEnumerable<Item>)itemsList).FirstOrDefault((Func<Item, bool>)((Item x) => x.itemId == item2.itemId && x.itemName == item2.itemName && item2.assetName == ((Object)x).name));
					if ((Object)(object)val != (Object)null)
					{
						list.Add(val);
					}
					else
					{
						list.Add(ScriptableObject.CreateInstance<Item>());
					}
				}
				foreach (Item item3 in itemsList)
				{
					if (!list.Contains(item3))
					{
						list.Add(item3);
					}
				}
				StartOfRound.Instance.allItemsList.itemsList = list;
				ES3.Save<List<ItemSaveOrderData>>("LethalLibAllItemsList", itemList, GameNetworkManager.Instance.currentSaveFileName);
			}
			orig.Invoke(self);
		}

		private static void Terminal_Awake(orig_Awake orig, Terminal self)
		{
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Expected O, but got Unknown
			//IL_0855: Unknown result type (might be due to invalid IL or missing references)
			//IL_085a: Unknown result type (might be due to invalid IL or missing references)
			//IL_088f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0898: Expected O, but got Unknown
			//IL_089a: Unknown result type (might be due to invalid IL or missing references)
			//IL_089f: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_08dc: Expected O, but got Unknown
			//IL_093f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0944: Unknown result type (might be due to invalid IL or missing references)
			//IL_094c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0959: Expected O, but got Unknown
			//IL_09e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_09eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a00: Expected O, but got Unknown
			StartOfRound instance = StartOfRound.Instance;
			foreach (ScrapItem scrapItem in scrapItems)
			{
				SelectableLevel[] levels = instance.levels;
				foreach (SelectableLevel val in levels)
				{
					string name = ((Object)val).name;
					bool flag = scrapItem.levelRarities.ContainsKey(Levels.LevelTypes.All) || (scrapItem.customLevelRarities != null && scrapItem.customLevelRarities.ContainsKey(name));
					if (scrapItem.levelRarities.ContainsKey(Levels.LevelTypes.Modded) && !Enum.IsDefined(typeof(Levels.LevelTypes), name))
					{
						flag = true;
					}
					if (!(Enum.IsDefined(typeof(Levels.LevelTypes), name) || flag))
					{
						continue;
					}
					Levels.LevelTypes levelEnum = (flag ? Levels.LevelTypes.All : ((Levels.LevelTypes)Enum.Parse(typeof(Levels.LevelTypes), name)));
					if (!flag && !scrapItem.levelRarities.Keys.Any((Levels.LevelTypes key) => key.HasFlag(levelEnum)))
					{
						continue;
					}
					int rarity = 0;
					if (scrapItem.levelRarities.Keys.Any((Levels.LevelTypes key) => key.HasFlag(levelEnum)))
					{
						rarity = scrapItem.levelRarities.First((KeyValuePair<Levels.LevelTypes, int> x) => x.Key.HasFlag(levelEnum)).Value;
					}
					else if (scrapItem.customLevelRarities != null && scrapItem.customLevelRarities.ContainsKey(name))
					{
						rarity = scrapItem.customLevelRarities[name];
					}
					SpawnableItemWithRarity item2 = new SpawnableItemWithRarity
					{
						spawnableItem = scrapItem.item,
						rarity = rarity
					};
					if (!val.spawnableScrap.Any((SpawnableItemWithRarity x) => (Object)(object)x.spawnableItem == (Object)(object)scrapItem.item))
					{
						val.spawnableScrap.Add(item2);
						if (Plugin.extendedLogging.Value)
						{
							Plugin.logger.LogInfo((object)("Added " + ((Object)scrapItem.item).name + " to " + name));
						}
					}
				}
			}
			foreach (ScrapItem scrapItem2 in scrapItems)
			{
				if (instance.allItemsList.itemsList.Contains(scrapItem2.item))
				{
					continue;
				}
				if (Plugin.extendedLogging.Value)
				{
					if (scrapItem2.modName != "LethalLib")
					{
						Plugin.logger.LogInfo((object)(scrapItem2.modName + " registered scrap item: " + scrapItem2.item.itemName));
					}
					else
					{
						Plugin.logger.LogInfo((object)("Registered scrap item: " + scrapItem2.item.itemName));
					}
				}
				LethalLibItemList.Add(scrapItem2.item);
				instance.allItemsList.itemsList.Add(scrapItem2.item);
			}
			foreach (ShopItem shopItem in shopItems)
			{
				if (instance.allItemsList.itemsList.Contains(shopItem.item))
				{
					continue;
				}
				if (Plugin.extendedLogging.Value)
				{
					if (shopItem.modName != "LethalLib")
					{
						Plugin.logger.LogInfo((object)(shopItem.modName + " registered shop item: " + shopItem.item.itemName));
					}
					else
					{
						Plugin.logger.LogInfo((object)("Registered shop item: " + shopItem.item.itemName));
					}
				}
				LethalLibItemList.Add(shopItem.item);
				instance.allItemsList.itemsList.Add(shopItem.item);
			}
			foreach (PlainItem plainItem in plainItems)
			{
				if (instance.allItemsList.itemsList.Contains(plainItem.item))
				{
					continue;
				}
				if (Plugin.extendedLogging.Value)
				{
					if (plainItem.modName != "LethalLib")
					{
						Plugin.logger.LogInfo((object)(plainItem.modName + " registered item: " + plainItem.item.itemName));
					}
					else
					{
						Plugin.logger.LogInfo((object)("Registered item: " + plainItem.item.itemName));
					}
				}
				LethalLibItemList.Add(plainItem.item);
				instance.allItemsList.itemsList.Add(plainItem.item);
			}
			terminal = self;
			List<Item> list = self.buyableItemsList.ToList();
			TerminalKeyword val2 = self.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "buy");
			TerminalNode result = val2.compatibleNouns[0].result.terminalOptions[1].result;
			TerminalKeyword val3 = self.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "info");
			Plugin.logger.LogInfo((object)$"Adding {shopItems.Count} items to terminal");
			foreach (ShopItem item in shopItems)
			{
				if (list.Any((Item x) => x.itemName == item.item.itemName) && !item.wasRemoved)
				{
					Plugin.logger.LogInfo((object)("Item " + item.item.itemName + " already exists in terminal, skipping"));
					continue;
				}
				item.wasRemoved = false;
				if (item.price == -1)
				{
					item.price = item.item.creditsWorth;
				}
				else
				{
					item.item.creditsWorth = item.price;
				}
				int num = -1;
				if (!list.Any((Item x) => (Object)(object)x == (Object)(object)item.item))
				{
					list.Add(item.item);
				}
				else
				{
					num = list.IndexOf(item.item);
				}
				int buyItemIndex = ((num == -1) ? (list.Count - 1) : num);
				string itemName = item.item.itemName;
				_ = itemName[itemName.Length - 1];
				string text = itemName;
				TerminalNode val4 = item.buyNode2;
				if ((Object)(object)val4 == (Object)null)
				{
					val4 = ScriptableObject.CreateInstance<TerminalNode>();
					((Object)val4).name = itemName.Replace(" ", "-") + "BuyNode2";
					val4.displayText = "Ordered [variableAmount] " + text + ". Your new balance is [playerCredits].\n\nOur contractors enjoy fast, free shipping while on the job! Any purchased items will arrive hourly at your approximate location.\r\n\r\n";
					val4.clearPreviousText = true;
					val4.maxCharactersToType = 15;
				}
				val4.buyItemIndex = buyItemIndex;
				val4.isConfirmationNode = false;
				val4.itemCost = item.price;
				val4.playSyncedClip = 0;
				TerminalNode val5 = item.buyNode1;
				if ((Object)(object)val5 == (Object)null)
				{
					val5 = ScriptableObject.CreateInstance<TerminalNode>();
					((Object)val5).name = itemName.Replace(" ", "-") + "BuyNode1";
					val5.displayText = "You have requested to order " + text + ". Amount: [variableAmount].\nTotal cost of items: [totalCost].\n\nPlease CONFIRM or DENY.\r\n\r\n";
					val5.clearPreviousText = true;
					val5.maxCharactersToType = 35;
				}
				val5.buyItemIndex = buyItemIndex;
				val5.isConfirmationNode = true;
				val5.overrideOptions = true;
				val5.itemCost = item.price;
				val5.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[2]
				{
					new CompatibleNoun
					{
						noun = self.terminalNodes.allKeywords.First((TerminalKeyword keyword2) => keyword2.word == "confirm"),
						result = val4
					},
					new CompatibleNoun
					{
						noun = self.terminalNodes.allKeywords.First((TerminalKeyword keyword2) => keyword2.word == "deny"),
						result = result
					}
				};
				TerminalKeyword val6 = TerminalUtils.CreateTerminalKeyword(itemName.ToLowerInvariant().Replace(" ", "-"), isVerb: false, null, null, val2);
				List<TerminalKeyword> list2 = self.terminalNodes.allKeywords.ToList();
				list2.Add(val6);
				self.terminalNodes.allKeywords = list2.ToArray();
				List<CompatibleNoun> list3 = val2.compatibleNouns.ToList();
				list3.Add(new CompatibleNoun
				{
					noun = val6,
					result = val5
				});
				val2.compatibleNouns = list3.ToArray();
				TerminalNode val7 = item.itemInfo;
				if ((Object)(object)val7 == (Object)null)
				{
					val7 = ScriptableObject.CreateInstance<TerminalNode>();
					((Object)val7).name = itemName.Replace(" ", "-") + "InfoNode";
					val7.displayText = "[No information about this object was found.]\n\n";
					val7.clearPreviousText = true;
					val7.maxCharactersToType = 25;
				}
				self.terminalNodes.allKeywords = list2.ToArray();
				List<CompatibleNoun> list4 = val3.compatibleNouns.ToList();
				list4.Add(new CompatibleNoun
				{
					noun = val6,
					result = val7
				});
				val3.compatibleNouns = list4.ToArray();
				BuyableItemAssetInfo buyableItemAssetInfo = default(BuyableItemAssetInfo);
				buyableItemAssetInfo.itemAsset = item.item;
				buyableItemAssetInfo.keyword = val6;
				BuyableItemAssetInfo item3 = buyableItemAssetInfo;
				buyableItemAssetInfos.Add(item3);
				if (Plugin.extendedLogging.Value)
				{
					Plugin.logger.LogInfo((object)$"Added {itemName} to terminal (Item price: {val5.itemCost}, Item Index: {val5.buyItemIndex}, Terminal keyword: {val6.word})");
				}
			}
			self.buyableItemsList = list.ToArray();
			orig.Invoke(self);
		}

		public static void RegisterScrap(Item spawnableItem, int rarity, Levels.LevelTypes levelFlags)
		{
			Item spawnableItem2 = spawnableItem;
			ScrapItem scrapItem = scrapItems.FirstOrDefault((ScrapItem x) => (Object)(object)x.origItem == (Object)(object)spawnableItem2 || (Object)(object)x.item == (Object)(object)spawnableItem2);
			if (scrapItem != null)
			{
				if (levelFlags != Levels.LevelTypes.None)
				{
					scrapItem.levelRarities.Add(levelFlags, rarity);
				}
			}
			else
			{
				scrapItem = new ScrapItem(spawnableItem2, rarity, levelFlags);
				string name = Assembly.GetCallingAssembly().GetName().Name;
				scrapItem.modName = name;
				scrapItems.Add(scrapItem);
			}
		}

		public static void RegisterScrap(Item spawnableItem, int rarity, Levels.LevelTypes levelFlags = Levels.LevelTypes.None, string[] levelOverrides = null)
		{
			Item spawnableItem2 = spawnableItem;
			ScrapItem scrapItem = scrapItems.FirstOrDefault((ScrapItem x) => (Object)(object)x.origItem == (Object)(object)spawnableItem2 || (Object)(object)x.item == (Object)(object)spawnableItem2);
			if (scrapItem != null)
			{
				if (levelFlags != Levels.LevelTypes.None)
				{
					scrapItem.levelRarities.Add(levelFlags, rarity);
				}
				if (levelOverrides != null)
				{
					foreach (string key in levelOverrides)
					{
						scrapItem.customLevelRarities.Add(key, rarity);
					}
				}
			}
			else
			{
				scrapItem = new ScrapItem(spawnableItem2, rarity, levelFlags, levelOverrides);
				string name = Assembly.GetCallingAssembly().GetName().Name;
				scrapItem.modName = name;
				scrapItems.Add(scrapItem);
			}
		}

		public static void RegisterScrap(Item spawnableItem, Dictionary<Levels.LevelTypes, int>? levelRarities = null, Dictionary<string, int>? customLevelRarities = null)
		{
			Item spawnableItem2 = spawnableItem;
			ScrapItem scrapItem = scrapItems.FirstOrDefault((ScrapItem x) => (Object)(object)x.origItem == (Object)(object)spawnableItem2 || (Object)(object)x.item == (Object)(object)spawnableItem2);
			if (scrapItem != null)
			{
				if (levelRarities != null)
				{
					foreach (KeyValuePair<Levels.LevelTypes, int> levelRarity in levelRarities)
					{
						scrapItem.levelRarities.Add(levelRarity.Key, levelRarity.Value);
					}
				}
				if (customLevelRarities == null)
				{
					return;
				}
				{
					foreach (KeyValuePair<string, int> customLevelRarity in customLevelRarities)
					{
						scrapItem.customLevelRarities.Add(customLevelRarity.Key, customLevelRarity.Value);
					}
					return;
				}
			}
			scrapItem = new ScrapItem(spawnableItem2, levelRarities, customLevelRarities);
			string name = Assembly.GetCallingAssembly().GetName().Name;
			scrapItem.modName = name;
			scrapItems.Add(scrapItem);
		}

		public static void RegisterShopItem(Item shopItem, TerminalNode buyNode1 = null, TerminalNode buyNode2 = null, TerminalNode itemInfo = null, int price = -1)
		{
			ShopItem shopItem2 = new ShopItem(shopItem, buyNode1, buyNode2, itemInfo, price);
			string name = Assembly.GetCallingAssembly().GetName().Name;
			shopItem2.modName = name;
			shopItems.Add(shopItem2);
		}

		public static void RegisterShopItem(Item shopItem, int price = -1)
		{
			ShopItem shopItem2 = new ShopItem(shopItem, null, null, null, price);
			string name = Assembly.GetCallingAssembly().GetName().Name;
			shopItem2.modName = name;
			shopItems.Add(shopItem2);
		}

		public static void RegisterItem(Item plainItem)
		{
			PlainItem plainItem2 = new PlainItem(plainItem);
			string name = Assembly.GetCallingAssembly().GetName().Name;
			plainItem2.modName = name;
			plainItems.Add(plainItem2);
		}

		public static void RemoveScrapFromLevels(Item scrapItem, Levels.LevelTypes levelFlags = Levels.LevelTypes.None, string[] levelOverrides = null)
		{
			Item scrapItem2 = scrapItem;
			if (!((Object)(object)StartOfRound.Instance != (Object)null))
			{
				return;
			}
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			foreach (SelectableLevel val in levels)
			{
				string name = ((Object)val).name;
				bool flag = levelFlags.HasFlag(Levels.LevelTypes.All) || (levelOverrides?.Any((string item) => item.ToLowerInvariant() == name.ToLowerInvariant()) ?? false);
				if (levelFlags.HasFlag(Levels.LevelTypes.Modded) && !Enum.IsDefined(typeof(Levels.LevelTypes), name))
				{
					flag = true;
				}
				if (!(Enum.IsDefined(typeof(Levels.LevelTypes), name) || flag))
				{
					continue;
				}
				Levels.LevelTypes levelTypes = (flag ? Levels.LevelTypes.All : ((Levels.LevelTypes)Enum.Parse(typeof(Levels.LevelTypes), name)));
				if (flag || levelFlags.HasFlag(levelTypes))
				{
					ScrapItem actualItem = scrapItems.FirstOrDefault((ScrapItem x) => (Object)(object)x.origItem == (Object)(object)scrapItem2 || (Object)(object)x.item == (Object)(object)scrapItem2);
					SpawnableItemWithRarity val2 = ((IEnumerable<SpawnableItemWithRarity>)val.spawnableScrap).FirstOrDefault((Func<SpawnableItemWithRarity, bool>)((SpawnableItemWithRarity x) => (Object)(object)x.spawnableItem == (Object)(object)actualItem.item));
					if (val2 != null)
					{
						val.spawnableScrap.Remove(val2);
					}
				}
			}
		}

		public static void RemoveShopItem(Item shopItem)
		{
			Item shopItem2 = shopItem;
			if (!((Object)(object)StartOfRound.Instance != (Object)null))
			{
				return;
			}
			ShopItem actualItem = shopItems.FirstOrDefault((ShopItem x) => (Object)(object)x.origItem == (Object)(object)shopItem2 || (Object)(object)x.item == (Object)(object)shopItem2);
			actualItem.wasRemoved = true;
			List<TerminalKeyword> list = terminal.terminalNodes.allKeywords.ToList();
			TerminalKeyword obj = terminal.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "info");
			TerminalKeyword val = terminal.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "buy");
			List<CompatibleNoun> list2 = val.compatibleNouns.ToList();
			List<CompatibleNoun> list3 = obj.compatibleNouns.ToList();
			if (buyableItemAssetInfos.Any((BuyableItemAssetInfo x) => (Object)(object)x.itemAsset == (Object)(object)actualItem.item))
			{
				BuyableItemAssetInfo asset = buyableItemAssetInfos.First((BuyableItemAssetInfo x) => (Object)(object)x.itemAsset == (Object)(object)actualItem.item);
				list.Remove(asset.keyword);
				list2.RemoveAll((CompatibleNoun noun) => (Object)(object)noun.noun == (Object)(object)asset.keyword);
				list3.RemoveAll((CompatibleNoun noun) => (Object)(object)noun.noun == (Object)(object)asset.keyword);
			}
			terminal.terminalNodes.allKeywords = list.ToArray();
			val.compatibleNouns = list2.ToArray();
			obj.compatibleNouns = list3.ToArray();
		}

		public static void UpdateShopItemPrice(Item shopItem, int price)
		{
			Item shopItem2 = shopItem;
			if (!((Object)(object)StartOfRound.Instance != (Object)null))
			{
				return;
			}
			ShopItem actualItem = shopItems.FirstOrDefault((ShopItem x) => (Object)(object)x.origItem == (Object)(object)shopItem2 || (Object)(object)x.item == (Object)(object)shopItem2);
			actualItem.item.creditsWorth = price;
			TerminalKeyword obj = terminal.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "buy");
			_ = obj.compatibleNouns[0].result.terminalOptions[1].result;
			List<CompatibleNoun> source = obj.compatibleNouns.ToList();
			if (!buyableItemAssetInfos.Any((BuyableItemAssetInfo x) => (Object)(object)x.itemAsset == (Object)(object)actualItem.item))
			{
				return;
			}
			BuyableItemAssetInfo asset = buyableItemAssetInfos.First((BuyableItemAssetInfo x) => (Object)(object)x.itemAsset == (Object)(object)actualItem.item);
			if (!source.Any((CompatibleNoun noun) => (Object)(object)noun.noun == (Object)(object)asset.keyword))
			{
				return;
			}
			TerminalNode result = source.First((CompatibleNoun noun) => (Object)(object)noun.noun == (Object)(object)asset.keyword).result;
			result.itemCost = price;
			if (result.terminalOptions.Length == 0)
			{
				return;
			}
			CompatibleNoun[] terminalOptions = result.terminalOptions;
			foreach (CompatibleNoun val in terminalOptions)
			{
				if ((Object)(object)val.result != (Object)null && val.result.buyItemIndex != -1)
				{
					val.result.itemCost = price;
				}
			}
		}
	}
	public class Levels
	{
		[Flags]
		public enum LevelTypes
		{
			None = 1,
			ExperimentationLevel = 4,
			AssuranceLevel = 8,
			VowLevel = 0x10,
			OffenseLevel = 0x20,
			MarchLevel = 0x40,
			RendLevel = 0x80,
			DineLevel = 0x100,
			TitanLevel = 0x200,
			Vanilla = 0x3FC,
			Modded = 0x400,
			All = -1
		}
	}
	public class MapObjects
	{
		public class RegisteredMapObject
		{
			public SpawnableMapObject mapObject;

			public SpawnableOutsideObjectWithRarity outsideObject;

			public Levels.LevelTypes levels;

			public string[] spawnLevelOverrides;

			public Func<SelectableLevel, AnimationCurve> spawnRateFunction;
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Awake <0>__StartOfRound_Awake;

			public static hook_SpawnMapObjects <1>__RoundManager_SpawnMapObjects;
		}

		public static List<RegisteredMapObject> mapObjects = new List<RegisteredMapObject>();

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			object obj = <>O.<0>__StartOfRound_Awake;
			if (obj == null)
			{
				hook_Awake val = StartOfRound_Awake;
				<>O.<0>__StartOfRound_Awake = val;
				obj = (object)val;
			}
			StartOfRound.Awake += (hook_Awake)obj;
			object obj2 = <>O.<1>__RoundManager_SpawnMapObjects;
			if (obj2 == null)
			{
				hook_SpawnMapObjects val2 = RoundManager_SpawnMapObjects;
				<>O.<1>__RoundManager_SpawnMapObjects = val2;
				obj2 = (object)val2;
			}
			RoundManager.SpawnMapObjects += (hook_SpawnMapObjects)obj2;
		}

		private static void RoundManager_SpawnMapObjects(orig_SpawnMapObjects orig, RoundManager self)
		{
			RandomMapObject[] array = Object.FindObjectsOfType<RandomMapObject>();
			foreach (RandomMapObject val in array)
			{
				foreach (RegisteredMapObject mapObject in mapObjects)
				{
					if (mapObject.mapObject != null && !val.spawnablePrefabs.Any((GameObject prefab) => (Object)(object)prefab == (Object)(object)mapObject.mapObject.prefabToSpawn))
					{
						val.spawnablePrefabs.Add(mapObject.mapObject.prefabToSpawn);
					}
				}
			}
			orig.Invoke(self);
		}

		private static void StartOfRound_Awake(orig_Awake orig, StartOfRound self)
		{
			orig.Invoke(self);
			foreach (RegisteredMapObject mapObject in mapObjects)
			{
				SelectableLevel[] levels = self.levels;
				foreach (SelectableLevel val in levels)
				{
					string name = ((Object)val).name;
					bool flag = mapObject.levels.HasFlag(Levels.LevelTypes.All) || (mapObject.spawnLevelOverrides != null && mapObject.spawnLevelOverrides.Any((string item) => item.ToLowerInvariant() == name.ToLowerInvariant()));
					if (mapObject.levels.HasFlag(Levels.LevelTypes.Modded) && !Enum.IsDefined(typeof(Levels.LevelTypes), name))
					{
						flag = true;
					}
					if (!(Enum.IsDefined(typeof(Levels.LevelTypes), name) || flag))
					{
						continue;
					}
					Levels.LevelTypes levelTypes = (flag ? Levels.LevelTypes.All : ((Levels.LevelTypes)Enum.Parse(typeof(Levels.LevelTypes), name)));
					if (!flag && !mapObject.levels.HasFlag(levelTypes))
					{
						continue;
					}
					if (mapObject.mapObject != null)
					{
						if (val.spawnableMapObjects.Any((SpawnableMapObject x) => (Object)(object)x.prefabToSpawn == (Object)(object)mapObject.mapObject.prefabToSpawn))
						{
							List<SpawnableMapObject> list = val.spawnableMapObjects.ToList();
							list.RemoveAll((SpawnableMapObject x) => (Object)(object)x.prefabToSpawn == (Object)(object)mapObject.mapObject.prefabToSpawn);
							val.spawnableMapObjects = list.ToArray();
						}
						SpawnableMapObject mapObject2 = mapObject.mapObject;
						if (mapObject.spawnRateFunction != null)
						{
							mapObject2.numberToSpawn = mapObject.spawnRateFunction(val);
						}
						List<SpawnableMapObject> list2 = val.spawnableMapObjects.ToList();
						list2.Add(mapObject2);
						val.spawnableMapObjects = list2.ToArray();
						if (Plugin.extendedLogging.Value)
						{
							Plugin.logger.LogInfo((object)("Added " + ((Object)mapObject2.prefabToSpawn).name + " to " + name));
						}
					}
					else
					{
						if (mapObject.outsideObject == null)
						{
							continue;
						}
						if (val.spawnableOutsideObjects.Any((SpawnableOutsideObjectWithRarity x) => (Object)(object)x.spawnableObject.prefabToSpawn == (Object)(object)mapObject.outsideObject.spawnableObject.prefabToSpawn))
						{
							List<SpawnableOutsideObjectWithRarity> list3 = val.spawnableOutsideObjects.ToList();
							list3.RemoveAll((SpawnableOutsideObjectWithRarity x) => (Object)(object)x.spawnableObject.prefabToSpawn == (Object)(object)mapObject.outsideObject.spawnableObject.prefabToSpawn);
							val.spawnableOutsideObjects = list3.ToArray();
						}
						SpawnableOutsideObjectWithRarity outsideObject = mapObject.outsideObject;
						if (mapObject.spawnRateFunction != null)
						{
							outsideObject.randomAmount = mapObject.spawnRateFunction(val);
						}
						List<SpawnableOutsideObjectWithRarity> list4 = val.spawnableOutsideObjects.ToList();
						list4.Add(outsideObject);
						val.spawnableOutsideObjects = list4.ToArray();
						if (Plugin.extendedLogging.Value)
						{
							Plugin.logger.LogInfo((object)("Added " + ((Object)outsideObject.spawnableObject.prefabToSpawn).name + " to " + name));
						}
					}
				}
			}
		}

		public static void RegisterMapObject(SpawnableMapObjectDef mapObject, Levels.LevelTypes levels, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null)
		{
			RegisterMapObject(mapObject.spawnableMapObject, levels, spawnRateFunction);
		}

		public static void RegisterMapObject(SpawnableMapObjectDef mapObject, Levels.LevelTypes levels = Levels.LevelTypes.None, string[] levelOverrides = null, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null)
		{
			RegisterMapObject(mapObject.spawnableMapObject, levels, levelOverrides, spawnRateFunction);
		}

		public static void RegisterMapObject(SpawnableMapObject mapObject, Levels.LevelTypes levels, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null)
		{
			mapObjects.Add(new RegisteredMapObject
			{
				mapObject = mapObject,
				levels = levels,
				spawnRateFunction = spawnRateFunction
			});
		}

		public static void RegisterMapObject(SpawnableMapObject mapObject, Levels.LevelTypes levels = Levels.LevelTypes.None, string[] levelOverrides = null, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null)
		{
			mapObjects.Add(new RegisteredMapObject
			{
				mapObject = mapObject,
				levels = levels,
				spawnRateFunction = spawnRateFunction,
				spawnLevelOverrides = levelOverrides
			});
		}

		public static void RegisterOutsideObject(SpawnableOutsideObjectDef mapObject, Levels.LevelTypes levels, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null)
		{
			RegisterOutsideObject(mapObject.spawnableMapObject, levels, spawnRateFunction);
		}

		public static void RegisterOutsideObject(SpawnableOutsideObjectDef mapObject, Levels.LevelTypes levels = Levels.LevelTypes.None, string[] levelOverrides = null, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null)
		{
			RegisterOutsideObject(mapObject.spawnableMapObject, levels, levelOverrides, spawnRateFunction);
		}

		public static void RegisterOutsideObject(SpawnableOutsideObjectWithRarity mapObject, Levels.LevelTypes levels, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null)
		{
			mapObjects.Add(new RegisteredMapObject
			{
				outsideObject = mapObject,
				levels = levels,
				spawnRateFunction = spawnRateFunction
			});
		}

		public static void RegisterOutsideObject(SpawnableOutsideObjectWithRarity mapObject, Levels.LevelTypes levels = Levels.LevelTypes.None, string[] levelOverrides = null, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null)
		{
			mapObjects.Add(new RegisteredMapObject
			{
				outsideObject = mapObject,
				levels = levels,
				spawnRateFunction = spawnRateFunction,
				spawnLevelOverrides = levelOverrides
			});
		}

		public static void RemoveMapObject(SpawnableMapObjectDef mapObject, Levels.LevelTypes levelFlags, string[] levelOverrides = null)
		{
			RemoveMapObject(mapObject.spawnableMapObject, levelFlags, levelOverrides);
		}

		public static void RemoveMapObject(SpawnableMapObject mapObject, Levels.LevelTypes levelFlags, string[] levelOverrides = null)
		{
			SpawnableMapObject mapObject2 = mapObject;
			if (!((Object)(object)StartOfRound.Instance != (Object)null))
			{
				return;
			}
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			foreach (SelectableLevel val in levels)
			{
				string name = ((Object)val).name;
				bool flag = levelFlags.HasFlag(Levels.LevelTypes.All) || (levelOverrides?.Any((string item) => item.ToLowerInvariant() == name.ToLowerInvariant()) ?? false);
				if (levelFlags.HasFlag(Levels.LevelTypes.Modded) && !Enum.IsDefined(typeof(Levels.LevelTypes), name))
				{
					flag = true;
				}
				if (!(Enum.IsDefined(typeof(Levels.LevelTypes), name) || flag))
				{
					continue;
				}
				Levels.LevelTypes levelTypes = (flag ? Levels.LevelTypes.All : ((Levels.LevelTypes)Enum.Parse(typeof(Levels.LevelTypes), name)));
				if (flag || levelFlags.HasFlag(levelTypes))
				{
					val.spawnableMapObjects = val.spawnableMapObjects.Where((SpawnableMapObject x) => (Object)(object)x.prefabToSpawn != (Object)(object)mapObject2.prefabToSpawn).ToArray();
				}
			}
		}

		public static void RemoveOutsideObject(SpawnableOutsideObjectDef mapObject, Levels.LevelTypes levelFlags, string[] levelOverrides = null)
		{
			RemoveOutsideObject(mapObject.spawnableMapObject, levelFlags, levelOverrides);
		}

		public static void RemoveOutsideObject(SpawnableOutsideObjectWithRarity mapObject, Levels.LevelTypes levelFlags, string[] levelOverrides = null)
		{
			SpawnableOutsideObjectWithRarity mapObject2 = mapObject;
			if (!((Object)(object)StartOfRound.Instance != (Object)null))
			{
				return;
			}
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			foreach (SelectableLevel val in levels)
			{
				string name = ((Object)val).name;
				bool flag = levelFlags.HasFlag(Levels.LevelTypes.All) || (levelOverrides?.Any((string item) => item.ToLowerInvariant() == name.ToLowerInvariant()) ?? false);
				if (levelFlags.HasFlag(Levels.LevelTypes.Modded) && !Enum.IsDefined(typeof(Levels.LevelTypes), name))
				{
					flag = true;
				}
				if (!(Enum.IsDefined(typeof(Levels.LevelTypes), name) || flag))
				{
					continue;
				}
				Levels.LevelTypes levelTypes = (flag ? Levels.LevelTypes.All : ((Levels.LevelTypes)Enum.Parse(typeof(Levels.LevelTypes), name)));
				if (flag || levelFlags.HasFlag(levelTypes))
				{
					val.spawnableOutsideObjects = val.spawnableOutsideObjects.Where((SpawnableOutsideObjectWithRarity x) => (Object)(object)x.spawnableObject.prefabToSpawn != (Object)(object)mapObject2.spawnableObject.prefabToSpawn).ToArray();
				}
			}
		}
	}
	public class NetworkPrefabs
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Start <0>__GameNetworkManager_Start;
		}

		private static List<GameObject> _networkPrefabs = new List<GameObject>();

		internal static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__GameNetworkManager_Start;
			if (obj == null)
			{
				hook_Start val = GameNetworkManager_Start;
				<>O.<0>__GameNetworkManager_Start = val;
				obj = (object)val;
			}
			GameNetworkManager.Start += (hook_Start)obj;
		}

		public static void RegisterNetworkPrefab(GameObject prefab)
		{
			if (!_networkPrefabs.Contains(prefab))
			{
				_networkPrefabs.Add(prefab);
			}
		}

		public static GameObject CreateNetworkPrefab(string name)
		{
			GameObject obj = PrefabUtils.CreatePrefab(name);
			obj.AddComponent<NetworkObject>();
			byte[] value = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(Assembly.GetCallingAssembly().GetName().Name + name));
			obj.GetComponent<NetworkObject>().GlobalObjectIdHash = BitConverter.ToUInt32(value, 0);
			RegisterNetworkPrefab(obj);
			return obj;
		}

		public static GameObject CloneNetworkPrefab(GameObject prefabToClone, string newName = null)
		{
			GameObject val = PrefabUtils.ClonePrefab(prefabToClone, newName);
			byte[] value = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(Assembly.GetCallingAssembly().GetName().Name + ((Object)val).name));
			val.GetComponent<NetworkObject>().GlobalObjectIdHash = BitConverter.ToUInt32(value, 0);
			RegisterNetworkPrefab(val);
			return val;
		}

		private static void GameNetworkManager_Start(orig_Start orig, GameNetworkManager self)
		{
			orig.Invoke(self);
			foreach (GameObject networkPrefab in _networkPrefabs)
			{
				if (!NetworkManager.Singleton.NetworkConfig.Prefabs.Contains(networkPrefab))
				{
					NetworkManager.Singleton.AddNetworkPrefab(networkPrefab);
				}
			}
		}
	}
	public class Player
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Awake <0>__StartOfRound_Awake;
		}

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

		public static Dictionary<string, int> ragdollIndexes = new Dictionary<string, int>();

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__StartOfRound_Awake;
			if (obj == null)
			{
				hook_Awake val = StartOfRound_Awake;
				<>O.<0>__StartOfRound_Awake = val;
				obj = (object)val;
			}
			StartOfRound.Awake += (hook_Awake)obj;
		}

		private static void StartOfRound_Awake(orig_Awake orig, StartOfRound self)
		{
			orig.Invoke(self);
			foreach (KeyValuePair<string, GameObject> ragdollRef in ragdollRefs)
			{
				if (!self.playerRagdolls.Contains(ragdollRef.Value))
				{
					self.playerRagdolls.Add(ragdollRef.Value);
					int value = self.playerRagdolls.Count - 1;
					if (ragdollIndexes.ContainsKey(ragdollRef.Key))
					{
						ragdollIndexes[ragdollRef.Key] = value;
					}
					else
					{
						ragdollIndexes.Add(ragdollRef.Key, value);
					}
				}
			}
		}

		public static int GetRagdollIndex(string id)
		{
			return ragdollIndexes[id];
		}

		public static GameObject GetRagdoll(string id)
		{
			return ragdollRefs[id];
		}

		public static void RegisterPlayerRagdoll(string id, GameObject ragdoll)
		{
			Plugin.logger.LogInfo((object)("Registering player ragdoll " + id));
			ragdollRefs.Add(id, ragdoll);
		}
	}
	public class PrefabUtils
	{
		internal static Lazy<GameObject> _prefabParent;

		internal static GameObject prefabParent => _prefabParent.Value;

		static PrefabUtils()
		{
			_prefabParent = new Lazy<GameObject>((Func<GameObject>)delegate
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: 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_001a: Expected O, but got Unknown
				GameObject val = new GameObject("LethalLibGeneratedPrefabs")
				{
					hideFlags = (HideFlags)61
				};
				val.SetActive(false);
				return val;
			});
		}

		public static GameObject ClonePrefab(GameObject prefabToClone, string newName = null)
		{
			GameObject val = Object.Instantiate<GameObject>(prefabToClone, prefabParent.transform);
			((Object)val).hideFlags = (HideFlags)61;
			if (newName != null)
			{
				((Object)val).name = newName;
			}
			else
			{
				((Object)val).name = ((Object)prefabToClone).name;
			}
			return val;
		}

		public static GameObject CreatePrefab(string name)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			GameObject val = new GameObject(name)
			{
				hideFlags = (HideFlags)61
			};
			val.transform.SetParent(prefabParent.transform);
			return val;
		}
	}
	public class Shaders
	{
		public static void FixShaders(GameObject gameObject)
		{
			Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Material[] materials = componentsInChildren[i].materials;
				foreach (Material val in materials)
				{
					if (((Object)val.shader).name.Contains("Standard"))
					{
						val.shader = Shader.Find("HDRP/Lit");
					}
				}
			}
		}
	}
	public class TerminalUtils
	{
		public static TerminalKeyword CreateTerminalKeyword(string word, bool isVerb = false, CompatibleNoun[] compatibleNouns = null, TerminalNode specialKeywordResult = null, TerminalKeyword defaultVerb = null, bool accessTerminalObjects = false)
		{
			TerminalKeyword obj = ScriptableObject.CreateInstance<TerminalKeyword>();
			((Object)obj).name = word;
			obj.word = word;
			obj.isVerb = isVerb;
			obj.compatibleNouns = compatibleNouns;
			obj.specialKeywordResult = specialKeywordResult;
			obj.defaultVerb = defaultVerb;
			obj.accessTerminalObjects = accessTerminalObjects;
			return obj;
		}
	}
	public enum StoreType
	{
		None,
		ShipUpgrade,
		Decor
	}
	public class Unlockables
	{
		public class RegisteredUnlockable
		{
			public UnlockableItem unlockable;

			public StoreType StoreType;

			public TerminalNode buyNode1;

			public TerminalNode buyNode2;

			public TerminalNode itemInfo;

			public int price;

			public string modName;

			public bool disabled;

			public bool wasAlwaysInStock;

			public RegisteredUnlockable(UnlockableItem unlockable, TerminalNode buyNode1 = null, TerminalNode buyNode2 = null, TerminalNode itemInfo = null, int price = -1)
			{
				this.unlockable = unlockable;
				this.buyNode1 = buyNode1;
				this.buyNode2 = buyNode2;
				this.itemInfo = itemInfo;
				this.price = price;
			}
		}

		public struct BuyableUnlockableAssetInfo
		{
			public UnlockableItem itemAsset;

			public TerminalKeyword keyword;
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Awake <0>__Terminal_Awake;

			public static hook_TextPostProcess <1>__Terminal_TextPostProcess;

			public static hook_RotateShipDecorSelection <2>__Terminal_RotateShipDecorSelection;
		}

		public static List<RegisteredUnlockable> registeredUnlockables = new List<RegisteredUnlockable>();

		public static List<BuyableUnlockableAssetInfo> buyableUnlockableAssetInfos = new List<BuyableUnlockableAssetInfo>();

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			object obj = <>O.<0>__Terminal_Awake;
			if (obj == null)
			{
				hook_Awake val = Terminal_Awake;
				<>O.<0>__Terminal_Awake = val;
				obj = (object)val;
			}
			Terminal.Awake += (hook_Awake)obj;
			object obj2 = <>O.<1>__Terminal_TextPostProcess;
			if (obj2 == null)
			{
				hook_TextPostProcess val2 = Terminal_TextPostProcess;
				<>O.<1>__Terminal_TextPostProcess = val2;
				obj2 = (object)val2;
			}
			Terminal.TextPostProcess += (hook_TextPostProcess)obj2;
			object obj3 = <>O.<2>__Terminal_RotateShipDecorSelection;
			if (obj3 == null)
			{
				hook_RotateShipDecorSelection val3 = Terminal_RotateShipDecorSelection;
				<>O.<2>__Terminal_RotateShipDecorSelection = val3;
				obj3 = (object)val3;
			}
			Terminal.RotateShipDecorSelection += (hook_RotateShipDecorSelection)obj3;
		}

		private static void Terminal_RotateShipDecorSelection(orig_RotateShipDecorSelection orig, Terminal self)
		{
			foreach (RegisteredUnlockable registeredUnlockable in registeredUnlockables)
			{
				if (registeredUnlockable.StoreType == StoreType.Decor && registeredUnlockable.disabled)
				{
					registeredUnlockable.wasAlwaysInStock = registeredUnlockable.unlockable.alwaysInStock;
					registeredUnlockable.unlockable.alwaysInStock = true;
				}
			}
			orig.Invoke(self);
			foreach (RegisteredUnlockable registeredUnlockable2 in registeredUnlockables)
			{
				if (registeredUnlockable2.StoreType == StoreType.Decor && registeredUnlockable2.disabled)
				{
					registeredUnlockable2.unlockable.alwaysInStock = registeredUnlockable2.wasAlwaysInStock;
				}
			}
		}

		private static string Terminal_TextPostProcess(orig_TextPostProcess orig, Terminal self, string modifiedDisplayText, TerminalNode node)
		{
			if (modifiedDisplayText.Contains("[buyableItemsList]") && modifiedDisplayText.Contains("[unlockablesSelectionList]"))
			{
				int num = modifiedDisplayText.IndexOf(":");
				foreach (RegisteredUnlockable registeredUnlockable in registeredUnlockables)
				{
					if (registeredUnlockable.StoreType == StoreType.ShipUpgrade && !registeredUnlockable.disabled)
					{
						string unlockableName = registeredUnlockable.unlockable.unlockableName;
						int price = registeredUnlockable.price;
						string value = $"\n* {unlockableName}    //    Price: ${price}";
						modifiedDisplayText = modifiedDisplayText.Insert(num + 1, value);
					}
				}
			}
			return orig.Invoke(self, modifiedDisplayText, node);
		}

		private static void Terminal_Awake(orig_Awake orig, Terminal self)
		{
			//IL_0473: Unknown result type (might be due to invalid IL or missing references)
			//IL_0478: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b6: Expected O, but got Unknown
			//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fa: Expected O, but got Unknown
			//IL_0576: Unknown result type (might be due to invalid IL or missing references)
			//IL_057b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0588: Unknown result type (might be due to invalid IL or missing references)
			//IL_0595: Expected O, but got Unknown
			//IL_0621: Unknown result type (might be due to invalid IL or missing references)
			//IL_0626: Unknown result type (might be due to invalid IL or missing references)
			//IL_0633: Unknown result type (might be due to invalid IL or missing references)
			//IL_0640: Expected O, but got Unknown
			StartOfR

plugins/LethalNetworkAPI/LethalNetworkAPI.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalNetworkAPI.NetcodePatcher;
using LethalNetworkAPI.Networking;
using LethalNetworkAPI.Serializable;
using Microsoft.CodeAnalysis;
using OdinSerializer;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RegisterFormatter(typeof(NetworkBehaviourReferenceFormatter), 0)]
[assembly: RegisterFormatter(typeof(NetworkObjectReferenceFormatter), 0)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("Xilophor")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Easily create networked mods.")]
[assembly: AssemblyFileVersion("2.1.6.0")]
[assembly: AssemblyInformationalVersion("2.1.6+2b8f80905fe30276fc377fd0534a4383a6ae9dc2")]
[assembly: AssemblyProduct("LethalNetworkAPI")]
[assembly: AssemblyTitle("LethalNetworkAPI")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Xilophor/LethalNetworkAPI")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.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 LethalNetworkAPI
{
	public sealed class LethalClientEvent : LNetworkEvent
	{
		public event Action? OnReceived;

		public event Action<ulong>? OnReceivedFromClient;

		public LethalClientEvent(string identifier, Action? onReceived = null, Action<ulong>? onReceivedFromClient = null)
			: base(identifier)
		{
			NetworkHandler.OnClientEvent += ReceiveClientEvent;
			NetworkHandler.OnSyncedClientEvent += ReceiveSyncedClientEvent;
			OnReceived += onReceived;
			OnReceivedFromClient += onReceivedFromClient;
		}

		public void InvokeServer()
		{
			//IL_0019: 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)
			if (!IsNetworkHandlerNull())
			{
				NetworkHandler.Instance.EventServerRpc(Identifier);
			}
		}

		public void InvokeAllClients(bool includeLocalClient = true, bool waitForServerResponse = false)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (!IsNetworkHandlerNull())
			{
				NetworkHandler.Instance.EventServerRpc(Identifier, toOtherClients: true, includeLocalClient && waitForServerResponse);
				if (includeLocalClient && !waitForServerResponse)
				{
					this.OnReceivedFromClient?.Invoke(NetworkManager.Singleton.LocalClientId);
				}
			}
		}

		public void InvokeAllClientsSynced()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (!IsNetworkHandlerNull())
			{
				NetworkTime localTime = NetworkManager.Singleton.LocalTime;
				double time = ((NetworkTime)(ref localTime)).Time;
				NetworkHandler.Instance.SyncedEventServerRpc(Identifier, time);
				ReceiveClientEvent(Identifier, NetworkManager.Singleton.LocalClientId);
			}
		}

		private void ReceiveClientEvent(string identifier, ulong originatorClientId)
		{
			if (!(identifier != Identifier))
			{
				if (originatorClientId == 99999)
				{
					this.OnReceived?.Invoke();
				}
				else
				{
					this.OnReceivedFromClient?.Invoke(originatorClientId);
				}
			}
		}

		private void ReceiveSyncedClientEvent(string identifier, double time, ulong originatorClientId)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (!(identifier != Identifier) && !((Object)(object)NetworkHandler.Instance == (Object)null))
			{
				NetworkTime serverTime = NetworkManager.Singleton.ServerTime;
				double num = time - ((NetworkTime)(ref serverTime)).Time;
				((MonoBehaviour)NetworkHandler.Instance).StartCoroutine(WaitAndInvokeEvent((float)num, originatorClientId));
			}
		}

		private IEnumerator WaitAndInvokeEvent(float timeToWait, ulong originatorClientId)
		{
			if (timeToWait > 0f)
			{
				yield return (object)new WaitForSeconds(timeToWait);
			}
			ReceiveClientEvent(Identifier, originatorClientId);
		}
	}
	public sealed class LethalServerEvent : LNetworkEvent
	{
		public event Action<ulong>? OnReceived;

		public LethalServerEvent(string identifier, Action<ulong>? onReceived = null)
			: base(identifier)
		{
			NetworkHandler.OnServerEvent += ReceiveServerEvent;
			NetworkHandler.OnSyncedServerEvent += ReceiveSyncedServerEvent;
			OnReceived += onReceived;
		}

		public void InvokeClient(ulong clientId)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if (!IsNetworkHandlerNull() && IsHostOrServer())
			{
				NetworkHandler.Instance.EventClientRpc(Identifier, 99999uL, GenerateClientParams(clientId));
			}
		}

		public void InvokeClients(IEnumerable<ulong> clientIds)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if (!IsNetworkHandlerNull() && IsHostOrServer())
			{
				NetworkHandler.Instance.EventClientRpc(Identifier, 99999uL, GenerateClientParams(clientIds));
			}
		}

		public void InvokeAllClients(bool receiveOnHost = true)
		{
			//IL_0048: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			if (!IsNetworkHandlerNull() && IsHostOrServer())
			{
				if (receiveOnHost)
				{
					NetworkHandler.Instance.EventClientRpc(Identifier, 99999uL);
				}
				else
				{
					NetworkHandler.Instance.EventClientRpc(Identifier, 99999uL, GenerateClientParamsExceptHost());
				}
			}
		}

		private void ReceiveServerEvent(string identifier, ulong originClientId)
		{
			if (!(identifier != Identifier))
			{
				this.OnReceived?.Invoke(originClientId);
			}
		}

		private void ReceiveSyncedServerEvent(string identifier, double time, ulong originatorClientId)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			if (!(identifier != Identifier) && !IsNetworkHandlerNull())
			{
				NetworkTime serverTime = NetworkManager.Singleton.ServerTime;
				double num = time - ((NetworkTime)(ref serverTime)).Time;
				NetworkHandler.Instance.SyncedEventClientRpc(identifier, time, originatorClientId, GenerateClientParamsExcept(originatorClientId));
				((MonoBehaviour)NetworkHandler.Instance).StartCoroutine(WaitAndInvokeEvent((float)num, originatorClientId));
			}
		}

		private IEnumerator WaitAndInvokeEvent(float timeToWait, ulong clientId)
		{
			if (timeToWait > 0f)
			{
				yield return (object)new WaitForSeconds(timeToWait);
			}
			this.OnReceived?.Invoke(clientId);
		}
	}
	public abstract class LNetworkEvent : LethalNetwork
	{
		protected LNetworkEvent(string identifier)
			: base("evt." + identifier, "Event")
		{
		}
	}
	public abstract class LethalNetwork
	{
		internal readonly string Identifier;

		private readonly string _networkType;

		protected LethalNetwork(string identifier, string networkType, int frameIndex = 3)
		{
			try
			{
				MethodBase method = new StackTrace().GetFrame(frameIndex).GetMethod();
				Assembly assembly = method.ReflectedType.Assembly;
				Type type2 = AccessTools.GetTypesFromAssembly(assembly).First((Type type) => type.GetCustomAttributes(typeof(BepInPlugin), inherit: false).Any());
				Identifier = MetadataHelper.GetMetadata(type2).GUID + "." + identifier;
				_networkType = networkType;
			}
			catch (Exception arg)
			{
				LethalNetworkAPIPlugin.Logger.LogError((object)$"Unable to find plugin info for calling mod for {_networkType.ToLower()} with identifier \"{Identifier}\". Are you using BepInEx? \n Stacktrace: {arg}");
			}
		}

		protected bool IsNetworkHandlerNull(bool log = true)
		{
			if ((Object)(object)NetworkHandler.Instance != (Object)null)
			{
				return false;
			}
			if (log)
			{
				LethalNetworkAPIPlugin.Logger.LogError((object)string.Format("Unable to invoke the {1} with identifier \"{0}\". Is the player in a lobby?", _networkType.ToLower(), Identifier));
			}
			return true;
		}

		protected bool IsHostOrServer(bool log = true)
		{
			if ((Object)(object)NetworkManager.Singleton == (Object)null)
			{
				return false;
			}
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				return true;
			}
			if (log)
			{
				LethalNetworkAPIPlugin.Logger.LogError((object)$"The client {NetworkManager.Singleton.LocalClientId} cannot use server methods. {_networkType} Identifier: \"{Identifier}\"");
			}
			return false;
		}

		private bool DoClientsExist(IEnumerable<ulong> clientIds, bool log = true)
		{
			if (clientIds.Any())
			{
				return true;
			}
			if (log)
			{
				LethalNetworkAPIPlugin.Logger.LogError((object)$"None of the specified clients {clientIds} are connected. {_networkType} Identifier: \"{Identifier}\"");
			}
			return false;
		}

		private ClientRpcParams GenerateClientParams(IEnumerable<ulong> clientIds, bool allExcept)
		{
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			ulong[] enumerable = (clientIds as ulong[]) ?? clientIds.ToArray();
			NativeArray<ulong> val = default(NativeArray<ulong>);
			if (!enumerable.Any() && allExcept)
			{
				val..ctor(NetworkManager.Singleton.ConnectedClientsIds.Where((ulong i) => i != 0).ToArray(), (Allocator)4);
			}
			else if (allExcept)
			{
				val..ctor(NetworkManager.Singleton.ConnectedClientsIds.Where((ulong i) => enumerable.All((ulong j) => i != j)).ToArray(), (Allocator)4);
			}
			else
			{
				val..ctor(enumerable.Where((ulong i) => NetworkManager.Singleton.ConnectedClientsIds.Contains(i)).ToArray(), (Allocator)4);
			}
			if (!DoClientsExist((IEnumerable<ulong>)(object)val))
			{
				return default(ClientRpcParams);
			}
			ClientRpcParams result = default(ClientRpcParams);
			result.Send = new ClientRpcSendParams
			{
				TargetClientIdsNativeArray = val
			};
			return result;
		}

		protected ClientRpcParams GenerateClientParams(IEnumerable<ulong> clientIds)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			return GenerateClientParams(clientIds, allExcept: false);
		}

		protected ClientRpcParams GenerateClientParams(ulong clientId)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			return GenerateClientParams(new <>z__ReadOnlyArray<ulong>(new ulong[1] { clientId }), allExcept: false);
		}

		protected ClientRpcParams GenerateClientParamsExcept(IEnumerable<ulong> clientIds)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			return GenerateClientParams(clientIds, allExcept: true);
		}

		protected ClientRpcParams GenerateClientParamsExcept(ulong clientId)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			return GenerateClientParams(new <>z__ReadOnlyArray<ulong>(new ulong[1] { clientId }), allExcept: true);
		}

		protected ClientRpcParams GenerateClientParamsExceptHost()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return GenerateClientParams(Array.Empty<ulong>(), allExcept: true);
		}
	}
	[BepInPlugin("LethalNetworkAPI", "LethalNetworkAPI", "2.1.6")]
	public class LethalNetworkAPIPlugin : BaseUnityPlugin
	{
		public static LethalNetworkAPIPlugin Instance;

		private static Harmony _harmony;

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			Instance = this;
			Logger = ((BaseUnityPlugin)this).Logger;
			_harmony = new Harmony("LethalNetworkAPI");
			NetcodePatcher();
			_harmony.PatchAll(typeof(NetworkObjectManager));
			Logger.LogInfo((object)"LethalNetworkAPI v2.1.6 has Loaded.");
		}

		private static void NetcodePatcher()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public static class LethalNetworkExtensions
	{
		public static PlayerControllerB? GetPlayerController(this ulong clientId)
		{
			return StartOfRound.Instance.allPlayerScripts[StartOfRound.Instance.ClientPlayerList[clientId]];
		}

		[Obsolete("GetPlayerFromId is deprecated, please use GetPlayerController instead.")]
		public static PlayerControllerB? GetPlayerFromId(this ulong clientId)
		{
			return clientId.GetPlayerController();
		}

		public static ulong GetClientId(this PlayerControllerB player)
		{
			return player.actualClientId;
		}

		public static LethalNetworkVariable<TData>? GetNetworkVariable<TData>(this NetworkBehaviour networkBehaviour, string identifier, bool serverOwned = false)
		{
			return ((Component)networkBehaviour).gameObject.NetworkVariable<TData>(identifier, serverOwned);
		}

		public static LethalNetworkVariable<TData>? GetNetworkVariable<TData>(this NetworkObject networkObject, string identifier, bool serverOwned = false)
		{
			return ((Component)networkObject).gameObject.NetworkVariable<TData>(identifier, serverOwned);
		}

		public static LethalNetworkVariable<TData>? GetNetworkVariable<TData>(this GameObject gameObject, string identifier, bool serverOwned = false)
		{
			return gameObject.NetworkVariable<TData>(identifier, serverOwned);
		}

		private static LethalNetworkVariable<TData>? NetworkVariable<TData>(this GameObject gameObject, string identifier, bool serverOwned)
		{
			string identifier2 = identifier;
			NetworkObject networkObjectComp = default(NetworkObject);
			if (!gameObject.TryGetComponent<NetworkObject>(ref networkObjectComp))
			{
				LethalNetworkAPIPlugin.Logger.LogError((object)$"Unable to find the network object component. Are you adding variable \"{identifier2}\" to a network object?");
				return null;
			}
			LethalNetworkVariable<TData> lethalNetworkVariable = (LethalNetworkVariable<TData>)NetworkHandler.Instance.ObjectNetworkVariableList.FirstOrDefault((ILethalNetVar i) => ((LethalNetworkVariable<TData>)i).Identifier == $"{identifier2}.{networkObjectComp.GlobalObjectIdHash}");
			if (lethalNetworkVariable != null)
			{
				return lethalNetworkVariable;
			}
			lethalNetworkVariable = new LethalNetworkVariable<TData>($"{identifier2}.{networkObjectComp.GlobalObjectIdHash}", networkObjectComp, serverOwned, 3);
			NetworkHandler.Instance.ObjectNetworkVariableList.Add(lethalNetworkVariable);
			return lethalNetworkVariable;
		}
	}
	public sealed class LethalClientMessage<TData> : LNetworkMessage
	{
		public event Action<TData>? OnReceived;

		public event Action<TData, ulong>? OnReceivedFromClient;

		public LethalClientMessage(string identifier, Action<TData>? onReceived = null, Action<TData, ulong>? onReceivedFromClient = null)
			: base(identifier)
		{
			NetworkHandler.OnClientMessage += ReceiveMessage;
			OnReceived += onReceived;
			OnReceivedFromClient += onReceivedFromClient;
		}

		public void SendServer(TData data)
		{
			//IL_001f: 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)
			if (!IsNetworkHandlerNull())
			{
				NetworkHandler.Instance.MessageServerRpc(Identifier, LethalNetworkSerializer.Serialize(data));
			}
		}

		public void SendAllClients(TData data, bool includeLocalClient = true, bool waitForServerResponse = false)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (!IsNetworkHandlerNull())
			{
				NetworkHandler.Instance.MessageServerRpc(Identifier, LethalNetworkSerializer.Serialize(data), toOtherClients: true, includeLocalClient && waitForServerResponse);
				if (includeLocalClient && !waitForServerResponse)
				{
					this.OnReceivedFromClient?.Invoke(data, NetworkManager.Singleton.LocalClientId);
				}
			}
		}

		private void ReceiveMessage(string identifier, byte[] data, ulong originatorClient)
		{
			if (!(identifier != Identifier))
			{
				if (originatorClient == 99999)
				{
					this.OnReceived?.Invoke(LethalNetworkSerializer.Deserialize<TData>(data));
				}
				else
				{
					this.OnReceivedFromClient?.Invoke(LethalNetworkSerializer.Deserialize<TData>(data), originatorClient);
				}
			}
		}
	}
	public class LethalServerMessage<TData> : LNetworkMessage
	{
		public event Action<TData, ulong>? OnReceived;

		public LethalServerMessage(string identifier, Action<TData, ulong>? onReceived = null)
			: base(identifier)
		{
			NetworkHandler.OnServerMessage += ReceiveServerMessage;
			OnReceived += onReceived;
		}

		public void SendClient(TData data, ulong clientId)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (!IsNetworkHandlerNull() && IsHostOrServer())
			{
				NetworkHandler.Instance.MessageClientRpc(Identifier, LethalNetworkSerializer.Serialize(data), 99999uL, GenerateClientParams(clientId));
			}
		}

		public void SendClients(TData data, IEnumerable<ulong> clientIds)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (!IsNetworkHandlerNull() && IsHostOrServer())
			{
				NetworkHandler.Instance.MessageClientRpc(Identifier, LethalNetworkSerializer.Serialize(data), 99999uL, GenerateClientParams(clientIds));
			}
		}

		public void SendAllClients(TData data, bool receiveOnHost = true)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//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)
			if (!IsNetworkHandlerNull() && IsHostOrServer())
			{
				if (receiveOnHost)
				{
					NetworkHandler.Instance.MessageClientRpc(Identifier, LethalNetworkSerializer.Serialize(data), 99999uL);
				}
				else
				{
					NetworkHandler.Instance.MessageClientRpc(Identifier, LethalNetworkSerializer.Serialize(data), 99999uL, GenerateClientParamsExceptHost());
				}
			}
		}

		private void ReceiveServerMessage(string identifier, byte[] data, ulong originClientId)
		{
			if (!(identifier != Identifier))
			{
				this.OnReceived?.Invoke(LethalNetworkSerializer.Deserialize<TData>(data), originClientId);
			}
		}
	}
	public abstract class LNetworkMessage : LethalNetwork
	{
		protected LNetworkMessage(string identifier)
			: base("msg." + identifier, "Message")
		{
		}
	}
	internal static class TextDefinitions
	{
		internal const string NotInLobbyMessage = "Unable to send the {0} with identifier \"{1}\" and data {{{2}}}. Is the player in a lobby?";

		internal const string UnableToFindGuid = "Unable to find plugin info for calling mod for {0} with identifier \"{1}\". Are you using BepInEx? \n Stacktrace: {2}";

		internal const string NotServerInfo = "The client {0} cannot use server methods. {1} Identifier: \"{2}\"";

		internal const string NotInLobbyEvent = "Unable to invoke the {1} with identifier \"{0}\". Is the player in a lobby?";

		internal const string NetworkHandlerDoesNotExist = "The NetworkHandler does not exist. This shouldn't occur!";

		internal const string TargetClientNotConnected = "The specified client {0} is not connected. {1} Identifier: \"{2}\"";

		internal const string TargetClientsNotConnected = "None of the specified clients {0} are connected. {1} Identifier: \"{2}\"";

		internal const string UnableToLocateNetworkObjectComponent = "Unable to find the network object component. Are you adding variable \"{0}\" to a network object?";
	}
	internal interface ILethalNetVar
	{
	}
	public sealed class LethalNetworkVariable<TData> : LethalNetwork, ILethalNetVar
	{
		private readonly bool _public;

		private readonly NetworkObject? _ownerObject;

		private bool _isDirty;

		private TData _value;

		public TData Value
		{
			get
			{
				return _value;
			}
			set
			{
				if (IsOwner && (value != null || _value != null) && (value == null || !value.Equals(_value)))
				{
					_value = value;
					_isDirty = true;
					this.OnValueChanged?.Invoke(_value);
				}
			}
		}

		private bool IsOwner
		{
			get
			{
				if (_public)
				{
					return true;
				}
				if ((Object)(object)NetworkManager.Singleton == (Object)null)
				{
					return true;
				}
				if (_ownerObject == null && NetworkManager.Singleton.IsServer)
				{
					return true;
				}
				if (_ownerObject != null)
				{
					return _ownerObject.OwnerClientId == NetworkManager.Singleton.LocalClientId;
				}
				return false;
			}
		}

		public event Action<TData>? OnValueChanged;

		public LethalNetworkVariable(string identifier)
			: this(identifier, (NetworkObject?)null, serverOwned: true, 2)
		{
		}

		internal LethalNetworkVariable(string identifier, NetworkObject? owner, bool serverOwned, int frameIndex)
			: base(identifier, "Variable", frameIndex + 1)
		{
			//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)
			_ownerObject = ((!serverOwned) ? owner : null);
			NetworkHandler.OnVariableUpdate += ReceiveUpdate;
			NetworkHandler.NetworkTick += OnNetworkTick;
			NetworkHandler.NetworkSpawn += delegate
			{
				if (!IsNetworkHandlerNull() && IsHostOrServer(log: false))
				{
					NetworkHandler.OnPlayerJoin += OnPlayerJoin;
					NetworkHandler.NetworkDespawn += ClearSubscriptions;
				}
			};
			NetworkHandler.GetVariableValue += delegate(string id, ulong clientId)
			{
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				if (!(id != Identifier) && !IsNetworkHandlerNull() && IsHostOrServer())
				{
					NetworkHandler.Instance.UpdateVariableClientRpc(Identifier, LethalNetworkSerializer.Serialize(_value), GenerateClientParams(clientId));
				}
			};
			if (typeof(LethalNetworkVariable<TData>).GetCustomAttributes(typeof(PublicNetworkVariableAttribute), inherit: true).Any())
			{
				_public = true;
			}
			if (!IsNetworkHandlerNull(log: false))
			{
				if (IsHostOrServer())
				{
					NetworkHandler.OnPlayerJoin += OnPlayerJoin;
				}
				else
				{
					NetworkHandler.Instance.GetVariableValueServerRpc(Identifier);
				}
			}
		}

		private void OnPlayerJoin(ulong clientId)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			if (!IsNetworkHandlerNull() && IsHostOrServer())
			{
				NetworkHandler.Instance.UpdateVariableClientRpc(Identifier, LethalNetworkSerializer.Serialize(_value), GenerateClientParams(clientId));
			}
		}

		private void ClearSubscriptions()
		{
			NetworkHandler.OnPlayerJoin -= OnPlayerJoin;
			NetworkHandler.NetworkDespawn -= ClearSubscriptions;
		}

		private void SendUpdate()
		{
			//IL_002a: 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)
			if (!IsNetworkHandlerNull() && IsOwner)
			{
				NetworkHandler.Instance.UpdateVariableServerRpc(Identifier, LethalNetworkSerializer.Serialize(_value));
			}
		}

		private void ReceiveUpdate(string identifier, byte[] data)
		{
			if (!(identifier != Identifier))
			{
				TData val = LethalNetworkSerializer.Deserialize<TData>(data);
				if (val != null)
				{
					_value = val;
					this.OnValueChanged?.Invoke(val);
				}
			}
		}

		private void OnNetworkTick()
		{
			if (_isDirty && _value != null)
			{
				SendUpdate();
				_isDirty = false;
			}
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
	public class PublicNetworkVariableAttribute : Attribute
	{
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LethalNetworkAPI";

		public const string PLUGIN_NAME = "LethalNetworkAPI";

		public const string PLUGIN_VERSION = "2.1.6";
	}
}
namespace LethalNetworkAPI.Serializable
{
	internal static class LethalNetworkSerializer
	{
		internal static byte[] Serialize<T>(T value)
		{
			//IL_003e: 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)
			if (value == null)
			{
				return Array.Empty<byte>();
			}
			object obj = value;
			GameObject val = (GameObject)((obj is GameObject) ? obj : null);
			if (val != null)
			{
				return SerializationUtility.SerializeValue<NetworkObjectReference>(NetworkObjectReference.op_Implicit(val), (DataFormat)0, (SerializationContext)null);
			}
			object obj2 = value;
			NetworkObject val2 = (NetworkObject)((obj2 is NetworkObject) ? obj2 : null);
			if (val2 != null)
			{
				return SerializationUtility.SerializeValue<NetworkObjectReference>(NetworkObjectReference.op_Implicit(val2), (DataFormat)0, (SerializationContext)null);
			}
			object obj3 = value;
			NetworkBehaviour val3 = (NetworkBehaviour)((obj3 is NetworkBehaviour) ? obj3 : null);
			if (val3 != null)
			{
				return SerializationUtility.SerializeValue<NetworkBehaviourReference>(NetworkBehaviourReference.op_Implicit(val3), (DataFormat)0, (SerializationContext)null);
			}
			return SerializationUtility.SerializeValue<T>(value, (DataFormat)0, (SerializationContext)null);
		}

		internal static T Deserialize<T>(byte[] data)
		{
			//IL_0042: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			if (data.Length == 0)
			{
				return default(T);
			}
			T val = default(T);
			if (!(val is GameObject))
			{
				if (!(val is NetworkObject))
				{
					if (val is NetworkBehaviour)
					{
						return (T)(object)NetworkBehaviourReference.op_Implicit(SerializationUtility.DeserializeValue<NetworkBehaviourReference>(data, (DataFormat)0, (DeserializationContext)null));
					}
					return SerializationUtility.DeserializeValue<T>(data, (DataFormat)0, (DeserializationContext)null);
				}
				return (T)(object)NetworkObjectReference.op_Implicit(SerializationUtility.DeserializeValue<NetworkObjectReference>(data, (DataFormat)0, (DeserializationContext)null));
			}
			return (T)(object)NetworkObjectReference.op_Implicit(SerializationUtility.DeserializeValue<NetworkObjectReference>(data, (DataFormat)0, (DeserializationContext)null));
		}
	}
	public class NetworkBehaviourReferenceFormatter : MinimalBaseFormatter<NetworkBehaviourReference>
	{
		private static readonly Serializer<ushort> UInt16Serializer = Serializer.Get<ushort>();

		private static readonly Serializer<NetworkObjectReference> NetworkObjectReferenceSerializer = Serializer.Get<NetworkObjectReference>();

		protected override void Read(ref NetworkBehaviourReference value, IDataReader reader)
		{
			//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)
			value.m_NetworkObjectReference = NetworkObjectReferenceSerializer.ReadValue(reader);
			value.m_NetworkBehaviourId = UInt16Serializer.ReadValue(reader);
		}

		protected override void Write(ref NetworkBehaviourReference value, IDataWriter writer)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			NetworkObjectReferenceSerializer.WriteValue(value.m_NetworkObjectReference, writer);
			UInt16Serializer.WriteValue(value.m_NetworkBehaviourId, writer);
		}
	}
	internal class NetworkObjectReferenceFormatter : MinimalBaseFormatter<NetworkObjectReference>
	{
		private static readonly Serializer<ulong> UInt64Serializer = Serializer.Get<ulong>();

		protected override void Read(ref NetworkObjectReference value, IDataReader reader)
		{
			((NetworkObjectReference)(ref value)).NetworkObjectId = UInt64Serializer.ReadValue(reader);
		}

		protected override void Write(ref NetworkObjectReference value, IDataWriter writer)
		{
			UInt64Serializer.WriteValue(((NetworkObjectReference)(ref value)).NetworkObjectId, writer);
		}
	}
}
namespace LethalNetworkAPI.Networking
{
	internal class NetworkHandler : NetworkBehaviour
	{
		internal readonly List<ILethalNetVar> ObjectNetworkVariableList = new List<ILethalNetVar>();

		internal static NetworkHandler? Instance { get; private set; }

		internal static event Action? NetworkSpawn;

		internal static event Action? NetworkDespawn;

		internal static event Action? NetworkTick;

		internal static event Action<ulong>? OnPlayerJoin;

		internal static event Action<string, byte[], ulong>? OnServerMessage;

		internal static event Action<string, byte[], ulong>? OnClientMessage;

		internal static event Action<string, byte[]>? OnVariableUpdate;

		internal static event Action<string, ulong>? GetVariableValue;

		internal static event Action<string, ulong>? OnServerEvent;

		internal static event Action<string, ulong>? OnClientEvent;

		internal static event Action<string, double, ulong>? OnSyncedServerEvent;

		internal static event Action<string, double, ulong>? OnSyncedClientEvent;

		public override void OnNetworkSpawn()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Object.Destroy((Object)(object)this);
				return;
			}
			Instance = this;
			NetworkHandler.NetworkSpawn?.Invoke();
			((NetworkBehaviour)this).NetworkManager.NetworkTickSystem.Tick += NetworkHandler.NetworkTick;
			NetworkManager.Singleton.OnClientConnectedCallback += OnClientConnectedCallback;
		}

		internal void Clean()
		{
			NetworkHandler.NetworkDespawn?.Invoke();
			NetworkHandler.OnPlayerJoin = null;
			NetworkHandler.NetworkDespawn = null;
			Instance = null;
		}

		private void OnClientConnectedCallback(ulong client)
		{
			NetworkHandler.OnPlayerJoin?.Invoke(client);
		}

		[ServerRpc(RequireOwnership = false)]
		internal void MessageServerRpc(string identifier, byte[] data, bool toOtherClients = false, bool sendToOriginator = false, ServerRpcParams serverRpcParams = default(ServerRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: 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_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: 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_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: 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)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: 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)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3629803754u, serverRpcParams, (RpcDelivery)0);
				bool flag = identifier != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(identifier, false);
				}
				bool flag2 = data != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives));
				if (flag2)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe<byte>(data, default(ForPrimitives));
				}
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref toOtherClients, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref sendToOriginator, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 3629803754u, serverRpcParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			ServerRpcParams serverRpcParams2 = serverRpcParams;
			if (!toOtherClients)
			{
				NetworkHandler.OnServerMessage?.Invoke(identifier, data, serverRpcParams2.Receive.SenderClientId);
			}
			else if (!sendToOriginator)
			{
				NativeArray<ulong> val2 = default(NativeArray<ulong>);
				val2..ctor(NetworkManager.Singleton.ConnectedClientsIds.Where((ulong i) => i != serverRpcParams2.Receive.SenderClientId).ToArray(), (Allocator)4);
				if (((IEnumerable<ulong>)(object)val2).Any())
				{
					MessageClientRpc(identifier, data, serverRpcParams2.Receive.SenderClientId, new ClientRpcParams
					{
						Send = new ClientRpcSendParams
						{
							TargetClientIdsNativeArray = val2
						}
					});
				}
			}
			else
			{
				MessageClientRpc(identifier, data, serverRpcParams2.Receive.SenderClientId);
			}
		}

		[ClientRpc]
		internal void MessageClientRpc(string identifier, byte[] data, ulong originatorClient = 99999uL, ClientRpcParams clientRpcParams = default(ClientRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: 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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3740138170u, clientRpcParams, (RpcDelivery)0);
				bool flag = identifier != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(identifier, false);
				}
				bool flag2 = data != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives));
				if (flag2)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe<byte>(data, default(ForPrimitives));
				}
				BytePacker.WriteValueBitPacked(val, originatorClient);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 3740138170u, clientRpcParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				NetworkHandler.OnClientMessage?.Invoke(identifier, data, originatorClient);
				clientRpcParams.Send.TargetClientIdsNativeArray?.Dispose();
			}
		}

		[ServerRpc(RequireOwnership = false)]
		internal void EventServerRpc(string identifier, bool toOtherClients = false, bool sendToOriginator = false, ServerRpcParams serverRpcParams = default(ServerRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: 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_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: 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_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: 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)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1959733556u, serverRpcParams, (RpcDelivery)0);
				bool flag = identifier != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(identifier, false);
				}
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref toOtherClients, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref sendToOriginator, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 1959733556u, serverRpcParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			ServerRpcParams serverRpcParams2 = serverRpcParams;
			if (!toOtherClients)
			{
				NetworkHandler.OnServerEvent?.Invoke(identifier, serverRpcParams2.Receive.SenderClientId);
			}
			else if (!sendToOriginator)
			{
				NativeArray<ulong> val2 = default(NativeArray<ulong>);
				val2..ctor(NetworkManager.Singleton.ConnectedClientsIds.Where((ulong i) => i != serverRpcParams2.Receive.SenderClientId).ToArray(), (Allocator)4);
				if (((IEnumerable<ulong>)(object)val2).Any())
				{
					EventClientRpc(identifier, serverRpcParams2.Receive.SenderClientId, new ClientRpcParams
					{
						Send = new ClientRpcSendParams
						{
							TargetClientIdsNativeArray = val2
						}
					});
				}
			}
			else
			{
				EventClientRpc(identifier, serverRpcParams2.Receive.SenderClientId);
			}
		}

		[ClientRpc]
		internal void EventClientRpc(string identifier, ulong originatorClient = 99999uL, ClientRpcParams clientRpcParams = default(ClientRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: 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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(53735464u, clientRpcParams, (RpcDelivery)0);
				bool flag = identifier != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(identifier, false);
				}
				BytePacker.WriteValueBitPacked(val, originatorClient);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 53735464u, clientRpcParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				NetworkHandler.OnClientEvent?.Invoke(identifier, originatorClient);
				clientRpcParams.Send.TargetClientIdsNativeArray?.Dispose();
			}
		}

		[ServerRpc(RequireOwnership = false)]
		internal void SyncedEventServerRpc(string identifier, double time, ServerRpcParams serverRpcParams = default(ServerRpcParams))
		{
			//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)
			//IL_0120: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(2669215490u, serverRpcParams, (RpcDelivery)0);
				bool flag = identifier != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(identifier, false);
				}
				((FastBufferWriter)(ref val)).WriteValueSafe<double>(ref time, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 2669215490u, serverRpcParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				NetworkHandler.OnSyncedServerEvent?.Invoke(identifier, time, serverRpcParams.Receive.SenderClientId);
			}
		}

		[ClientRpc]
		internal void SyncedEventClientRpc(string identifier, double time, ulong originatorClient, ClientRpcParams clientRpcParams = default(ClientRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: 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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(899832842u, clientRpcParams, (RpcDelivery)0);
				bool flag = identifier != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(identifier, false);
				}
				((FastBufferWriter)(ref val)).WriteValueSafe<double>(ref time, default(ForPrimitives));
				BytePacker.WriteValueBitPacked(val, originatorClient);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 899832842u, clientRpcParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				NetworkHandler.OnSyncedClientEvent?.Invoke(identifier, time, originatorClient);
				clientRpcParams.Send.TargetClientIdsNativeArray?.Dispose();
			}
		}

		[ServerRpc(RequireOwnership = false)]
		internal void UpdateVariableServerRpc(string identifier, byte[] data, ServerRpcParams serverRpcParams = default(ServerRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: 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)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1359429614u, serverRpcParams, (RpcDelivery)0);
				bool flag = identifier != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(identifier, false);
				}
				bool flag2 = data != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives));
				if (flag2)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe<byte>(data, default(ForPrimitives));
				}
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 1359429614u, serverRpcParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ServerRpcParams serverRpcParams2 = serverRpcParams;
				if (serverRpcParams2.Receive.SenderClientId != 0L)
				{
					NetworkHandler.OnVariableUpdate?.Invoke(identifier, data);
				}
				NativeArray<ulong> val2 = default(NativeArray<ulong>);
				val2..ctor(NetworkManager.Singleton.ConnectedClientsIds.Where((ulong i) => i != serverRpcParams2.Receive.SenderClientId).ToArray(), (Allocator)4);
				if (((IEnumerable<ulong>)(object)val2).Any())
				{
					UpdateVariableClientRpc(identifier, data, new ClientRpcParams
					{
						Send = new ClientRpcSendParams
						{
							TargetClientIdsNativeArray = val2
						}
					});
				}
			}
		}

		[ClientRpc]
		internal void UpdateVariableClientRpc(string identifier, byte[] data, ClientRpcParams clientRpcParams = default(ClientRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: 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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1641402893u, clientRpcParams, (RpcDelivery)0);
				bool flag = identifier != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(identifier, false);
				}
				bool flag2 = data != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives));
				if (flag2)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe<byte>(data, default(ForPrimitives));
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 1641402893u, clientRpcParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				NetworkHandler.OnVariableUpdate?.Invoke(identifier, data);
				clientRpcParams.Send.TargetClientIdsNativeArray?.Dispose();
			}
		}

		[ServerRpc(RequireOwnership = false)]
		internal void GetVariableValueServerRpc(string identifier, ServerRpcParams serverRpcParams = default(ServerRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: 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)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(2442151635u, serverRpcParams, (RpcDelivery)0);
				bool flag = identifier != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(identifier, false);
				}
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 2442151635u, serverRpcParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				NetworkHandler.GetVariableValue?.Invoke(identifier, serverRpcParams.Receive.SenderClientId);
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_NetworkHandler()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3629803754u, new RpcReceiveHandler(__rpc_handler_3629803754));
			NetworkManager.__rpc_func_table.Add(3740138170u, new RpcReceiveHandler(__rpc_handler_3740138170));
			NetworkManager.__rpc_func_table.Add(1959733556u, new RpcReceiveHandler(__rpc_handler_1959733556));
			NetworkManager.__rpc_func_table.Add(53735464u, new RpcReceiveHandler(__rpc_handler_53735464));
			NetworkManager.__rpc_func_table.Add(2669215490u, new RpcReceiveHandler(__rpc_handler_2669215490));
			NetworkManager.__rpc_func_table.Add(899832842u, new RpcReceiveHandler(__rpc_handler_899832842));
			NetworkManager.__rpc_func_table.Add(1359429614u, new RpcReceiveHandler(__rpc_handler_1359429614));
			NetworkManager.__rpc_func_table.Add(1641402893u, new RpcReceiveHandler(__rpc_handler_1641402893));
			NetworkManager.__rpc_func_table.Add(2442151635u, new RpcReceiveHandler(__rpc_handler_2442151635));
		}

		private static void __rpc_handler_3629803754(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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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 identifier = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref identifier, false);
				}
				bool flag2 = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
				byte[] data = null;
				if (flag2)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref data, default(ForPrimitives));
				}
				bool toOtherClients = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref toOtherClients, default(ForPrimitives));
				bool sendToOriginator = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref sendToOriginator, default(ForPrimitives));
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NetworkHandler)(object)target).MessageServerRpc(identifier, data, toOtherClients, sendToOriginator, server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3740138170(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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00bd: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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 identifier = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref identifier, false);
				}
				bool flag2 = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
				byte[] data = null;
				if (flag2)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref data, default(ForPrimitives));
				}
				ulong originatorClient = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref originatorClient);
				ClientRpcParams client = rpcParams.Client;
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((NetworkHandler)(object)target).MessageClientRpc(identifier, data, originatorClient, client);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1959733556(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_0082: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string identifier = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref identifier, false);
				}
				bool toOtherClients = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref toOtherClients, default(ForPrimitives));
				bool sendToOriginator = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref sendToOriginator, default(ForPrimitives));
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NetworkHandler)(object)target).EventServerRpc(identifier, toOtherClients, sendToOriginator, server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_53735464(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_005b: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_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 identifier = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref identifier, false);
				}
				ulong originatorClient = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref originatorClient);
				ClientRpcParams client = rpcParams.Client;
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((NetworkHandler)(object)target).EventClientRpc(identifier, originatorClient, client);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2669215490(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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string identifier = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref identifier, false);
				}
				double time = default(double);
				((FastBufferReader)(ref reader)).ReadValueSafe<double>(ref time, default(ForPrimitives));
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NetworkHandler)(object)target).SyncedEventServerRpc(identifier, time, server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_899832842(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_0076: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_00b9: 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 identifier = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref identifier, false);
				}
				double time = default(double);
				((FastBufferReader)(ref reader)).ReadValueSafe<double>(ref time, default(ForPrimitives));
				ulong originatorClient = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref originatorClient);
				ClientRpcParams client = rpcParams.Client;
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((NetworkHandler)(object)target).SyncedEventClientRpc(identifier, time, originatorClient, client);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1359429614(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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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 identifier = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref identifier, false);
				}
				bool flag2 = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
				byte[] data = null;
				if (flag2)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref data, default(ForPrimitives));
				}
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NetworkHandler)(object)target).UpdateVariableServerRpc(identifier, data, server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1641402893(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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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 identifier = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref identifier, false);
				}
				bool flag2 = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
				byte[] data = null;
				if (flag2)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref data, default(ForPrimitives));
				}
				ClientRpcParams client = rpcParams.Client;
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((NetworkHandler)(object)target).UpdateVariableClientRpc(identifier, data, client);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2442151635(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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_0089: 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 identifier = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref identifier, false);
				}
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NetworkHandler)(object)target).GetVariableValueServerRpc(identifier, server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string? __getTypeName()
		{
			return "NetworkHandler";
		}
	}
	[HarmonyPatch]
	[HarmonyPriority(800)]
	[HarmonyWrapSafe]
	internal class NetworkObjectManager
	{
		private static GameObject _networkPrefab;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		private static void Init()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			if (!((Object)(object)_networkPrefab != (Object)null))
			{
				GameObject val = new GameObject("NetworkAPIContainer")
				{
					hideFlags = (HideFlags)61
				};
				val.SetActive(false);
				_networkPrefab = MakePrefab<NetworkHandler>("LethalNetworkAPI.Handler", val, 889887688u);
			}
		}

		private static GameObject MakePrefab<T>(string name, GameObject parent, uint overrideGuid = 0u) where T : NetworkBehaviour
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent.transform);
			val.AddComponent<NetworkObject>();
			val.AddComponent<T>();
			((Object)val).hideFlags = (HideFlags)61;
			if (overrideGuid != 0)
			{
				val.GetComponent<NetworkObject>().GlobalObjectIdHash = overrideGuid;
			}
			else
			{
				uint globalObjectIdHash = BitConverter.ToUInt32(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(Assembly.GetExecutingAssembly().GetName().Name + name)), 0);
				val.GetComponent<NetworkObject>().GlobalObjectIdHash = globalObjectIdHash;
			}
			NetworkManager.Singleton.AddNetworkPrefab(val);
			return val;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		private static void SpawnNetworkHandler()
		{
			//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 (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				GameObject val = Object.Instantiate<GameObject>(_networkPrefab, Vector3.zero, Quaternion.identity, ((Component)StartOfRound.Instance).transform);
				val.GetComponent<NetworkObject>().Spawn(false);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "OnDisable")]
		private static void OnDisconnect()
		{
			NetworkHandler.Instance.Clean();
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	int IReadOnlyCollection<T>.Count => _items.Length;

	T IReadOnlyList<T>.this[int index] => _items[index];

	int ICollection<T>.Count => _items.Length;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlyArray(T[] items)
	{
		_items = items;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return ((IEnumerable)_items).GetEnumerator();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return ((IEnumerable<T>)_items).GetEnumerator();
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return ((ICollection<T>)_items).Contains(item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		((ICollection<T>)_items).CopyTo(array, arrayIndex);
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		return ((IList<T>)_items).IndexOf(item);
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}
namespace LethalNetworkAPI.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}

plugins/LethalPresents.dll

Decompiled 9 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On;
using Unity.Netcode;
using UnityEngine;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LethalPresents
{
	[BepInPlugin("LethalPresents", "LethalPresents", "1.0.4")]
	public class LethalPresentsPlugin : BaseUnityPlugin
	{
		public static ManualLogSource mls;

		private static int spawnChance = 5;

		private static string[] disabledEnemies = new string[0];

		private static bool IsAllowlist = false;

		private static bool ShouldSpawnMines = false;

		private static bool ShouldSpawnTurrets = false;

		private static bool ShouldSpawnBees = false;

		private static bool isHost => ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost;

		private static SelectableLevel currentLevel => RoundManager.Instance.currentLevel;

		internal static T GetPrivateField<T>(object instance, string fieldName)
		{
			FieldInfo field = instance.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic);
			return (T)field.GetValue(instance);
		}

		private void Awake()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			mls = Logger.CreateLogSource("LethalPresents");
			mls.LogInfo((object)"Plugin LethalPresents is loaded!");
			loadConfig();
			RoundManager.AdvanceHourAndSpawnNewBatchOfEnemies += new hook_AdvanceHourAndSpawnNewBatchOfEnemies(updateCurrentLevelInfo);
			GiftBoxItem.OpenGiftBoxServerRpc += new hook_OpenGiftBoxServerRpc(spawnRandomEntity);
		}

		private void updateCurrentLevelInfo(orig_AdvanceHourAndSpawnNewBatchOfEnemies orig, RoundManager self)
		{
			orig.Invoke(self);
			mls.LogInfo((object)"List of spawnable enemies (inside):");
			currentLevel.Enemies.ForEach(delegate(SpawnableEnemyWithRarity e)
			{
				mls.LogInfo((object)((Object)e.enemyType).name);
			});
			mls.LogInfo((object)"List of spawnable enemies (outside):");
			currentLevel.OutsideEnemies.ForEach(delegate(SpawnableEnemyWithRarity e)
			{
				mls.LogInfo((object)((Object)e.enemyType).name);
			});
		}

		private void loadConfig()
		{
			spawnChance = ((BaseUnityPlugin)this).Config.Bind<int>("General", "SpawnChance", 5, "Chance of spawning an enemy when opening a present [0-100]").Value;
			disabledEnemies = ((BaseUnityPlugin)this).Config.Bind<string>("General", "EnemyBlocklist", "", "Enemy blocklist separated by , and without whitespaces").Value.Split(",");
			IsAllowlist = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "IsAllowlist", false, "Turns blocklist into allowlist, blocklist must contain at least one inside and one outside enemy, use at your own risk").Value;
			ShouldSpawnMines = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShouldSpawnMines", true, "Add mines to the spawn pool").Value;
			ShouldSpawnTurrets = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShouldSpawnTurrets", true, "Add turrets to the spawn pool").Value;
			if (IsAllowlist)
			{
				mls.LogInfo((object)"Only following enemies can spawn from the gift:");
			}
			else
			{
				mls.LogInfo((object)"Following enemies wont be spawned from the gift:");
			}
			string[] array = disabledEnemies;
			foreach (string text in array)
			{
				mls.LogInfo((object)text);
			}
		}

		private void spawnRandomEntity(orig_OpenGiftBoxServerRpc orig, GiftBoxItem self)
		{
			//IL_00fe: 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)
			NetworkManager networkManager = ((NetworkBehaviour)self).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				orig.Invoke(self);
				return;
			}
			int privateField = GetPrivateField<int>(self, "__rpc_exec_stage");
			mls.LogInfo((object)("IsServer:" + networkManager.IsServer + " IsHost:" + networkManager.IsHost + " __rpc_exec_stage:" + privateField));
			if (privateField != 1 || !isHost)
			{
				orig.Invoke(self);
				return;
			}
			int num = Random.Range(1, 100);
			mls.LogInfo((object)("Player's fortune:" + num));
			if (num >= spawnChance)
			{
				orig.Invoke(self);
				return;
			}
			chooseAndSpawnEnemy(((GrabbableObject)self).isInFactory, ((Component)self).transform.position, ((Component)self.previousPlayerHeldBy).transform.position);
			orig.Invoke(self);
		}

		private static void chooseAndSpawnEnemy(bool inside, Vector3 pos, Vector3 player_pos)
		{
			//IL_000b: 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_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: 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_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource obj = mls;
			Vector3 val = player_pos;
			obj.LogInfo((object)("Player pos " + ((object)(Vector3)(ref val)).ToString()));
			List<SpawnableEnemyWithRarity> list = currentLevel.Enemies.Where((SpawnableEnemyWithRarity e) => disabledEnemies.Contains(((Object)e.enemyType).name) ? IsAllowlist : (!IsAllowlist)).ToList();
			List<SpawnableEnemyWithRarity> list2 = currentLevel.OutsideEnemies.Where((SpawnableEnemyWithRarity e) => disabledEnemies.Contains(((Object)e.enemyType).name) ? IsAllowlist : (!IsAllowlist)).ToList();
			int num = Random.Range(1, 2 + (list2.Count + list.Count) / 2);
			if (num == 2 && !ShouldSpawnMines)
			{
				num = 1;
			}
			if (num == 1 && !ShouldSpawnTurrets)
			{
				num = 2;
			}
			if (num == 2 && !ShouldSpawnMines)
			{
				num = 3;
			}
			switch (num)
			{
			case 1:
			{
				SpawnableMapObject[] spawnableMapObjects2 = currentLevel.spawnableMapObjects;
				foreach (SpawnableMapObject val4 in spawnableMapObjects2)
				{
					if (!((Object)(object)val4.prefabToSpawn.GetComponentInChildren<Turret>() == (Object)null))
					{
						pos -= Vector3.up * 1.8f;
						GameObject val5 = Object.Instantiate<GameObject>(val4.prefabToSpawn, pos, Quaternion.identity);
						val5.transform.position = pos;
						Transform transform = val5.transform;
						val = player_pos - pos;
						transform.forward = ((Vector3)(ref val)).normalized;
						val5.GetComponent<NetworkObject>().Spawn(true);
						ManualLogSource obj3 = mls;
						val = pos;
						obj3.LogInfo((object)("Tried spawning a turret at " + ((object)(Vector3)(ref val)).ToString()));
						break;
					}
				}
				return;
			}
			case 2:
			{
				SpawnableMapObject[] spawnableMapObjects = currentLevel.spawnableMapObjects;
				foreach (SpawnableMapObject val2 in spawnableMapObjects)
				{
					if (!((Object)(object)val2.prefabToSpawn.GetComponentInChildren<Landmine>() == (Object)null))
					{
						pos -= Vector3.up * 1.8f;
						GameObject val3 = Object.Instantiate<GameObject>(val2.prefabToSpawn, pos, Quaternion.identity);
						val3.transform.position = pos;
						val3.transform.forward = new Vector3(1f, 0f, 0f);
						val3.GetComponent<NetworkObject>().Spawn(true);
						ManualLogSource obj2 = mls;
						val = pos;
						obj2.LogInfo((object)("Tried spawning a mine at " + ((object)(Vector3)(ref val)).ToString()));
						break;
					}
				}
				return;
			}
			}
			SpawnableEnemyWithRarity val6;
			if (inside)
			{
				if (list.Count < 1)
				{
					mls.LogInfo((object)"Cant spawn enemy - no other enemies present to copy from");
					return;
				}
				val6 = list[Random.Range(0, list.Count - 1)];
			}
			else
			{
				if (list2.Count < 1)
				{
					mls.LogInfo((object)"Cant spawn enemy - no other enemies present to copy from");
					return;
				}
				val6 = list2[Random.Range(0, list2.Count - 1)];
			}
			pos += Vector3.up * 0.25f;
			ManualLogSource obj4 = mls;
			string enemyName = val6.enemyType.enemyName;
			val = pos;
			obj4.LogInfo((object)("Spawning " + enemyName + " at " + ((object)(Vector3)(ref val)).ToString()));
			SpawnEnemy(val6, pos, 0f);
		}

		private static void SpawnEnemy(SpawnableEnemyWithRarity enemy, Vector3 pos, float rot)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			RoundManager.Instance.SpawnEnemyGameObject(pos, rot, -1, enemy.enemyType);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "LethalPresents";

		public const string PLUGIN_NAME = "LethalPresents";

		public const string PLUGIN_VERSION = "1.0.4";
	}
}

plugins/LethalProgression.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalProgression.Config;
using LethalProgression.GUI;
using LethalProgression.Patches;
using LethalProgression.Skills;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LethalProgression")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Progression Mod")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+3dc7eef442dce452b17ebbe7d003936b2d4276a3")]
[assembly: AssemblyProduct("LethalProgression")]
[assembly: AssemblyTitle("LethalProgression")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
internal class <Module>
{
	static <Module>()
	{
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<float>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<float>();
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LethalProgression
{
	[HarmonyPatch]
	internal class LP_NetworkManager
	{
		public static GameObject xpNetworkObject;

		public static XP xpInstance;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		public static void Init()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			if (!((Object)(object)xpNetworkObject != (Object)null))
			{
				xpNetworkObject = (GameObject)LethalPlugin.skillBundle.LoadAsset("LP_XPHandler");
				xpNetworkObject.AddComponent<XP>();
				NetworkManager.Singleton.AddNetworkPrefab(xpNetworkObject);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		private static void SpawnNetworkHandler()
		{
			//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)
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				GameObject val = Object.Instantiate<GameObject>(xpNetworkObject, Vector3.zero, Quaternion.identity);
				val.GetComponent<NetworkObject>().Spawn(false);
				xpInstance = val.GetComponent<XP>();
				LethalPlugin.Log.LogInfo((object)"XPHandler Initialized.");
			}
		}
	}
	[BepInPlugin("Stoneman.LethalProgression", "Lethal Progression", "1.3.2")]
	internal class LethalPlugin : BaseUnityPlugin
	{
		private const string modGUID = "Stoneman.LethalProgression";

		private const string modName = "Lethal Progression";

		private const string modVersion = "1.3.2";

		private const string modAuthor = "Stoneman";

		public static AssetBundle skillBundle;

		internal static ManualLogSource Log;

		internal static bool ReservedSlots;

		public static LethalPlugin Instance { get; private set; }

		private void Awake()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			Instance = this;
			Harmony val = new Harmony("Stoneman.LethalProgression");
			val.PatchAll(Assembly.GetExecutingAssembly());
			skillBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "skillmenu"));
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"Lethal Progression loaded.");
			foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
			{
				if (pluginInfo.Value.Metadata.GUID.IndexOf("ReservedItem") >= 0)
				{
					ReservedSlots = true;
				}
				if (pluginInfo.Value.Metadata.GUID.IndexOf("mikestweaks") < 0)
				{
					continue;
				}
				ConfigEntryBase[] configEntries = pluginInfo.Value.Instance.Config.GetConfigEntries();
				ConfigEntryBase[] array = configEntries;
				foreach (ConfigEntryBase val2 in array)
				{
					if (val2.Definition.Key == "ExtraItemSlots")
					{
						if (int.Parse(val2.GetSerializedValue()) > 0)
						{
							ReservedSlots = true;
						}
						break;
					}
				}
			}
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array2 = types;
			foreach (Type type in array2)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array3 = methods;
				foreach (MethodInfo methodInfo in array3)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			SkillConfig.InitConfig();
		}

		public void BindConfig<T>(string section, string key, T defaultValue, string description = "")
		{
			((BaseUnityPlugin)this).Config.Bind<T>(section, key, defaultValue, description);
		}

		public IDictionary<string, string> GetAllConfigEntries()
		{
			return ((BaseUnityPlugin)this).Config.GetConfigEntries().ToDictionary((ConfigEntryBase entry) => entry.Definition.Key, (ConfigEntryBase entry) => entry.GetSerializedValue());
		}
	}
	internal class XP : NetworkBehaviour
	{
		public NetworkVariable<int> xpPoints = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<int> xpLevel = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<int> profit = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<int> xpReq = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<float> teamLootValue = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public int skillPoints;

		public SkillList skillList;

		public SkillsGUI guiObj;

		public bool Initialized = false;

		public void Start()
		{
			LethalPlugin.Log.LogInfo((object)"XP Network Behavior Made!");
			PlayerConnect_ServerRpc();
		}

		public void LoadSaveData()
		{
			int num = GameNetworkManager.Instance.saveFileNum + 1;
			string path = Application.persistentDataPath + "/lethalprogression/save" + num + ".txt";
			if (!File.Exists(path))
			{
				Directory.CreateDirectory(Application.persistentDataPath + "/lethalprogression");
				File.WriteAllText(path, "");
				string text = "";
				text += "0\n";
				text += "0\n";
				text += "0\n";
				File.WriteAllText(path, text);
			}
			string[] array = File.ReadAllLines(path);
			LethalPlugin.Log.LogError((object)"Loading XP!");
			xpLevel.Value = int.Parse(array[0]);
			xpPoints.Value = int.Parse(array[1]);
			profit.Value = int.Parse(array[2]);
			xpReq.Value = GetXPRequirement();
			LethalPlugin.Log.LogInfo((object)GetXPRequirement().ToString());
		}

		public int GetXPRequirement()
		{
			int connectedPlayersAmount = StartOfRound.Instance.connectedPlayersAmount;
			int timesFulfilledQuota = TimeOfDay.Instance.timesFulfilledQuota;
			int num = int.Parse(SkillConfig.hostConfig["XP Minimum"]);
			int num2 = int.Parse(SkillConfig.hostConfig["XP Maximum"]);
			int num3 = int.Parse(SkillConfig.hostConfig["Person Multiplier"]);
			int num4 = connectedPlayersAmount * num3;
			int num5 = num + num4;
			int num6 = int.Parse(SkillConfig.hostConfig["Quota Multiplier"]);
			int num7 = timesFulfilledQuota * num6;
			num5 += (int)((float)num5 * ((float)num7 / 100f));
			if (num5 > num2)
			{
				num5 = num2;
			}
			LethalPlugin.Log.LogInfo((object)$"{connectedPlayersAmount} players, {timesFulfilledQuota} quotas, {num} initial cost, {num4} person value, {num7} quota value, {num5} total cost.");
			return num5;
		}

		public int GetXP()
		{
			return xpPoints.Value;
		}

		public int GetLevel()
		{
			return xpLevel.Value;
		}

		public int GetProfit()
		{
			return profit.Value;
		}

		public int GetSkillPoints()
		{
			return skillPoints;
		}

		public void SetSkillPoints(int num)
		{
			skillPoints = num;
		}

		public void AddSkillPoint()
		{
			skillPoints++;
		}

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

		public IEnumerator XPRequirementCoroutine()
		{
			yield return (object)new WaitForSeconds(0.5f);
			xpReq.Value = GetXPRequirement();
		}

		[ServerRpc(RequireOwnership = false)]
		public void AddXPServerRPC(int xp)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3074971930u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, xp);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3074971930u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			int xP = GetXP();
			NetworkVariable<int> obj = xpPoints;
			obj.Value += xp;
			NetworkVariable<int> obj2 = profit;
			obj2.Value += xp;
			int num = GetXP();
			XPHUDUpdate_ClientRPC(xP, num, xp);
			if (num >= xpReq.Value)
			{
				int num2 = 0;
				while (num >= xpReq.Value)
				{
					num2++;
					num -= xpReq.Value;
					Givepoint_ClientRPC();
				}
				xpPoints.Value = num;
				NetworkVariable<int> obj3 = xpLevel;
				obj3.Value += num2;
				LevelUp_ClientRPC();
			}
		}

		[ClientRpc]
		public void XPHUDUpdate_ClientRPC(int oldXP, int newXP, int xpGained)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3462423043u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, oldXP);
					BytePacker.WriteValueBitPacked(val2, newXP);
					BytePacker.WriteValueBitPacked(val2, xpGained);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3462423043u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					HUDManagerPatch.ShowXPUpdate(oldXP, newXP, newXP - oldXP);
				}
			}
		}

		[ClientRpc]
		public void LevelUp_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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(820724324u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 820724324u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					HUDManagerPatch.ShowLevelUp();
				}
			}
		}

		[ClientRpc]
		public void Givepoint_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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(179361894u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 179361894u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					skillPoints++;
				}
			}
		}

		public void TeamLootValueUpdate(float update, int newValue)
		{
			TeamLootValueUpdate_ServerRpc(update);
		}

		[ServerRpc(RequireOwnership = false)]
		public void TeamLootValueUpdate_ServerRpc(float updatedValue)
		{
			//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)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3281224843u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref updatedValue, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3281224843u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					float multiplier = LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.Value].GetMultiplier();
					float num = updatedValue * multiplier;
					NetworkVariable<float> obj = teamLootValue;
					obj.Value += num;
					LethalPlugin.Log.LogInfo((object)$"Changed team loot value by {updatedValue * multiplier} turning into {teamLootValue.Value}.");
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void ServerHandSlots_ServerRpc(ulong playerID, int newSlots)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2696007838u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerID);
					BytePacker.WriteValueBitPacked(val2, newSlots);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2696007838u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && !LethalPlugin.ReservedSlots)
				{
					SetPlayerHandslots_ClientRpc(playerID, newSlots);
				}
			}
		}

		[ClientRpc]
		public void SetPlayerHandslots_ClientRpc(ulong playerID, int newSlots)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2549144616u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerID);
					BytePacker.WriteValueBitPacked(val2, newSlots);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2549144616u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					SetHandSlot(playerID, newSlots);
				}
			}
		}

		public void SetHandSlot(ulong playerID, int newSlots)
		{
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (val.playerClientId != playerID)
				{
					continue;
				}
				int num = 4 + newSlots;
				List<GrabbableObject> list = new List<GrabbableObject>(val.ItemSlots);
				val.ItemSlots = (GrabbableObject[])(object)new GrabbableObject[num];
				for (int j = 0; j < num; j++)
				{
					if (list.Count >= num)
					{
						val.ItemSlots[j] = list[j];
					}
				}
				LethalPlugin.Log.LogInfo((object)$"Player {playerID} has {val.ItemSlots.Length} slots after setting.");
				break;
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void GetEveryoneHandSlots_ServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2063608820u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2063608820u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost) || LethalPlugin.ReservedSlots || !LP_NetworkManager.xpInstance.skillList.IsSkillValid(UpgradeType.HandSlot))
			{
				return;
			}
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val3 in allPlayerScripts)
			{
				if (((Component)val3).gameObject.activeSelf)
				{
					ulong playerClientId = val3.playerClientId;
					int handSlots = val3.ItemSlots.Length - 4;
					SendEveryoneHandSlots_ClientRpc(playerClientId, handSlots);
				}
			}
		}

		[ClientRpc]
		public void SendEveryoneHandSlots_ClientRpc(ulong playerID, int handSlots)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4146414765u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerID);
					BytePacker.WriteValueBitPacked(val2, handSlots);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4146414765u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					SetHandSlot(playerID, handSlots);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void PlayerConnect_ServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2203520695u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2203520695u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					IDictionary<string, string> allConfigEntries = LethalPlugin.Instance.GetAllConfigEntries();
					string serializedConfig = JsonConvert.SerializeObject((object)allConfigEntries);
					SendEveryoneConfigs_ClientRpc(serializedConfig);
				}
			}
		}

		[ClientRpc]
		public void SendEveryoneConfigs_ClientRpc(string serializedConfig)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_00ba: 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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2502216668u, val, (RpcDelivery)0);
				bool flag = serializedConfig != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(serializedConfig, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2502216668u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			IDictionary<string, string> dictionary = JsonConvert.DeserializeObject<IDictionary<string, string>>(serializedConfig);
			foreach (KeyValuePair<string, string> item in dictionary)
			{
				SkillConfig.hostConfig[item.Key] = item.Value;
				LethalPlugin.Log.LogInfo((object)("Loaded host config: " + item.Key + " = " + item.Value));
			}
			if (!Initialized)
			{
				Initialized = true;
				LP_NetworkManager.xpInstance = this;
				skillList = new SkillList();
				skillList.InitializeSkills();
				guiObj = new SkillsGUI();
				NetworkVariable<float> obj = teamLootValue;
				obj.OnValueChanged = (OnValueChangedDelegate<float>)(object)Delegate.Combine((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<float>(guiObj.TeamLootHudUpdate));
				if (GameNetworkManager.Instance.isHostingGame)
				{
					LoadSaveData();
				}
				skillPoints = xpLevel.Value + 5;
				GetEveryoneHandSlots_ServerRpc();
				ChangeXPRequirement_ServerRpc();
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_XP()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3672466612u, new RpcReceiveHandler(__rpc_handler_3672466612));
			NetworkManager.__rpc_func_table.Add(3074971930u, new RpcReceiveHandler(__rpc_handler_3074971930));
			NetworkManager.__rpc_func_table.Add(3462423043u, new RpcReceiveHandler(__rpc_handler_3462423043));
			NetworkManager.__rpc_func_table.Add(820724324u, new RpcReceiveHandler(__rpc_handler_820724324));
			NetworkManager.__rpc_func_table.Add(179361894u, new RpcReceiveHandler(__rpc_handler_179361894));
			NetworkManager.__rpc_func_table.Add(3281224843u, new RpcReceiveHandler(__rpc_handler_3281224843));
			NetworkManager.__rpc_func_table.Add(2696007838u, new RpcReceiveHandler(__rpc_handler_2696007838));
			NetworkManager.__rpc_func_table.Add(2549144616u, new RpcReceiveHandler(__rpc_handler_2549144616));
			NetworkManager.__rpc_func_table.Add(2063608820u, new RpcReceiveHandler(__rpc_handler_2063608820));
			NetworkManager.__rpc_func_table.Add(4146414765u, new RpcReceiveHandler(__rpc_handler_4146414765));
			NetworkManager.__rpc_func_table.Add(2203520695u, new RpcReceiveHandler(__rpc_handler_2203520695));
			NetworkManager.__rpc_func_table.Add(2502216668u, new RpcReceiveHandler(__rpc_handler_2502216668));
		}

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

		private static void __rpc_handler_3074971930(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int xp = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref xp);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((XP)(object)target).AddXPServerRPC(xp);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3462423043(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int oldXP = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref oldXP);
				int newXP = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref newXP);
				int xpGained = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref xpGained);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((XP)(object)target).XPHUDUpdate_ClientRPC(oldXP, newXP, xpGained);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

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

		private static void __rpc_handler_3281224843(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float updatedValue = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref updatedValue, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((XP)(object)target).TeamLootValueUpdate_ServerRpc(updatedValue);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2696007838(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong playerID = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerID);
				int newSlots = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref newSlots);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((XP)(object)target).ServerHandSlots_ServerRpc(playerID, newSlots);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2549144616(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong playerID = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerID);
				int newSlots = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref newSlots);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((XP)(object)target).SetPlayerHandslots_ClientRpc(playerID, newSlots);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		private static void __rpc_handler_4146414765(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong playerID = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerID);
				int handSlots = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref handSlots);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((XP)(object)target).SendEveryoneHandSlots_ClientRpc(playerID, handSlots);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

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

		protected internal override string __getTypeName()
		{
			return "XP";
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LethalProgression";

		public const string PLUGIN_NAME = "LethalProgression";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace LethalProgression.GUI
{
	[HarmonyPatch]
	internal class GUIUpdate
	{
		public static bool isMenuOpen;

		public static SkillsGUI guiInstance;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(QuickMenuManager), "Update")]
		private static void SkillMenuUpdate(QuickMenuManager __instance)
		{
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: 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_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: 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_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			if (guiInstance == null || !Object.op_Implicit((Object)(object)guiInstance.mainPanel))
			{
				return;
			}
			if (isMenuOpen)
			{
				if (bool.Parse(SkillConfig.hostConfig["Unspec in Ship Only"]) && !bool.Parse(SkillConfig.hostConfig["Disable Unspec"]))
				{
					if (GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom)
					{
						guiInstance.SetUnspec(show: true);
					}
					else
					{
						guiInstance.SetUnspec(show: false);
					}
				}
				if (bool.Parse(SkillConfig.hostConfig["Disable Unspec"]))
				{
					guiInstance.SetUnspec(show: false);
				}
				Vector2 val = ((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue();
				GameObject gameObject = ((Component)guiInstance.mainPanel.transform.GetChild(2)).gameObject;
				float x = gameObject.transform.position.x;
				Rect rect = gameObject.GetComponent<RectTransform>().rect;
				float num = x - ((Rect)(ref rect)).width;
				float x2 = gameObject.transform.position.x;
				rect = gameObject.GetComponent<RectTransform>().rect;
				float num2 = x2 + ((Rect)(ref rect)).width;
				float y = gameObject.transform.position.y;
				rect = gameObject.GetComponent<RectTransform>().rect;
				float num3 = y - ((Rect)(ref rect)).height;
				float y2 = gameObject.transform.position.y;
				rect = gameObject.GetComponent<RectTransform>().rect;
				float num4 = y2 + ((Rect)(ref rect)).height;
				if (val.x >= num && val.x <= num2)
				{
					if (val.y >= num3 && val.y <= num4)
					{
						((Component)guiInstance.mainPanel.transform.GetChild(2).GetChild(2)).gameObject.SetActive(true);
					}
					else
					{
						((Component)guiInstance.mainPanel.transform.GetChild(2).GetChild(2)).gameObject.SetActive(false);
					}
				}
				else
				{
					((Component)guiInstance.mainPanel.transform.GetChild(2).GetChild(2)).gameObject.SetActive(false);
				}
				guiInstance.mainPanel.SetActive(true);
				GameObject val2 = GameObject.Find("Systems/UI/Canvas/QuickMenu/MainButtons");
				val2.SetActive(false);
				GameObject val3 = GameObject.Find("Systems/UI/Canvas/QuickMenu/PlayerList");
				val3.SetActive(false);
				RealTimeUpdateInfo();
			}
			else
			{
				guiInstance.mainPanel.SetActive(false);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(QuickMenuManager), "CloseQuickMenu")]
		private static void SkillMenuClose(QuickMenuManager __instance)
		{
			isMenuOpen = false;
		}

		private static void RealTimeUpdateInfo()
		{
			GameObject gameObject = ((Component)guiInstance.mainPanel.transform.GetChild(2)).gameObject;
			gameObject = ((Component)gameObject.transform.GetChild(1)).gameObject;
			TextMeshProUGUI component = gameObject.GetComponent<TextMeshProUGUI>();
			((TMP_Text)component).text = LP_NetworkManager.xpInstance.GetSkillPoints().ToString();
		}
	}
	internal class SkillsGUI
	{
		public GameObject mainPanel;

		public GameObject infoPanel;

		public Skill activeSkill;

		public GameObject templateSlot;

		public List<GameObject> skillButtonsList = new List<GameObject>();

		public int shownSkills = 0;

		public SkillsGUI()
		{
			CreateSkillMenu();
			GUIUpdate.guiInstance = this;
		}

		public void OpenSkillMenu()
		{
			GUIUpdate.isMenuOpen = true;
			mainPanel.SetActive(true);
		}

		public void CreateSkillMenu()
		{
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			mainPanel = Object.Instantiate<GameObject>(LethalPlugin.skillBundle.LoadAsset<GameObject>("SkillMenu"));
			((Object)mainPanel).name = "SkillMenu";
			mainPanel.SetActive(false);
			templateSlot = Object.Instantiate<GameObject>(GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD/Inventory/Slot3"));
			((Object)templateSlot).name = "TemplateSlot";
			templateSlot.SetActive(false);
			infoPanel = ((Component)mainPanel.transform.GetChild(1)).gameObject;
			infoPanel.SetActive(false);
			GameObject gameObject = ((Component)mainPanel.transform.GetChild(4)).gameObject;
			gameObject.GetComponent<Button>().onClick = new ButtonClickedEvent();
			((UnityEvent)gameObject.GetComponent<Button>().onClick).AddListener(new UnityAction(BackButton));
			shownSkills = 0;
			if (LP_NetworkManager.xpInstance.skillList.skills == null)
			{
				return;
			}
			foreach (KeyValuePair<UpgradeType, Skill> skill in LP_NetworkManager.xpInstance.skillList.skills)
			{
				LethalPlugin.Log.LogInfo((object)("Creating button for " + skill.Value.GetShortName()));
				GameObject val = SetupUpgradeButton(skill.Value);
				LethalPlugin.Log.LogInfo((object)"Setup passed!");
				skillButtonsList.Add(val);
				LethalPlugin.Log.LogInfo((object)"Added to skill list..");
				LoadSkillData(skill.Value, val);
			}
			TeamLootHudUpdate(1f, 1f);
		}

		public void BackButton()
		{
			GUIUpdate.isMenuOpen = false;
			GameObject val = GameObject.Find("Systems/UI/Canvas/QuickMenu/MainButtons");
			val.SetActive(true);
			GameObject val2 = GameObject.Find("Systems/UI/Canvas/QuickMenu/PlayerList");
			val2.SetActive(true);
		}

		public void SetUnspec(bool show)
		{
			GameObject gameObject = ((Component)infoPanel.transform.GetChild(6)).gameObject;
			GameObject gameObject2 = ((Component)infoPanel.transform.GetChild(7)).gameObject;
			GameObject gameObject3 = ((Component)infoPanel.transform.GetChild(8)).gameObject;
			gameObject.SetActive(show);
			gameObject2.SetActive(show);
			gameObject3.SetActive(show);
			if (!bool.Parse(SkillConfig.hostConfig["Disable Unspec"]))
			{
				GameObject gameObject4 = ((Component)infoPanel.transform.GetChild(9)).gameObject;
				gameObject4.SetActive(!show);
			}
		}

		public GameObject SetupUpgradeButton(Skill skill)
		{
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Expected O, but got Unknown
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Expected O, but got Unknown
			GameObject gameObject = ((Component)mainPanel.transform.GetChild(0)).gameObject;
			GameObject val = Object.Instantiate<GameObject>(gameObject);
			if (!Object.op_Implicit((Object)(object)gameObject))
			{
				LethalPlugin.Log.LogError((object)"Couldn't find template button!");
				return null;
			}
			((Object)val).name = skill.GetShortName();
			GameObject gameObject2 = ((Component)mainPanel.transform.GetChild(3)).gameObject;
			GameObject gameObject3 = ((Component)gameObject2.transform.GetChild(1)).gameObject;
			val.transform.SetParent(gameObject3.transform, false);
			shownSkills++;
			GameObject gameObject4 = ((Component)val.transform.GetChild(0)).gameObject;
			((TMP_Text)gameObject4.GetComponent<TextMeshProUGUI>()).SetText(skill.GetShortName(), true);
			GameObject gameObject5 = ((Component)val.transform.GetChild(1)).gameObject;
			((TMP_Text)gameObject5.GetComponent<TextMeshProUGUI>()).SetText(skill.GetLevel().ToString(), true);
			GameObject gameObject6 = ((Component)val.transform.GetChild(2)).gameObject;
			((TMP_Text)gameObject6.GetComponent<TextMeshProUGUI>()).SetText("(" + skill.GetLevel() + " " + skill.GetAttribute() + ")", true);
			((TMP_Text)val.GetComponentInChildren<TextMeshProUGUI>()).SetText(skill.GetShortName() + ":", true);
			val.SetActive(true);
			val.GetComponent<Button>().onClick = new ButtonClickedEvent();
			((UnityEvent)val.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				UpdateStatInfo(skill);
			});
			return val;
		}

		public void LoadSkillData(Skill skill, GameObject skillButton)
		{
			if (!skill._teamShared)
			{
				GameObject gameObject = ((Component)skillButton.transform.GetChild(0)).gameObject;
				((TMP_Text)gameObject.GetComponent<TextMeshProUGUI>()).SetText(skill.GetShortName(), true);
				GameObject gameObject2 = ((Component)skillButton.transform.GetChild(1)).gameObject;
				((TMP_Text)gameObject2.GetComponent<TextMeshProUGUI>()).SetText(skill.GetLevel().ToString(), true);
				GameObject gameObject3 = ((Component)skillButton.transform.GetChild(2)).gameObject;
				((TMP_Text)gameObject3.GetComponent<TextMeshProUGUI>()).SetText("(+" + (float)skill.GetLevel() * skill.GetMultiplier() + "% " + skill.GetAttribute() + ")", true);
				((TMP_Text)skillButton.GetComponentInChildren<TextMeshProUGUI>()).SetText(skill.GetShortName() + ":", true);
			}
		}

		public void UpdateStatInfo(Skill skill)
		{
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Expected O, but got Unknown
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Expected O, but got Unknown
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Expected O, but got Unknown
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Expected O, but got Unknown
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Expected O, but got Unknown
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Expected O, but got Unknown
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Expected O, but got Unknown
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Expected O, but got Unknown
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Expected O, but got Unknown
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Expected O, but got Unknown
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Expected O, but got Unknown
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Expected O, but got Unknown
			if (!infoPanel.activeSelf)
			{
				infoPanel.SetActive(true);
			}
			TextMeshProUGUI component = ((Component)infoPanel.transform.GetChild(0)).gameObject.GetComponent<TextMeshProUGUI>();
			TextMeshProUGUI component2 = ((Component)infoPanel.transform.GetChild(1)).gameObject.GetComponent<TextMeshProUGUI>();
			TextMeshProUGUI component3 = ((Component)infoPanel.transform.GetChild(2)).gameObject.GetComponent<TextMeshProUGUI>();
			activeSkill = skill;
			((TMP_Text)component).SetText(skill.GetName(), true);
			if (skill.GetMaxLevel() == 99999)
			{
				((TMP_Text)component2).SetText($"{skill.GetLevel()}", true);
			}
			else
			{
				((TMP_Text)component2).SetText($"{skill.GetLevel()} / {skill.GetMaxLevel()}", true);
			}
			((TMP_Text)component3).SetText(skill.GetDescription(), true);
			GameObject gameObject = ((Component)infoPanel.transform.GetChild(3)).gameObject;
			GameObject gameObject2 = ((Component)infoPanel.transform.GetChild(4)).gameObject;
			GameObject gameObject3 = ((Component)infoPanel.transform.GetChild(5)).gameObject;
			gameObject.GetComponent<Button>().onClick = new ButtonClickedEvent();
			((UnityEvent)gameObject.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				AddSkillPoint(skill, 5);
			});
			gameObject2.GetComponent<Button>().onClick = new ButtonClickedEvent();
			((UnityEvent)gameObject2.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				AddSkillPoint(skill, 2);
			});
			gameObject3.GetComponent<Button>().onClick = new ButtonClickedEvent();
			((UnityEvent)gameObject3.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				AddSkillPoint(skill, 1);
			});
			GameObject gameObject4 = ((Component)infoPanel.transform.GetChild(6)).gameObject;
			GameObject gameObject5 = ((Component)infoPanel.transform.GetChild(7)).gameObject;
			GameObject gameObject6 = ((Component)infoPanel.transform.GetChild(8)).gameObject;
			gameObject4.GetComponent<Button>().onClick = new ButtonClickedEvent();
			((UnityEvent)gameObject4.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				RemoveSkillPoint(skill, 5);
			});
			gameObject5.GetComponent<Button>().onClick = new ButtonClickedEvent();
			((UnityEvent)gameObject5.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				RemoveSkillPoint(skill, 2);
			});
			gameObject6.GetComponent<Button>().onClick = new ButtonClickedEvent();
			((UnityEvent)gameObject6.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				RemoveSkillPoint(skill, 1);
			});
		}

		public void AddSkillPoint(Skill skill, int amt)
		{
			if (LP_NetworkManager.xpInstance.GetSkillPoints() <= 0)
			{
				return;
			}
			int skillPoints = LP_NetworkManager.xpInstance.GetSkillPoints();
			if (skillPoints < amt)
			{
				amt = skillPoints;
			}
			if (skill.GetLevel() + amt > skill.GetMaxLevel())
			{
				amt = skill.GetMaxLevel() - skill.GetLevel();
			}
			skill.AddLevel(amt);
			LP_NetworkManager.xpInstance.SetSkillPoints(LP_NetworkManager.xpInstance.GetSkillPoints() - amt);
			UpdateStatInfo(skill);
			foreach (GameObject skillButtons in skillButtonsList)
			{
				if (((Object)skillButtons).name == skill.GetShortName())
				{
					LoadSkillData(skill, skillButtons);
				}
			}
		}

		public void RemoveSkillPoint(Skill skill, int amt)
		{
			if (skill.GetLevel() == 0)
			{
				return;
			}
			int level = skill.GetLevel();
			if (level < amt)
			{
				amt = level;
			}
			skill.AddLevel(-amt);
			LP_NetworkManager.xpInstance.SetSkillPoints(LP_NetworkManager.xpInstance.GetSkillPoints() + amt);
			UpdateStatInfo(skill);
			foreach (GameObject skillButtons in skillButtonsList)
			{
				if (((Object)skillButtons).name == skill.GetShortName())
				{
					LoadSkillData(skill, skillButtons);
				}
			}
		}

		public void TeamLootHudUpdate(float oldValue, float newValue)
		{
			foreach (GameObject skillButtons in skillButtonsList)
			{
				if (((Object)skillButtons).name == "VAL")
				{
					Skill skill = LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.Value];
					LoadSkillData(skill, skillButtons);
					GameObject gameObject = ((Component)skillButtons.transform.GetChild(0)).gameObject;
					((TMP_Text)gameObject.GetComponent<TextMeshProUGUI>()).SetText(skill.GetShortName(), true);
					GameObject gameObject2 = ((Component)skillButtons.transform.GetChild(1)).gameObject;
					((TMP_Text)gameObject2.GetComponent<TextMeshProUGUI>()).SetText(skill.GetLevel().ToString(), true);
					((TMP_Text)skillButtons.GetComponentInChildren<TextMeshProUGUI>()).SetText(skill.GetShortName() + ":", true);
					GameObject gameObject3 = ((Component)skillButtons.transform.GetChild(2)).gameObject;
					((TMP_Text)gameObject3.GetComponent<TextMeshProUGUI>()).SetText("(+" + LP_NetworkManager.xpInstance.teamLootValue.Value + "% " + skill.GetAttribute() + ")", true);
					LethalPlugin.Log.LogInfo((object)$"Setting team value hud to {LP_NetworkManager.xpInstance.teamLootValue.Value}");
				}
			}
		}
	}
}
namespace LethalProgression.Skills
{
	public enum UpgradeType
	{
		HPRegen,
		Stamina,
		Battery,
		HandSlot,
		Value,
		Oxygen
	}
	internal class SkillList
	{
		public Dictionary<UpgradeType, Skill> skills = new Dictionary<UpgradeType, Skill>();

		public void CreateSkill(UpgradeType upgrade, string name, string description, string shortname, string attribute, UpgradeType upgradeType, int cost, int maxLevel, float multiplier, Action<int, int> callback = null, bool teamShared = false)
		{
			Skill value = new Skill(name, description, shortname, attribute, upgradeType, cost, maxLevel, multiplier, callback, teamShared);
			skills.Add(upgrade, value);
		}

		public bool IsSkillListValid()
		{
			if (skills.Count == 0)
			{
				return false;
			}
			return true;
		}

		public bool IsSkillValid(UpgradeType upgrade)
		{
			if (!skills.ContainsKey(upgrade))
			{
				LethalPlugin.Log.LogInfo((object)("Skill " + upgrade.ToString() + " is not in the skill list!"));
				return false;
			}
			return true;
		}

		public void InitializeSkills()
		{
			if (bool.Parse(SkillConfig.hostConfig["Health Regen Enabled"]))
			{
				LethalPlugin.Log.LogInfo((object)"HP Regen check 1");
				CreateSkill(UpgradeType.HPRegen, "Health Regen", "The company installs a basic healer into your suit, letting you regenerate health slowly. Only regenerate up to 100 HP.", "HPR", "Health Regeneration", UpgradeType.HPRegen, 1, int.Parse(SkillConfig.hostConfig["Health Regen Max Level"]), float.Parse(SkillConfig.hostConfig["Health Regen Multiplier"], CultureInfo.InvariantCulture));
			}
			if (bool.Parse(SkillConfig.hostConfig["Stamina Enabled"]))
			{
				CreateSkill(UpgradeType.Stamina, "Stamina", "Hours on that company gym finally coming into play. Allows you to run for longer.", "STM", "Stamina", UpgradeType.Stamina, 1, int.Parse(SkillConfig.hostConfig["Stamina Max Level"]), float.Parse(SkillConfig.hostConfig["Stamina Multiplier"], CultureInfo.InvariantCulture), Stamina.StaminaUpdate);
			}
			if (bool.Parse(SkillConfig.hostConfig["Battery Life Enabled"]))
			{
				CreateSkill(UpgradeType.Battery, "Battery Life", "The company provides you with better batteries. Replace your batteries AT THE SHIP'S CHARGER to see an effect.", "BAT", "Battery Life", UpgradeType.Battery, 1, int.Parse(SkillConfig.hostConfig["Battery Life Max Level"]), float.Parse(SkillConfig.hostConfig["Battery Life Multiplier"], CultureInfo.InvariantCulture));
			}
			if (bool.Parse(SkillConfig.hostConfig["Hand Slots Enabled"]) && !LethalPlugin.ReservedSlots)
			{
				CreateSkill(UpgradeType.HandSlot, "Hand Slot", "The company finally gives you a better belt! Fit more stuff! (Reach 100% for one slot.)", "HND", "Hand Slots", UpgradeType.HandSlot, 1, int.Parse(SkillConfig.hostConfig["Hand Slots Max Level"]), float.Parse(SkillConfig.hostConfig["Hand Slots Multiplier"], CultureInfo.InvariantCulture), HandSlots.HandSlotsUpdate);
			}
			if (bool.Parse(SkillConfig.hostConfig["Loot Value Enabled"]))
			{
				CreateSkill(UpgradeType.Value, "Loot Value", "The company gives you a better pair of eyes, allowing you to see the value in things.", "VAL", "Loot Value", UpgradeType.Value, 1, int.Parse(SkillConfig.hostConfig["Loot Value Max Level"]), float.Parse(SkillConfig.hostConfig["Loot Value Multiplier"], CultureInfo.InvariantCulture), LootValue.LootValueUpdate);
			}
			if (bool.Parse(SkillConfig.hostConfig["Oxygen Enabled"]))
			{
				CreateSkill(UpgradeType.Oxygen, "Oxygen", "The company installs you with oxygen tanks. You gain extra time in the water. (Start drowning when the bar is empty.)", "OXY", "Extra Oxygen", UpgradeType.Oxygen, 1, int.Parse(SkillConfig.hostConfig["Oxygen Max Level"]), float.Parse(SkillConfig.hostConfig["Oxygen Multiplier"], CultureInfo.InvariantCulture));
			}
		}
	}
	internal class Skill
	{
		private readonly string _shortName;

		private readonly string _name;

		private readonly string _attribute;

		private readonly string _description;

		private readonly UpgradeType _upgradeType;

		private readonly int _cost;

		private readonly int _maxLevel;

		private readonly float _multiplier;

		private readonly Action<int, int> _callback;

		public bool _teamShared;

		private int _level;

		public Skill(string name, string description, string shortname, string attribute, UpgradeType upgradeType, int cost, int maxLevel, float multiplier, Action<int, int> callback = null, bool teamShared = false)
		{
			_name = name;
			_shortName = shortname;
			_attribute = attribute;
			_description = description;
			_upgradeType = upgradeType;
			_cost = cost;
			_maxLevel = maxLevel;
			_multiplier = multiplier;
			_level = 0;
			_callback = callback;
			_teamShared = teamShared;
		}

		public string GetName()
		{
			return _name;
		}

		public string GetShortName()
		{
			return _shortName;
		}

		public string GetAttribute()
		{
			return _attribute;
		}

		public string GetDescription()
		{
			return _description;
		}

		public UpgradeType GetUpgradeType()
		{
			return _upgradeType;
		}

		public int GetCost()
		{
			return _cost;
		}

		public int GetMaxLevel()
		{
			return _maxLevel;
		}

		public int GetLevel()
		{
			return _level;
		}

		public float GetMultiplier()
		{
			return _multiplier;
		}

		public float GetTrueValue()
		{
			return _multiplier * (float)_level;
		}

		public void SetLevel(int level)
		{
			_level = level;
		}

		public void AddLevel(int level)
		{
			_level += level;
			int level2 = _level;
			_callback?.Invoke(level, level2);
		}
	}
	[HarmonyPatch]
	internal class BatteryLife
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(GrabbableObject), "SyncBatteryServerRpc")]
		public static void BatteryUpdate(ref int charge)
		{
			if (LP_NetworkManager.xpInstance.skillList.IsSkillListValid() && LP_NetworkManager.xpInstance.skillList.IsSkillValid(UpgradeType.Battery) && charge == 100)
			{
				charge += (int)LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.Battery].GetTrueValue();
			}
		}
	}
	internal class HandSlots
	{
		public static int currentSlotCount = 4;

		public static void HandSlotsUpdate(int updateValue, int newValue)
		{
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: 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_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			if (LethalPlugin.ReservedSlots || !LP_NetworkManager.xpInstance.skillList.IsSkillListValid() || !LP_NetworkManager.xpInstance.skillList.IsSkillValid(UpgradeType.HandSlot))
			{
				return;
			}
			XP xpInstance = LP_NetworkManager.xpInstance;
			float num = xpInstance.skillList.skills[UpgradeType.HandSlot].GetTrueValue() / 100f;
			int num2 = 4 + (int)Math.Floor(num);
			int num3 = num2 - currentSlotCount;
			GameObject val = GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD/Inventory");
			List<string> list = new List<string> { "Slot0", "Slot1", "Slot2", "Slot3" };
			for (int i = 0; i < val.transform.childCount; i++)
			{
				Transform child = val.transform.GetChild(i);
				if (!list.Contains(((Object)((Component)child).gameObject).name))
				{
					Object.Destroy((Object)(object)((Component)child).gameObject);
				}
			}
			int num4 = (int)xpInstance.skillList.skills[UpgradeType.HandSlot].GetTrueValue();
			int newSlots = (int)Math.Floor((double)(num4 / 100));
			Image[] array = (Image[])(object)new Image[num2];
			array[0] = HUDManager.Instance.itemSlotIconFrames[0];
			array[1] = HUDManager.Instance.itemSlotIconFrames[1];
			array[2] = HUDManager.Instance.itemSlotIconFrames[2];
			array[3] = HUDManager.Instance.itemSlotIconFrames[3];
			Image[] array2 = (Image[])(object)new Image[num2];
			array2[0] = HUDManager.Instance.itemSlotIcons[0];
			array2[1] = HUDManager.Instance.itemSlotIcons[1];
			array2[2] = HUDManager.Instance.itemSlotIcons[2];
			array2[3] = HUDManager.Instance.itemSlotIcons[3];
			GameObject val2 = GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD/Inventory/Slot3");
			GameObject templateSlot = xpInstance.guiObj.templateSlot;
			GameObject val3 = val2;
			currentSlotCount = num2;
			for (int j = 0; j < (int)num; j++)
			{
				GameObject val4 = Object.Instantiate<GameObject>(templateSlot);
				((Object)val4).name = $"Slot{3 + (j + 1)}";
				val4.transform.SetParent(val.transform);
				Vector3 localPosition = val3.transform.localPosition;
				val4.transform.SetLocalPositionAndRotation(new Vector3(localPosition.x + 50f, localPosition.y, localPosition.z), val3.transform.localRotation);
				val3 = val4;
				array[3 + (j + 1)] = val4.GetComponent<Image>();
				array2[3 + (j + 1)] = ((Component)val4.transform.GetChild(0)).GetComponent<Image>();
				val4.SetActive(true);
			}
			for (int k = 0; k < array.Length; k++)
			{
				Vector3 localPosition2 = ((Component)array[k]).transform.localPosition;
				((Component)array[k]).transform.SetLocalPositionAndRotation(new Vector3(localPosition2.x - (float)(num3 * 25), localPosition2.y, localPosition2.z), ((Component)array[k]).transform.localRotation);
			}
			HUDManager.Instance.itemSlotIconFrames = array;
			HUDManager.Instance.itemSlotIcons = array2;
			ulong playerClientId = GameNetworkManager.Instance.localPlayerController.playerClientId;
			xpInstance.ServerHandSlots_ServerRpc(playerClientId, newSlots);
		}
	}
	[HarmonyPatch]
	internal class HPRegen
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
		private static void HPRegenUpdate(PlayerControllerB __instance)
		{
			if (__instance.health >= 100 || !LP_NetworkManager.xpInstance.skillList.IsSkillListValid() || !LP_NetworkManager.xpInstance.skillList.IsSkillValid(UpgradeType.HPRegen) || LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.HPRegen].GetLevel() == 0)
			{
				return;
			}
			if (__instance.healthRegenerateTimer <= 0f)
			{
				Skill skill = LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.HPRegen];
				float trueValue = skill.GetTrueValue();
				__instance.healthRegenerateTimer = 1f / trueValue;
				__instance.health++;
				if (__instance.health >= 20)
				{
					__instance.MakeCriticallyInjured(false);
				}
				HUDManager.Instance.UpdateHealthUI(__instance.health, false);
			}
			else
			{
				__instance.healthRegenerateTimer -= Time.deltaTime;
			}
		}
	}
	[HarmonyPatch]
	internal class LootValue
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")]
		private static void AddLootValue()
		{
			if (LP_NetworkManager.xpInstance.skillList.IsSkillListValid() && LP_NetworkManager.xpInstance.skillList.IsSkillValid(UpgradeType.Value))
			{
				RoundManager.Instance.scrapValueMultiplier = RoundManager.Instance.scrapValueMultiplier + LP_NetworkManager.xpInstance.teamLootValue.Value / 100f;
			}
		}

		public static void LootValueUpdate(int change, int newLevel)
		{
			if (LP_NetworkManager.xpInstance.skillList.IsSkillListValid() && LP_NetworkManager.xpInstance.skillList.IsSkillValid(UpgradeType.Value))
			{
				LP_NetworkManager.xpInstance.TeamLootValueUpdate(change, newLevel);
			}
		}
	}
	[HarmonyPatch]
	internal class Oxygen
	{
		private static GameObject oxygenBar;

		private static float oxygen = 0f;

		private static float oxygenTimer = 0f;

		private static bool inWater = false;

		private static bool canDrown = true;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "SetFaceUnderwaterClientRpc")]
		private static void EnteredWater(PlayerControllerB __instance)
		{
			inWater = true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "SetFaceOutOfWaterClientRpc")]
		private static void LeftWater(PlayerControllerB __instance)
		{
			inWater = false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(PlayerControllerB), "SetFaceUnderwaterFilters")]
		private static void ShouldDrown(PlayerControllerB __instance)
		{
			if (!canDrown)
			{
				StartOfRound.Instance.drowningTimer = 99f;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
		private static void OxygenUpdate(PlayerControllerB __instance)
		{
			if (!LP_NetworkManager.xpInstance.skillList.IsSkillListValid() || !LP_NetworkManager.xpInstance.skillList.IsSkillValid(UpgradeType.Oxygen))
			{
				return;
			}
			if (__instance.isPlayerDead)
			{
				if (Object.op_Implicit((Object)(object)oxygenBar))
				{
					oxygenBar.SetActive(false);
				}
				return;
			}
			if (LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.Oxygen].GetLevel() == 0)
			{
				if (Object.op_Implicit((Object)(object)oxygenBar))
				{
					oxygenBar.SetActive(false);
				}
				if (!canDrown)
				{
					canDrown = true;
					StartOfRound.Instance.drowningTimer = 1f;
				}
				return;
			}
			if (!Object.op_Implicit((Object)(object)oxygenBar))
			{
				CreateOxygenBar();
			}
			Skill skill = LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.Oxygen];
			float trueValue = skill.GetTrueValue();
			if (inWater)
			{
				oxygenBar.SetActive(true);
				if (oxygenTimer <= 0f)
				{
					oxygenTimer = 0.1f;
					if (oxygen > 0f)
					{
						oxygen -= 0.1f;
					}
					else if (!canDrown)
					{
						canDrown = true;
						StartOfRound.Instance.drowningTimer = 1f;
					}
				}
				else
				{
					oxygenTimer -= Time.deltaTime;
				}
			}
			if (!inWater)
			{
				if (oxygenTimer <= 0f)
				{
					oxygenTimer = 0.1f;
					if (oxygen < trueValue)
					{
						oxygenBar.SetActive(true);
						oxygen += 0.1f;
						canDrown = false;
					}
					else
					{
						oxygenBar.SetActive(false);
					}
				}
				else
				{
					oxygenTimer -= Time.deltaTime;
				}
			}
			if (oxygen > trueValue)
			{
				oxygenBar.SetActive(false);
				oxygen = trueValue;
			}
			if (oxygenBar.activeSelf)
			{
				float fillAmount = oxygen / trueValue;
				((Component)oxygenBar.transform.GetChild(0).GetChild(0)).GetComponent<Image>().fillAmount = fillAmount;
			}
		}

		public static void CreateOxygenBar()
		{
			oxygenBar = Object.Instantiate<GameObject>(LethalPlugin.skillBundle.LoadAsset<GameObject>("OxygenBar"));
			oxygenBar.SetActive(false);
		}
	}
	internal class Stamina
	{
		public static void StaminaUpdate(int updatedValue, int newStamina)
		{
			if (LP_NetworkManager.xpInstance.skillList.IsSkillListValid() && LP_NetworkManager.xpInstance.skillList.IsSkillValid(UpgradeType.Stamina))
			{
				Skill skill = LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.Stamina];
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				float num = (float)updatedValue * skill.GetMultiplier() / 100f * 11f;
				localPlayerController.sprintTime += num;
				LethalPlugin.Log.LogInfo((object)$"{updatedValue} change, {newStamina} new stamina points, Adding {num} resulting in {localPlayerController.sprintTime} stamina");
			}
		}
	}
}
namespace LethalProgression.Patches
{
	[HarmonyPatch]
	internal class HUDManagerPatch
	{
		private static GameObject _tempBar;

		private static TextMeshProUGUI _tempText;

		private static float _tempBarTime;

		private static GameObject levelText;

		private static float levelTextTime;

		private static Dictionary<string, int> _enemyReward = new Dictionary<string, int>
		{
			{ "HoarderBug (EnemyType)", 30 },
			{ "BaboonBird (EnemyType)", 15 },
			{ "MouthDog (EnemyType)", 200 },
			{ "Centipede (EnemyType)", 30 },
			{ "Flowerman (EnemyType)", 200 },
			{ "SandSpider (EnemyType)", 50 },
			{ "Crawler (EnemyType)", 50 },
			{ "Puffer (EnemyType)", 15 }
		};

		[HarmonyPrefix]
		[HarmonyPatch(typeof(HUDManager), "AddNewScrapFoundToDisplay")]
		private static void GiveXPForScrap(GrabbableObject GObject)
		{
			if (GameNetworkManager.Instance.isHostingGame)
			{
				int scrapValue = GObject.scrapValue;
				LP_NetworkManager.xpInstance.AddXPServerRPC(scrapValue);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(EnemyAI), "KillEnemy")]
		private static void GiveXPForKill(EnemyAI __instance)
		{
			string text = ((object)__instance.enemyType).ToString();
			LethalPlugin.Log.LogInfo((object)("Enemy type: " + text));
			int xp = 30;
			if (_enemyReward.ContainsKey(text))
			{
				xp = _enemyReward[text];
			}
			LP_NetworkManager.xpInstance.AddXPServerRPC(xp);
		}

		public static void ShowXPUpdate(int oldXP, int newXP, int xp)
		{
			if (!Object.op_Implicit((Object)(object)_tempBar))
			{
				MakeBar();
			}
			GameObject val = GameObject.Find("/Systems/UI/Canvas/IngamePlayerHUD/BottomMiddle/XPUpdate/XPBarProgress");
			val.GetComponent<Image>().fillAmount = (float)newXP / (float)LP_NetworkManager.xpInstance.GetXPRequirement();
			((TMP_Text)_tempText).text = newXP + " / " + (float)LP_NetworkManager.xpInstance.GetXPRequirement();
			_tempBarTime = 2f;
			if (!_tempBar.activeSelf)
			{
				((MonoBehaviour)GameNetworkManager.Instance).StartCoroutine(XPBarCoroutine());
			}
		}

		private static IEnumerator XPBarCoroutine()
		{
			_tempBar.SetActive(true);
			while (_tempBarTime > 0f)
			{
				float time = _tempBarTime;
				_tempBarTime = 0f;
				yield return (object)new WaitForSeconds(time);
			}
			_tempBar.SetActive(false);
		}

		public static void ShowLevelUp()
		{
			if (!Object.op_Implicit((Object)(object)levelText))
			{
				MakeLevelUp();
			}
			levelTextTime = 5f;
			if (!levelText.gameObject.activeSelf)
			{
				((MonoBehaviour)GameNetworkManager.Instance).StartCoroutine(LevelUpCoroutine());
			}
		}

		public static void MakeLevelUp()
		{
			levelText = Object.Instantiate<GameObject>(LethalPlugin.skillBundle.LoadAsset<GameObject>("LevelUp"));
			((TMP_Text)((Component)levelText.transform.GetChild(0)).GetComponent<TextMeshProUGUI>()).text = "Level Up! Spend your skill points.";
			levelText.gameObject.SetActive(false);
		}

		private static IEnumerator LevelUpCoroutine()
		{
			levelText.gameObject.SetActive(true);
			while (levelTextTime > 0f)
			{
				float time = levelTextTime;
				levelTextTime = 0f;
				yield return (object)new WaitForSeconds(time);
			}
			levelText.gameObject.SetActive(false);
		}

		private static void MakeBar()
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: 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)
			GameObject val = GameObject.Find("/Systems/UI/Canvas/QuickMenu/XPBar");
			QuickMenuManagerPatch.MakeNewXPBar();
			val = GameObject.Find("/Systems/UI/Canvas/QuickMenu/XPBar");
			_tempBar = Object.Instantiate<GameObject>(val);
			((Object)_tempBar).name = "XPUpdate";
			_tempText = _tempBar.GetComponentInChildren<TextMeshProUGUI>();
			GameObject val2 = GameObject.Find("/Systems/UI/Canvas/IngamePlayerHUD/BottomMiddle");
			_tempBar.transform.SetParent(val2.transform, false);
			_tempBar.transform.localScale = new Vector3(0.4f, 0.4f, 0.4f);
			GameObject val3 = GameObject.Find("/Systems/UI/Canvas/IngamePlayerHUD/BottomMiddle/XPUpdate/XPLevel");
			Object.Destroy((Object)(object)val3);
			GameObject val4 = GameObject.Find("/Systems/UI/Canvas/IngamePlayerHUD/BottomMiddle/XPUpdate/XPProfit");
			Object.Destroy((Object)(object)val4);
			_tempBar.transform.Translate(3.1f, -2.1f, 0f);
			Vector3 localPosition = _tempBar.transform.localPosition;
			_tempBar.transform.localPosition = new Vector3(localPosition.x, localPosition.y + 5f, localPosition.z);
			_tempBar.SetActive(false);
		}
	}
	[HarmonyPatch]
	internal class QuickMenuManagerPatch
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static UnityAction <0>__OpenSkillTree;
		}

		private static GameObject _xpBar;

		private static GameObject _xpBarProgress;

		private static TextMeshProUGUI _xpText;

		private static TextMeshProUGUI _xpLevel;

		private static TextMeshProUGUI _profit;

		private static GameObject skillTreeButton;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(QuickMenuManager), "OpenQuickMenu")]
		private static void QuickMenuXPBar(QuickMenuManager __instance)
		{
			if (__instance.isMenuOpen)
			{
				if (!Object.op_Implicit((Object)(object)_xpBar) || !Object.op_Implicit((Object)(object)_xpBarProgress))
				{
					MakeNewXPBar();
				}
				_xpBar.SetActive(true);
				_xpBarProgress.SetActive(true);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(QuickMenuManager), "Update")]
		private static void XPMenuUpdate(QuickMenuManager __instance)
		{
			if (Object.op_Implicit((Object)(object)_xpBar) && Object.op_Implicit((Object)(object)_xpBarProgress))
			{
				if (__instance.mainButtonsPanel.activeSelf)
				{
					_xpBar.SetActive(true);
					_xpBarProgress.SetActive(true);
				}
				else
				{
					_xpBar.SetActive(false);
					_xpBarProgress.SetActive(false);
				}
				((TMP_Text)_xpText).text = LP_NetworkManager.xpInstance.GetXP() + " / " + LP_NetworkManager.xpInstance.xpReq.Value;
				((TMP_Text)_xpLevel).text = "Level: " + LP_NetworkManager.xpInstance.GetLevel();
				((TMP_Text)_profit).text = "You've made.. " + LP_NetworkManager.xpInstance.GetProfit() + "$";
				_xpBarProgress.GetComponent<Image>().fillAmount = (float)LP_NetworkManager.xpInstance.GetXP() / (float)LP_NetworkManager.xpInstance.xpReq.Value;
			}
		}

		public static void MakeNewXPBar()
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("/Systems/UI/Canvas/QuickMenu");
			if (!Object.op_Implicit((Object)(object)_xpBar))
			{
				GameObject val2 = GameObject.Find("/Systems/UI/Canvas/EndgameStats/LevelUp/LevelUpBox");
				_xpBar = Object.Instantiate<GameObject>(val2);
				((Object)_xpBar).name = "XPBar";
				_xpBar.transform.SetParent(val.transform, false);
				_xpBar.transform.localScale = new Vector3(0.75f, 0.75f, 0.75f);
				_xpBar.transform.Translate(-2f, 1f, 0f);
			}
			if (!Object.op_Implicit((Object)(object)_xpBarProgress))
			{
				GameObject val3 = GameObject.Find("/Systems/UI/Canvas/EndgameStats/LevelUp/LevelUpMeter");
				_xpBarProgress = Object.Instantiate<GameObject>(val3);
				((Object)_xpBarProgress).name = "XPBarProgress";
				_xpBarProgress.transform.SetParent(_xpBar.transform, false);
				_xpBarProgress.GetComponent<Image>().fillAmount = 0f;
				_xpBarProgress.transform.localScale = new Vector3(0.597f, 5.21f, 1f);
				_xpBarProgress.transform.Translate(-0.8f, 0.2f, 0f);
				Vector3 localPosition = _xpBarProgress.transform.localPosition;
				_xpBarProgress.transform.localPosition = new Vector3(localPosition.x + 7f, localPosition.y - 3.5f, 0f);
				GameObject val4 = GameObject.Find("/Systems/UI/Canvas/EndgameStats/LevelUp/Total");
				_xpText = Object.Instantiate<GameObject>(val4).GetComponent<TextMeshProUGUI>();
				((Object)_xpText).name = "XPText";
				((TMP_Text)_xpText).alignment = (TextAlignmentOptions)514;
				((TMP_Text)_xpText).SetText("0/1000", true);
				((TMP_Text)_xpText).transform.SetParent(_xpBar.transform, false);
				((Graphic)_xpText).color = new Color(1f, 0.6f, 0f, 1f);
				((TMP_Text)_xpText).transform.Translate(-0.75f, 0.21f, 0f);
				_xpLevel = Object.Instantiate<GameObject>(val4).GetComponent<TextMeshProUGUI>();
				((Object)_xpLevel).name = "XPLevel";
				((TMP_Text)_xpLevel).alignment = (TextAlignmentOptions)514;
				((TMP_Text)_xpLevel).SetText("Level: 0", true);
				((TMP_Text)_xpLevel).transform.SetParent(_xpBar.transform, false);
				((Graphic)_xpLevel).color = new Color(1f, 0.6f, 0f, 1f);
				((TMP_Text)_xpLevel).transform.Translate(-1f, 0.4f, 0f);
				_profit = Object.Instantiate<GameObject>(val4).GetComponent<TextMeshProUGUI>();
				((Object)_profit).name = "XPProfit";
				((TMP_Text)_profit).alignment = (TextAlignmentOptions)514;
				((TMP_Text)_profit).SetText("You've made.. 0$.", true);
				((TMP_Text)_profit).transform.SetParent(_xpBar.transform, false);
				((Graphic)_profit).color = new Color(1f, 0.6f, 0f, 1f);
				((TMP_Text)_profit).transform.Translate(-0.8f, 0f, 0f);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(QuickMenuManager), "OpenQuickMenu")]
		private static void SkillTreeAwake(QuickMenuManager __instance)
		{
			if (__instance.isMenuOpen && !Object.op_Implicit((Object)(object)skillTreeButton))
			{
				MakeSkillTreeButton();
			}
		}

		private static void MakeSkillTreeButton()
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_00b1: 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_00bc: Expected O, but got Unknown
			GameObject val = GameObject.Find("Systems/UI/Canvas/QuickMenu/MainButtons/Resume");
			skillTreeButton = Object.Instantiate<GameObject>(val);
			GameObject val2 = GameObject.Find("Systems/UI/Canvas/QuickMenu/MainButtons");
			skillTreeButton.transform.SetParent(val2.transform, false);
			((Object)skillTreeButton).name = "Skills";
			((TMP_Text)skillTreeButton.GetComponentInChildren<TextMeshProUGUI>()).text = "> Skills";
			skillTreeButton.transform.Translate(0.7f, 1.1f, 0f);
			skillTreeButton.GetComponent<Button>().onClick = new ButtonClickedEvent();
			ButtonClickedEvent onClick = skillTreeButton.GetComponent<Button>().onClick;
			object obj = <>O.<0>__OpenSkillTree;
			if (obj == null)
			{
				UnityAction val3 = OpenSkillTree;
				<>O.<0>__OpenSkillTree = val3;
				obj = (object)val3;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj);
		}

		private static void OpenSkillTree()
		{
			LP_NetworkManager.xpInstance.guiObj.OpenSkillMenu();
		}
	}
	[HarmonyPatch]
	internal class XPPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "SaveGameValues")]
		private static void SaveXPValues(GameNetworkManager __instance)
		{
			if (GameNetworkManager.Instance.isHostingGame && StartOfRound.Instance.inShipPhase)
			{
				int num = __instance.saveFileNum + 1;
				string path = Application.persistentDataPath + "/lethalprogression/save" + num + ".txt";
				string text = "";
				text = text + LP_NetworkManager.xpInstance.GetLevel() + "\n";
				text = text + LP_NetworkManager.xpInstance.GetXP() + "\n";
				text = text + LP_NetworkManager.xpInstance.GetProfit() + "\n";
				File.WriteAllText(path, text);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "FirePlayersAfterDeadlineClientRpc")]
		private static void ResetXPValues(StartOfRound __instance)
		{
			XP xpInstance = LP_NetworkManager.xpInstance;
			int num = GameNetworkManager.Instance.saveFileNum + 1;
			string path = Application.persistentDataPath + "/lethalprogression/save" + num + ".txt";
			if (File.Exists(path))
			{
				File.Delete(path);
			}
			Directory.CreateDirectory(Application.persistentDataPath + "/lethalprogression");
			File.WriteAllText(path, "");
			string text = "";
			text += "0\n";
			text += "0\n";
			text += "0\n";
			File.WriteAllText(path, text);
			xpInstance.xpReq.Value = xpInstance.GetXPRequirement();
			foreach (Skill value in xpInstance.skillList.skills.Values)
			{
				value.SetLevel(0);
			}
			xpInstance.SetSkillPoints(5);
			xpInstance.xpLevel.Value = 0;
			xpInstance.xpPoints.Value = 0;
			xpInstance.profit.Value = 0;
			xpInstance.teamLootValue.Value = 0f;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(DeleteFileButton), "DeleteFile")]
		private static void XPFileDeleteReset()
		{
			int num = GameNetworkManager.Instance.saveFileNum + 1;
			string path = Application.persistentDataPath + "/lethalprogression/save" + num + ".txt";
			if (File.Exists(path))
			{
				File.Delete(path);
			}
			Directory.CreateDirectory(Application.persistentDataPath + "/lethalprogression");
			File.WriteAllText(path, "");
			string text = "";
			text += "0\n";
			text += "0\n";
			text += "0\n";
			File.WriteAllText(path, text);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "Disconnect")]
		private static void DisconnectXPHandler()
		{
			int level = LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.HandSlot].GetLevel();
			LP_NetworkManager.xpInstance.TeamLootValueUpdate(-level, 0);
			GUIUpdate.isMenuOpen = false;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(TimeOfDay), "SetNewProfitQuota")]
		private static void ProfitQuotaUpdate(TimeOfDay __instance)
		{
			if (GameNetworkManager.Instance.isHostingGame)
			{
				LP_NetworkManager.xpInstance.xpReq.Value = LP_NetworkManager.xpInstance.GetXPRequirement();
			}
		}
	}
}
namespace LethalProgression.Config
{
	internal class SkillConfig
	{
		public static IDictionary<string, string> hostConfig = new Dictionary<string, string>();

		public static void InitConfig()
		{
			LethalPlugin.Instance.BindConfig("General", "Person Multiplier", 35, "How much does XP cost to level up go up per person?");
			LethalPlugin.Instance.BindConfig("General", "Quota Multiplier", 30, "How much more XP does it cost to level up go up per quota? (Percent)");
			LethalPlugin.Instance.BindConfig("General", "XP Minimum", 40, "Minimum XP to level up.");
			LethalPlugin.Instance.BindConfig("General", "XP Maximum", 750, "Maximum XP to level up.");
			LethalPlugin.Instance.BindConfig("General", "Unspec in Ship Only", defaultValue: true, "Disallows unspecing stats if you're not currently on the ship.");
			LethalPlugin.Instance.BindConfig("General", "Disable Unspec", defaultValue: false, "Disallows unspecing altogether.");
			LethalPlugin.Instance.BindConfig("Skills", "Health Regen Enabled", defaultValue: true, "Enable the Health Regen skill?");
			LethalPlugin.Instance.BindConfig("Skills", "Health Regen Max Level", 20, "Maximum level for the health regen.");
			LethalPlugin.Instance.BindConfig("Skills", "Health Regen Multiplier", 0.05f, "How much does the health regen skill increase per level?");
			LethalPlugin.Instance.BindConfig("Skills", "Stamina Enabled", defaultValue: true, "Enable the Stamina skill?");
			LethalPlugin.Instance.BindConfig("Skills", "Stamina Max Level", 99999, "Maximum level for the stamina.");
			LethalPlugin.Instance.BindConfig("Skills", "Stamina Multiplier", 2f, "How much does the stamina skill increase per level?");
			LethalPlugin.Instance.BindConfig("Skills", "Battery Life Enabled", defaultValue: true, "Enable the Battery Life skill?");
			LethalPlugin.Instance.BindConfig("Skills", "Battery Life Max Level", 99999, "Maximum level for the battery life.");
			LethalPlugin.Instance.BindConfig("Skills", "Battery Life Multiplier", 5f, "How much does the battery life skill increase per level?");
			LethalPlugin.Instance.BindConfig("Skills", "Hand Slots Enabled", defaultValue: true, "Enable the Hand Slots skill?");
			LethalPlugin.Instance.BindConfig("Skills", "Hand Slots Max Level", 30, "Maximum level for the hand slots.");
			LethalPlugin.Instance.BindConfig("Skills", "Hand Slots Multiplier", 10f, "How much does the hand slots skill increase per level?");
			LethalPlugin.Instance.BindConfig("Skills", "Loot Value Enabled", defaultValue: true, "Enable the Loot Value skill?");
			LethalPlugin.Instance.BindConfig("Skills", "Loot Value Max Level", 99999, "Maximum level for the loot value.");
			LethalPlugin.Instance.BindConfig("Skills", "Loot Value Multiplier", 0.25f, "How much does the loot value skill increase per level?");
			LethalPlugin.Instance.BindConfig("Skills", "Oxygen Enabled", defaultValue: true, "Enable the Oxygen skill?");
			LethalPlugin.Instance.BindConfig("Skills", "Oxygen Max Level", 99999, "Maximum level for Oxygen.");
			LethalPlugin.Instance.BindConfig("Skills", "Oxygen Multiplier", 1f, "How much does the Oxygen skill increase per level?");
		}
	}
}

plugins/LethalSirenHead.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using LethalSirenHead.NetcodePatcher;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LeathalSirenHead")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LeathalSirenHead")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("22afcc53-9f27-49f9-b82d-3ff7e8026cce")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace LethalSirenHead
{
	[BepInPlugin("Ccode.SirenHead", "SirenHead", "0.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private const string MyGuid = "Ccode.SirenHead";

		private const string PluginName = "SirenHead";

		private const string VersionString = "0.0.1";

		private static readonly Harmony Harmony = new Harmony("Ccode.SirenHead");

		public static ManualLogSource Log;

		public static EnemyType SirenEnemy;

		public void Awake()
		{
			Assets.PopulateAssets();
			SirenEnemy = Assets.MainAssetBundle.LoadAsset<EnemyType>("SirenHead");
			TerminalNode val = Assets.MainAssetBundle.LoadAsset<TerminalNode>("SirenHeadTN");
			TerminalKeyword val2 = Assets.MainAssetBundle.LoadAsset<TerminalKeyword>("SirenHeadKW");
			NetworkPrefabs.RegisterNetworkPrefab(SirenEnemy.enemyPrefab);
			Harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"SirenHead 0.0.1 loaded.");
			Enemies.RegisterEnemy(SirenEnemy, 100, (LevelTypes)16, (SpawnType)2, val, val2);
			Log = ((BaseUnityPlugin)this).Logger;
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public static class Assets
	{
		public static AssetBundle MainAssetBundle;

		public static void PopulateAssets()
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			MainAssetBundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "modassets"));
			if ((Object)(object)MainAssetBundle == (Object)null)
			{
				Plugin.Log.LogError((object)"Failed to load custom assets.");
			}
		}
	}
}
namespace LethalSirenHead.Enemy
{
	public class SirenHeadAI : EnemyAI
	{
		private enum State
		{
			WANDERING,
			CHASING
		}

		private AISearchRoutine wander = new AISearchRoutine();

		private PlayerControllerB[] players;

		public override void DoAIInterval()
		{
			//IL_0061: 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)
			((EnemyAI)this).DoAIInterval();
			players = ((EnemyAI)this).GetAllPlayersInLineOfSight(50f, 70, base.eye, 3f, StartOfRound.Instance.collidersRoomDefaultAndFoliage);
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				if (!wander.inProgress)
				{
					((EnemyAI)this).StartSearch(((Component)this).transform.position, wander);
				}
				if (players != null)
				{
					((EnemyAI)this).StopSearch(wander, true);
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
				}
				break;
			case 1:
				if (players == null)
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				}
				else
				{
					((EnemyAI)this).SetDestinationToPosition(((Component)players[0]).transform.position, false);
				}
				break;
			}
		}

		public void LateUpdate()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)base.inSpecialAnimationWithPlayer != (Object)null)
			{
				((Component)base.inSpecialAnimationWithPlayer).transform.position = ((Component)this).gameObject.GetComponent<SirenHeadVars>().holdPlayerPoint.position;
				((Component)base.inSpecialAnimationWithPlayer).transform.rotation = ((Component)this).gameObject.GetComponent<SirenHeadVars>().holdPlayerPoint.rotation;
			}
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			((EnemyAI)this).OnCollideWithPlayer(other);
			PlayerControllerB val = (base.inSpecialAnimationWithPlayer = ((Component)other).gameObject.GetComponent<PlayerControllerB>());
			base.inSpecialAnimationWithPlayer.inSpecialInteractAnimation = true;
			base.inSpecialAnimationWithPlayer.inAnimationWithEnemy = (EnemyAI)(object)this;
			if ((Object)(object)val != (Object)null && !val.isPlayerDead && val.AllowPlayerDeath())
			{
				if (((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsServer)
				{
					StartEatingPlayerClientRpc(val.playerClientId);
				}
				else
				{
					RequestStartEatingPlayerServerRpc(val.playerClientId);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void RequestStartEatingPlayerServerRpc(ulong player)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1905488255u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, player);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1905488255u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					StartEatingPlayerClientRpc(player);
				}
			}
		}

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

		public IEnumerator EatPlayer(ulong player)
		{
			PlayerControllerB PlayerObject = StartOfRound.Instance.allPlayerScripts[player];
			base.creatureAnimator.SetBool("Eating", true);
			base.inSpecialAnimation = true;
			PlayerObject.isInElevator = false;
			PlayerObject.isInHangarShipRoom = false;
			yield return (object)new WaitForSeconds(2.916f);
			base.inSpecialAnimation = false;
			PlayerObject.KillPlayer(Vector3.zero, false, (CauseOfDeath)8, 0);
			((EnemyAI)this).SwitchToBehaviourState(0);
			base.creatureAnimator.SetBool("Eating", false);
			base.inSpecialAnimation = false;
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_SirenHeadAI()
		{
			//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(1905488255u, new RpcReceiveHandler(__rpc_handler_1905488255));
			NetworkManager.__rpc_func_table.Add(1290495213u, new RpcReceiveHandler(__rpc_handler_1290495213));
		}

		private static void __rpc_handler_1905488255(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong player = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref player);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SirenHeadAI)(object)target).RequestStartEatingPlayerServerRpc(player);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1290495213(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong player = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref player);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SirenHeadAI)(object)target).StartEatingPlayerClientRpc(player);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "SirenHeadAI";
		}
	}
	internal class SirenHeadVars : MonoBehaviour
	{
		public Transform holdPlayerPoint;
	}
}
namespace LethalSirenHead.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}

plugins/LethalThings/LethalThings.dll

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

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("LethalThings")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Mod for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+dffd1fa1a88c1099e7d37ac2a79e708256ab06a6")]
[assembly: AssemblyProduct("LethalThings")]
[assembly: AssemblyTitle("LethalThings")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>();
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<Vector3>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<Vector3>();
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<float>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<float>();
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<HackingTool.HackState>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedValueEquals<HackingTool.HackState>();
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

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

			public static hook_SaveItemsInShip <1>__GameNetworkManager_SaveItemsInShip;

			public static hook_LoadShipGrabbableItems <2>__StartOfRound_LoadShipGrabbableItems;
		}

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

		public static void Init()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			object obj = <>O.<0>__GameNetworkManager_ResetSavedGameValues;
			if (obj == null)
			{
				hook_ResetSavedGameValues val = GameNetworkManager_ResetSavedGameValues;
				<>O.<0>__GameNetworkManager_ResetSavedGameValues = val;
				obj = (object)val;
			}
			GameNetworkManager.ResetSavedGameValues += (hook_ResetSavedGameValues)obj;
			object obj2 = <>O.<1>__GameNetworkManager_SaveItemsInShip;
			if (obj2 == null)
			{
				hook_SaveItemsInShip val2 = GameNetworkManager_SaveItemsInShip;
				<>O.<1>__GameNetworkManager_SaveItemsInShip = val2;
				obj2 = (object)val2;
			}
			GameNetworkManager.SaveItemsInShip += (hook_SaveItemsInShip)obj2;
			object obj3 = <>O.<2>__StartOfRound_LoadShipGrabbableItems;
			if (obj3 == null)
			{
				hook_LoadShipGrabbableItems val3 = StartOfRound_LoadShipGrabbableItems;
				<>O.<2>__StartOfRound_LoadShipGrabbableItems = val3;
				obj3 = (object)val3;
			}
			StartOfRound.LoadShipGrabbableItems += (hook_LoadShipGrabbableItems)obj3;
		}

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

		private static void GameNetworkManager_SaveItemsInShip(orig_SaveItemsInShip orig, GameNetworkManager self)
		{
			orig.Invoke(self);
			SaveableObject[] array = Object.FindObjectsOfType<SaveableObject>();
			SaveableNetworkBehaviour[] array2 = Object.FindObjectsOfType<SaveableNetworkBehaviour>();
			SaveableObject[] array3 = array;
			foreach (SaveableObject saveableObject in array3)
			{
				saveableObject.SaveObjectData();
			}
			SaveableNetworkBehaviour[] array4 = array2;
			foreach (SaveableNetworkBehaviour saveableNetworkBehaviour in array4)
			{
				saveableNetworkBehaviour.SaveObjectData();
			}
			ES3.Save<List<string>>("LethalLibItemSaveKeys", saveKeys, GameNetworkManager.Instance.currentSaveFileName);
		}

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

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

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

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

		public static ContentLoader ContentLoader;

		public static GameObject devMenuPrefab;

		public static GameObject configManagerPrefab;

		public static void Init()
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Expected O, but got Unknown
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Expected O, but got Unknown
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Expected O, but got Unknown
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Expected O, but got Unknown
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Expected O, but got Unknown
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Expected O, but got Unknown
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Expected O, but got Unknown
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Expected O, but got Unknown
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Expected O, but got Unknown
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Expected O, but got Unknown
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Expected O, but got Unknown
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Expected O, but got Unknown
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Expected O, but got Unknown
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Expected O, but got Unknown
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Expected O, but got Unknown
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Expected O, but got Unknown
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Expected O, but got Unknown
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Expected O, but got Unknown
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Expected O, but got Unknown
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Expected O, but got Unknown
			//IL_0423: Unknown result type (might be due to invalid IL or missing references)
			//IL_0429: Expected O, but got Unknown
			//IL_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_045e: Expected O, but got Unknown
			MainAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "lethalthings"));
			configManagerPrefab = MainAssets.LoadAsset<GameObject>("Assets/Custom/LethalThings/LTNetworkConfig.prefab");
			NetworkPrefabs.RegisterNetworkPrefab(configManagerPrefab);
			ContentLoader = new ContentLoader(Plugin.pluginInfo, MainAssets, (Action<CustomContent, GameObject>)delegate(CustomContent content, GameObject prefab)
			{
				Prefabs.Add(content.ID, prefab);
			});
			CustomContent[] array = (CustomContent[])(object)new CustomContent[26]
			{
				(CustomContent)new ScrapItem("Arson", "Assets/Custom/LethalThings/Scrap/Arson/ArsonPlush.asset", NetworkConfig.arsonSpawnChance.Value, (LevelTypes)(-1), (string[])null, (Action<Item>)null),
				(CustomContent)new ScrapItem("Cookie", "Assets/Custom/LethalThings/Scrap/Cookie/CookieFumo.asset", NetworkConfig.cookieSpawnChance.Value, (LevelTypes)(-1), (string[])null, (Action<Item>)null),
				(CustomContent)new ScrapItem("Bilka", "Assets/Custom/LethalThings/Scrap/Toimari/ToimariPlush.asset", NetworkConfig.toimariSpawnChance.Value, (LevelTypes)(-1), (string[])null, (Action<Item>)null),
				(CustomContent)new ScrapItem("Hamis", "Assets/Custom/LethalThings/Scrap/Hamis/HamisPlush.asset", NetworkConfig.hamisSpawnChance.Value, (LevelTypes)(-1), (string[])null, (Action<Item>)null),
				(CustomContent)new ScrapItem("ArsonDirty", "Assets/Custom/LethalThings/Scrap/Arson/ArsonPlushDirty.asset", NetworkConfig.dirtyArsonSpawnChance.Value, (LevelTypes)(-1), (string[])null, (Action<Item>)null),
				(CustomContent)new ScrapItem("Maxwell", "Assets/Custom/LethalThings/Scrap/Maxwell/Dingus.asset", NetworkConfig.maxwellSpawnChance.Value, (LevelTypes)(-1), (string[])null, (Action<Item>)null),
				(CustomContent)new ScrapItem("Glizzy", "Assets/Custom/LethalThings/Scrap/glizzy/glizzy.asset", NetworkConfig.glizzySpawnChance.Value, (LevelTypes)(-1), (string[])null, (Action<Item>)null),
				(CustomContent)new ScrapItem("Revolver", "Assets/Custom/LethalThings/Scrap/Flaggun/Toygun.asset", NetworkConfig.revolverSpawnChance.Value, (LevelTypes)(-1), (string[])null, (Action<Item>)null),
				(CustomContent)new ScrapItem("GremlinEnergy", "Assets/Custom/LethalThings/Scrap/GremlinEnergy/GremlinEnergy.asset", NetworkConfig.gremlinSodaSpawnChance.Value, (LevelTypes)(-1), (string[])null, (Action<Item>)null),
				(CustomContent)new ScrapItem("ToyHammerScrap", "Assets/Custom/LethalThings/Items/ToyHammer/ToyHammer.asset", NetworkConfig.toyHammerScrapSpawnChance.Value, (LevelTypes)(-1), (string[])null, (Action<Item>)null),
				(CustomContent)new ScrapItem("Gnarpy", "Assets/Custom/LethalThings/Scrap/Gnarpy/GnarpyPlush.asset", NetworkConfig.gnarpySpawnChance.Value, (LevelTypes)(-1), (string[])null, (Action<Item>)null),
				(CustomContent)new ShopItem("RocketLauncher", "Assets/Custom/LethalThings/Items/RocketLauncher/RocketLauncher.asset", NetworkConfig.rocketLauncherPrice.Value, (string)null, (string)null, "Assets/Custom/LethalThings/Items/RocketLauncher/RocketLauncherInfo.asset", (Action<Item>)delegate(Item item)
				{
					NetworkPrefabs.RegisterNetworkPrefab(item.spawnPrefab.GetComponent<RocketLauncher>().missilePrefab);
				}),
				(CustomContent)new ShopItem("Flaregun", "Assets/Custom/LethalThings/Items/Flaregun/Flaregun.asset", NetworkConfig.flareGunPrice.Value, (string)null, (string)null, "Assets/Custom/LethalThings/Items/Flaregun/FlaregunInfo.asset", (Action<Item>)delegate(Item item)
				{
					NetworkPrefabs.RegisterNetworkPrefab(item.spawnPrefab.GetComponent<ProjectileWeapon>().projectilePrefab);
				}),
				(CustomContent)new ShopItem("FlaregunAmmo", "Assets/Custom/LethalThings/Items/Flaregun/FlaregunAmmo.asset", NetworkConfig.flareGunAmmoPrice.Value, (string)null, (string)null, "Assets/Custom/LethalThings/Items/Flaregun/FlaregunAmmoInfo.asset", (Action<Item>)null),
				(CustomContent)new ShopItem("ToyHammerShop", "Assets/Custom/LethalThings/Items/ToyHammer/ToyHammer.asset", NetworkConfig.toyHammerPrice.Value, (string)null, (string)null, "Assets/Custom/LethalThings/Items/ToyHammer/ToyHammerInfo.asset", (Action<Item>)null),
				(CustomContent)new ShopItem("RemoteRadar", "Assets/Custom/LethalThings/Items/Radar/HandheldRadar.asset", NetworkConfig.remoteRadarPrice.Value, (string)null, (string)null, "Assets/Custom/LethalThings/Items/Radar/HandheldRadarInfo.asset", (Action<Item>)null),
				(CustomContent)new ShopItem("PouchyBelt", "Assets/Custom/LethalThings/Items/Pouch/Pouch.asset", NetworkConfig.pouchyBeltPrice.Value, (string)null, (string)null, "Assets/Custom/LethalThings/Items/Pouch/PouchInfo.asset", (Action<Item>)null),
				(CustomContent)new ShopItem("HackingTool", "Assets/Custom/LethalThings/Items/HackingTool/HackingTool.asset", NetworkConfig.hackingToolPrice.Value, (string)null, (string)null, "Assets/Custom/LethalThings/Items/HackingTool/HackingToolInfo.asset", (Action<Item>)null),
				(CustomContent)new ShopItem("Pinger", "Assets/Custom/LethalThings/Items/PingingTool/PingTool.asset", NetworkConfig.pingerPrice.Value, (string)null, (string)null, "Assets/Custom/LethalThings/Items/PingingTool/PingToolInfo.asset", (Action<Item>)delegate(Item item)
				{
					NetworkPrefabs.RegisterNetworkPrefab(item.spawnPrefab.GetComponent<Pinger>().pingMarkerPrefab);
				}),
				(CustomContent)new CustomItem("Dart", "Assets/Custom/LethalThings/Unlockables/dartboard/Dart.asset", (Action<Item>)null),
				(CustomContent)new Unlockable("SmallRug", "Assets/Custom/LethalThings/Unlockables/Rug/SmallRug.asset", NetworkConfig.smallRugPrice.Value, (string)null, (string)null, "Assets/Custom/LethalThings/Unlockables/Rug/RugInfo.asset", (StoreType)2, (Action<UnlockableItem>)null),
				(CustomContent)new Unlockable("LargeRug", "Assets/Custom/LethalThings/Unlockables/Rug/LargeRug.asset", NetworkConfig.largeRugPrice.Value, (string)null, (string)null, "Assets/Custom/LethalThings/Unlockables/Rug/RugInfo.asset", (StoreType)2, (Action<UnlockableItem>)null),
				(CustomContent)new Unlockable("FatalitiesSign", "Assets/Custom/LethalThings/Unlockables/Sign/Sign.asset", NetworkConfig.fatalitiesSignPrice.Value, (string)null, (string)null, "Assets/Custom/LethalThings/Unlockables/Sign/SignInfo.asset", (StoreType)2, (Action<UnlockableItem>)null),
				(CustomContent)new Unlockable("Dartboard", "Assets/Custom/LethalThings/Unlockables/dartboard/Dartboard.asset", NetworkConfig.dartBoardPrice.Value, (string)null, (string)null, "Assets/Custom/LethalThings/Unlockables/dartboard/DartboardInfo.asset", (StoreType)2, (Action<UnlockableItem>)null),
				(CustomContent)new CustomEnemy("Boomba", "Assets/Custom/LethalThings/Enemies/Roomba/Boomba.asset", NetworkConfig.boombaSpawnWeight.Value, (LevelTypes)(-1), (SpawnType)0, (string[])null, "Assets/Custom/LethalThings/Enemies/Roomba/BoombaFile.asset", (string)null, (Action<EnemyType>)null),
				(CustomContent)new MapHazard("TeleporterTrap", "Assets/Custom/LethalThings/hazards/TeleporterTrap/TeleporterTrap.asset", (LevelTypes)(-1), (string[])null, (Func<SelectableLevel, AnimationCurve>)((SelectableLevel level) => new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, 0f),
					new Keyframe(1f, 4f)
				})), (Action<SpawnableMapObjectDef>)null)
			};
			ContentLoader.RegisterAll(array);
			foreach (KeyValuePair<string, GameObject> prefab in Prefabs)
			{
				GameObject value = prefab.Value;
				string key = prefab.Key;
				AudioSource[] componentsInChildren = value.GetComponentsInChildren<AudioSource>();
				if (componentsInChildren.Length != 0)
				{
					ConfigEntry<float> val = NetworkConfig.VolumeConfig.Bind<float>("Volume", key ?? "", 100f, "Audio volume for " + key + " (0 - 100)");
					AudioSource[] array2 = componentsInChildren;
					foreach (AudioSource val2 in array2)
					{
						val2.volume *= val.Value / 100f;
					}
				}
			}
			GameObject val3 = MainAssets.LoadAsset<GameObject>("Assets/Custom/LethalThings/DevMenu.prefab");
			NetworkPrefabs.RegisterNetworkPrefab(val3);
			devMenuPrefab = val3;
			try
			{
				IEnumerable<Type> loadableTypes = Assembly.GetExecutingAssembly().GetLoadableTypes();
				foreach (Type item in loadableTypes)
				{
					MethodInfo[] methods = item.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
					MethodInfo[] array3 = methods;
					foreach (MethodInfo methodInfo in array3)
					{
						object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
						if (customAttributes.Length != 0)
						{
							methodInfo.Invoke(null, null);
						}
					}
				}
			}
			catch (Exception)
			{
			}
		}
	}
	public static class InputCompat
	{
		public static InputActionAsset Asset;

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

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

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

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

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

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

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

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

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

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

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

		public AudioSource noiseAudioFar;

		public AudioSource musicAudio;

		public AudioSource musicAudioFar;

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

		public AudioClip[] noiseSFXFar;

		public AudioClip evilNoise;

		[Space(3f)]
		public float noiseRange;

		public float maxLoudness;

		public float minLoudness;

		public float minPitch;

		public float maxPitch;

		private Random noisemakerRandom;

		public Animator triggerAnimator;

		private int timesPlayedWithoutTurningOff = 0;

		private RoundManager roundManager;

		private float noiseInterval = 1f;

		public Animator danceAnimator;

		public bool wasLoadedFromSave = false;

		public bool exploding = false;

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

		public GameObject evilObject;

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

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

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

		public override void LoadObjectData()
		{
			if (((NetworkBehaviour)this).IsHost)
			{
				bool flag = SaveData.LoadObjectData<bool>("dingusBeEvil", uniqueId);
				Plugin.logger.LogInfo((object)$"Loading object[{uniqueId}] save data, evil? {flag}");
				if (flag)
				{
					isEvil.Value = flag;
				}
			}
		}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "Dingus";
		}
	}
	public class Missile : NetworkBehaviour
	{
		public int damage = 50;

		public float maxDistance = 10f;

		public float minDistance = 0f;

		public float gravity = 2.4f;

		public float flightDelay = 0.5f;

		public float flightForce = 150f;

		public float flightTime = 2f;

		public float autoDestroyTime = 3f;

		private float timeAlive = 0f;

		public float LobForce = 100f;

		public ParticleSystem particleSystem;

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

		private void Start()
		{
			//IL_0025: 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)
			((Component)this).GetComponent<Rigidbody>().useGravity = false;
			if (((NetworkBehaviour)this).IsHost)
			{
				((Component)this).GetComponent<Rigidbody>().AddForce(((Component)this).transform.forward * LobForce, (ForceMode)1);
			}
		}

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

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

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

		public void Boom()
		{
			//IL_006c: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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)
			if ((Object)(object)particleSystem == (Object)null)
			{
				Debug.LogError((object)"No particle system set on missile, destruction time!!");
				CreateExplosion();
				if (((NetworkBehaviour)this).IsHost)
				{
					Object.Destroy((Object)(object)((Component)this).gameObject);
				}
				return;
			}
			particleSystem.Stop(true, (ParticleSystemStopBehavior)1);
			((Component)particleSystem).transform.SetParent((Transform)null);
			((Component)particleSystem).transform.localScale = Vector3.one;
			GameObject gameObject = ((Component)particleSystem).gameObject;
			MainModule main = particleSystem.main;
			float duration = ((MainModule)(ref main)).duration;
			main = particleSystem.main;
			MinMaxCurve startLifetime = ((MainModule)(ref main)).startLifetime;
			Object.Destroy((Object)(object)gameObject, duration + ((MinMaxCurve)(ref startLifetime)).constant);
			CreateExplosion();
			if (((NetworkBehaviour)this).IsHost)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

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

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

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

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

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

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

			public static hook_BeginGrabObject <1>__PlayerControllerB_BeginGrabObject;
		}

		public Transform beltCosmetic;

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

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

		public int beltCapacity = 3;

		private PlayerControllerB previousPlayerHeldBy;

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

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

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

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

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

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

		public override void LateUpdate()
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).LateUpdate();
			if ((Object)(object)previousPlayerHeldBy != (Object)null)
			{
				((Component)beltCosmetic).gameObject.SetActive(true);
				beltCosmetic.SetParent((Transform)null);
				((Renderer)((Component)beltCosmetic).GetComponent<MeshRenderer>()).enabled = true;
				if (((NetworkBehaviour)this).IsOwner)
				{
					((Renderer)((Component)beltCosmetic).GetComponent<MeshRenderer>()).enabled = false;
				}
				Transform parent = previousPlayerHeldBy.lowerSpine.parent;
				beltCosmetic.position = parent.position + beltCosmeticPositionOffset;
				Quaternion rotation = parent.rotation;
				Quaternion rotation2 = Quaternion.Euler(((Quaternion)(ref rotation)).eulerAngles + beltCosmeticRotationOffset);
				beltCosmetic.rotation = rotation2;
				((Renderer)base.mainObjectRenderer).enabled = false;
				((Component)this).gameObject.SetActive(true);
			}
			else
			{
				((Component)beltCosmetic).gameObject.SetActive(false);
				((Renderer)base.mainObjectRenderer).enabled = true;
				beltCosmetic.SetParent(((Component)this).transform);
			}
		}

		public void UpdateHUD(bool add)
		{
			//IL_0095: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			slotIndexes.Clear();
			HUDManager instance = HUDManager.Instance;
			if (add)
			{
				int num = 0;
				GrabbableObject[] itemSlots = GameNetworkManager.Instance.localPlayerController.ItemSlots;
				foreach (GrabbableObject val in itemSlots)
				{
					if (val is PouchyBelt)
					{
						num++;
					}
				}
				Image val2 = instance.itemSlotIconFrames[0];
				Image val3 = instance.itemSlotIcons[0];
				int num2 = instance.itemSlotIconFrames.Length;
				CanvasScaler componentInParent = ((Component)val2).GetComponentInParent<CanvasScaler>();
				AspectRatioFitter componentInParent2 = ((Component)val2).GetComponentInParent<AspectRatioFitter>();
				float x = ((Graphic)val2).rectTransform.sizeDelta.x;
				float y = ((Graphic)val2).rectTransform.sizeDelta.y;
				float num3 = ((Graphic)val2).rectTransform.anchoredPosition.y + 1.125f * y * (float)num;
				Vector3 localEulerAngles = ((Transform)((Graphic)val2).rectTransform).localEulerAngles;
				Vector3 localEulerAngles2 = ((Transform)((Graphic)val3).rectTransform).localEulerAngles;
				List<Image> list = instance.itemSlotIconFrames.ToList();
				List<Image> list2 = instance.itemSlotIcons.ToList();
				int count = list.Count;
				float num4 = (float)beltCapacity * x + (float)(beltCapacity - 1) * 15f;
				Debug.Log((object)$"Adding {beltCapacity} item slots! Surely this will go well..");
				Debug.Log((object)$"Adding after index: {count}");
				for (int j = 0; j < beltCapacity; j++)
				{
					float num5 = 0f - ((Component)((Transform)((Graphic)val2).rectTransform).parent).GetComponent<RectTransform>().sizeDelta.x / 2f - 3f;
					float num6 = num5 + (float)j * x + (float)j * 15f;
					Image val4 = list[0];
					Image val5 = Object.Instantiate<Image>(val4, ((Component)val2).transform.parent);
					((Object)val5).name = $"Slot{num2 + j}[LethalThingsBelt]";
					((Graphic)val5).rectTransform.anchoredPosition = new Vector2(num6, num3);
					((Transform)((Graphic)val5).rectTransform).eulerAngles = localEulerAngles;
					Image component = ((Component)((Component)val5).transform.GetChild(0)).GetComponent<Image>();
					((Object)component).name = "icon";
					((Behaviour)component).enabled = false;
					((Transform)((Graphic)component).rectTransform).eulerAngles = localEulerAngles2;
					((Transform)((Graphic)component).rectTransform).Rotate(new Vector3(0f, 0f, -90f));
					int num7 = count + j;
					list.Insert(num7, val5);
					list2.Insert(num7, component);
					slotIndexes.Add(num7);
					((Component)val5).transform.SetSiblingIndex(num7);
				}
				instance.itemSlotIconFrames = list.ToArray();
				instance.itemSlotIcons = list2.ToArray();
				Debug.Log((object)$"Added {beltCapacity} item slots!");
				return;
			}
			List<Image> list3 = instance.itemSlotIconFrames.ToList();
			List<Image> list4 = instance.itemSlotIcons.ToList();
			int count2 = list3.Count;
			int num8 = 0;
			for (int num9 = count2 - 1; num9 >= 0; num9--)
			{
				if (((Object)list3[num9]).name.Contains("[LethalThingsBelt]"))
				{
					num8++;
					Image val6 = list3[num9];
					list3.RemoveAt(num9);
					list4.RemoveAt(num9);
					Object.Destroy((Object)(object)((Component)val6).gameObject);
					if (num8 >= beltCapacity)
					{
						break;
					}
				}
			}
			instance.itemSlotIconFrames = list3.ToArray();
			instance.itemSlotIcons = list4.ToArray();
			Debug.Log((object)$"Removed {beltCapacity} item slots!");
		}

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

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

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

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

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

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

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

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "PouchyBelt";
		}
	}
	public class PowerOutletStun : NetworkBehaviour
	{
		private Coroutine electrocutionCoroutine;

		public AudioSource strikeAudio;

		public ParticleSystem strikeParticle;

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

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

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

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			if (((NetworkBehaviour)this).IsHost)
			{
				damage.Value = NetworkConfig.itemChargerElectrocutionDamage.Value;
			}
		}

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

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

		private void Electrocuted(Vector3 position)
		{
			//IL_0008: 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)
			StormyWeather val = Object.FindObjectOfType<StormyWeather>(true);
			Utilities.CreateExplosion(position, spawnExplosionEffect: false, damage.Value, 0f, 5f, 3, (CauseOfDeath)11);
			strikeParticle.Play();
			val.PlayThunderEffects(position, strikeAudio);
		}

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

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

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

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

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "PowerOutletStun";
		}
	}
	public class ProjectileWeapon : SaveableObject
	{
		public AudioSource mainAudio;

		public AudioClip[] activateClips;

		public AudioClip[] noAmmoSounds;

		public AudioClip[] reloadSounds;

		public Transform aimDirection;

		public int maxAmmo = 4;

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

		public GameObject projectilePrefab;

		public float LobForce = 100f;

		private float timeSinceLastShot;

		private PlayerControllerB previousPlayerHeldBy;

		public Animator Animator;

		public ParticleSystem particleSystem;

		public Item ammoItem;

		public int ammoSlotToUse = -1;

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

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

		public static void Init()
		{
		}

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

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

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

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

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

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

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

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

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

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

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

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

		[ServerRpc]
		private void SpawnProjectileServerRpc(Vector3 aimPosition, Quaternion aimRotation, Vector3 forward)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Invalid comparison between Unknown and I4
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: 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(1043162412u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref aimPosition);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref aimRotation);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref forward);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1043162412u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ProjectileSpawner(aimPosition, aimRotation, forward);
			}
		}

		private void ProjectileSpawner(Vector3 aimPosition, Quaternion aimRotation, Vector3 forward)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_002f: 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)
			GameObject val = Object.Instantiate<GameObject>(projectilePrefab, aimPosition, aimRotation);
			val.GetComponent<NetworkObject>().SpawnWithOwnership(((NetworkBehaviour)this).OwnerClientId, false);
			ApplyProjectileForceClientRpc(NetworkObjectReference.op_Implicit(val.GetComponent<NetworkObject>()), aimPosition, aimRotation, forward);
		}

		[ClientRpc]
		public void ApplyProjectileForceClientRpc(NetworkObjectReference projectile, Vector3 aimPosition, Quaternion aimRotation, Vector3 forward)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: 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(2170744407u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref projectile, default(ForNetworkSerializable));
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref aimPosition);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref aimRotation);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref forward);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2170744407u, val, (RpcDelivery)0);
				}
				NetworkObject val3 = default(NetworkObject);
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && ((NetworkObjectReference)(ref projectile)).TryGet(ref val3, (NetworkManager)null))
				{
					GameObject gameObject = ((Component)val3).gameObject;
					gameObject.transform.position = aimPosition;
					gameObject.transform.rotation = aimRotation;
					gameObject.GetComponent<Rigidbody>().AddForce(forward * LobForce, (ForceMode)1);
				}
			}
		}

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

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

		private void OnEnable()
		{
		}

		private void OnDisable()
		{
		}

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

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

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

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

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

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

		public void DestroyItemInSlot(int itemSlot)
		{
			if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null || (Object)(object)NetworkManager.Singleton == (Object)null || NetworkManager.Singleton.ShutdownInProgress)
			{
				return;
			}
			GrabbableObject val = ((GrabbableObject)this).playerHeldBy.ItemSlots[itemSlot];
			if ((Object)(object)val == (Object)null || (Object)(object)val.itemProperties == (Object)null)
			{
				Plugin.logger.LogError((object)"Item properties are null, cannot destroy item in slot");
				return;
			}
			PlayerControllerB playerHeldBy = ((GrabbableObject)this).playerHeldBy;
			playerHeldBy.carryWeight -= Mathf.Clamp(val.itemProperties.weight - 1f, 0f, 10f);
			if (((GrabbableObject)this).playerHeldBy.currentItemSlot == itemSlot)
			{
				((GrabbableObject)this).playerHeldBy.isHoldingObject = false;
				((GrabbableObject)this).playerHeldBy.twoHanded = false;
				if (((NetworkBehaviour)((GrabbableObject)this).playerHeldBy).IsOwner)
				{
					((GrabbableObject)this).playerHeldBy.playerBodyAnimator.SetBool("cancelHolding", true);
					((GrabbableObject)this).playerHeldBy.playerBodyAnimator.SetTrigger("Throw");
					((Behaviour)HUDManager.Instance.holdingTwoHandedItem).enabled = false;
					HUDManager.Instance.ClearControlTips();
					((GrabbableObject)this).playerHeldBy.activatingItem = false;
				}
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				((Behaviour)HUDManager.Instance.itemSlotIcons[itemSlot]).enabled = false;
			}
			if ((Object)(object)((GrabbableObject)this).playerHeldBy.currentlyHeldObjectServer != (Object)null && (Object)(object)((GrabbableObject)this).playerHeldBy.currentlyHeldObjectServer == (Object)(object)val)
			{
				if (((NetworkBehaviour)((GrabbableObject)this).playerHeldBy).IsOwner)
				{
					((GrabbableObject)this).playerHeldBy.SetSpecialGrabAnimationBool(false, ((GrabbableObject)this).playerHeldBy.currentlyHeldObjectServer);
					((GrabbableObject)this).playerHeldBy.currentlyHeldObjectServer.DiscardItemOnClient();
				}
				((GrabbableObject)this).playerHeldBy.currentlyHeldObjectServer = null;
			}
			((GrabbableObject)this).playerHeldBy.ItemSlots[itemSlot] = null;
			if (((NetworkBehaviour)this).IsServer)
			{
				((NetworkBehaviour)val).NetworkObject.Despawn(true);
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_ProjectileWeapon()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(43845628u, new RpcReceiveHandler(__rpc_handler_43845628));
			NetworkManager.__rpc_func_table.Add(948021082u, new RpcReceiveHandler(__rpc_handler_948021082));
			NetworkManager.__rpc_func_table.Add(1064596822u, new RpcReceiveHandler(__rpc_handler_1064596822));
			NetworkManager.__rpc_func_table.Add(3520251861u, new RpcReceiv

plugins/LethalTradingCards.dll

Decompiled 9 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using LethalLib.Modules;
using LethalTradingCards.Behaviours;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LethalTradingCards")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LethalTradingCards")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5501de44-7100-420d-a2ac-f00c9cb10c1d")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace LethalTradingCards
{
	[BepInPlugin("ModusInteractive.LethalTradingCards", "Lethal Trading Cards", "1.0.0.0")]
	public class LethalCardsBase : BaseUnityPlugin
	{
		private const string modGUID = "ModusInteractive.LethalTradingCards";

		private const string modName = "Lethal Trading Cards";

		private const string modVersion = "1.0.0.0";

		private ConfigEntry<int> boosterPackRarity;

		private readonly Harmony harmony = new Harmony("ModusInteractive.LethalTradingCards");

		private static LethalCardsBase Instance;

		public List<GameObject> cardList;

		public List<int> cardWeights;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			boosterPackRarity = ((BaseUnityPlugin)this).Config.Bind<int>("General", "BoosterPackRarity", 40, "The rate at which the booster pack will spawn. Generally between 1-100.");
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "lethaltradingcardsassetbundle");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			Item val2 = val.LoadAsset<Item>("Assets/LethalTradingCards/BoosterPackItem.asset");
			BoosterPackScript boosterPackScript = val2.spawnPrefab.AddComponent<BoosterPackScript>();
			((GrabbableObject)boosterPackScript).grabbable = true;
			((GrabbableObject)boosterPackScript).grabbableToEnemies = true;
			((GrabbableObject)boosterPackScript).itemProperties = val2;
			Item val3 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card01Item.asset");
			Item val4 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card01_holoItem.asset");
			Item val5 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card02Item.asset");
			Item val6 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card02_holoItem.asset");
			Item val7 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card03Item.asset");
			Item val8 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card03_holoItem.asset");
			Item val9 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card04Item.asset");
			Item val10 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card04_holoItem.asset");
			Item val11 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card05Item.asset");
			Item val12 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card05_holoItem.asset");
			Item val13 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card06Item.asset");
			Item val14 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card06_holoItem.asset");
			Item val15 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card07Item.asset");
			Item val16 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card07_holoItem.asset");
			Item val17 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card08Item.asset");
			Item val18 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card08_holoItem.asset");
			Item val19 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card09Item.asset");
			Item val20 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card09_holoItem.asset");
			Item val21 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card10Item.asset");
			Item val22 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card10_holoItem.asset");
			Item val23 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card11Item.asset");
			Item val24 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card11_holoItem.asset");
			Item val25 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card12Item.asset");
			Item val26 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card12_holoItem.asset");
			Item val27 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card13Item.asset");
			Item val28 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card13_holoItem.asset");
			Item val29 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card14Item.asset");
			Item val30 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card14_holoItem.asset");
			Item val31 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card15Item.asset");
			Item val32 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card15_holoItem.asset");
			Item val33 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card16Item.asset");
			Item val34 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card16_holoItem.asset");
			cardList = new List<GameObject>
			{
				val3.spawnPrefab, val4.spawnPrefab, val5.spawnPrefab, val6.spawnPrefab, val7.spawnPrefab, val8.spawnPrefab, val9.spawnPrefab, val10.spawnPrefab, val11.spawnPrefab, val12.spawnPrefab,
				val13.spawnPrefab, val14.spawnPrefab, val15.spawnPrefab, val16.spawnPrefab, val17.spawnPrefab, val18.spawnPrefab, val19.spawnPrefab, val20.spawnPrefab, val21.spawnPrefab, val22.spawnPrefab,
				val23.spawnPrefab, val24.spawnPrefab, val25.spawnPrefab, val26.spawnPrefab, val27.spawnPrefab, val28.spawnPrefab, val29.spawnPrefab, val30.spawnPrefab, val31.spawnPrefab, val32.spawnPrefab,
				val33.spawnPrefab, val34.spawnPrefab
			};
			cardWeights = new List<int>
			{
				20, 6, 15, 3, 20, 6, 6, 1, 15, 5,
				15, 5, 6, 1, 20, 5, 10, 2, 10, 2,
				6, 1, 10, 2, 15, 5, 15, 5, 10, 2,
				15, 5
			};
			boosterPackScript.packContents = cardList;
			boosterPackScript.packWeights = cardWeights;
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val3.spawnPrefab);
			Utilities.FixMixerGroups(val3.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val4.spawnPrefab);
			Utilities.FixMixerGroups(val4.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val5.spawnPrefab);
			Utilities.FixMixerGroups(val5.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val6.spawnPrefab);
			Utilities.FixMixerGroups(val6.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val7.spawnPrefab);
			Utilities.FixMixerGroups(val7.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val8.spawnPrefab);
			Utilities.FixMixerGroups(val8.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val9.spawnPrefab);
			Utilities.FixMixerGroups(val9.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val10.spawnPrefab);
			Utilities.FixMixerGroups(val10.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val11.spawnPrefab);
			Utilities.FixMixerGroups(val11.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val12.spawnPrefab);
			Utilities.FixMixerGroups(val12.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val13.spawnPrefab);
			Utilities.FixMixerGroups(val13.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val14.spawnPrefab);
			Utilities.FixMixerGroups(val14.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val15.spawnPrefab);
			Utilities.FixMixerGroups(val15.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val16.spawnPrefab);
			Utilities.FixMixerGroups(val16.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val17.spawnPrefab);
			Utilities.FixMixerGroups(val17.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val18.spawnPrefab);
			Utilities.FixMixerGroups(val18.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val19.spawnPrefab);
			Utilities.FixMixerGroups(val19.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val20.spawnPrefab);
			Utilities.FixMixerGroups(val20.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val21.spawnPrefab);
			Utilities.FixMixerGroups(val21.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val22.spawnPrefab);
			Utilities.FixMixerGroups(val22.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val23.spawnPrefab);
			Utilities.FixMixerGroups(val23.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val24.spawnPrefab);
			Utilities.FixMixerGroups(val24.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val25.spawnPrefab);
			Utilities.FixMixerGroups(val25.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val26.spawnPrefab);
			Utilities.FixMixerGroups(val26.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val27.spawnPrefab);
			Utilities.FixMixerGroups(val27.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val28.spawnPrefab);
			Utilities.FixMixerGroups(val28.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val29.spawnPrefab);
			Utilities.FixMixerGroups(val29.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val30.spawnPrefab);
			Utilities.FixMixerGroups(val30.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val31.spawnPrefab);
			Utilities.FixMixerGroups(val31.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val32.spawnPrefab);
			Utilities.FixMixerGroups(val32.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val33.spawnPrefab);
			Utilities.FixMixerGroups(val33.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val34.spawnPrefab);
			Utilities.FixMixerGroups(val34.spawnPrefab);
			Items.RegisterItem(val3);
			Items.RegisterItem(val5);
			Items.RegisterItem(val7);
			Items.RegisterItem(val9);
			Items.RegisterItem(val11);
			Items.RegisterItem(val13);
			Items.RegisterItem(val15);
			Items.RegisterItem(val17);
			Items.RegisterItem(val19);
			Items.RegisterItem(val21);
			Items.RegisterItem(val23);
			Items.RegisterItem(val25);
			Items.RegisterItem(val27);
			Items.RegisterItem(val29);
			Items.RegisterItem(val31);
			Items.RegisterItem(val33);
			Items.RegisterItem(val4);
			Items.RegisterItem(val6);
			Items.RegisterItem(val8);
			Items.RegisterItem(val10);
			Items.RegisterItem(val12);
			Items.RegisterItem(val14);
			Items.RegisterItem(val16);
			Items.RegisterItem(val18);
			Items.RegisterItem(val20);
			Items.RegisterItem(val22);
			Items.RegisterItem(val24);
			Items.RegisterItem(val26);
			Items.RegisterItem(val28);
			Items.RegisterItem(val30);
			Items.RegisterItem(val32);
			Items.RegisterItem(val34);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			Items.RegisterScrap(val2, boosterPackRarity.Value, (LevelTypes)(-1));
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "ModusInteractive.LethalTradingCards");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Lethal Trading Cards");
		}
	}
}
namespace LethalTradingCards.Behaviours
{
	internal class BoosterPackScript : GiftBoxItem
	{
		public List<GameObject> packContents;

		public List<int> packWeights;

		public int weightTotal;

		public float valueMultiplier = 1.5f;

		public override void Start()
		{
			((GiftBoxItem)this).Start();
			weightTotal = 0;
			foreach (int packWeight in packWeights)
			{
				weightTotal += packWeight;
			}
			Debug.Log((object)("Random Roll: " + RandomWeighted()));
			base.objectInPresent = packContents[RandomWeighted()];
			GrabbableObject component = base.objectInPresent.GetComponent<GrabbableObject>();
			base.objectInPresentValue = (int)((float)Random.Range(component.itemProperties.minValue, component.itemProperties.maxValue) * RoundManager.Instance.scrapValueMultiplier * valueMultiplier);
			base.PoofParticle = ((Component)this).GetComponentInChildren<ParticleSystem>();
			if (!Object.op_Implicit((Object)(object)base.presentAudio))
			{
				base.presentAudio = ((Component)this).GetComponentInChildren<AudioSource>();
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GiftBoxItem)this).ItemActivate(used, buttonDown);
		}

		private int RandomWeighted()
		{
			int num = 0;
			int num2 = 0;
			int num3 = Random.Range(0, weightTotal + 1);
			for (num = 0; num < packWeights.Count; num++)
			{
				num2 += packWeights[num];
				if (num2 >= num3)
				{
					break;
				}
			}
			return num;
		}
	}
}

plugins/Malfunctions.dll

Decompiled 9 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Malfunctions.Helpers;
using TMPro;
using UnityEngine;
using UnityEngine.VFX;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Malfunctions")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Malfunctions")]
[assembly: AssemblyCopyright("Copyright © zealsprince 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("335007c9-7068-4df7-85b3-b406e9795203")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Malfunctions
{
	internal class Assets
	{
		public enum LoadStatusCode : ushort
		{
			Success,
			Failed,
			Exists
		}

		public static AssetBundle Bundle;

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

		public static readonly Dictionary<string, string> Manifest = new Dictionary<string, string> { { "sparks", "assets/exported/malfunctions/effects/sparks.prefab" } };

		public static LoadStatusCode Load()
		{
			if ((Object)(object)Bundle != (Object)null)
			{
				return LoadStatusCode.Exists;
			}
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Malfunctions");
			Bundle = AssetBundle.LoadFromFile(text);
			if ((Object)(object)Bundle == (Object)null)
			{
				Plugin.logger.LogInfo((object)("Failed to load asset bundle from path: " + text));
				return LoadStatusCode.Failed;
			}
			Plugin.logger.LogInfo((object)("Loaded asset bundle from path: " + text));
			string[] allAssetNames = Bundle.GetAllAssetNames();
			foreach (string text2 in allAssetNames)
			{
				Plugin.logger.LogDebug((object)("Loaded asset: " + text2));
			}
			foreach (KeyValuePair<string, string> item in Manifest)
			{
				Prefabs.Add(item.Key, Bundle.LoadAsset<GameObject>(item.Value));
			}
			return LoadStatusCode.Success;
		}

		public static GameObject SpawnPrefab(string name, Vector3 position)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Prefabs.ContainsKey(name))
				{
					Plugin.logger.LogDebug((object)("Loading prefab '" + name + "'"));
					return Object.Instantiate<GameObject>(Prefabs[name], position, Quaternion.identity);
				}
				Plugin.logger.LogWarning((object)("Prefab " + name + " not found!"));
			}
			catch (Exception ex) when (ex is ArgumentException || ex is NullReferenceException)
			{
				Plugin.logger.LogError((object)ex.Message);
			}
			return null;
		}
	}
	public class Config
	{
		public static ConfigEntry<double> MalfunctionChanceNavigation;

		public static ConfigEntry<double> MalfunctionChanceTeleporter;

		public static ConfigEntry<double> MalfunctionChanceDistortion;

		public static ConfigEntry<double> MalfunctionChanceDoor;

		public static ConfigEntry<double> MalfunctionChancePower;

		public static ConfigEntry<int> MalfunctionPassedDaysNavigation;

		public static ConfigEntry<int> MalfunctionPassedDaysTeleporter;

		public static ConfigEntry<int> MalfunctionPassedDaysDistortion;

		public static ConfigEntry<int> MalfunctionPassedDaysDoor;

		public static ConfigEntry<int> MalfunctionPassedDaysPower;

		public static ConfigEntry<bool> MalfunctionPenaltyEnabled;

		public static ConfigEntry<bool> MalfunctionPenaltyOnly;

		public static ConfigEntry<double> MalfunctionPenaltyMultiplier;

		public static ConfigEntry<bool> MalfunctionPowerBlockLever;

		public static ConfigEntry<double> MalfunctionPowerBlockLeverChance;

		public static void Load()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Expected O, but got Unknown
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Expected O, but got Unknown
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Expected O, but got Unknown
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Expected O, but got Unknown
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Expected O, but got Unknown
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Expected O, but got Unknown
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Expected O, but got Unknown
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Expected O, but got Unknown
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Expected O, but got Unknown
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Expected O, but got Unknown
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Expected O, but got Unknown
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Expected O, but got Unknown
			MalfunctionChanceNavigation = Plugin.config.Bind<double>("Chances", "MalfunctionChanceNavigation", 7.5, new ConfigDescription("Set the chance of the navigation malfunction happening - this will force the ship to route to a random moon with no regard to cost", (AcceptableValueBase)(object)new AcceptableValueRange<double>(0.0, 100.0), Array.Empty<object>()));
			MalfunctionChanceTeleporter = Plugin.config.Bind<double>("Chances", "MalfunctionChanceTeleporter", 7.5, new ConfigDescription("Set the chance of the teleporter malfunction happening - this will cause teleporters to disable themselves either at landing or after a random interval into the match", (AcceptableValueBase)(object)new AcceptableValueRange<double>(0.0, 100.0), Array.Empty<object>()));
			MalfunctionChanceDistortion = Plugin.config.Bind<double>("Chances", "MalfunctionChanceDistortion", 5.0, new ConfigDescription("Set the chance of the distortion malfunction happening - this will cause the map and terminal displays as well as walkies to become unusable either at landing or after a random interval into the match", (AcceptableValueBase)(object)new AcceptableValueRange<double>(0.0, 100.0), Array.Empty<object>()));
			MalfunctionChanceDoor = Plugin.config.Bind<double>("Chances", "MalfunctionChanceDoor", 3.0, new ConfigDescription("Set the chance of the door malfunction happening - this will disable ship door controls either at landing or after a random interval into the match", (AcceptableValueBase)(object)new AcceptableValueRange<double>(0.0, 100.0), Array.Empty<object>()));
			MalfunctionChancePower = Plugin.config.Bind<double>("Chances", "MalfunctionChancePower", 1.5, new ConfigDescription("Set the chance of the power malfunction happening - this will make the entire ship to go dark after landing, disabling battery charging, door controls, terminal and map displays", (AcceptableValueBase)(object)new AcceptableValueRange<double>(0.0, 100.0), Array.Empty<object>()));
			MalfunctionPassedDaysNavigation = Plugin.config.Bind<int>("Passed Days", "MalfunctionPassedDaysNavigation", 3, new ConfigDescription("Set how many days must have passed for the navigation malfunction to enable", (AcceptableValueBase)null, Array.Empty<object>()));
			MalfunctionPassedDaysTeleporter = Plugin.config.Bind<int>("Passed Days", "MalfunctionPassedDaysTeleporter", 11, new ConfigDescription("Set how many days must have passed for the teleporter malfunction to enable", (AcceptableValueBase)null, Array.Empty<object>()));
			MalfunctionPassedDaysDistortion = Plugin.config.Bind<int>("Passed Days", "MalfunctionPassedDaysDistortion", 3, new ConfigDescription("Set how many days must have passed for the distortion malfunction to enable", (AcceptableValueBase)null, Array.Empty<object>()));
			MalfunctionPassedDaysDoor = Plugin.config.Bind<int>("Passed Days", "MalfunctionPassedDaysDoor", 7, new ConfigDescription("Set how many days must have passed for the door malfunction to enable", (AcceptableValueBase)null, Array.Empty<object>()));
			MalfunctionPassedDaysPower = Plugin.config.Bind<int>("Passed Days", "MalfunctionPassedDaysPower", 11, new ConfigDescription("Set how many days must have passed for the power malfunction to enable", (AcceptableValueBase)null, Array.Empty<object>()));
			MalfunctionPenaltyEnabled = Plugin.config.Bind<bool>("Penalty", "MalfunctionPenaltyEnabled", true, new ConfigDescription("Enable the penalty system that increases malfunction chances after not recovering a player", (AcceptableValueBase)null, Array.Empty<object>()));
			MalfunctionPenaltyOnly = Plugin.config.Bind<bool>("Penalty", "MalfunctionPenaltyOnly", false, new ConfigDescription("Only enable malfunctions when a player has not been recovered", (AcceptableValueBase)null, Array.Empty<object>()));
			MalfunctionPenaltyMultiplier = Plugin.config.Bind<double>("Penalty", "MalfunctionPenaltyMultiplier", 2.0, new ConfigDescription("Set the multiplier on triggering a malfunction after not recovering a player", (AcceptableValueBase)null, Array.Empty<object>()));
			MalfunctionPowerBlockLever = Plugin.config.Bind<bool>("Power Malfunction", "MalfunctionPowerBlockLever", true, new ConfigDescription("Enable a chance of pulling the lever and taking off blocking when the power malfunction is active", (AcceptableValueBase)null, Array.Empty<object>()));
			MalfunctionPowerBlockLeverChance = Plugin.config.Bind<double>("Power Malfunction", "MalfunctionPowerBlockLeverChance", 50.0, new ConfigDescription("Chance that pulling the lever will not cause take-off", (AcceptableValueBase)(object)new AcceptableValueRange<double>(0.0, 100.0), Array.Empty<object>()));
		}
	}
	internal class Malfunction
	{
		public bool Active;

		public bool Notified;

		protected List<GameObject> effects;

		public Malfunction()
		{
			Active = false;
			Notified = false;
			effects = new List<GameObject>();
		}

		public void AssignChild(GameObject child)
		{
			effects.Add(child);
		}

		public void DestroyChildren()
		{
			foreach (GameObject effect in effects)
			{
				Object.Destroy((Object)(object)effect);
			}
			effects.Clear();
		}

		public virtual void Reset()
		{
			Active = false;
			Notified = false;
			DestroyChildren();
		}
	}
	internal class MalfunctionWithTrigger : Malfunction
	{
		public bool Triggered;

		public MalfunctionWithTrigger()
		{
			Triggered = false;
		}

		public override void Reset()
		{
			base.Reset();
			Triggered = false;
		}
	}
	internal class MalfunctionWithDelay : MalfunctionWithTrigger
	{
		public int Delay;

		public MalfunctionWithDelay()
		{
			Delay = 0;
		}

		public override void Reset()
		{
			base.Reset();
			Delay = 0;
		}
	}
	internal class State
	{
		public static Malfunction MalfunctionNavigation;

		public static MalfunctionWithDelay MalfunctionTeleporter;

		public static MalfunctionWithDelay MalfunctionDistortion;

		public static MalfunctionWithDelay MalfunctionDoor;

		public static MalfunctionWithDelay MalfunctionPower;

		public static void Load()
		{
			MalfunctionNavigation = new Malfunction();
			MalfunctionTeleporter = new MalfunctionWithDelay();
			MalfunctionDistortion = new MalfunctionWithDelay();
			MalfunctionDoor = new MalfunctionWithDelay();
			MalfunctionPower = new MalfunctionWithDelay();
		}

		public static void Reset()
		{
			MalfunctionNavigation.Reset();
			MalfunctionTeleporter.Reset();
			MalfunctionDistortion.Reset();
			MalfunctionDoor.Reset();
			MalfunctionPower.Reset();
		}
	}
	[BepInPlugin("com.zealsprince.malfunctions", "Malfunctions", "1.5.5")]
	public class Plugin : BaseUnityPlugin
	{
		public const string ModGUID = "com.zealsprince.malfunctions";

		public const string ModName = "Malfunctions";

		public const string ModVersion = "1.5.5";

		public static ManualLogSource logger;

		public static ConfigFile config;

		private readonly Harmony harmony = new Harmony("com.zealsprince.malfunctions");

		private void Awake()
		{
			logger = ((BaseUnityPlugin)this).Logger;
			config = ((BaseUnityPlugin)this).Config;
			Config.Load();
			if (Assets.Load() == Assets.LoadStatusCode.Success)
			{
				State.Load();
				harmony.PatchAll();
			}
		}
	}
}
namespace Malfunctions.Patches
{
	[HarmonyPatch(typeof(HangarShipDoor))]
	internal class HangarShipDoorPatches
	{
		private static float lockdownTime;

		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		private static void OverwriteDoorPower(HangarShipDoor __instance)
		{
			if (!State.MalfunctionPower.Active && State.MalfunctionDoor.Active && State.MalfunctionDoor.Triggered)
			{
				__instance.doorPower = 1f;
				lockdownTime = (lockdownTime + Time.deltaTime) % 6f;
				((TMP_Text)__instance.doorPowerDisplay).text = ((lockdownTime > 3f) ? "LOCKED" : "OPEN 10PM") ?? "";
			}
		}
	}
	[HarmonyPatch(typeof(StartMatchLever))]
	internal class StartMatchLeverPatches
	{
		[HarmonyPrefix]
		[HarmonyPatch("PullLever")]
		private static bool InterruptPullLever(StartMatchLever __instance)
		{
			if (State.MalfunctionPower.Active && State.MalfunctionPower.Triggered && Config.MalfunctionPowerBlockLever.Value && State.MalfunctionPower.Delay != 0)
			{
				((TMP_Text)HUDManager.Instance.globalNotificationText).text = "SHIP CORE DEPLETION:\nAWAIT 12AM EMERGENCY AUTOPILOT";
				HUDManager.Instance.globalNotificationAnimator.SetTrigger("TriggerNotif");
				HUDManager.Instance.UIAudio.PlayOneShot(HUDManager.Instance.radiationWarningAudio, 1f);
				__instance.leverHasBeenPulled = false;
				__instance.triggerScript.interactable = true;
				__instance.leverAnimatorObject.SetBool("pullLever", !__instance.leverHasBeenPulled);
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(WalkieTalkie))]
	internal class WalkieTalkiePatches
	{
		[HarmonyPrefix]
		[HarmonyPatch("ItemActivate")]
		private static bool InterruptItemActivate(WalkieTalkie __instance)
		{
			if (State.MalfunctionDistortion.Active && State.MalfunctionDistortion.Triggered)
			{
				__instance.thisAudio.PlayOneShot(__instance.playerDieOnWalkieTalkieSFX);
				((GrabbableObject)__instance).UseUpBatteries();
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(ShipLights))]
	internal class ShipLightsPatches
	{
		[HarmonyPrefix]
		[HarmonyPatch("ToggleShipLights")]
		private static bool InterruptToggleShipLights()
		{
			if (State.MalfunctionPower.Active && State.MalfunctionPower.Triggered)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(ItemCharger))]
	internal class ItemChargerPatches
	{
		[HarmonyPrefix]
		[HarmonyPatch("ChargeItem")]
		private static bool InterruptChargeItem()
		{
			if (State.MalfunctionPower.Active && State.MalfunctionPower.Triggered)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(ManualCameraRenderer))]
	internal class ManualCameraRendererPatches
	{
		[HarmonyPrefix]
		[HarmonyPatch("SwitchScreenButton")]
		private static bool InterruptSwitchScreenButton()
		{
			if ((State.MalfunctionPower.Active && State.MalfunctionPower.Triggered) || (State.MalfunctionDistortion.Active && State.MalfunctionDistortion.Triggered))
			{
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("SwitchRadarTargetClientRpc")]
		private static bool InterruptSwitchCameraView()
		{
			if ((State.MalfunctionPower.Active && State.MalfunctionPower.Triggered) || (State.MalfunctionDistortion.Active && State.MalfunctionDistortion.Triggered))
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(ShipTeleporter))]
	internal class ShipTeleporterPatches
	{
		[HarmonyPrefix]
		[HarmonyPatch("PressTeleportButtonOnLocalClient")]
		private static bool InterruptPressTeleportButton(ShipTeleporter __instance)
		{
			if ((State.MalfunctionTeleporter.Active && State.MalfunctionTeleporter.Triggered) || (State.MalfunctionPower.Active && State.MalfunctionPower.Triggered))
			{
				__instance.buttonAnimator.SetTrigger("press");
				__instance.buttonAudio.PlayOneShot(__instance.buttonPressSFX);
				return false;
			}
			return true;
		}

		[HarmonyPostfix]
		[HarmonyPatch("PressTeleportButtonOnLocalClient")]
		private static void RandomizePressTeleportButton()
		{
			if (State.MalfunctionDistortion.Active && State.MalfunctionDistortion.Triggered)
			{
				PlayerControllerB[] array = (from player in Object.FindObjectsByType<PlayerControllerB>((FindObjectsSortMode)0)
					where player.isPlayerControlled
					select player).ToArray();
				if (array.Length != 0)
				{
					StartOfRound.Instance.mapScreen.targetedPlayer = array[Random.Range(0, array.Length)];
				}
			}
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	internal class TerminalPatches
	{
		[HarmonyPrefix]
		[HarmonyPatch("LoadNewNodeIfAffordable")]
		private static bool BlockMoonConfirmNode(Terminal __instance, TerminalNode node)
		{
			if (State.MalfunctionNavigation.Active && node.buyRerouteToMoon > -1)
			{
				node.displayText = "ROUTE TABLE OFFSET: NAVIGATION ERROR\n\nIT IS ADVISED TO LAND THE SHIP TO ALLOW RECALIBRATION OF SYSTEMS AND RESTORATION OF FUNCTIONALITY\n\n";
				node.terminalEvent = "ERROR";
				__instance.PlayTerminalAudioServerRpc(3);
				__instance.LoadNewNode(node);
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(TimeOfDay))]
	internal class TimeOfDayPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		private static void CheckMalfunctionTeleporterTrigger(TimeOfDay __instance)
		{
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			if (!State.MalfunctionPower.Active && State.MalfunctionTeleporter.Active && !State.MalfunctionTeleporter.Triggered && __instance.currentDayTimeStarted && __instance.hour >= 1 + State.MalfunctionTeleporter.Delay)
			{
				Plugin.logger.LogDebug((object)"Triggered teleporter malfunction!");
				State.MalfunctionTeleporter.Triggered = true;
				if (!State.MalfunctionTeleporter.Notified)
				{
					((TMP_Text)HUDManager.Instance.globalNotificationText).text = "SHIP TELEPORTER MALFUNCTION:\nTIMEOUT FROM ATOMIC MISALIGNMENT";
					HUDManager.Instance.globalNotificationAnimator.SetTrigger("TriggerNotif");
					HUDManager.Instance.UIAudio.PlayOneShot(HUDManager.Instance.radiationWarningAudio, 1f);
					State.MalfunctionTeleporter.Notified = true;
				}
				ShipTeleporter val = Object.FindObjectOfType<ShipTeleporter>();
				if ((Object)(object)val == (Object)null)
				{
					Plugin.logger.LogError((object)"Failed to find a teleporter object.");
					return;
				}
				GameObject val2 = Assets.SpawnPrefab("sparks", ((Component)val).transform.position);
				val2.transform.SetParent(((Component)val).transform, true);
				State.MalfunctionTeleporter.AssignChild(val2);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		private static void CheckMalfunctionDistortionTrigger(TimeOfDay __instance)
		{
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			if (!State.MalfunctionPower.Active && State.MalfunctionDistortion.Active && !State.MalfunctionDistortion.Triggered && __instance.currentDayTimeStarted && __instance.hour >= 1 + State.MalfunctionDistortion.Delay)
			{
				Plugin.logger.LogDebug((object)"Triggered distortion malfunction!");
				State.MalfunctionDistortion.Triggered = true;
				if (!State.MalfunctionDistortion.Notified)
				{
					((TMP_Text)HUDManager.Instance.globalNotificationText).text = "SHIP COMS DISTURBANCE:\nELECTROMAGNETIC ANOMALY";
					HUDManager.Instance.globalNotificationAnimator.SetTrigger("TriggerNotif");
					HUDManager.Instance.UIAudio.PlayOneShot(HUDManager.Instance.radiationWarningAudio, 1f);
					State.MalfunctionDistortion.Notified = true;
				}
				__instance.playersManager.mapScreen.SwitchScreenOn(false);
				Terminal val = Object.FindObjectOfType<Terminal>();
				if ((Object)(object)val == (Object)null)
				{
					Plugin.logger.LogError((object)"Failed to find the terminal object.");
					return;
				}
				val.terminalTrigger.interactable = false;
				GameObject val2 = Assets.SpawnPrefab("sparks", ((Component)val).transform.position);
				val2.transform.SetParent(((Component)val).transform, true);
				State.MalfunctionDistortion.AssignChild(val2);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		private static void CheckMalfunctionDoorTrigger(TimeOfDay __instance)
		{
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			if (!State.MalfunctionPower.Active && State.MalfunctionDoor.Active && !State.MalfunctionDoor.Triggered)
			{
				if (!__instance.currentDayTimeStarted || __instance.hour < 1 + State.MalfunctionDoor.Delay || __instance.hour >= 16)
				{
					return;
				}
				Plugin.logger.LogDebug((object)"Triggered door malfunction!");
				State.MalfunctionDoor.Triggered = true;
				if (!State.MalfunctionDoor.Notified)
				{
					((TMP_Text)HUDManager.Instance.globalNotificationText).text = "SHIP DOOR LOCK FAIL:\nCRACKDOWN PROTOCOL ACTIVE";
					HUDManager.Instance.globalNotificationAnimator.SetTrigger("TriggerNotif");
					HUDManager.Instance.UIAudio.PlayOneShot(HUDManager.Instance.radiationWarningAudio, 1f);
					State.MalfunctionDoor.Notified = true;
				}
				HangarShipDoor val = Object.FindAnyObjectByType<HangarShipDoor>();
				if ((Object)(object)val != (Object)null)
				{
					val.SetDoorClosed();
					val.PlayDoorAnimation(true);
				}
				GameObject val2 = GameObject.Find("HangarDoorButtonPanel");
				if ((Object)(object)val2 == (Object)null)
				{
					Plugin.logger.LogError((object)"Failed to find door panel object.");
					return;
				}
				InteractTrigger[] componentsInChildren = val2.GetComponentsInChildren<InteractTrigger>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].interactable = false;
				}
				GameObject val3 = Assets.SpawnPrefab("sparks", val2.transform.position);
				val3.transform.SetParent(val2.transform, true);
				State.MalfunctionDoor.AssignChild(val3);
			}
			else
			{
				if (State.MalfunctionPower.Active || !State.MalfunctionDoor.Active || !State.MalfunctionDoor.Triggered || __instance.hour < 16)
				{
					return;
				}
				State.MalfunctionDoor.Triggered = false;
				HangarShipDoor val4 = Object.FindAnyObjectByType<HangarShipDoor>();
				if ((Object)(object)val4 != (Object)null)
				{
					val4.SetDoorOpen();
					val4.PlayDoorAnimation(false);
				}
				GameObject val5 = GameObject.Find("HangarDoorButtonPanel");
				if ((Object)(object)val5 != (Object)null)
				{
					InteractTrigger[] componentsInChildren = val5.GetComponentsInChildren<InteractTrigger>(true);
					for (int i = 0; i < componentsInChildren.Length; i++)
					{
						componentsInChildren[i].interactable = true;
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatches
	{
		private static GameObject elevatorPanelScreen;

		private static GameObject floodlight1;

		private static GameObject floodlight2;

		private static Material floodlightMaterial;

		private static bool hadUnrecoveredDeadPlayers;

		[HarmonyPrefix]
		[HarmonyPatch("EndOfGame")]
		private static void CheckDeadPlayers(StartOfRound __instance, int bodiesInsured)
		{
			int num = __instance.connectedPlayersAmount + 1 - __instance.livingPlayers;
			if (num > bodiesInsured)
			{
				hadUnrecoveredDeadPlayers = true;
				Plugin.logger.LogDebug((object)$"There were unrecovered players! (Players: {__instance.connectedPlayersAmount + 1} / Dead: {num} / Recovered: {bodiesInsured})");
			}
			else
			{
				hadUnrecoveredDeadPlayers = false;
				Plugin.logger.LogDebug((object)$"All players are alive or recovered! (Players: {__instance.connectedPlayersAmount + 1} / Dead: {num} / Recovered: {bodiesInsured})");
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("ReviveDeadPlayers")]
		private static void RollMalfunctions(StartOfRound __instance)
		{
			int num = (int)(DateTime.Parse(DateTime.UtcNow.ToString("yyyy-MM-dd")) - new DateTime(1970, 1, 1)).TotalSeconds;
			int num2 = __instance.randomMapSeed + num;
			Random random = new Random(num2);
			Plugin.logger.LogDebug((object)$"Got random synced seed: {num2}");
			double num3 = random.NextDouble() * 100.0;
			double num4 = random.NextDouble() * 100.0;
			double num5 = random.NextDouble() * 100.0;
			double num6 = random.NextDouble() * 100.0;
			double num7 = random.NextDouble() * 100.0;
			double num8 = 1.0;
			if (Config.MalfunctionPenaltyEnabled.Value)
			{
				Plugin.logger.LogDebug((object)"Penalty multiplier active. Checking for unrecovered players.");
				if (hadUnrecoveredDeadPlayers)
				{
					num8 = Config.MalfunctionPenaltyMultiplier.Value;
					Plugin.logger.LogDebug((object)"Had unrecovered players. Increasing malfunction multiplier for this round.");
				}
				else if (Config.MalfunctionPenaltyOnly.Value)
				{
					num8 = 0.0;
					Plugin.logger.LogDebug((object)"No unrecovered players. Setting probability to zero as penalty mode only is enabled.");
				}
			}
			bool flag = Config.MalfunctionChanceNavigation.Value != 0.0 && num3 < Config.MalfunctionChanceNavigation.Value * num8;
			bool flag2 = Config.MalfunctionChanceTeleporter.Value != 0.0 && num4 < Config.MalfunctionChanceTeleporter.Value * num8;
			bool flag3 = Config.MalfunctionChanceDistortion.Value != 0.0 && num5 < Config.MalfunctionChanceDistortion.Value * num8;
			bool flag4 = Config.MalfunctionChanceDoor.Value != 0.0 && num7 < Config.MalfunctionChanceDoor.Value * num8;
			bool flag5 = Config.MalfunctionChancePower.Value != 0.0 && num6 < Config.MalfunctionChancePower.Value * num8;
			Plugin.logger.LogDebug((object)string.Format("Malfunction Navigation Roll: {0} < {1} ({2})", num3, Config.MalfunctionChanceNavigation.Value * num8, flag ? "SUCCESS" : "FAIL"));
			Plugin.logger.LogDebug((object)string.Format("Malfunction Teleporter Roll: {0} < {1} ({2})", num4, Config.MalfunctionChanceTeleporter.Value * num8, flag2 ? "SUCCESS" : "FAIL"));
			Plugin.logger.LogDebug((object)string.Format("Malfunction Distortion Roll: {0} < {1} ({2})", num5, Config.MalfunctionChanceDistortion.Value * num8, flag3 ? "SUCCESS" : "FAIL"));
			Plugin.logger.LogDebug((object)string.Format("Malfunction Door Roll: {0} < {1} ({2})", num7, Config.MalfunctionChanceDoor.Value * num8, flag4 ? "SUCCESS" : "FAIL"));
			Plugin.logger.LogDebug((object)string.Format("Malfunction Power Roll: {0} < {1} ({2})", num6, Config.MalfunctionChancePower.Value * num8, flag5 ? "SUCCESS" : "FAIL"));
			Plugin.logger.LogDebug((object)$"Elapsed days: {__instance.gameStats.daysSpent} / Days to next deadline: {TimeOfDay.Instance.daysUntilDeadline}");
			if (State.MalfunctionNavigation.Active || TimeOfDay.Instance.daysUntilDeadline < 2)
			{
				State.MalfunctionNavigation.Reset();
			}
			else if (((Object)__instance.currentLevel).name != "CompanyBuildingLevel" && TimeOfDay.Instance.daysUntilDeadline >= 2 && __instance.gameStats.daysSpent > Config.MalfunctionPassedDaysNavigation.Value && flag)
			{
				SelectableLevel[] array = __instance.levels.Where((SelectableLevel level) => ((Object)level).name != "CompanyBuildingLevel").ToArray();
				SelectableLevel val = random.NextFromCollection(array);
				__instance.ChangeLevel(val.levelID);
				SelectableLevel[] array2 = array;
				foreach (SelectableLevel val2 in array2)
				{
					Plugin.logger.LogDebug((object)$"Level ID: {val2.levelID} / Level Name: {((Object)val2).name}");
				}
				Plugin.logger.LogDebug((object)$"Selected Level ID: {val.levelID}");
				State.MalfunctionNavigation.Active = true;
			}
			if (State.MalfunctionTeleporter.Active || TimeOfDay.Instance.daysUntilDeadline < 2)
			{
				State.MalfunctionTeleporter.Reset();
			}
			else if (!State.MalfunctionPower.Active && ((Object)__instance.currentLevel).name != "CompanyBuildingLevel" && TimeOfDay.Instance.daysUntilDeadline >= 2 && __instance.gameStats.daysSpent > Config.MalfunctionPassedDaysTeleporter.Value && flag2)
			{
				if ((Object)(object)Object.FindObjectOfType<ShipTeleporter>() != (Object)null)
				{
					State.MalfunctionTeleporter.Delay = 1 + random.Next(11);
					State.MalfunctionTeleporter.Active = true;
					Plugin.logger.LogDebug((object)$"Teleporter malfunction will trigger at {7 + State.MalfunctionTeleporter.Delay}:00");
				}
				else
				{
					Plugin.logger.LogDebug((object)"Didn't find a teleporter! Skipping teleporter malfunction.");
				}
			}
			if (State.MalfunctionDistortion.Active || TimeOfDay.Instance.daysUntilDeadline < 2)
			{
				State.MalfunctionDistortion.Reset();
				Terminal val3 = Object.FindObjectOfType<Terminal>();
				if ((Object)(object)val3 != (Object)null)
				{
					val3.terminalTrigger.interactable = true;
				}
			}
			else if (!State.MalfunctionPower.Active && ((Object)__instance.currentLevel).name != "CompanyBuildingLevel" && TimeOfDay.Instance.daysUntilDeadline >= 2 && __instance.gameStats.daysSpent > Config.MalfunctionPassedDaysDistortion.Value && flag3)
			{
				State.MalfunctionDistortion.Delay = random.Next(0);
				State.MalfunctionDistortion.Active = true;
				Plugin.logger.LogDebug((object)$"Distortion malfunction will trigger at {7 + State.MalfunctionDistortion.Delay}:00");
			}
			if (State.MalfunctionDoor.Active || TimeOfDay.Instance.daysUntilDeadline < 2)
			{
				State.MalfunctionDoor.Reset();
				GameObject obj = elevatorPanelScreen;
				if (obj != null)
				{
					obj.SetActive(true);
				}
				GameObject val4 = GameObject.Find("HangarDoorButtonPanel");
				if ((Object)(object)val4 != (Object)null)
				{
					InteractTrigger[] componentsInChildren = val4.GetComponentsInChildren<InteractTrigger>(true);
					for (int i = 0; i < componentsInChildren.Length; i++)
					{
						componentsInChildren[i].interactable = true;
					}
				}
			}
			else if (!State.MalfunctionPower.Active && ((Object)__instance.currentLevel).name != "CompanyBuildingLevel" && TimeOfDay.Instance.daysUntilDeadline >= 2 && __instance.gameStats.daysSpent > Config.MalfunctionPassedDaysDoor.Value && flag4)
			{
				elevatorPanelScreen = GameObject.Find("ElevatorPanelScreen");
				State.MalfunctionDoor.Delay = 4 + random.Next(8);
				State.MalfunctionDoor.Active = true;
				Plugin.logger.LogDebug((object)$"Door malfunction will trigger at {7 + State.MalfunctionDoor.Delay}:00");
			}
			if (State.MalfunctionPower.Active || TimeOfDay.Instance.daysUntilDeadline < 2)
			{
				State.MalfunctionPower.Reset();
				if ((Object)(object)floodlight1 != (Object)null && (Object)(object)floodlight2 != (Object)null)
				{
					Light[] componentsInChildren2 = floodlight1.GetComponentsInChildren<Light>(true);
					Light[] componentsInChildren3 = floodlight2.GetComponentsInChildren<Light>(true);
					Light[] array3 = componentsInChildren2;
					for (int i = 0; i < array3.Length; i++)
					{
						((Behaviour)array3[i]).enabled = true;
					}
					array3 = componentsInChildren3;
					for (int i = 0; i < array3.Length; i++)
					{
						((Behaviour)array3[i]).enabled = true;
					}
					MeshRenderer component = floodlight1.GetComponent<MeshRenderer>();
					MeshRenderer component2 = floodlight2.GetComponent<MeshRenderer>();
					if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null)
					{
						Material[] materials = ((Renderer)component).materials;
						materials[2] = floodlightMaterial;
						((Renderer)component).materials = materials;
						((Renderer)component2).materials = materials;
					}
				}
				Terminal val5 = Object.FindObjectOfType<Terminal>();
				if ((Object)(object)val5 != (Object)null)
				{
					val5.terminalTrigger.interactable = true;
				}
				GameObject obj2 = elevatorPanelScreen;
				if (obj2 != null)
				{
					obj2.SetActive(true);
				}
				GameObject val6 = GameObject.Find("HangarDoorButtonPanel");
				if ((Object)(object)val6 != (Object)null)
				{
					InteractTrigger[] componentsInChildren = val6.GetComponentsInChildren<InteractTrigger>(true);
					for (int i = 0; i < componentsInChildren.Length; i++)
					{
						componentsInChildren[i].interactable = true;
					}
				}
			}
			else if (((Object)__instance.currentLevel).name != "CompanyBuildingLevel" && TimeOfDay.Instance.daysUntilDeadline >= 2 && __instance.gameStats.daysSpent > Config.MalfunctionPassedDaysPower.Value && flag5)
			{
				elevatorPanelScreen = GameObject.Find("ElevatorPanelScreen");
				State.MalfunctionPower.Active = true;
				double num9 = random.NextDouble() * 100.0;
				bool flag6 = Config.MalfunctionPowerBlockLeverChance.Value != 0.0 && num9 < Config.MalfunctionPowerBlockLeverChance.Value;
				if (Config.MalfunctionPowerBlockLever.Value && flag6)
				{
					State.MalfunctionPower.Delay = 1;
				}
				else
				{
					State.MalfunctionPower.Delay = 0;
				}
				Plugin.logger.LogDebug((object)string.Format("Malfunction Power - Block Lever Roll : {0} < {1} ({2})", num9, Config.MalfunctionPowerBlockLeverChance.Value, flag6 ? "SUCCESS" : "FAIL"));
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("SetMapScreenInfoToCurrentLevel")]
		[HarmonyAfter(new string[] { "jamil.corporate_restructure" })]
		private static void OverwriteMapScreenInfo(StartOfRound __instance)
		{
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			if (((Object)__instance.currentLevel).name != "CompanyBuildingLevel" && State.MalfunctionNavigation.Active && !State.MalfunctionNavigation.Notified)
			{
				((TMP_Text)HUDManager.Instance.globalNotificationText).text = "SHIP NAVIGATION MALFUNCTION:\nROUTE TABLE OFFSET ERROR";
				HUDManager.Instance.globalNotificationAnimator.SetTrigger("TriggerNotif");
				HUDManager.Instance.UIAudio.PlayOneShot(HUDManager.Instance.radiationWarningAudio, 1f);
				State.MalfunctionNavigation.Notified = true;
				((TMP_Text)__instance.screenLevelDescription).text = "SHIP NAVIGATION MALFUNCTION\nOrbiting: Unknown\nWeather: Unknown\nBE ADVISED THE ROUTE TABLE WILL RECALIBRATE AFTER LANDING";
				((Behaviour)__instance.screenLevelVideoReel).enabled = false;
				__instance.screenLevelVideoReel.clip = null;
				((Component)__instance.screenLevelVideoReel).gameObject.SetActive(false);
				__instance.screenLevelVideoReel.Stop();
				StartMatchLever val = Object.FindObjectOfType<StartMatchLever>();
				if ((Object)(object)val == (Object)null)
				{
					Plugin.logger.LogError((object)"Failed to find lever device object.");
					return;
				}
				GameObject val2 = Assets.SpawnPrefab("sparks", ((Component)val).transform.position);
				val2.transform.SetParent(((Component)val).transform, true);
				State.MalfunctionNavigation.AssignChild(val2);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("openingDoorsSequence")]
		private static void TriggerPowerMalfunction(StartOfRound __instance)
		{
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			if (!State.MalfunctionPower.Active)
			{
				return;
			}
			Plugin.logger.LogDebug((object)"Triggered power malfunction!");
			State.MalfunctionPower.Triggered = true;
			if (State.MalfunctionPower.Notified)
			{
				return;
			}
			if ((Object)(object)floodlight1 != (Object)null && (Object)(object)floodlight2 != (Object)null)
			{
				Light[] componentsInChildren = floodlight1.GetComponentsInChildren<Light>(true);
				Light[] componentsInChildren2 = floodlight2.GetComponentsInChildren<Light>(true);
				Light[] array = componentsInChildren;
				for (int i = 0; i < array.Length; i++)
				{
					((Behaviour)array[i]).enabled = false;
				}
				array = componentsInChildren2;
				for (int i = 0; i < array.Length; i++)
				{
					((Behaviour)array[i]).enabled = false;
				}
				MeshRenderer component = floodlight1.GetComponent<MeshRenderer>();
				MeshRenderer component2 = floodlight2.GetComponent<MeshRenderer>();
				if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null)
				{
					Material[] materials = ((Renderer)component).materials;
					materials[2] = ((Renderer)component).materials[0];
					((Renderer)component).materials = materials;
					((Renderer)component2).materials = materials;
				}
			}
			Terminal val = Object.FindObjectOfType<Terminal>();
			if ((Object)(object)val != (Object)null)
			{
				val.terminalTrigger.interactable = false;
			}
			GameObject obj = elevatorPanelScreen;
			if (obj != null)
			{
				obj.SetActive(false);
			}
			GameObject val2 = GameObject.Find("HangarDoorButtonPanel");
			if ((Object)(object)val2 != (Object)null)
			{
				InteractTrigger[] componentsInChildren3 = val2.GetComponentsInChildren<InteractTrigger>(true);
				for (int i = 0; i < componentsInChildren3.Length; i++)
				{
					componentsInChildren3[i].interactable = false;
				}
			}
			__instance.PowerSurgeShip();
			Object.FindObjectOfType<StormyWeather>(true).PlayThunderEffects(((Component)val).transform.position, val.terminalAudio);
			((TMP_Text)HUDManager.Instance.globalNotificationText).text = "SHIP CORE SURGE:\nRUNNING ON EMERGENCY POWER";
			HUDManager.Instance.globalNotificationAnimator.SetTrigger("TriggerNotif");
			HUDManager.Instance.UIAudio.PlayOneShot(HUDManager.Instance.radiationWarningAudio, 1f);
			State.MalfunctionPower.Notified = true;
		}

		[HarmonyPostfix]
		[HarmonyPatch("OnShipLandedMiscEvents")]
		private static void CaptureFloodlights()
		{
			if (!((Object)(object)floodlightMaterial == (Object)null))
			{
				return;
			}
			floodlight1 = GameObject.Find("Floodlight1");
			floodlight2 = GameObject.Find("Floodlight2");
			if ((Object)(object)floodlight1 == (Object)null || (Object)(object)floodlight2 == (Object)null)
			{
				Plugin.logger.LogWarning((object)"Failed to capture floodlight gameobjects!");
				return;
			}
			MeshRenderer component = floodlight1.GetComponent<MeshRenderer>();
			if ((Object)(object)component != (Object)null)
			{
				floodlightMaterial = ((Renderer)component).materials[2];
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void Reset()
		{
			State.Reset();
		}
	}
}
namespace Malfunctions.MonoBehaviours
{
	public class Sparks : MonoBehaviour
	{
		public float delayMin = 0.5f;

		public float delayMax = 10f;

		public float maxIntensity = 40000f;

		private float currentIntensity;

		private float now;

		private float next;

		private bool sentStop;

		private AudioSource audioSource;

		private Light pointLight;

		private VisualEffect visualEffect;

		private static VFXExposedProperty beginBurstTrigger;

		private static VFXExposedProperty stopBurstTrigger;

		private void Start()
		{
			beginBurstTrigger.name = "BeginBurst";
			stopBurstTrigger.name = "StopBurst";
			audioSource = ((Component)this).GetComponent<AudioSource>();
			pointLight = ((Component)this).GetComponent<Light>();
			visualEffect = ((Component)this).GetComponent<VisualEffect>();
			GameObject val = GameObject.Find("Player");
			Camera val2 = ((!((Object)(object)val == (Object)null)) ? val.GetComponentInChildren<Camera>() : Object.FindAnyObjectByType<Camera>());
			((Component)val2).gameObject.tag = "MainCamera";
		}

		private void Update()
		{
			now = Time.time;
			if (now > next)
			{
				next = now + Random.Range(delayMin, delayMax);
				sentStop = false;
				((Behaviour)pointLight).enabled = true;
				currentIntensity = maxIntensity;
				audioSource.pitch = Random.Range(0.7f, 2f);
				audioSource.Play();
				visualEffect.SendEvent(beginBurstTrigger.name);
			}
			else if (!sentStop)
			{
				visualEffect.SendEvent(stopBurstTrigger.name);
				sentStop = true;
			}
			pointLight.intensity = currentIntensity;
			currentIntensity = Mathf.Lerp(currentIntensity, 0f, Time.deltaTime * 100f);
		}
	}
}
namespace Malfunctions.Helpers
{
	public static class RandomHelper
	{
		public static TSource NextFromCollection<TSource>(this Random rand, IList<TSource> collection)
		{
			int index = rand.Next(collection.Count());
			return collection[index];
		}
	}
}

plugins/MaxwellScrap.dll

Decompiled 9 months ago
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("LaserTweaks")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LaserTweaks")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4963e0ea-7a99-4390-9cae-a4bdd01b6b43")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace MaxwellScrap
{
	public class Assets
	{
		public static AssetBundle MainAssetBundle;

		public static Item Item;

		internal static Stream GetEmbededResource(string name)
		{
			return Assembly.GetExecutingAssembly().GetManifestResourceStream("MaxwellScrap." + name);
		}

		public static void Init()
		{
			MainAssetBundle = AssetBundle.LoadFromStream(GetEmbededResource("maxwell.bundle"));
			Item = MainAssetBundle.LoadAsset<Item>("Assets/Mods/MaxwellScrapItem/Maxwell.asset");
		}
	}
	[BepInPlugin("Kittenji.MaxwellScrap", "Maxwell Scrap", "1.0.1")]
	public class Loader : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(GameNetworkManager))]
		internal class GameNetworkManagerPatch
		{
			[HarmonyPatch("Start")]
			[HarmonyPostfix]
			private static void StartPatch()
			{
				((Component)GameNetworkManager.Instance).GetComponent<NetworkManager>().AddNetworkPrefab(Assets.Item.spawnPrefab);
				Debug.Log((object)"[MAXWELL] Added network prefab");
			}
		}

		[HarmonyPatch(typeof(StartOfRound))]
		internal class StartOfRoundPatch
		{
			[HarmonyPatch("Awake")]
			[HarmonyPostfix]
			private static void AwakePatch(ref StartOfRound __instance)
			{
				//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_0103: Expected O, but got Unknown
				SelectableLevel[] levels = __instance.levels;
				foreach (SelectableLevel val in levels)
				{
					if (val.spawnableScrap.Any((SpawnableItemWithRarity x) => (Object)(object)x.spawnableItem == (Object)(object)Assets.Item))
					{
						continue;
					}
					int num = 2;
					SpawnableItemWithRarity val2 = val.spawnableScrap.Find((SpawnableItemWithRarity s) => Object.op_Implicit((Object)(object)s.spawnableItem) && Object.op_Implicit((Object)(object)s.spawnableItem.spawnPrefab) && ((Object)s.spawnableItem.spawnPrefab).name == "CashRegisterItem");
					if (val2 != null)
					{
						num = val2.rarity;
					}
					else if (val.spawnableScrap.Count > 0)
					{
						int num2 = int.MaxValue;
						foreach (SpawnableItemWithRarity item2 in val.spawnableScrap)
						{
							if (item2.rarity < num2)
							{
								num2 = item2.rarity;
							}
						}
						num = num2;
					}
					num = Mathf.Min(100, Mathf.Max(1, num));
					SpawnableItemWithRarity item = new SpawnableItemWithRarity
					{
						spawnableItem = Assets.Item,
						rarity = num
					};
					val.spawnableScrap.Add(item);
				}
				if (!__instance.allItemsList.itemsList.Contains(Assets.Item))
				{
					__instance.allItemsList.itemsList.Add(Assets.Item);
				}
			}
		}

		private const string modGUID = "Kittenji.MaxwellScrap";

		private readonly Harmony harmony = new Harmony("Kittenji.MaxwellScrap");

		private const int DefaultSpawnRarity = 2;

		private void Awake()
		{
			Assets.Init();
			harmony.PatchAll();
		}
	}
}

plugins/MemeSoundboard.dll

Decompiled 9 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("MemeSoundboard")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MemeSoundboard")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2a19c5a9-6341-4a09-b1eb-a1a2ae48ec34")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MemeSoundboard
{
	[BepInPlugin("florianbutz.memesoundboard", "Meme Soundboard", "1.1.2.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class MemeSoundboardBase : BaseUnityPlugin
	{
		private const string modGUID = "florianbutz.memesoundboard";

		private const string modName = "Meme Soundboard";

		private const string modVersion = "1.1.2.0";

		private static string bundlePath = "";

		private readonly Harmony harmony = new Harmony("florianbutz.memesoundboard");

		public static MemeSoundboardBase instance;

		internal ManualLogSource logSource;

		public static GameObject soundboardItemPrefab;

		private void Awake()
		{
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)(instance = null)))
			{
				instance = this;
			}
			logSource = Logger.CreateLogSource("Meme Soundboard");
			Configuration.Init();
			bundlePath = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "soundboarditemmodel");
			Assets.LoadAssetBundle(bundlePath);
			AssetBundle bundle = Assets.GetBundle();
			Item val = bundle.LoadAsset<Item>("soundboarditem");
			Soundboard soundboard = val.spawnPrefab.AddComponent<Soundboard>();
			((GrabbableObject)soundboard).itemProperties = val;
			AudioSource component = val.spawnPrefab.GetComponent<AudioSource>();
			component.volume = Mathf.Clamp(Configuration.SoundboardVolume, 0f, 1f);
			component.dopplerLevel = Mathf.Clamp(Configuration.DopplerLevel, 0f, 2f);
			Soundboard.soundboardClips = new List<AudioClip>();
			Soundboard.soundboardClipNames = new List<string>();
			AddNewSound("Vine Boom", bundle.LoadAsset<AudioClip>("vineboom"));
			AddNewSound("Tacco Bell", bundle.LoadAsset<AudioClip>("bell"));
			AddNewSound("Siren", bundle.LoadAsset<AudioClip>("siren"));
			AddNewSound("Violin Screech", bundle.LoadAsset<AudioClip>("violinscreech"));
			AddNewSound("Wilhelm Scream", bundle.LoadAsset<AudioClip>("wilhelmscream"));
			AddNewSound("Augh", bundle.LoadAsset<AudioClip>("augh"));
			AddNewSound("Reverb Fart", bundle.LoadAsset<AudioClip>("reverbfart"));
			AddNewSound("Horn", bundle.LoadAsset<AudioClip>("horn"));
			AddNewSound("Bowomp", bundle.LoadAsset<AudioClip>("bowomp"));
			AddNewSound("Ghost", bundle.LoadAsset<AudioClip>("ghost"));
			AddNewSound("Inception", bundle.LoadAsset<AudioClip>("inception"));
			AddNewSound("Fnaf Jumpscare", bundle.LoadAsset<AudioClip>("fnafjumpscare"));
			AddNewSound("Metal Pipe", bundle.LoadAsset<AudioClip>("metalpipe"));
			AddNewSound("What the hell bruh", bundle.LoadAsset<AudioClip>("browthbruh"));
			AddNewSound("Yippee", bundle.LoadAsset<AudioClip>("yippee"));
			soundboard.switchSoundClip = bundle.LoadAsset<AudioClip>("switchsound");
			TerminalNode val2 = (TerminalNode)ScriptableObject.CreateInstance("TerminalNode");
			Items.RegisterShopItem(val, (TerminalNode)null, (TerminalNode)null, val2, 15);
			soundboardItemPrefab = val.spawnPrefab;
			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);
					}
				}
			}
			logSource.LogInfo((object)"Meme Soundboard has started successfully!");
			harmony.PatchAll();
		}

		public static void AddNewSound(string soundName, AudioClip soundClip)
		{
			Soundboard.soundboardClips.Add(soundClip);
			Soundboard.soundboardClipNames.Add(soundName);
		}
	}
	public class Soundboard : GrabbableObject
	{
		private AudioSource soundboardSource;

		private Text selectedSoundText;

		public AudioClip switchSoundClip;

		public static List<AudioClip> soundboardClips;

		public static List<string> soundboardClipNames;

		private Animator antennaLightAnim;

		public NetworkVariable<int> selectedSound = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private bool isItemInMainHand;

		public void Awake()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			base.customGrabTooltip = "Grab - Play Meme Sounds!";
			base.grabbable = true;
			base.grabbableToEnemies = true;
			base.mainObjectRenderer = ((Component)this).GetComponent<MeshRenderer>();
			base.useCooldown = 2f;
			base.insertedBattery = new Battery(false, 5f);
			soundboardSource = ((Component)this).GetComponent<AudioSource>();
			antennaLightAnim = ((Component)this).GetComponentInChildren<Animator>();
			Text[] componentsInChildren = ((Component)this).GetComponentsInChildren<Text>();
			foreach (Text val in componentsInChildren)
			{
				if (((Object)((Component)val).gameObject).name == "SelectedSound")
				{
					selectedSoundText = val;
				}
			}
			selectedSoundText.text = soundboardClipNames[selectedSound.Value];
			foreach (string soundboardClipName in soundboardClipNames)
			{
				Debug.Log((object)soundboardClipName);
			}
			NetworkVariable<int> obj = selectedSound;
			obj.OnValueChanged = (OnValueChangedDelegate<int>)(object)Delegate.Combine((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<int>(OnValueChanged));
		}

		[ServerRpc(RequireOwnership = false)]
		public void ChangeSelectedSoundServerRpc(int index)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(4043019660u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, index);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4043019660u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					selectedSound.Value = index;
					soundboardSource.Stop();
				}
			}
		}

		private void OnValueChanged(int previous, int current)
		{
			Debug.Log((object)$"Detected NetworkVariable Change: Previous: {previous} | Current: {current}");
			selectedSoundText.text = soundboardClipNames[selectedSound.Value];
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			soundboardSource.PlayOneShot(GetSoundboardSound(), Configuration.SoundboardVolume);
			antennaLightAnim.Play("AntennaLightFlicker_Animation");
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			if (((ButtonControl)Keyboard.current[(Key)32]).wasPressedThisFrame && base.isHeld && ((NetworkBehaviour)this).IsOwner && isItemInMainHand)
			{
				Debug.Log((object)"Key was pressed! Switching Sound...");
				ChangeSelectedSoundServerRpc(NextIndex());
				selectedSoundText.text = soundboardClipNames[selectedSound.Value];
				Debug.Log((object)("Next Sound: " + (object)soundboardClips[selectedSound.Value]));
				soundboardSource.PlayOneShot(switchSoundClip, 0.35f);
			}
			if (((ButtonControl)Keyboard.current[(Key)31]).wasPressedThisFrame && base.isHeld && ((NetworkBehaviour)this).IsOwner && isItemInMainHand)
			{
				Debug.Log((object)"Key was pressed! Switching Sound...");
				ChangeSelectedSoundServerRpc(LastIndex());
				selectedSoundText.text = soundboardClipNames[selectedSound.Value];
				Debug.Log((object)("Next Sound: " + (object)soundboardClips[selectedSound.Value]));
				soundboardSource.PlayOneShot(switchSoundClip, 0.35f);
			}
			if (((ButtonControl)Keyboard.current[(Key)2]).wasPressedThisFrame && base.isHeld && ((NetworkBehaviour)this).IsOwner)
			{
				_ = isItemInMainHand;
			}
		}

		public override void PocketItem()
		{
			((GrabbableObject)this).PocketItem();
			((Component)((Component)selectedSoundText).transform.parent).gameObject.SetActive(false);
			selectedSoundText.text = soundboardClipNames[selectedSound.Value];
			isItemInMainHand = false;
			soundboardSource.Stop();
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			((Component)((Component)selectedSoundText).transform.parent).gameObject.SetActive(true);
			isItemInMainHand = true;
			selectedSoundText.text = soundboardClipNames[selectedSound.Value];
		}

		public AudioClip GetSoundboardSound()
		{
			return soundboardClips[selectedSound.Value];
		}

		public int NextIndex()
		{
			Debug.Log((object)"Getting next soundindex...");
			if (soundboardClips.Count > selectedSound.Value + 1)
			{
				Debug.Log((object)"Aquired next sound index");
				return selectedSound.Value + 1;
			}
			return 0;
		}

		public int LastIndex()
		{
			Debug.Log((object)"Getting next soundindex...");
			if (0 <= selectedSound.Value - 1)
			{
				Debug.Log((object)"Aquired last sound index");
				return selectedSound.Value - 1;
			}
			return soundboardClips.Count - 1;
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_Soundboard()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(4043019660u, new RpcReceiveHandler(__rpc_handler_4043019660));
		}

		private static void __rpc_handler_4043019660(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int index = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref index);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Soundboard)(object)target).ChangeSelectedSoundServerRpc(index);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "Soundboard";
		}
	}
	[HarmonyPatch]
	public class NetworkObjectManager
	{
		private static GameObject networkPrefab;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		public static void Init()
		{
			if (!((Object)(object)networkPrefab != (Object)null))
			{
				networkPrefab = MemeSoundboardBase.soundboardItemPrefab;
				NetworkManager.Singleton.AddNetworkPrefab(networkPrefab);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		private static void SpawnNetworkHandler()
		{
			//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)
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				Object.Instantiate<GameObject>(networkPrefab, Vector3.zero, Quaternion.identity).GetComponent<NetworkObject>().Spawn(false);
			}
		}
	}
	internal class Assets
	{
		internal static AssetBundle mainAssetBundle;

		private static string[] assetNames = new string[0];

		internal static void LoadAssetBundle(string assetbundlePath)
		{
			if ((Object)(object)mainAssetBundle == (Object)null)
			{
				mainAssetBundle = AssetBundle.LoadFromFile(assetbundlePath);
			}
			assetNames = mainAssetBundle.GetAllAssetNames();
		}

		internal static AssetBundle GetBundle()
		{
			if (!Object.op_Implicit((Object)(object)mainAssetBundle))
			{
				Debug.LogError((object)"There is no AssetBundle to load assets from.");
				return null;
			}
			return mainAssetBundle;
		}
	}
	internal static class Configuration
	{
		private const string CONFIG_FILE_NAME = "Soundboard.cfg";

		private static ConfigFile config;

		private static ConfigEntry<float> soundboardVolume;

		private static ConfigEntry<float> dopplerLevel;

		public static float SoundboardVolume => soundboardVolume.Value;

		public static float DopplerLevel => dopplerLevel.Value;

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			config = new ConfigFile(Path.Combine(Paths.ConfigPath, "Soundboard.cfg"), true);
			soundboardVolume = config.Bind<float>("Config", "Soundboard master volume", 1f, "Changes the volume of the soundboard sounds. Value can be between 0 and 1.");
			dopplerLevel = config.Bind<float>("Config", "Soundboard doppler level", 0.5f, "Changes the doppler level of the soundboard sounds. Value can be between 0 and 2.");
		}
	}
}

plugins/MetalRecharging.dll

Decompiled 9 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MetalRecharging")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Allows you to charge metal objects")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MetalRecharging")]
[assembly: AssemblyTitle("MetalRecharging")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MetalRecharging
{
	[BepInPlugin("MetalRecharging", "MetalRecharging", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin MetalRecharging is loaded!");
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "MetalRecharging";

		public const string PLUGIN_NAME = "MetalRecharging";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace MetalRecharging.Patches
{
	[HarmonyPatch(typeof(HUDManager))]
	internal class ChatPatch
	{
		private static bool _justExploded;

		private static SpawnableMapObject? _landmine;

		[HarmonyPatch("AddPlayerChatMessageServerRpc")]
		[HarmonyPatch("AddChatMessage")]
		[HarmonyPostfix]
		private static void OnServerMessageAdded(HUDManager __instance, ref string chatMessage)
		{
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			if (_justExploded || (Object)(object)((NetworkBehaviour)__instance).NetworkManager == (Object)null || !chatMessage.Contains("iexplode"))
			{
				return;
			}
			string[] array = chatMessage.Split('-');
			if (array.Length != 3)
			{
				return;
			}
			ulong playerId = ulong.Parse(array[1]);
			PlayerControllerB val = ((IEnumerable<PlayerControllerB>)__instance.playersManager.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB x) => x.playerClientId == playerId));
			if (_landmine == null)
			{
				_landmine = __instance.playersManager?.levels?.SelectMany((SelectableLevel x) => x.spawnableMapObjects).FirstOrDefault((Func<SpawnableMapObject, bool>)((SpawnableMapObject x) => ((Object)x.prefabToSpawn).name == "Landmine"));
			}
			if (!((Object)(object)val == (Object)null) && _landmine != null)
			{
				if (!((NetworkBehaviour)__instance).NetworkManager.IsHost && !((NetworkBehaviour)__instance).NetworkManager.IsServer)
				{
					LandminePatch.LastExplosionWasCharger = true;
					return;
				}
				LandminePatch.LastExplosionWasCharger = true;
				Debug.Log((object)"Explisuion time.");
				_justExploded = true;
				Vector3 val2 = ((Component)val).transform.position - new Vector3(0f, 0.25f, 0f);
				GameObject obj = Object.Instantiate<GameObject>(_landmine.prefabToSpawn, val2, Quaternion.identity, RoundManager.Instance.mapPropsContainer.transform);
				Landmine componentInChildren = obj.GetComponentInChildren<Landmine>();
				obj.GetComponent<NetworkObject>().Spawn(true);
				componentInChildren.ExplodeMineServerRpc();
				Unexplode();
			}
		}

		private static async Task Unexplode()
		{
			await Task.Delay(200);
			_justExploded = false;
		}

		public static void SendExplosionChat()
		{
			if (!((Object)(object)GameNetworkManager.Instance == (Object)null) && !((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null))
			{
				int num = (int)GameNetworkManager.Instance.localPlayerController.playerClientId;
				HUDManager.Instance.AddTextToChatOnServer("<size=0>-" + num + "-iexplode</size>", num);
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class InteractPerformedPatch
	{
		private static bool _swappingTwoHandedValue;

		[HarmonyPatch("Interact_performed")]
		[HarmonyPrefix]
		internal static void InteractPerformedPrefix(PlayerControllerB __instance)
		{
			if (!((Object)(object)__instance.hoveringOverTrigger == (Object)null) && __instance.twoHanded)
			{
				Transform parent = ((Component)__instance.hoveringOverTrigger).transform.parent;
				if (!((Object)(object)parent == (Object)null) && !(((Object)((Component)parent).gameObject).name != "ChargeStationTrigger"))
				{
					_swappingTwoHandedValue = true;
					__instance.twoHanded = false;
				}
			}
		}

		[HarmonyPatch("Interact_performed")]
		[HarmonyPostfix]
		internal static void InteractPerformedPostfix(PlayerControllerB __instance)
		{
			if (_swappingTwoHandedValue)
			{
				_swappingTwoHandedValue = false;
				__instance.twoHanded = true;
			}
		}
	}
	[HarmonyPatch(typeof(ItemCharger))]
	internal class ItemChargerPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static bool ItemChargerUpdate(ItemCharger __instance, ref float ___updateInterval, ref InteractTrigger ___triggerScript)
		{
			if ((Object)(object)NetworkManager.Singleton == (Object)null)
			{
				return false;
			}
			if (___updateInterval > 1f)
			{
				___updateInterval = 0f;
				if ((Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
				{
					GrabbableObject currentlyHeldObjectServer = GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer;
					if ((Object)(object)currentlyHeldObjectServer == (Object)null || (!currentlyHeldObjectServer.itemProperties.isConductiveMetal && !currentlyHeldObjectServer.itemProperties.requiresBattery))
					{
						___triggerScript.interactable = false;
						___triggerScript.disabledHoverTip = "(Requires battery-powered or metal item)";
					}
					else
					{
						___triggerScript.interactable = true;
					}
					___triggerScript.twoHandedItemAllowed = true;
					return false;
				}
			}
			___updateInterval += Time.deltaTime;
			return false;
		}

		[HarmonyPatch("ChargeItem")]
		[HarmonyPostfix]
		private static void ItemChargerCharge(ItemCharger __instance)
		{
			GrabbableObject currentlyHeldObjectServer = GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer;
			if ((Object)(object)currentlyHeldObjectServer != (Object)null && !currentlyHeldObjectServer.itemProperties.requiresBattery && currentlyHeldObjectServer.itemProperties.isConductiveMetal)
			{
				LandminePatch.LastExplosionWasLocalPlayer = true;
				ChatPatch.SendExplosionChat();
			}
		}
	}
	[HarmonyPatch(typeof(Landmine))]
	internal class LandminePatch
	{
		public static bool LastExplosionWasLocalPlayer;

		public static bool LastExplosionWasCharger;

		[HarmonyPatch("SpawnExplosion")]
		[HarmonyPrefix]
		private static bool SpawnExplosion(Vector3 explosionPosition, bool spawnExplosionEffect = false, float killRange = 1f, float damageRange = 1f)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"Spawning explosion");
			Debug.Log((object)"Charger:");
			Debug.Log((object)LastExplosionWasCharger);
			Debug.Log((object)LastExplosionWasLocalPlayer);
			if (!LastExplosionWasCharger)
			{
				return true;
			}
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			Vector3 val = (((Component)localPlayerController.gameplayCamera).transform.position - explosionPosition) * 80f / Vector3.Distance(((Component)localPlayerController.gameplayCamera).transform.position, explosionPosition);
			if (LastExplosionWasLocalPlayer)
			{
				localPlayerController.KillPlayer(val, true, (CauseOfDeath)3, 0);
			}
			LastExplosionWasCharger = false;
			LastExplosionWasLocalPlayer = false;
			int num = ~LayerMask.GetMask(new string[1] { "Room" });
			num = ~LayerMask.GetMask(new string[1] { "Colliders" });
			Collider[] array = Physics.OverlapSphere(explosionPosition, 10f, num);
			for (int i = 0; i < array.Length; i++)
			{
				Rigidbody component = ((Component)array[i]).GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					component.AddExplosionForce(70f, explosionPosition, 10f);
				}
			}
			return false;
		}
	}
}

plugins/MoreBlood.dll

Decompiled 9 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using MoreBlood.Config;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MoreBlood")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MoreBlood")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d1f1321d-30a3-4600-9bf8-1e69fe1abf8c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MoreBlood
{
	[BepInPlugin("FlipMods.MoreBlood", "MoreBlood", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin instance;

		private Harmony _harmony;

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

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

		public const string PLUGIN_NAME = "MoreBlood";

		public const string PLUGIN_VERSION = "1.0.2";
	}
}
namespace MoreBlood.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class MoreBloodPatcher
	{
		private static int bloodCount;

		[HarmonyPatch("DropBlood")]
		[HarmonyPostfix]
		public static void MoreBlood(PlayerControllerB __instance, Vector3 direction = default(Vector3), bool leaveBlood = true, bool leaveFootprint = false)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			bloodCount++;
			if (bloodCount < ConfigSettings.numBloodPools.Value)
			{
				__instance.DropBlood(direction, leaveBlood, leaveFootprint);
			}
			else
			{
				bloodCount = 0;
			}
		}

		[HarmonyPatch("RandomizeBloodRotationAndScale")]
		[HarmonyPostfix]
		public static void RandomizeBloodScale(ref Transform blood, PlayerControllerB __instance)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//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)
			Transform obj = blood;
			obj.localScale *= ConfigSettings.bloodScale.Value;
			blood.position += new Vector3((float)Random.Range(-1, 1) * ConfigSettings.bloodScale.Value, 0.55f, (float)Random.Range(-1, 1) * ConfigSettings.bloodScale.Value);
		}
	}
}
namespace MoreBlood.Config
{
	public static class ConfigSettings
	{
		public static ConfigEntry<float> bloodScale;

		public static ConfigEntry<int> numBloodPools;

		public static void BindConfigSettings()
		{
			Plugin.Log("BindingConfigs");
			bloodScale = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("MoreBlood", "BloodScale", 4f, "The size of the blood pools");
			numBloodPools = ((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("MoreBlood", "NumberOfBloodPools", 4, "Max number of blood pools spread around the blood source.");
		}
	}
}

plugins/MoreCompany.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MoreCompany.Cosmetics;
using MoreCompany.Utils;
using Steamworks;
using Steamworks.Data;
using TMPro;
using Unity.Netcode;
using Unity.Netcode.Transports.UTP;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MoreCompany")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("Copyright © NotNotSwipez 2023")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MoreCompany")]
[assembly: AssemblyTitle("MoreCompany")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MoreCompany
{
	[HarmonyPatch(typeof(AudioMixer), "SetFloat")]
	public static class AudioMixerSetFloatPatch
	{
		public static bool Prefix(string name, float value)
		{
			if (name.StartsWith("PlayerVolume") || name.StartsWith("PlayerPitch"))
			{
				string s = name.Replace("PlayerVolume", "").Replace("PlayerPitch", "");
				int num = int.Parse(s);
				PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[num];
				if ((Object)(object)val != (Object)null)
				{
					AudioSource currentVoiceChatAudioSource = val.currentVoiceChatAudioSource;
					if (Object.op_Implicit((Object)(object)currentVoiceChatAudioSource))
					{
						if (name.StartsWith("PlayerVolume"))
						{
							currentVoiceChatAudioSource.volume = value / 16f;
						}
						else if (name.StartsWith("PlayerPitch"))
						{
							currentVoiceChatAudioSource.pitch = value;
						}
					}
					return false;
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(HUDManager), "AddTextToChatOnServer")]
	public static class SendChatToServerPatch
	{
		public static bool Prefix(HUDManager __instance, string chatMessage, int playerId = -1)
		{
			if (((NetworkBehaviour)StartOfRound.Instance).IsHost && chatMessage.StartsWith("/mc") && DebugCommandRegistry.commandEnabled)
			{
				string text = chatMessage.Replace("/mc ", "");
				DebugCommandRegistry.HandleCommand(text.Split(' '));
				return false;
			}
			if (chatMessage.StartsWith("[morecompanycosmetics]"))
			{
				ReflectionUtils.InvokeMethod(__instance, "AddPlayerChatMessageServerRpc", new object[2] { chatMessage, 99 });
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(HUDManager), "AddPlayerChatMessageServerRpc")]
	public static class ServerReceiveMessagePatch
	{
		public static string previousDataMessage = "";

		public static bool Prefix(HUDManager __instance, ref string chatMessage, int playerId)
		{
			NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager;
			if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening)
			{
				return false;
			}
			if (chatMessage.StartsWith("[morecompanycosmetics]") && networkManager.IsServer)
			{
				previousDataMessage = chatMessage;
				chatMessage = "[replacewithdata]";
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
	public static class ConnectClientToPlayerObjectPatch
	{
		public static void Postfix(PlayerControllerB __instance)
		{
			string text = "[morecompanycosmetics]";
			text = text + ";" + __instance.playerClientId;
			foreach (string locallySelectedCosmetic in CosmeticRegistry.locallySelectedCosmetics)
			{
				text = text + ";" + locallySelectedCosmetic;
			}
			HUDManager.Instance.AddTextToChatOnServer(text, -1);
		}
	}
	[HarmonyPatch(typeof(HUDManager), "AddChatMessage")]
	public static class AddChatMessagePatch
	{
		public static bool Prefix(HUDManager __instance, string chatMessage, string nameOfUserWhoTyped = "")
		{
			if (chatMessage.StartsWith("[replacewithdata]") || chatMessage.StartsWith("[morecompanycosmetics]"))
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(HUDManager), "AddPlayerChatMessageClientRpc")]
	public static class ClientReceiveMessagePatch
	{
		public static bool ignoreSample;

		public static bool Prefix(ref HUDManager __instance, ref string chatMessage, int playerId)
		{
			NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager;
			if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening)
			{
				return false;
			}
			if (networkManager.IsServer)
			{
				if (chatMessage.StartsWith("[replacewithdata]"))
				{
					chatMessage = ServerReceiveMessagePatch.previousDataMessage;
					HandleDataMessage(ref chatMessage);
				}
				else if (chatMessage.StartsWith("[morecompanycosmetics]"))
				{
					return false;
				}
			}
			else if (chatMessage.StartsWith("[morecompanycosmetics]"))
			{
				HandleDataMessage(ref chatMessage);
			}
			return true;
		}

		private static void HandleDataMessage(ref string chatMessage)
		{
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			if (ignoreSample)
			{
				return;
			}
			chatMessage = chatMessage.Replace("[morecompanycosmetics]", "");
			string[] array = chatMessage.Split(';');
			string text = array[1];
			int num = int.Parse(text);
			CosmeticApplication component = ((Component)((Component)StartOfRound.Instance.allPlayerScripts[num]).transform.Find("ScavengerModel").Find("metarig")).gameObject.GetComponent<CosmeticApplication>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.ClearCosmetics();
				Object.Destroy((Object)(object)component);
			}
			CosmeticApplication cosmeticApplication = ((Component)((Component)StartOfRound.Instance.allPlayerScripts[num]).transform.Find("ScavengerModel").Find("metarig")).gameObject.AddComponent<CosmeticApplication>();
			cosmeticApplication.ClearCosmetics();
			List<string> list = new List<string>();
			string[] array2 = array;
			foreach (string text2 in array2)
			{
				if (!(text2 == text))
				{
					list.Add(text2);
					if (MainClass.showCosmetics)
					{
						cosmeticApplication.ApplyCosmetic(text2, startEnabled: true);
					}
				}
			}
			if (num == StartOfRound.Instance.thisClientPlayerId)
			{
				cosmeticApplication.ClearCosmetics();
			}
			foreach (CosmeticInstance spawnedCosmetic in cosmeticApplication.spawnedCosmetics)
			{
				Transform transform = ((Component)spawnedCosmetic).transform;
				transform.localScale *= 0.38f;
			}
			MainClass.playerIdsAndCosmetics.Remove(num);
			MainClass.playerIdsAndCosmetics.Add(num, list);
			if (!GameNetworkManager.Instance.isHostingGame || num == 0)
			{
				return;
			}
			ignoreSample = true;
			foreach (KeyValuePair<int, List<string>> playerIdsAndCosmetic in MainClass.playerIdsAndCosmetics)
			{
				string text3 = "[morecompanycosmetics]";
				text3 = text3 + ";" + playerIdsAndCosmetic.Key;
				foreach (string item in playerIdsAndCosmetic.Value)
				{
					text3 = text3 + ";" + item;
				}
				HUDManager.Instance.AddTextToChatOnServer(text3, -1);
			}
			ignoreSample = false;
		}
	}
	public class DebugCommandRegistry
	{
		public static bool commandEnabled;

		public static void HandleCommand(string[] args)
		{
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			if (!commandEnabled)
			{
				return;
			}
			PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
			switch (args[0])
			{
			case "money":
			{
				int groupCredits = int.Parse(args[1]);
				Terminal val5 = Resources.FindObjectsOfTypeAll<Terminal>().First();
				val5.groupCredits = groupCredits;
				break;
			}
			case "spawnscrap":
			{
				string text = "";
				for (int i = 1; i < args.Length; i++)
				{
					text = text + args[i] + " ";
				}
				text = text.Trim();
				Vector3 val = ((Component)localPlayerController).transform.position + ((Component)localPlayerController).transform.forward * 2f;
				SpawnableItemWithRarity val2 = null;
				foreach (SpawnableItemWithRarity item in StartOfRound.Instance.currentLevel.spawnableScrap)
				{
					if (item.spawnableItem.itemName.ToLower() == text.ToLower())
					{
						val2 = item;
						break;
					}
				}
				GameObject val3 = Object.Instantiate<GameObject>(val2.spawnableItem.spawnPrefab, val, Quaternion.identity, (Transform)null);
				GrabbableObject component = val3.GetComponent<GrabbableObject>();
				((Component)component).transform.rotation = Quaternion.Euler(component.itemProperties.restingRotation);
				component.fallTime = 0f;
				NetworkObject component2 = val3.GetComponent<NetworkObject>();
				component2.Spawn(false);
				break;
			}
			case "spawnenemy":
			{
				string text2 = "";
				for (int j = 1; j < args.Length; j++)
				{
					text2 = text2 + args[j] + " ";
				}
				text2 = text2.Trim();
				SpawnableEnemyWithRarity val4 = null;
				foreach (SpawnableEnemyWithRarity enemy in StartOfRound.Instance.currentLevel.Enemies)
				{
					if (enemy.enemyType.enemyName.ToLower() == text2.ToLower())
					{
						val4 = enemy;
						break;
					}
				}
				RoundManager.Instance.SpawnEnemyGameObject(((Component)localPlayerController).transform.position + ((Component)localPlayerController).transform.forward * 2f, 0f, -1, val4.enemyType);
				break;
			}
			case "listall":
				MainClass.StaticLogger.LogInfo((object)"Spawnable scrap:");
				foreach (SpawnableItemWithRarity item2 in StartOfRound.Instance.currentLevel.spawnableScrap)
				{
					MainClass.StaticLogger.LogInfo((object)item2.spawnableItem.itemName);
				}
				MainClass.StaticLogger.LogInfo((object)"Spawnable enemies:");
				{
					foreach (SpawnableEnemyWithRarity enemy2 in StartOfRound.Instance.currentLevel.Enemies)
					{
						MainClass.StaticLogger.LogInfo((object)enemy2.enemyType.enemyName);
					}
					break;
				}
			}
		}
	}
	[HarmonyPatch(typeof(ForestGiantAI), "LookForPlayers")]
	public static class LookForPlayersForestGiantPatch
	{
		public static void Prefix(ref ForestGiantAI __instance)
		{
			if (__instance.playerStealthMeters.Length != MainClass.newPlayerCount)
			{
				Array.Resize(ref __instance.playerStealthMeters, MainClass.newPlayerCount);
				for (int i = 0; i < MainClass.newPlayerCount; i++)
				{
					__instance.playerStealthMeters[i] = 0f;
				}
			}
		}
	}
	[HarmonyPatch(typeof(BlobAI), "Start")]
	public static class BlobAIStartPatch
	{
		public static void Postfix(ref BlobAI __instance)
		{
			Collider[] value = (Collider[])(object)new Collider[MainClass.newPlayerCount];
			ReflectionUtils.SetFieldValue(__instance, "ragdollColliders", value);
		}
	}
	[HarmonyPatch(typeof(CrawlerAI), "Start")]
	public static class CrawlerAIStartPatch
	{
		public static void Postfix(ref CrawlerAI __instance)
		{
			Collider[] value = (Collider[])(object)new Collider[MainClass.newPlayerCount];
			ReflectionUtils.SetFieldValue(__instance, "nearPlayerColliders", value);
		}
	}
	[HarmonyPatch(typeof(SpringManAI), "Update")]
	public static class SpringManAIUpdatePatch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>();
			bool flag = false;
			bool flag2 = false;
			foreach (CodeInstruction instruction in instructions)
			{
				if (!flag2)
				{
					if (!flag && ((object)instruction).ToString() == "call static float UnityEngine.Vector3::Distance(UnityEngine.Vector3 a, UnityEngine.Vector3 b)")
					{
						flag = true;
					}
					else if (flag && ((object)instruction).ToString() == "ldc.i4.4 NULL")
					{
						flag2 = true;
						CodeInstruction item = new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MainClass), "newPlayerCount"));
						list.Add(item);
						continue;
					}
				}
				list.Add(instruction);
			}
			return list.AsEnumerable();
		}
	}
	[HarmonyPatch(typeof(SpringManAI), "DoAIInterval")]
	public static class SpringManAIIntervalPatch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>();
			bool flag = false;
			bool flag2 = false;
			foreach (CodeInstruction instruction in instructions)
			{
				if (!flag2)
				{
					if (!flag && ((object)instruction).ToString() == "call void EnemyAI::SwitchToBehaviourState(int stateIndex)")
					{
						flag = true;
					}
					else if (flag && ((object)instruction).ToString() == "ldc.i4.4 NULL")
					{
						flag2 = true;
						CodeInstruction item = new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MainClass), "newPlayerCount"));
						list.Add(item);
						continue;
					}
				}
				list.Add(instruction);
			}
			return list.AsEnumerable();
		}
	}
	[HarmonyPatch(typeof(EnemyAI), "GetClosestPlayer")]
	public static class GetClosestPlayerPatch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>();
			bool flag = false;
			foreach (CodeInstruction instruction in instructions)
			{
				if (!flag && ((object)instruction).ToString() == "ldc.i4.4 NULL")
				{
					flag = true;
					CodeInstruction item = new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MainClass), "newPlayerCount"));
					list.Add(item);
				}
				else
				{
					list.Add(instruction);
				}
			}
			return list.AsEnumerable();
		}
	}
	[HarmonyPatch(typeof(EnemyAI), "GetAllPlayersInLineOfSight")]
	public static class GetAllPlayersInLineOfSightPatch
	{
		public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>();
			bool flag = false;
			foreach (CodeInstruction instruction in instructions)
			{
				if (!flag && ((object)instruction).ToString() == "ldc.i4.4 NULL")
				{
					flag = true;
					CodeInstruction item = new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MainClass), "newPlayerCount"));
					list.Add(item);
				}
				else
				{
					list.Add(instruction);
				}
			}
			return list.AsEnumerable();
		}
	}
	[HarmonyPatch(typeof(DressGirlAI), "ChoosePlayerToHaunt")]
	public static class DressGirlHauntPatch
	{
		public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>();
			foreach (CodeInstruction instruction in instructions)
			{
				if (((object)instruction).ToString() == "ldc.i4.4 NULL")
				{
					CodeInstruction item = new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MainClass), "newPlayerCount"));
					list.Add(item);
				}
				else
				{
					list.Add(instruction);
				}
			}
			return list.AsEnumerable();
		}
	}
	[HarmonyPatch(typeof(HUDManager), "AddChatMessage")]
	public static class HudChatPatch
	{
		public static void Prefix(HUDManager __instance, ref string chatMessage, string nameOfUserWhoTyped = "")
		{
			if (!(__instance.lastChatMessage == chatMessage))
			{
				StringBuilder stringBuilder = new StringBuilder(chatMessage);
				for (int i = 0; i < MainClass.newPlayerCount; i++)
				{
					string oldValue = $"[playerNum{i}]";
					string playerUsername = StartOfRound.Instance.allPlayerScripts[i].playerUsername;
					stringBuilder.Replace(oldValue, playerUsername);
				}
				chatMessage = stringBuilder.ToString();
			}
		}
	}
	[HarmonyPatch(typeof(MenuManager), "Awake")]
	public static class MenuManagerLogoOverridePatch
	{
		public static List<TMP_InputField> inputFields = new List<TMP_InputField>();

		public static void Postfix(MenuManager __instance)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				MainClass.ReadSettingsFromFile();
				GameObject gameObject = ((Component)((Component)__instance).transform.parent).gameObject;
				Sprite sprite = Sprite.Create(MainClass.mainLogo, new Rect(0f, 0f, (float)((Texture)MainClass.mainLogo).width, (float)((Texture)MainClass.mainLogo).height), new Vector2(0.5f, 0.5f));
				Transform val = gameObject.transform.Find("MenuContainer/MainButtons/HeaderImage");
				if ((Object)(object)val != (Object)null)
				{
					((Component)val).gameObject.GetComponent<Image>().sprite = sprite;
				}
				Transform val2 = gameObject.transform.Find("MenuContainer/LoadingScreen");
				if ((Object)(object)val2 != (Object)null)
				{
					val2.localScale = new Vector3(1.02f, 1.06f, 1.02f);
					Transform val3 = val2.Find("Image");
					if ((Object)(object)val3 != (Object)null)
					{
						((Component)val3).GetComponent<Image>().sprite = sprite;
					}
				}
				CosmeticRegistry.SpawnCosmeticGUI();
				LANMenu.InitializeMenu();
				inputFields.Clear();
				Transform val4 = gameObject.transform.Find("MenuContainer/LobbyHostSettings/HostSettingsContainer/LobbyHostOptions");
				if ((Object)(object)val4 != (Object)null)
				{
					CreateCrewCountInput(val4.Find(GameNetworkManager.Instance.disableSteam ? "LANOptions" : "OptionsNormal"));
				}
				Transform val5 = gameObject.transform.Find("MenuContainer/LobbyJoinSettings/JoinSettingsContainer/LobbyJoinOptions");
				if ((Object)(object)val5 != (Object)null)
				{
					CreateCrewCountInput(val5.Find("LANOptions"));
				}
			}
			catch (Exception ex)
			{
				MainClass.StaticLogger.LogError((object)ex);
			}
		}

		private static void CreateCrewCountInput(Transform parent)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(MainClass.crewCountUI, parent);
			RectTransform component = val.GetComponent<RectTransform>();
			((Transform)component).localPosition = new Vector3(96.9f, -70f, -6.7f);
			TMP_InputField inputField = ((Component)val.transform.Find("InputField (TMP)")).GetComponent<TMP_InputField>();
			inputField.characterLimit = 3;
			inputField.text = MainClass.newPlayerCount.ToString();
			inputFields.Add(inputField);
			((UnityEvent<string>)(object)inputField.onValueChanged).AddListener((UnityAction<string>)delegate(string s)
			{
				if (!(inputField.text == MainClass.newPlayerCount.ToString()))
				{
					if (int.TryParse(s, out var result))
					{
						MainClass.newPlayerCount = Mathf.Clamp(result, MainClass.minPlayerCount, MainClass.maxPlayerCount);
						foreach (TMP_InputField inputField2 in inputFields)
						{
							inputField2.text = MainClass.newPlayerCount.ToString();
						}
						MainClass.SaveSettingsToFile();
						MainClass.StaticLogger.LogInfo((object)$"Changed Crew Count: {MainClass.newPlayerCount}");
					}
					else if (s.Length != 0)
					{
						foreach (TMP_InputField inputField3 in inputFields)
						{
							inputField3.text = MainClass.newPlayerCount.ToString();
							inputField3.caretPosition = 1;
						}
					}
				}
			});
		}
	}
	[HarmonyPatch(typeof(QuickMenuManager), "AddUserToPlayerList")]
	public static class AddUserPlayerListPatch
	{
		private static bool Prefix(QuickMenuManager __instance, ulong steamId, string playerName, int playerObjectId)
		{
			QuickmenuVisualInjectPatch.PopulateQuickMenu(__instance);
			MainClass.EnablePlayerObjectsBasedOnConnected();
			return false;
		}
	}
	[HarmonyPatch(typeof(QuickMenuManager), "RemoveUserFromPlayerList")]
	public static class RemoveUserPlayerListPatch
	{
		public static bool Prefix(QuickMenuManager __instance)
		{
			QuickmenuVisualInjectPatch.PopulateQuickMenu(__instance);
			return false;
		}
	}
	[HarmonyPatch(typeof(QuickMenuManager), "Update")]
	public static class QuickMenuUpdatePatch
	{
		public static bool Prefix()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(QuickMenuManager), "NonHostPlayerSlotsEnabled")]
	public static class QuickMenuDisplayPatch
	{
		public static bool Prefix(ref bool __result)
		{
			__result = false;
			for (int i = 1; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
			{
				PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[i];
				if (val.isPlayerControlled || val.isPlayerDead)
				{
					__result = true;
					break;
				}
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(QuickMenuManager), "Start")]
	public static class QuickmenuVisualInjectPatch
	{
		public static GameObject quickMenuScrollInstance;

		public static void Postfix(QuickMenuManager __instance)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			GameObject gameObject = ((Component)__instance.playerListPanel.transform.Find("Image")).gameObject;
			GameObject val = Object.Instantiate<GameObject>(MainClass.quickMenuScrollParent);
			val.transform.SetParent(gameObject.transform);
			RectTransform component = val.GetComponent<RectTransform>();
			((Transform)component).localPosition = new Vector3(0f, -31.2f, 0f);
			((Transform)component).localScale = Vector3.one;
			quickMenuScrollInstance = val;
		}

		public static void PopulateQuickMenu(QuickMenuManager __instance)
		{
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Expected O, but got Unknown
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Expected O, but got Unknown
			int childCount = quickMenuScrollInstance.transform.Find("Holder").childCount;
			List<GameObject> list = new List<GameObject>();
			for (int i = 0; i < childCount; i++)
			{
				list.Add(((Component)quickMenuScrollInstance.transform.Find("Holder").GetChild(i)).gameObject);
			}
			foreach (GameObject item in list)
			{
				Object.Destroy((Object)(object)item);
			}
			if (!Object.op_Implicit((Object)(object)StartOfRound.Instance))
			{
				return;
			}
			for (int j = 0; j < StartOfRound.Instance.allPlayerScripts.Length; j++)
			{
				PlayerControllerB playerScript = StartOfRound.Instance.allPlayerScripts[j];
				if (!playerScript.isPlayerControlled && !playerScript.isPlayerDead)
				{
					continue;
				}
				GameObject val = Object.Instantiate<GameObject>(MainClass.playerEntry, quickMenuScrollInstance.transform.Find("Holder"));
				RectTransform component = val.GetComponent<RectTransform>();
				((Transform)component).localScale = Vector3.one;
				((Transform)component).localPosition = new Vector3(0f, 0f - ((Transform)component).localPosition.y, 0f);
				TextMeshProUGUI component2 = ((Component)val.transform.Find("PlayerNameButton").Find("PName")).GetComponent<TextMeshProUGUI>();
				((TMP_Text)component2).text = playerScript.playerUsername;
				Slider playerVolume = ((Component)val.transform.Find("PlayerVolumeSlider")).GetComponent<Slider>();
				int finalIndex = j;
				((UnityEvent<float>)(object)playerVolume.onValueChanged).AddListener((UnityAction<float>)delegate(float f)
				{
					if (playerScript.isPlayerControlled || playerScript.isPlayerDead)
					{
						float num = f / playerVolume.maxValue + 1f;
						if (num <= -1f)
						{
							SoundManager.Instance.playerVoiceVolumes[finalIndex] = -70f;
						}
						else
						{
							SoundManager.Instance.playerVoiceVolumes[finalIndex] = num;
						}
					}
				});
				if ((Object)(object)StartOfRound.Instance.localPlayerController != (Object)null && StartOfRound.Instance.localPlayerController.playerClientId == playerScript.playerClientId)
				{
					((Component)playerVolume).gameObject.SetActive(false);
					((Component)val.transform.Find("Text (1)")).gameObject.SetActive(false);
				}
				Button component3 = ((Component)val.transform.Find("KickButton")).GetComponent<Button>();
				((UnityEvent)component3.onClick).AddListener((UnityAction)delegate
				{
					__instance.KickUserFromServer(finalIndex);
				});
				if (!GameNetworkManager.Instance.isHostingGame)
				{
					((Component)component3).gameObject.SetActive(false);
				}
				Button component4 = ((Component)val.transform.Find("ProfileIcon")).GetComponent<Button>();
				((UnityEvent)component4.onClick).AddListener((UnityAction)delegate
				{
					//IL_001d: Unknown result type (might be due to invalid IL or missing references)
					if (!GameNetworkManager.Instance.disableSteam)
					{
						SteamFriends.OpenUserOverlay(SteamId.op_Implicit(playerScript.playerSteamId), "steamid");
					}
				});
			}
		}
	}
	[HarmonyPatch(typeof(QuickMenuManager), "ConfirmKickUserFromServer")]
	public static class KickPatch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>();
			bool flag = false;
			bool flag2 = false;
			foreach (CodeInstruction instruction in instructions)
			{
				if (!flag2)
				{
					if (!flag && ((object)instruction).ToString() == "ldfld int QuickMenuManager::playerObjToKick")
					{
						flag = true;
					}
					else if (flag && ((object)instruction).ToString() == "ldc.i4.3 NULL")
					{
						flag2 = true;
						CodeInstruction item = new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MainClass), "newPlayerCount"));
						list.Add(item);
						continue;
					}
				}
				list.Add(instruction);
			}
			return list.AsEnumerable();
		}
	}
	[HarmonyPatch(typeof(HUDManager), "UpdateBoxesSpectateUI")]
	public static class SpectatorBoxUpdatePatch
	{
		public static void Postfix(HUDManager __instance)
		{
			//IL_009c: 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)
			Dictionary<Animator, PlayerControllerB> fieldValue = ReflectionUtils.GetFieldValue<Dictionary<Animator, PlayerControllerB>>(__instance, "spectatingPlayerBoxes");
			int num = -64;
			int num2 = 0;
			int num3 = 0;
			int num4 = -70;
			int num5 = 230;
			int num6 = 4;
			foreach (KeyValuePair<Animator, PlayerControllerB> item in fieldValue)
			{
				if (((Component)item.Key).gameObject.activeInHierarchy)
				{
					GameObject gameObject = ((Component)item.Key).gameObject;
					RectTransform component = gameObject.GetComponent<RectTransform>();
					int num7 = (int)Math.Floor((double)num3 / (double)num6);
					int num8 = num3 % num6;
					int num9 = num8 * num4;
					int num10 = num7 * num5;
					component.anchoredPosition = Vector2.op_Implicit(new Vector3((float)(num + num10), (float)(num2 + num9), 0f));
					num3++;
				}
			}
		}
	}
	[HarmonyPatch(typeof(HUDManager), "Start")]
	public static class HudStartPatch
	{
		public static void Postfix(HUDManager __instance)
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			EndOfGameStatUIElements statsUIElements = __instance.statsUIElements;
			GameObject gameObject = ((Component)((Component)statsUIElements.playerNamesText[0]).gameObject.transform.parent).gameObject;
			GameObject gameObject2 = ((Component)gameObject.transform.parent.parent).gameObject;
			GameObject gameObject3 = ((Component)gameObject2.transform.Find("BGBoxes")).gameObject;
			gameObject2.transform.parent.Find("DeathScreen").SetSiblingIndex(3);
			gameObject3.transform.localScale = new Vector3(2.5f, 1f, 1f);
			MakePlayerHolder(4, gameObject, statsUIElements, new Vector3(426.9556f, -0.7932f, 0f));
			MakePlayerHolder(5, gameObject, statsUIElements, new Vector3(426.9556f, -115.4483f, 0f));
			MakePlayerHolder(6, gameObject, statsUIElements, new Vector3(-253.6783f, -115.4483f, 0f));
			MakePlayerHolder(7, gameObject, statsUIElements, new Vector3(-253.6783f, -0.7932f, 0f));
			for (int i = 8; i < MainClass.newPlayerCount; i++)
			{
				MakePlayerHolder(i, gameObject, statsUIElements, new Vector3(10000f, 10000f, 0f));
			}
		}

		public static void MakePlayerHolder(int index, GameObject original, EndOfGameStatUIElements uiElements, Vector3 localPosition)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			if (index + 1 <= MainClass.newPlayerCount)
			{
				GameObject val = Object.Instantiate<GameObject>(original);
				RectTransform component = val.GetComponent<RectTransform>();
				RectTransform component2 = original.GetComponent<RectTransform>();
				((Transform)component).SetParent(((Transform)component2).parent);
				((Transform)component).localScale = new Vector3(1f, 1f, 1f);
				((Transform)component).localPosition = localPosition;
				GameObject gameObject = ((Component)val.transform.Find("PlayerName1")).gameObject;
				GameObject gameObject2 = ((Component)val.transform.Find("Notes")).gameObject;
				((Transform)gameObject2.GetComponent<RectTransform>()).localPosition = new Vector3(-95.7222f, 43.3303f, 0f);
				GameObject gameObject3 = ((Component)val.transform.Find("Symbol")).gameObject;
				if (index >= uiElements.playerNamesText.Length)
				{
					Array.Resize(ref uiElements.playerNamesText, index + 1);
					Array.Resize(ref uiElements.playerStates, index + 1);
					Array.Resize(ref uiElements.playerNotesText, index + 1);
				}
				uiElements.playerNamesText[index] = gameObject.GetComponent<TextMeshProUGUI>();
				uiElements.playerNotesText[index] = gameObject2.GetComponent<TextMeshProUGUI>();
				uiElements.playerStates[index] = gameObject3.GetComponent<Image>();
			}
		}
	}
	public class LANMenu : MonoBehaviour
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__0_0;

			internal void <InitializeMenu>b__0_0()
			{
				TextMeshProUGUI component = GameObject.Find("Canvas/MenuContainer/LobbyJoinSettings/JoinSettingsContainer/PrivatePublicDescription").GetComponent<TextMeshProUGUI>();
				if ((Object)(object)component != (Object)null)
				{
					((TMP_Text)component).text = "The mod will attempt to auto-detect the crew size however you can manually specify it to reduce chance of failure.";
				}
				GameObject.Find("Canvas/MenuContainer/LobbyJoinSettings").gameObject.SetActive(true);
			}
		}

		public static void InitializeMenu()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//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_0069: Expected O, but got Unknown
			CreateUI();
			GameObject val = GameObject.Find("Canvas/MenuContainer/MainButtons/StartLAN");
			if (!((Object)(object)val != (Object)null))
			{
				return;
			}
			MainClass.StaticLogger.LogInfo((object)"LANMenu startLAN Patched");
			val.GetComponent<Button>().onClick = new ButtonClickedEvent();
			ButtonClickedEvent onClick = val.GetComponent<Button>().onClick;
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				UnityAction val2 = delegate
				{
					TextMeshProUGUI component = GameObject.Find("Canvas/MenuContainer/LobbyJoinSettings/JoinSettingsContainer/PrivatePublicDescription").GetComponent<TextMeshProUGUI>();
					if ((Object)(object)component != (Object)null)
					{
						((TMP_Text)component).text = "The mod will attempt to auto-detect the crew size however you can manually specify it to reduce chance of failure.";
					}
					GameObject.Find("Canvas/MenuContainer/LobbyJoinSettings").gameObject.SetActive(true);
				};
				<>c.<>9__0_0 = val2;
				obj = (object)val2;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj);
		}

		private static GameObject CreateUI()
		{
			//IL_0066: 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_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Expected O, but got Unknown
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Expected O, but got Unknown
			if ((Object)(object)GameObject.Find("Canvas/MenuContainer/LobbyJoinSettings") != (Object)null)
			{
				return null;
			}
			GameObject val = GameObject.Find("Canvas/MenuContainer");
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			GameObject val2 = GameObject.Find("Canvas/MenuContainer/LobbyHostSettings");
			if ((Object)(object)val2 == (Object)null)
			{
				return null;
			}
			GameObject val3 = Object.Instantiate<GameObject>(val2, val2.transform.position, val2.transform.rotation, val.transform);
			((Object)val3).name = "LobbyJoinSettings";
			Transform val4 = val3.transform.Find("HostSettingsContainer");
			if ((Object)(object)val4 != (Object)null)
			{
				((Object)val4).name = "JoinSettingsContainer";
				((Object)((Component)val4).transform.Find("LobbyHostOptions")).name = "LobbyJoinOptions";
				Object.Destroy((Object)(object)((Component)val3.transform.Find("ChallengeLeaderboard")).gameObject);
				Object.Destroy((Object)(object)((Component)val3.transform.Find("FilesPanel")).gameObject);
				Object.Destroy((Object)(object)((Component)((Component)val4).transform.Find("LobbyJoinOptions/OptionsNormal")).gameObject);
				Object.Destroy((Object)(object)((Component)((Component)val4).transform.Find("LobbyJoinOptions/LANOptions/AllowRemote")).gameObject);
				Object.Destroy((Object)(object)((Component)((Component)val4).transform.Find("LobbyJoinOptions/LANOptions/Local")).gameObject);
				Transform val5 = ((Component)val4).transform.Find("LobbyJoinOptions/LANOptions/Header");
				if ((Object)(object)val5 != (Object)null)
				{
					((TMP_Text)((Component)val5).GetComponent<TextMeshProUGUI>()).text = "Join LAN Server:";
				}
				Transform val6 = ((Component)val4).transform.Find("LobbyJoinOptions/LANOptions/ServerNameField");
				if ((Object)(object)val6 != (Object)null)
				{
					((Component)val6).transform.localPosition = new Vector3(0f, 15f, -6.5f);
					((Component)val6).gameObject.SetActive(true);
				}
				TMP_InputField ip_field = ((Component)val6).GetComponent<TMP_InputField>();
				if ((Object)(object)ip_field != (Object)null)
				{
					TextMeshProUGUI ip_placeholder = ((Component)ip_field.placeholder).GetComponent<TextMeshProUGUI>();
					((TMP_Text)ip_placeholder).text = ES3.Load<string>("LANIPAddress", "LCGeneralSaveData", "127.0.0.1");
					Transform obj = ((Component)val4).transform.Find("Confirm");
					Button val7 = ((obj != null) ? ((Component)obj).GetComponent<Button>() : null);
					if ((Object)(object)val7 != (Object)null)
					{
						val7.onClick = new ButtonClickedEvent();
						((UnityEvent)val7.onClick).AddListener((UnityAction)delegate
						{
							string text = "127.0.0.1";
							text = ((!(ip_field.text != "")) ? ((TMP_Text)ip_placeholder).text : ip_field.text);
							ES3.Save<string>("LANIPAddress", text, "LCGeneralSaveData");
							GameObject.Find("Canvas/MenuContainer/LobbyJoinSettings").gameObject.SetActive(false);
							((Component)NetworkManager.Singleton).GetComponent<UnityTransport>().ConnectionData.Address = text;
							MainClass.StaticLogger.LogInfo((object)("Listening to LAN server: " + text));
							GameObject.Find("MenuManager").GetComponent<MenuManager>().StartAClient();
						});
					}
				}
				TextMeshProUGUI component = ((Component)((Component)val4).transform.Find("PrivatePublicDescription")).GetComponent<TextMeshProUGUI>();
				if ((Object)(object)component != (Object)null)
				{
					((TMP_Text)component).text = "The mod will attempt to auto-detect the crew size however you can manually specify it to reduce chance of failure.";
				}
				((Component)((Component)val4).transform.Find("LobbyJoinOptions/LANOptions")).gameObject.SetActive(true);
			}
			return val3;
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager), "SetConnectionDataBeforeConnecting")]
	public static class ConnectionDataPatch
	{
		public static void Postfix(ref GameNetworkManager __instance)
		{
			if (__instance.disableSteam)
			{
				NetworkManager.Singleton.NetworkConfig.ConnectionData = Encoding.ASCII.GetBytes(__instance.gameVersionNum + "," + MainClass.newPlayerCount);
			}
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager), "OnLocalClientConnectionDisapproved")]
	public static class ConnectionDisapprovedPatch
	{
		private static int crewSizeMismatch;

		private static IEnumerator delayedReconnect()
		{
			yield return (object)new WaitForSeconds(0.5f);
			GameObject.Find("MenuManager").GetComponent<MenuManager>().StartAClient();
		}

		private static void Prefix(ref GameNetworkManager __instance, ulong clientId)
		{
			crewSizeMismatch = 0;
			if (!__instance.disableSteam)
			{
				return;
			}
			try
			{
				if (!string.IsNullOrEmpty(NetworkManager.Singleton.DisconnectReason) && NetworkManager.Singleton.DisconnectReason.StartsWith("Crew size mismatch!"))
				{
					crewSizeMismatch = int.Parse(NetworkManager.Singleton.DisconnectReason.Split("Their size: ")[1].Split(". ")[0]);
				}
			}
			catch
			{
			}
		}

		private static void Postfix(ref GameNetworkManager __instance, ulong clientId)
		{
			if (__instance.disableSteam && crewSizeMismatch != 0)
			{
				MainClass.newPlayerCount = Mathf.Clamp(crewSizeMismatch, MainClass.minPlayerCount, MainClass.maxPlayerCount);
				GameObject.Find("MenuManager").GetComponent<MenuManager>().menuNotification.SetActive(false);
				Object.FindObjectOfType<MenuManager>().SetLoadingScreen(true, (RoomEnter)5, "");
				((MonoBehaviour)__instance).StartCoroutine(delayedReconnect());
				crewSizeMismatch = 0;
			}
		}
	}
	public static class PluginInformation
	{
		public const string PLUGIN_NAME = "MoreCompany";

		public const string PLUGIN_VERSION = "1.8.1";

		public const string PLUGIN_GUID = "me.swipez.melonloader.morecompany";
	}
	[BepInPlugin("me.swipez.melonloader.morecompany", "MoreCompany", "1.8.1")]
	public class MainClass : BaseUnityPlugin
	{
		public static int newPlayerCount = 32;

		public static int minPlayerCount = 4;

		public static int maxPlayerCount = 50;

		public static bool showCosmetics = true;

		public static List<PlayerControllerB> notSupposedToExistPlayers = new List<PlayerControllerB>();

		public static Texture2D mainLogo;

		public static GameObject quickMenuScrollParent;

		public static GameObject playerEntry;

		public static GameObject crewCountUI;

		public static GameObject cosmeticGUIInstance;

		public static GameObject cosmeticButton;

		public static ManualLogSource StaticLogger;

		public static Dictionary<int, List<string>> playerIdsAndCosmetics = new Dictionary<int, List<string>>();

		public static string cosmeticSavePath = Application.persistentDataPath + "/morecompanycosmetics.txt";

		public static string moreCompanySave = Application.persistentDataPath + "/morecompanysave.txt";

		public static string dynamicCosmeticsPath = Paths.PluginPath + "/MoreCompanyCosmetics";

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			StaticLogger = ((BaseUnityPlugin)this).Logger;
			Harmony val = new Harmony("me.swipez.melonloader.morecompany");
			try
			{
				val.PatchAll();
			}
			catch (Exception ex)
			{
				StaticLogger.LogError((object)("Failed to patch: " + ex));
			}
			StaticLogger.LogInfo((object)"Loading MoreCompany...");
			SteamFriends.OnGameLobbyJoinRequested += delegate(Lobby lobby, SteamId steamId)
			{
				newPlayerCount = ((Lobby)(ref lobby)).MaxMembers;
			};
			SteamMatchmaking.OnLobbyEntered += delegate(Lobby lobby)
			{
				newPlayerCount = ((Lobby)(ref lobby)).MaxMembers;
			};
			StaticLogger.LogInfo((object)("Checking: " + dynamicCosmeticsPath));
			if (!Directory.Exists(dynamicCosmeticsPath))
			{
				StaticLogger.LogInfo((object)"Creating cosmetics directory");
				Directory.CreateDirectory(dynamicCosmeticsPath);
			}
			ReadSettingsFromFile();
			ReadCosmeticsFromFile();
			StaticLogger.LogInfo((object)"Read settings and cosmetics");
			AssetBundle bundle = BundleUtilities.LoadBundleFromInternalAssembly("morecompany.assets", Assembly.GetExecutingAssembly());
			AssetBundle val2 = BundleUtilities.LoadBundleFromInternalAssembly("morecompany.cosmetics", Assembly.GetExecutingAssembly());
			CosmeticRegistry.LoadCosmeticsFromBundle(val2);
			val2.Unload(false);
			StaticLogger.LogInfo((object)"Loading USER COSMETICS...");
			RecursiveCosmeticLoad(Paths.PluginPath);
			LoadAssets(bundle);
			StaticLogger.LogInfo((object)"Loaded MoreCompany FULLY");
		}

		private void RecursiveCosmeticLoad(string directory)
		{
			string[] directories = Directory.GetDirectories(directory);
			foreach (string directory2 in directories)
			{
				RecursiveCosmeticLoad(directory2);
			}
			string[] files = Directory.GetFiles(directory);
			foreach (string text in files)
			{
				if (text.EndsWith(".cosmetics"))
				{
					AssetBundle val = AssetBundle.LoadFromFile(text);
					CosmeticRegistry.LoadCosmeticsFromBundle(val);
					val.Unload(false);
				}
			}
		}

		public static void EnablePlayerObjectsBasedOnConnected()
		{
			int connectedPlayersAmount = StartOfRound.Instance.connectedPlayersAmount;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				for (int j = 0; j < connectedPlayersAmount + 1; j++)
				{
					if (!val.isPlayerControlled)
					{
						((Component)val).gameObject.SetActive(false);
					}
					else
					{
						((Component)val).gameObject.SetActive(true);
					}
				}
			}
		}

		private void ReadCosmeticsFromFile()
		{
			if (File.Exists(cosmeticSavePath))
			{
				string[] array = File.ReadAllLines(cosmeticSavePath);
				string[] array2 = array;
				foreach (string item in array2)
				{
					CosmeticRegistry.locallySelectedCosmetics.Add(item);
				}
			}
		}

		public static void WriteCosmeticsToFile()
		{
			string text = "";
			foreach (string locallySelectedCosmetic in CosmeticRegistry.locallySelectedCosmetics)
			{
				text = text + locallySelectedCosmetic + "\n";
			}
			File.WriteAllText(cosmeticSavePath, text);
		}

		public static void SaveSettingsToFile()
		{
			string text = "";
			text = text + newPlayerCount + "\n";
			text = text + showCosmetics + "\n";
			File.WriteAllText(moreCompanySave, text);
		}

		public static void ReadSettingsFromFile()
		{
			if (File.Exists(moreCompanySave))
			{
				string[] array = File.ReadAllLines(moreCompanySave);
				try
				{
					newPlayerCount = Mathf.Clamp(int.Parse(array[0]), minPlayerCount, maxPlayerCount);
					showCosmetics = bool.Parse(array[1]);
				}
				catch (Exception)
				{
					StaticLogger.LogError((object)"Failed to read settings from file, resetting to default");
					newPlayerCount = 32;
					showCosmetics = true;
				}
			}
		}

		private static void LoadAssets(AssetBundle bundle)
		{
			if (Object.op_Implicit((Object)(object)bundle))
			{
				mainLogo = bundle.LoadPersistentAsset<Texture2D>("assets/morecompanyassets/morecompanytransparentred.png");
				quickMenuScrollParent = bundle.LoadPersistentAsset<GameObject>("assets/morecompanyassets/quickmenuoverride.prefab");
				playerEntry = bundle.LoadPersistentAsset<GameObject>("assets/morecompanyassets/playerlistslot.prefab");
				cosmeticGUIInstance = bundle.LoadPersistentAsset<GameObject>("assets/morecompanyassets/testoverlay.prefab");
				cosmeticButton = bundle.LoadPersistentAsset<GameObject>("assets/morecompanyassets/cosmeticinstance.prefab");
				crewCountUI = bundle.LoadPersistentAsset<GameObject>("assets/morecompanyassets/crewcountfield.prefab");
				bundle.Unload(false);
			}
		}

		public static void ResizePlayerCache(Dictionary<uint, Dictionary<int, NetworkObject>> ScenePlacedObjects)
		{
			//IL_0139: 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_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Expected O, but got Unknown
			StartOfRound instance = StartOfRound.Instance;
			if (instance.allPlayerObjects.Length != newPlayerCount)
			{
				StaticLogger.LogInfo((object)$"ResizePlayerCache: {newPlayerCount}");
				playerIdsAndCosmetics.Clear();
				uint num = 10000u;
				int num2 = instance.allPlayerObjects.Length;
				int num3 = newPlayerCount - num2;
				Array.Resize(ref instance.allPlayerObjects, newPlayerCount);
				Array.Resize(ref instance.allPlayerScripts, newPlayerCount);
				Array.Resize(ref instance.gameStats.allPlayerStats, newPlayerCount);
				Array.Resize(ref instance.playerSpawnPositions, newPlayerCount);
				StaticLogger.LogInfo((object)$"Resizing player cache from {num2} to {newPlayerCount} with difference of {num3}");
				if (num3 > 0)
				{
					GameObject val = instance.allPlayerObjects[3];
					for (int i = 0; i < num3; i++)
					{
						uint num4 = num + (uint)i;
						GameObject val2 = Object.Instantiate<GameObject>(val, val.transform.parent);
						NetworkObject component = val2.GetComponent<NetworkObject>();
						ReflectionUtils.SetFieldValue(component, "GlobalObjectIdHash", num4);
						Scene scene = ((Component)component).gameObject.scene;
						int handle = ((Scene)(ref scene)).handle;
						uint num5 = num4;
						if (!ScenePlacedObjects.ContainsKey(num5))
						{
							ScenePlacedObjects.Add(num5, new Dictionary<int, NetworkObject>());
						}
						if (ScenePlacedObjects[num5].ContainsKey(handle))
						{
							string arg = (((Object)(object)ScenePlacedObjects[num5][handle] != (Object)null) ? ((Object)ScenePlacedObjects[num5][handle]).name : "Null Entry");
							throw new Exception(((Object)component).name + " tried to registered with ScenePlacedObjects which already contains " + string.Format("the same {0} value {1} for {2}!", "GlobalObjectIdHash", num5, arg));
						}
						ScenePlacedObjects[num5].Add(handle, component);
						((Object)val2).name = $"Player ({4 + i})";
						PlayerControllerB componentInChildren = val2.GetComponentInChildren<PlayerControllerB>();
						notSupposedToExistPlayers.Add(componentInChildren);
						componentInChildren.playerClientId = (ulong)(4 + i);
						componentInChildren.playerUsername = $"Player #{componentInChildren.playerClientId}";
						componentInChildren.isPlayerControlled = false;
						componentInChildren.isPlayerDead = false;
						componentInChildren.DropAllHeldItems(false, false);
						componentInChildren.TeleportPlayer(instance.notSpawnedPosition.position, false, 0f, false, true);
						UnlockableSuit.SwitchSuitForPlayer(componentInChildren, 0, false);
						instance.allPlayerObjects[num2 + i] = val2;
						instance.gameStats.allPlayerStats[num2 + i] = new PlayerStats();
						instance.allPlayerScripts[num2 + i] = componentInChildren;
						instance.playerSpawnPositions[num2 + i] = instance.playerSpawnPositions[3];
					}
				}
			}
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val3 in allPlayerScripts)
			{
				((TMP_Text)val3.usernameBillboardText).text = val3.playerUsername;
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "Start")]
	public static class PlayerControllerBStartPatch
	{
		public static void Postfix(ref PlayerControllerB __instance)
		{
			Collider[] value = (Collider[])(object)new Collider[MainClass.newPlayerCount];
			ReflectionUtils.SetFieldValue(__instance, "nearByPlayers", value);
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "SendNewPlayerValuesServerRpc")]
	public static class SendNewPlayerValuesServerRpcPatch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>();
			bool flag = false;
			bool flag2 = false;
			foreach (CodeInstruction instruction in instructions)
			{
				if (!flag2)
				{
					if (!flag && ((object)instruction).ToString() == "callvirt virtual void System.Collections.Generic.List<ulong>::Add(ulong item)")
					{
						flag = true;
					}
					else if (flag && ((object)instruction).ToString() == "ldc.i4.4 NULL")
					{
						flag2 = true;
						CodeInstruction item = new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MainClass), "newPlayerCount"));
						list.Add(item);
						continue;
					}
				}
				list.Add(instruction);
			}
			return list.AsEnumerable();
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "SendNewPlayerValuesClientRpc")]
	public static class SendNewPlayerValuesClientRpcPatch
	{
		public static void Prefix(PlayerControllerB __instance, ref ulong[] playerSteamIds)
		{
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager;
			if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening || StartOfRound.Instance.mapScreen.radarTargets.Count == StartOfRound.Instance.allPlayerScripts.Length)
			{
				return;
			}
			List<PlayerControllerB> useless = new List<PlayerControllerB>();
			foreach (PlayerControllerB notSupposedToExistPlayer in MainClass.notSupposedToExistPlayers)
			{
				if (Object.op_Implicit((Object)(object)notSupposedToExistPlayer))
				{
					StartOfRound.Instance.mapScreen.radarTargets.Add(new TransformAndName(((Component)notSupposedToExistPlayer).transform, notSupposedToExistPlayer.playerUsername, false));
				}
				else
				{
					useless.Add(notSupposedToExistPlayer);
				}
			}
			MainClass.notSupposedToExistPlayers.RemoveAll((PlayerControllerB x) => useless.Contains(x));
		}
	}
	[HarmonyPatch(typeof(HUDManager), "SyncAllPlayerLevelsServerRpc", new Type[] { })]
	public static class SyncAllPlayerLevelsPatch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>();
			foreach (CodeInstruction instruction in instructions)
			{
				if (((object)instruction).ToString() == "ldc.i4.4 NULL")
				{
					CodeInstruction item = new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MainClass), "newPlayerCount"));
					list.Add(item);
				}
				else
				{
					list.Add(instruction);
				}
			}
			return list.AsEnumerable();
		}
	}
	[HarmonyPatch]
	public static class SyncShipUnlockablesPatch
	{
		[HarmonyPatch(typeof(StartOfRound), "SyncShipUnlockablesServerRpc")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> ServerTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>();
			bool flag = false;
			int num = 0;
			foreach (CodeInstruction instruction in instructions)
			{
				if (num != 2)
				{
					if (!flag && ((object)instruction).ToString() == "callvirt bool Unity.Netcode.NetworkManager::get_IsHost()")
					{
						flag = true;
					}
					else if (((object)instruction).ToString().StartsWith("ldc.i4.4 NULL"))
					{
						num++;
						CodeInstruction val = new CodeInstruction(instruction);
						val.opcode = OpCodes.Ldsfld;
						val.operand = AccessTools.Field(typeof(MainClass), "newPlayerCount");
						list.Add(val);
						continue;
					}
				}
				list.Add(instruction);
			}
			return list.AsEnumerable();
		}

		[HarmonyPatch(typeof(StartOfRound), "SyncShipUnlockablesClientRpc")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> ClientTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>();
			bool flag = false;
			bool flag2 = false;
			foreach (CodeInstruction instruction in instructions)
			{
				if (!flag2)
				{
					if (!flag && ((object)instruction).ToString() == "callvirt void UnityEngine.Renderer::set_sharedMaterial(UnityEngine.Material value)")
					{
						flag = true;
					}
					else if (flag && ((object)instruction).ToString() == "ldc.i4.4 NULL")
					{
						flag2 = true;
						CodeInstruction item = new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MainClass), "newPlayerCount"));
						list.Add(item);
						continue;
					}
				}
				list.Add(instruction);
			}
			return list.AsEnumerable();
		}
	}
	[HarmonyPatch(typeof(NetworkSceneManager), "PopulateScenePlacedObjects")]
	public static class ScenePlacedObjectsInitPatch
	{
		public static void Postfix(ref Dictionary<uint, Dictionary<int, NetworkObject>> ___ScenePlacedObjects)
		{
			MainClass.ResizePlayerCache(___ScenePlacedObjects);
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager), "LobbyDataIsJoinable")]
	public static class LobbyDataJoinablePatch
	{
		public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>();
			bool flag = false;
			bool flag2 = false;
			foreach (CodeInstruction instruction in instructions)
			{
				if (!flag2)
				{
					if (!flag && ((object)instruction).ToString() == "call int Steamworks.Data.Lobby::get_MemberCount()")
					{
						flag = true;
					}
					else if (flag && ((object)instruction).ToString() == "ldc.i4.4 NULL")
					{
						flag2 = true;
						CodeInstruction item = new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MainClass), "maxPlayerCount"));
						list.Add(item);
						continue;
					}
				}
				list.Add(instruction);
			}
			return list.AsEnumerable();
		}
	}
	[HarmonyPatch(typeof(SteamMatchmaking), "CreateLobbyAsync")]
	public static class LobbyThingPatch
	{
		public static void Prefix(ref int maxMembers)
		{
			MainClass.ReadSettingsFromFile();
			maxMembers = MainClass.newPlayerCount;
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager), "ConnectionApproval")]
	public static class ConnectionApproval
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>();
			bool flag = false;
			bool flag2 = false;
			foreach (CodeInstruction instruction in instructions)
			{
				if (!flag2)
				{
					if (!flag && ((object)instruction).ToString() == "ldfld int GameNetworkManager::connectedPlayers")
					{
						flag = true;
					}
					else if (flag && ((object)instruction).ToString() == "ldc.i4.4 NULL")
					{
						flag2 = true;
						CodeInstruction item = new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MainClass), "newPlayerCount"));
						list.Add(item);
						continue;
					}
				}
				list.Add(instruction);
			}
			return list.AsEnumerable();
		}

		private static void Postfix(ref GameNetworkManager __instance, ref ConnectionApprovalRequest request, ref ConnectionApprovalResponse response)
		{
			if (response.Approved && __instance.disableSteam)
			{
				string @string = Encoding.ASCII.GetString(request.Payload);
				string[] array = @string.Split(",");
				if (!string.IsNullOrEmpty(@string) && (array.Length < 2 || array[1] != MainClass.newPlayerCount.ToString()))
				{
					response.Reason = $"Crew size mismatch! Their size: {MainClass.newPlayerCount}. Your size: {array[1]}";
					response.Approved = false;
				}
			}
		}
	}
	public class MimicPatches
	{
		[HarmonyPatch(typeof(MaskedPlayerEnemy), "SetEnemyOutside")]
		public class MaskedPlayerEnemyOnEnablePatch
		{
			public static void Postfix(MaskedPlayerEnemy __instance)
			{
				//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)__instance.mimickingPlayer != (Object)null) || !MainClass.showCosmetics)
				{
					return;
				}
				List<string> list = MainClass.playerIdsAndCosmetics[(int)__instance.mimickingPlayer.playerClientId];
				Transform val = ((Component)__instance).transform.Find("ScavengerModel").Find("metarig");
				CosmeticApplication component = ((Component)val).GetComponent<CosmeticApplication>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.ClearCosmetics();
					Object.Destroy((Object)(object)component);
				}
				component = ((Component)val).gameObject.AddComponent<CosmeticApplication>();
				foreach (string item in list)
				{
					component.ApplyCosmetic(item, startEnabled: true);
				}
				foreach (CosmeticInstance spawnedCosmetic in component.spawnedCosmetics)
				{
					Transform transform = ((Component)spawnedCosmetic).transform;
					transform.localScale *= 0.38f;
				}
			}
		}
	}
	public class ReflectionUtils
	{
		public static void InvokeMethod(object obj, string methodName, object[] parameters)
		{
			Type type = obj.GetType();
			MethodInfo method = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			method.Invoke(obj, parameters);
		}

		public static void InvokeMethod(object obj, Type forceType, string methodName, object[] parameters)
		{
			MethodInfo method = forceType.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			method.Invoke(obj, parameters);
		}

		public static void SetPropertyValue(object obj, string propertyName, object value)
		{
			Type type = obj.GetType();
			PropertyInfo property = type.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			property.SetValue(obj, value);
		}

		public static T InvokeMethod<T>(object obj, string methodName, object[] parameters)
		{
			Type type = obj.GetType();
			MethodInfo method = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			return (T)method.Invoke(obj, parameters);
		}

		public static T GetFieldValue<T>(object obj, string fieldName)
		{
			Type type = obj.GetType();
			FieldInfo field = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			return (T)field.GetValue(obj);
		}

		public static void SetFieldValue(object obj, string fieldName, object value)
		{
			Type type = obj.GetType();
			FieldInfo field = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			field.SetValue(obj, value);
		}
	}
	[HarmonyPatch(typeof(ShipTeleporter), "Awake")]
	public static class ShipTeleporterAwakePatch
	{
		public static void Postfix(ref ShipTeleporter __instance)
		{
			int[] array = new int[MainClass.newPlayerCount];
			for (int i = 0; i < MainClass.newPlayerCount; i++)
			{
				array[i] = -1;
			}
			ReflectionUtils.SetFieldValue(__instance, "playersBeingTeleported", array);
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "SpectateNextPlayer")]
	public static class SpectatePatches
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>();
			foreach (CodeInstruction instruction in instructions)
			{
				if (((object)instruction).ToString() == "ldc.i4.4 NULL")
				{
					CodeInstruction item = new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MainClass), "newPlayerCount"));
					list.Add(item);
				}
				else
				{
					list.Add(instruction);
				}
			}
			return list.AsEnumerable();
		}
	}
	[HarmonyPatch(typeof(SoundManager), "Start")]
	public static class SoundManagerStartPatch
	{
		public static void Postfix(ref SoundManager __instance)
		{
			Array.Resize(ref __instance.playerVoicePitchLerpSpeed, MainClass.newPlayerCount);
			Array.Resize(ref __instance.playerVoicePitchTargets, MainClass.newPlayerCount);
			Array.Resize(ref __instance.playerVoicePitches, MainClass.newPlayerCount);
			Array.Resize(ref __instance.playerVoiceVolumes, MainClass.newPlayerCount);
			Array.Resize(ref __instance.playerVoiceMixers, MainClass.newPlayerCount);
			AudioMixerGroup val = ((IEnumerable<AudioMixerGroup>)Resources.FindObjectsOfTypeAll<AudioMixerGroup>()).FirstOrDefault((Func<AudioMixerGroup, bool>)((AudioMixerGroup x) => ((Object)x).name.Contains("Voice")));
			for (int i = 0; i < MainClass.newPlayerCount; i++)
			{
				__instance.playerVoicePitchLerpSpeed[i] = 3f;
				__instance.playerVoicePitchTargets[i] = 1f;
				__instance.playerVoicePitches[i] = 1f;
				__instance.playerVoiceVolumes[i] = 0.5f;
				if (!Object.op_Implicit((Object)(object)__instance.playerVoiceMixers[i]))
				{
					__instance.playerVoiceMixers[i] = val;
				}
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "GetPlayerSpawnPosition")]
	public static class SpawnPositionClampPatch
	{
		public static void Prefix(ref StartOfRound __instance, ref int playerNum, bool simpleTeleport = false)
		{
			if (!Object.op_Implicit((Object)(object)__instance.playerSpawnPositions[playerNum]))
			{
				playerNum = __instance.playerSpawnPositions.Length - 1;
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "OnClientConnect")]
	public static class OnClientConnectedPatch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>();
			bool flag = false;
			bool flag2 = false;
			foreach (CodeInstruction instruction in instructions)
			{
				if (!flag2)
				{
					if (!flag && ((object)instruction).ToString() == "callvirt virtual bool System.Collections.Generic.List<int>::Contains(int item)")
					{
						flag = true;
					}
					else if (flag && ((object)instruction).ToString() == "ldc.i4.4 NULL")
					{
						flag2 = true;
						CodeInstruction item = new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MainClass), "newPlayerCount"));
						list.Add(item);
						continue;
					}
				}
				list.Add(instruction);
			}
			return list.AsEnumerable();
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	public static class LoadLobbyListAndFilterPatch
	{
		private static void Postfix()
		{
			LobbySlot[] array = Object.FindObjectsOfType<LobbySlot>();
			LobbySlot[] array2 = array;
			foreach (LobbySlot val in array2)
			{
				((TMP_Text)val.playerCount).text = $"{((Lobby)(ref val.thisLobby)).MemberCount} / {((Lobby)(ref val.thisLobby)).MaxMembers}";
			}
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager), "Awake")]
	public static class GameNetworkAwakePatch
	{
		public static int originalVersion;

		public static void Postfix(GameNetworkManager __instance)
		{
			originalVersion = __instance.gameVersionNum;
			if (!AssemblyChecker.HasAssemblyLoaded("lc_api"))
			{
				__instance.gameVersionNum = 9999;
			}
		}
	}
	[HarmonyPatch(typeof(MenuManager), "Awake")]
	public static class MenuManagerVersionDisplayPatch
	{
		public static void Postfix(MenuManager __instance)
		{
			if ((Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)__instance.versionNumberText != (Object)null)
			{
				((TMP_Text)__instance.versionNumberText).text = $"v{GameNetworkAwakePatch.originalVersion} (MC)";
			}
		}
	}
}
namespace MoreCompany.Utils
{
	public class AssemblyChecker
	{
		public static bool HasAssemblyLoaded(string name)
		{
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			Assembly[] array = assemblies;
			foreach (Assembly assembly in array)
			{
				if (assembly.GetName().Name.ToLower().Equals(name))
				{
					return true;
				}
			}
			return false;
		}
	}
	public class BundleUtilities
	{
		public static byte[] GetResourceBytes(string filename, Assembly assembly)
		{
			string[] manifestResourceNames = assembly.GetManifestResourceNames();
			foreach (string text in manifestResourceNames)
			{
				if (!text.Contains(filename))
				{
					continue;
				}
				using Stream stream = assembly.GetManifestResourceStream(text);
				if (stream == null)
				{
					return null;
				}
				byte[] array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
				return array;
			}
			return null;
		}

		public static AssetBundle LoadBundleFromInternalAssembly(string filename, Assembly assembly)
		{
			return AssetBundle.LoadFromMemory(GetResourceBytes(filename, assembly));
		}
	}
	public static class AssetBundleExtension
	{
		public static T LoadPersistentAsset<T>(this AssetBundle bundle, string name) where T : Object
		{
			Object val = bundle.LoadAsset(name);
			if (val != (Object)null)
			{
				val.hideFlags = (HideFlags)32;
				return (T)(object)val;
			}
			return default(T);
		}
	}
}
namespace MoreCompany.Cosmetics
{
	public class CosmeticApplication : MonoBehaviour
	{
		public Transform head;

		public Transform hip;

		public Transform lowerArmRight;

		public Transform shinLeft;

		public Transform shinRight;

		public Transform chest;

		public List<CosmeticInstance> spawnedCosmetics = new List<CosmeticInstance>();

		public void Awake()
		{
			head = ((Component)this).transform.Find("spine").Find("spine.001").Find("spine.002")
				.Find("spine.003")
				.Find("spine.004");
			chest = ((Component)this).transform.Find("spine").Find("spine.001").Find("spine.002")
				.Find("spine.003");
			lowerArmRight = ((Component)this).transform.Find("spine").Find("spine.001").Find("spine.002")
				.Find("spine.003")
				.Find("shoulder.R")
				.Find("arm.R_upper")
				.Find("arm.R_lower");
			hip = ((Component)this).transform.Find("spine");
			shinLeft = ((Component)this).transform.Find("spine").Find("thigh.L").Find("shin.L");
			shinRight = ((Component)this).transform.Find("spine").Find("thigh.R").Find("shin.R");
			RefreshAllCosmeticPositions();
		}

		private void OnDisable()
		{
			foreach (CosmeticInstance spawnedCosmetic in spawnedCosmetics)
			{
				((Component)spawnedCosmetic).gameObject.SetActive(false);
			}
		}

		private void OnEnable()
		{
			foreach (CosmeticInstance spawnedCosmetic in spawnedCosmetics)
			{
				((Component)spawnedCosmetic).gameObject.SetActive(true);
			}
		}

		public void ClearCosmetics()
		{
			foreach (CosmeticInstance spawnedCosmetic in spawnedCosmetics)
			{
				Object.Destroy((Object)(object)((Component)spawnedCosmetic).gameObject);
			}
			spawnedCosmetics.Clear();
		}

		public void ApplyCosmetic(string cosmeticId, bool startEnabled)
		{
			if (CosmeticRegistry.cosmeticInstances.ContainsKey(cosmeticId))
			{
				CosmeticInstance cosmeticInstance = CosmeticRegistry.cosmeticInstances[cosmeticId];
				GameObject val = Object.Instantiate<GameObject>(((Component)cosmeticInstance).gameObject);
				val.SetActive(startEnabled);
				CosmeticInstance component = val.GetComponent<CosmeticInstance>();
				spawnedCosmetics.Add(component);
				if (startEnabled)
				{
					ParentCosmetic(component);
				}
			}
		}

		public void RefreshAllCosmeticPositions()
		{
			foreach (CosmeticInstance spawnedCosmetic in spawnedCosmetics)
			{
				ParentCosmetic(spawnedCosmetic);
			}
		}

		private void ParentCosmetic(CosmeticInstance cosmeticInstance)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			Transform val = null;
			switch (cosmeticInstance.cosmeticType)
			{
			case CosmeticType.HAT:
				val = head;
				break;
			case CosmeticType.R_LOWER_ARM:
				val = lowerArmRight;
				break;
			case CosmeticType.HIP:
				val = hip;
				break;
			case CosmeticType.L_SHIN:
				val = shinLeft;
				break;
			case CosmeticType.R_SHIN:
				val = shinRight;
				break;
			case CosmeticType.CHEST:
				val = chest;
				break;
			}
			((Component)cosmeticInstance).transform.position = val.position;
			((Component)cosmeticInstance).transform.rotation = val.rotation;
			((Component)cosmeticInstance).transform.parent = val;
		}
	}
	public class CosmeticInstance : MonoBehaviour
	{
		public CosmeticType cosmeticType;

		public string cosmeticId;

		public Texture2D icon;
	}
	public class CosmeticGeneric
	{
		public virtual string gameObjectPath { get; }

		public virtual string cosmeticId { get; }

		public virtual string textureIconPath { get; }

		public CosmeticType cosmeticType { get; }

		public void LoadFromBundle(AssetBundle bundle)
		{
			GameObject val = bundle.LoadPersistentAsset<GameObject>(gameObjectPath);
			Texture2D icon = bundle.LoadPersistentAsset<Texture2D>(textureIconPath);
			CosmeticInstance cosmeticInstance = val.AddComponent<CosmeticInstance>();
			cosmeticInstance.cosmeticId = cosmeticId;
			cosmeticInstance.icon = icon;
			cosmeticInstance.cosmeticType = cosmeticType;
			MainClass.StaticLogger.LogInfo((object)("Loaded cosmetic: " + cosmeticId + " from bundle: " + ((Object)bundle).name));
			CosmeticRegistry.cosmeticInstances.Add(cosmeticId, cosmeticInstance);
		}
	}
	public enum CosmeticType
	{
		HAT,
		WRIST,
		CHEST,
		R_LOWER_ARM,
		HIP,
		L_SHIN,
		R_SHIN
	}
	public class CosmeticRegistry
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__8_0;

			public static UnityAction <>9__8_1;

			internal void <SpawnCosmeticGUI>b__8_0()
			{
				MainClass.showCosmetics = true;
				MainClass.SaveSettingsToFile();
			}

			internal void <SpawnCosmeticGUI>b__8_1()
			{
				MainClass.showCosmetics = false;
				MainClass.SaveSettingsToFile();
			}
		}

		public static Dictionary<string, CosmeticInstance> cosmeticInstances = new Dictionary<string, CosmeticInstance>();

		public static GameObject cosmeticGUI;

		private static GameObject displayGuy;

		private static CosmeticApplication cosmeticApplication;

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

		public const float COSMETIC_PLAYER_SCALE_MULT = 0.38f;

		public static void LoadCosmeticsFromBundle(AssetBundle bundle)
		{
			string[] allAssetNames = bundle.GetAllAssetNames();
			foreach (string text in allAssetNames)
			{
				if (!text.EndsWith(".prefab"))
				{
					continue;
				}
				GameObject val = bundle.LoadPersistentAsset<GameObject>(text);
				CosmeticInstance component = val.GetComponent<CosmeticInstance>();
				if (!((Object)(object)component == (Object)null))
				{
					MainClass.StaticLogger.LogInfo((object)("Loaded cosmetic: " + component.cosmeticId + " from bundle"));
					if (cosmeticInstances.ContainsKey(component.cosmeticId))
					{
						MainClass.StaticLogger.LogError((object)("Duplicate cosmetic id: " + component.cosmeticId));
					}
					else
					{
						cosmeticInstances.Add(component.cosmeticId, component);
					}
				}
			}
		}

		public static void LoadCosmeticsFromAssembly(Assembly assembly, AssetBundle bundle)
		{
			Type[] types = assembly.GetTypes();
			foreach (Type type in types)
			{
				if (type.IsSubclassOf(typeof(CosmeticGeneric)))
				{
					CosmeticGeneric cosmeticGeneric = (CosmeticGeneric)type.GetConstructor(new Type[0]).Invoke(new object[0]);
					cosmeticGeneric.LoadFromBundle(bundle);
				}
			}
		}

		public static void SpawnCosmeticGUI()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Expected O, but got Unknown
			cosmeticGUI = Object.Instantiate<GameObject>(MainClass.cosmeticGUIInstance);
			((Component)cosmeticGUI.transform.Find("Canvas").Find("GlobalScale")).transform.localScale = new Vector3(2f, 2f, 2f);
			displayGuy = ((Component)cosmeticGUI.transform.Find("Canvas").Find("GlobalScale").Find("CosmeticsScreen")
				.Find("ObjectHolder")
				.Find("ScavengerModel")
				.Find("metarig")).gameObject;
			cosmeticApplication = displayGuy.AddComponent<CosmeticApplication>();
			GameObject gameObject = ((Component)cosmeticGUI.transform.Find("Canvas").Find("GlobalScale").Find("CosmeticsScreen")
				.Find("EnableButton")).gameObject;
			ButtonClickedEvent onClick = gameObject.GetComponent<Button>().onClick;
			object obj = <>c.<>9__8_0;
			if (obj == null)
			{
				UnityAction val = delegate
				{
					MainClass.showCosmetics = true;
					MainClass.SaveSettingsToFile();
				};
				<>c.<>9__8_0 = val;
				obj = (object)val;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj);
			GameObject gameObject2 = ((Component)cosmeticGUI.transform.Find("Canvas").Find("GlobalScale").Find("CosmeticsScreen")
				.Find("DisableButton")).gameObject;
			ButtonClickedEvent onClick2 = gameObject2.GetComponent<Button>().onClick;
			object obj2 = <>c.<>9__8_1;
			if (obj2 == null)
			{
				UnityAction val2 = delegate
				{
					MainClass.showCosmetics = false;
					MainClass.SaveSettingsToFile();
				};
				<>c.<>9__8_1 = val2;
				obj2 = (object)val2;
			}
			((UnityEvent)onClick2).AddListener((UnityAction)obj2);
			if (MainClass.showCosmetics)
			{
				gameObject.SetActive(false);
				gameObject2.SetActive(true);
			}
			else
			{
				gameObject.SetActive(true);
				gameObject2.SetActive(false);
			}
			PopulateCosmetics();
			UpdateCosmeticsOnDisplayGuy(startEnabled: false);
		}

		public static void PopulateCosmetics()
		{
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Expected O, but got Unknown
			GameObject gameObject = ((Component)cosmeticGUI.transform.Find("Canvas").Find("GlobalScale").Find("CosmeticsScreen")
				.Find("CosmeticsHolder")
				.Find("Content")).gameObject;
			List<Transform> list = new List<Transform>();
			for (int i = 0; i < gameObject.transform.childCount; i++)
			{
				list.Add(gameObject.transform.GetChild(i));
			}
			foreach (Transform item in list)
			{
				Object.Destroy((Object)(object)((Component)item).gameObject);
			}
			foreach (KeyValuePair<string, CosmeticInstance> cosmeticInstance in cosmeticInstances)
			{
				GameObject val = Object.Instantiate<GameObject>(MainClass.cosmeticButton, gameObject.transform);
				val.transform.localScale = Vector3.one;
				GameObject disabledOverlay = ((Component)val.transform.Find("Deselected")).gameObject;
				disabledOverlay.SetActive(true);
				GameObject enabledOverlay = ((Component)val.transform.Find("Selected")).gameObject;
				enabledOverlay.SetActive(true);
				if (IsEquipped(cosmeticInstance.Value.cosmeticId))
				{
					enabledOverlay.SetActive(true);
					disabledOverlay.SetActive(false);
				}
				else
				{
					enabledOverlay.SetActive(false);
					disabledOverlay.SetActive(true);
				}
				RawImage component = ((Component)val.transform.Find("Icon")).GetComponent<RawImage>();
				component.texture = (Texture)(object)cosmeticInstance.Value.icon;
				Button component2 = val.GetComponent<Button>();
				((UnityEvent)component2.onClick).AddListener((UnityAction)delegate
				{
					ToggleCosmetic(cosmeticInstance.Value.cosmeticId);
					if (IsEquipped(cosmeticInstance.Value.cosmeticId))
					{
						enabledOverlay.SetActive(true);
						disabledOverlay.SetActive(false);
					}
					else
					{
						enabledOverlay.SetActive(false);
						disabledOverlay.SetActive(true);
					}
					MainClass.WriteCosmeticsToFile();
					UpdateCosmeticsOnDisplayGuy(startEnabled: true);
				});
			}
		}

		private static Color HexToColor(string hex)
		{
			//IL_0003: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			Color result = default(Color);
			ColorUtility.TryParseHtmlString(hex, ref result);
			return result;
		}

		public static void UpdateCosmeticsOnDisplayGuy(bool startEnabled)
		{
			cosmeticApplication.ClearCosmetics();
			foreach (string locallySelectedCosmetic in locallySelectedCosmetics)
			{
				cosmeticApplication.ApplyCosmetic(locallySelectedCosmetic, startEnabled);
			}
			foreach (CosmeticInstance spawnedCosmetic in cosmeticApplication.spawnedCosmetics)
			{
				RecursiveLayerChange(((Component)spawnedCosmetic).transform, 5);
			}
		}

		private static void RecursiveLayerChange(Transform transform, int layer)
		{
			((Component)transform).gameObject.layer = layer;
			for (int i = 0; i < transform.childCount; i++)
			{
				RecursiveLayerChange(transform.GetChild(i), layer);
			}
		}

		public static bool IsEquipped(string cosmeticId)
		{
			return locallySelectedCosmetics.Contains(cosmeticId);
		}

		public static void ToggleCosmetic(string cosmeticId)
		{
			if (locallySelectedCosmetics.Contains(cosmeticId))
			{
				locallySelectedCosmetics.Remove(cosmeticId);
			}
			else
			{
				locallySelectedCosmetics.Add(cosmeticId);
			}
		}
	}
}
namespace MoreCompany.Behaviors
{
	public class SpinDragger : MonoBehaviour, IPointerDownHandler, IEventSystemHandler, IPointerUpHandler
	{
		public float speed = 1f;

		private Vector2 lastMousePosition;

		private bool dragging = false;

		private Vector3 rotationalVelocity = Vector3.zero;

		public float dragSpeed = 1f;

		public float airDrag = 0.99f;

		public GameObject target;

		private void Update()
		{
			//IL_0076: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			if (dragging)
			{
				Vector3 val = Vector2.op_Implicit(((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue() - lastMousePosition);
				rotationalVelocity += new Vector3(0f, 0f - val.x, 0f) * dragSpeed;
				lastMousePosition = ((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue();
			}
			rotationalVelocity *= airDrag;
			target.transform.Rotate(rotationalVelocity * Time.deltaTime * speed, (Space)0);
		}

		public void OnPointerDown(PointerEventData eventData)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			lastMousePosition = ((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue();
			dragging = true;
		}

		public void OnPointerUp(PointerEventData eventData)
		{
			dragging = false;
		}
	}
}

plugins/MoreEmotes1.3.3.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using MoreEmotes.Patch;
using MoreEmotes.Scripts;
using RuntimeNetcodeRPCValidator;
using TMPro;
using Tools;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Animations.Rigging;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FuckYouMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FuckYouMod")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5ecc2bf2-af12-4e83-a6f1-cf2eacbf3060")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Tools
{
	public class Ref
	{
		public static object GetInstanceField(Type type, object instance, string fieldName)
		{
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
			FieldInfo field = type.GetField(fieldName, bindingAttr);
			return field.GetValue(instance);
		}

		public static object Method(object instance, string methodName, params object[] args)
		{
			MethodInfo method = instance.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.NonPublic);
			if (method != null)
			{
				return method.Invoke(instance, args);
			}
			return null;
		}
	}
	public class D : MonoBehaviour
	{
		public static bool Debug;

		public static void L(string msg)
		{
			if (Debug)
			{
				Debug.Log((object)msg);
			}
		}

		public static void W(string msg)
		{
			if (Debug)
			{
				Debug.LogWarning((object)msg);
			}
		}
	}
}
namespace MoreEmotes
{
	[BepInPlugin("MoreEmotes", "MoreEmotes-Sligili", "1.3.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class MoreEmotesInitialization : BaseUnityPlugin
	{
		private Harmony _harmony;

		private NetcodeValidator netcodeValidator;

		private ConfigEntry<string> config_KeyWheel;

		private ConfigEntry<string> config_KeyWheel_c;

		private ConfigEntry<bool> config_InventoryCheck;

		private ConfigEntry<bool> config_UseConfigFile;

		private ConfigEntry<string> config_KeyEmote3;

		private ConfigEntry<string> config_KeyEmote4;

		private ConfigEntry<string> config_KeyEmote5;

		private ConfigEntry<string> config_KeyEmote6;

		private ConfigEntry<string> config_KeyEmote7;

		private ConfigEntry<string> config_KeyEmote8;

		private ConfigEntry<string> config_KeyEmote9;

		private ConfigEntry<string> config_KeyEmote10;

		private void Awake()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"MoreEmotes loaded");
			LoadAssetBundles();
			LoadAssets();
			ConfigFile();
			SearchForIncompatibleMods();
			_harmony = new Harmony("MoreEmotes");
			_harmony.PatchAll(typeof(EmotePatch));
			netcodeValidator = new NetcodeValidator("MoreEmotes");
			netcodeValidator.PatchAll();
			netcodeValidator.BindToPreExistingObjectByBehaviour<SignEmoteText, PlayerControllerB>();
			netcodeValidator.BindToPreExistingObjectByBehaviour<SyncAnimatorToOthers, PlayerControllerB>();
		}

		private void LoadAssetBundles()
		{
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MoreEmotes/animationsbundle");
			string text2 = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MoreEmotes/animatorbundle");
			try
			{
				EmotePatch.AnimationsBundle = AssetBundle.LoadFromFile(text);
				EmotePatch.AnimatorBundle = AssetBundle.LoadFromFile(text2);
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load AssetBundles. Make sure \"animatorsbundle\" and \"animationsbundle\" are inside the MoreEmotes folder.\nError: " + ex.Message));
			}
		}

		private void LoadAssets()
		{
			string path = "Assets/MoreEmotes";
			EmotePatch.local = EmotePatch.AnimatorBundle.LoadAsset<RuntimeAnimatorController>(Path.Combine(path, "NEWmetarig.controller"));
			EmotePatch.others = EmotePatch.AnimatorBundle.LoadAsset<RuntimeAnimatorController>(Path.Combine(path, "NEWmetarigOtherPlayers.controller"));
			MoreEmotesEvents.ClapSounds[0] = EmotePatch.AnimationsBundle.LoadAsset<AudioClip>(Path.Combine(path, "SingleClapEmote1.wav"));
			MoreEmotesEvents.ClapSounds[1] = EmotePatch.AnimationsBundle.LoadAsset<AudioClip>(Path.Combine(path, "SingleClapEmote2.wav"));
			EmotePatch.SettingsPrefab = EmotePatch.AnimationsBundle.LoadAsset<GameObject>(Path.Combine(path, "Resources/MoreEmotesPanel.prefab"));
			EmotePatch.ButtonPrefab = EmotePatch.AnimationsBundle.LoadAsset<GameObject>(Path.Combine(path, "Resources/MoreEmotesButton.prefab"));
			EmotePatch.LegsPrefab = EmotePatch.AnimationsBundle.LoadAsset<GameObject>(Path.Combine(path, "Resources/plegs.prefab"));
			EmotePatch.SignPrefab = EmotePatch.AnimationsBundle.LoadAsset<GameObject>(Path.Combine(path, "Resources/Sign.prefab"));
			EmotePatch.SignUIPrefab = EmotePatch.AnimationsBundle.LoadAsset<GameObject>(Path.Combine(path, "Resources/SignTextUI.prefab"));
			EmotePatch.WheelPrefab = EmotePatch.AnimationsBundle.LoadAsset<GameObject>("Assets/MoreEmotes/Resources/MoreEmotesMenu.prefab");
		}

		private void ConfigFile()
		{
			EmotePatch.ConfigFile_Keybinds = new string[32];
			config_KeyWheel = ((BaseUnityPlugin)this).Config.Bind<string>("EMOTE WHEEL", "Key", "v", (ConfigDescription)null);
			EmotePatch.ConfigFile_WheelKeybind = config_KeyWheel.Value;
			config_KeyWheel_c = ((BaseUnityPlugin)this).Config.Bind<string>("EMOTE WHEEL (Controller)", "Key", "leftshoulder", (ConfigDescription)null);
			EmotePatch.ConfigFile_WheelKeybind_controller = config_KeyWheel_c.Value;
			config_InventoryCheck = ((BaseUnityPlugin)this).Config.Bind<bool>("OTHERS", "InventoryCheck", true, "Prevents some emotes from performing while holding any item/scrap");
			EmotePatch.ConfigFile_InventoryCheck = config_InventoryCheck.Value;
			config_UseConfigFile = ((BaseUnityPlugin)this).Config.Bind<bool>("OTHERS", "ConfigFile", false, "Ignores all in-game saved settings and instead uses the config file");
			EmotePatch.UseConfigFile = config_UseConfigFile.Value;
			config_KeyEmote3 = ((BaseUnityPlugin)this).Config.Bind<string>("QUICK EMOTES", "Middle Finger", "3", (ConfigDescription)null);
			EmotePatch.ConfigFile_Keybinds[2] = config_KeyEmote3.Value.Replace(" ", "");
			config_KeyEmote4 = ((BaseUnityPlugin)this).Config.Bind<string>("QUICK EMOTES", "The Griddy", "6", (ConfigDescription)null);
			EmotePatch.ConfigFile_Keybinds[5] = config_KeyEmote4.Value.Replace(" ", "");
			config_KeyEmote5 = ((BaseUnityPlugin)this).Config.Bind<string>("QUICK EMOTES", "Shy", "5", (ConfigDescription)null);
			EmotePatch.ConfigFile_Keybinds[4] = config_KeyEmote5.Value.Replace(" ", "");
			config_KeyEmote6 = ((BaseUnityPlugin)this).Config.Bind<string>("QUICK EMOTES", "Clap", "4", (ConfigDescription)null);
			EmotePatch.ConfigFile_Keybinds[3] = config_KeyEmote6.Value.Replace(" ", "");
			config_KeyEmote7 = ((BaseUnityPlugin)this).Config.Bind<string>("QUICK EMOTES", "Twerk", "7", (ConfigDescription)null);
			EmotePatch.ConfigFile_Keybinds[6] = config_KeyEmote7.Value.Replace(" ", "");
			config_KeyEmote8 = ((BaseUnityPlugin)this).Config.Bind<string>("QUICK EMOTES", "Salute", "8", (ConfigDescription)null);
			EmotePatch.ConfigFile_Keybinds[7] = config_KeyEmote8.Value.Replace(" ", "");
			config_KeyEmote9 = ((BaseUnityPlugin)this).Config.Bind<string>("QUICK EMOTES", "Prisyadka", "9", (ConfigDescription)null);
			EmotePatch.ConfigFile_Keybinds[8] = config_KeyEmote9.Value.Replace(" ", "");
			config_KeyEmote10 = ((BaseUnityPlugin)this).Config.Bind<string>("QUICK EMOTES", "Sign", "0", (ConfigDescription)null);
			EmotePatch.ConfigFile_Keybinds[9] = config_KeyEmote10.Value.Replace(" ", "");
		}

		private void SearchForIncompatibleMods()
		{
			foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
			{
				BepInPlugin metadata = pluginInfo.Value.Metadata;
				if (metadata.GUID.Equals("com.malco.lethalcompany.moreshipupgrades", StringComparison.OrdinalIgnoreCase) || metadata.GUID.Equals("Stoneman.LethalProgression", StringComparison.OrdinalIgnoreCase))
				{
					EmotePatch.IncompatibleStuff = true;
					break;
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string GUID = "MoreEmotes";

		public const string NAME = "MoreEmotes-Sligili";

		public const string VER = "1.3.3";
	}
}
namespace MoreEmotes.Patch
{
	public enum Emotes
	{
		D_Sign = 1010,
		D_Clap = 1004,
		D_Middle_Finger = 1003,
		Dance = 1,
		Point = 2,
		Middle_Finger = 3,
		Clap = 4,
		Shy = 5,
		The_Griddy = 6,
		Twerk = 7,
		Salute = 8,
		Prisyadka = 9,
		Sign = 10
	}
	public class EmotePatch
	{
		public static AssetBundle AnimationsBundle;

		public static AssetBundle AnimatorBundle;

		public static RuntimeAnimatorController local;

		public static RuntimeAnimatorController others;

		public static bool UseConfigFile;

		public static string[] ConfigFile_Keybinds;

		public static string ConfigFile_WheelKeybind;

		public static string ConfigFile_WheelKeybind_controller;

		public static bool ConfigFile_InventoryCheck;

		public static string EmoteWheelKeyboard;

		public static string EmoteWheelController;

		public static bool IncompatibleStuff;

		private static int s_currentEmoteID = 0;

		private static float s_defaultPlayerSpeed;

		private static bool[] s_wasPerformingEmote = new bool[32];

		public static bool IsEmoteWheelOpen;

		private static bool s_isPlayerFirstFrame;

		private static bool s_isFirstTimeOnMenu;

		private static bool s_isPlayerSpawning;

		public const int AlternateEmoteIDOffset = 1000;

		private static int[] s_doubleEmotesIDS = new int[2] { 3, 4 };

		public static bool LocalArmsSeparatedFromCamera;

		private static Transform s_freeArmsTarget;

		private static Transform s_lockedArmsTarget;

		private static CallbackContext emptyContext;

		public static GameObject ButtonPrefab;

		public static GameObject SettingsPrefab;

		public static GameObject LegsPrefab;

		public static GameObject SignPrefab;

		public static GameObject SignUIPrefab;

		public static GameObject WheelPrefab;

		private static GameObject s_localPlayerLevelBadge;

		private static GameObject s_localPlayerBetaBadge;

		private static Transform s_legsMesh;

		private static EmoteWheel s_selectionWheel;

		private static SignUI s_customSignInputField;

		private static SyncAnimatorToOthers s_syncAnimator;

		private static int _AlternateEmoteIDOffset => 1000;

		private static void InstantiateSettingsMenu(Transform container)
		{
			RebindButton.ConfigFile_Keybinds = ConfigFile_Keybinds;
			if (!PlayerPrefs.HasKey("InvCheck") || UseConfigFile)
			{
				PlayerPrefs.SetInt("InvCheck", ConfigFile_InventoryCheck ? 1 : 0);
			}
			ToggleButton.s_InventoryCheck = (UseConfigFile ? ConfigFile_InventoryCheck : (PlayerPrefs.GetInt("InvCheck") == 1));
			SetupUI.UseConfigFile = UseConfigFile;
			SetupUI.InventoryCheck = ToggleButton.s_InventoryCheck;
			GameObject gameObject = ((Component)((Component)container).transform.Find("SettingsPanel")).gameObject;
			Object.Instantiate<GameObject>(ButtonPrefab, gameObject.transform).transform.SetSiblingIndex(7);
			Object.Instantiate<GameObject>(SettingsPrefab, gameObject.transform);
			gameObject.AddComponent<SetupUI>();
		}

		private static void CheckEmoteInput(string keyBind, bool needsEmptyHands, int emoteID, PlayerControllerB player)
		{
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			Emotes emotes = (Emotes)emoteID;
			string text = emotes.ToString();
			bool flag;
			if (UseConfigFile)
			{
				flag = ConfigFile_InventoryCheck;
				keyBind = ConfigFile_Keybinds[emoteID - 1];
			}
			else
			{
				flag = PlayerPrefs.GetInt("InvCheck") == 1;
				if (PlayerPrefs.HasKey(text))
				{
					keyBind = PlayerPrefs.GetString(text);
				}
				else
				{
					PlayerPrefs.SetString(text, keyBind);
				}
			}
			if (!keyBind.Equals(string.Empty) && InputControlExtensions.IsPressed(((InputControl)Keyboard.current)[keyBind], 0f) && (!player.isHoldingObject || !needsEmptyHands || !flag))
			{
				player.PerformEmote(emptyContext, emoteID);
			}
		}

		private static void CheckWheelInput(string keybind, string controller, PlayerControllerB player)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			bool flag2 = false;
			if (Gamepad.all.Count != 0 && !controller.Equals(string.Empty))
			{
				flag = InputControlExtensions.IsPressed(((InputControl)Gamepad.current)[controller], 0f);
			}
			if (keybind != string.Empty)
			{
				flag2 = InputControlExtensions.IsPressed(((InputControl)Keyboard.current)[keybind], 0f) && !((ButtonControl)Keyboard.current[(Key)55]).wasPressedThisFrame;
			}
			bool flag3 = flag || flag2;
			if (flag3 && !IsEmoteWheelOpen && !player.isPlayerDead && !player.inTerminalMenu && !player.quickMenuManager.isMenuOpen && !player.isTypingChat && !s_customSignInputField.IsSignUIOpen)
			{
				IsEmoteWheelOpen = true;
				Cursor.visible = true;
				Cursor.lockState = (CursorLockMode)2;
				((Component)s_selectionWheel).gameObject.SetActive(IsEmoteWheelOpen);
				player.disableLookInput = true;
			}
			else
			{
				if (!IsEmoteWheelOpen || (flag3 && !player.quickMenuManager.isMenuOpen && !player.isTypingChat && !s_customSignInputField.IsSignUIOpen))
				{
					return;
				}
				int selectedEmoteID = s_selectionWheel.SelectedEmoteID;
				if (!player.quickMenuManager.isMenuOpen && !s_customSignInputField.IsSignUIOpen)
				{
					Cursor.visible = false;
					Cursor.lockState = (CursorLockMode)1;
				}
				if (!player.isPlayerDead && !player.quickMenuManager.isMenuOpen)
				{
					if (selectedEmoteID <= 3 || selectedEmoteID == 6 || !ConfigFile_InventoryCheck)
					{
						player.PerformEmote(emptyContext, selectedEmoteID);
					}
					else if (!player.isHoldingObject)
					{
						player.PerformEmote(emptyContext, selectedEmoteID);
					}
				}
				if (!s_customSignInputField.IsSignUIOpen)
				{
					player.disableLookInput = false;
				}
				IsEmoteWheelOpen = false;
				((Component)s_selectionWheel).gameObject.SetActive(IsEmoteWheelOpen);
			}
		}

		private static void OnFirstLocalPlayerFrameWithNewAnimator(PlayerControllerB player)
		{
			s_isPlayerFirstFrame = false;
			TurnControllerIntoAnOverrideController(player.playerBodyAnimator.runtimeAnimatorController);
			s_syncAnimator = ((Component)player).GetComponent<SyncAnimatorToOthers>();
			s_customSignInputField.Player = player;
			s_freeArmsTarget = Object.Instantiate<Transform>(player.localArmsRotationTarget, player.localArmsRotationTarget.parent.parent);
			s_lockedArmsTarget = player.localArmsRotationTarget;
			Transform val = ((Component)player).transform.Find("ScavengerModel").Find("metarig").Find("spine")
				.Find("spine.001")
				.Find("spine.002")
				.Find("spine.003");
			s_localPlayerLevelBadge = ((Component)val.Find("LevelSticker")).gameObject;
			s_localPlayerBetaBadge = ((Component)val.Find("BetaBadge")).gameObject;
			player.SpawnPlayerAnimation();
		}

		private static void SpawnSign(PlayerControllerB player)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(SignPrefab, ((Component)((Component)((Component)player).transform.Find("ScavengerModel")).transform.Find("metarig")).transform);
			val.transform.SetSiblingIndex(6);
			((Object)val).name = "Sign";
			val.transform.localPosition = new Vector3(0.029f, -0.45f, 1.3217f);
			val.transform.localRotation = Quaternion.Euler(65.556f, 180f, 180f);
		}

		private static void SpawnLegs(PlayerControllerB player)
		{
			//IL_00b4: 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)
			GameObject val = Object.Instantiate<GameObject>(LegsPrefab, ((Component)((Component)player.playerBodyAnimator).transform.parent).transform);
			s_legsMesh = val.transform.Find("Mesh");
			((Component)s_legsMesh).transform.parent = ((Component)player.playerBodyAnimator).transform.parent;
			((Object)s_legsMesh).name = "LEGS";
			GameObject gameObject = ((Component)val.transform.Find("Armature")).gameObject;
			gameObject.transform.parent = ((Component)player.playerBodyAnimator).transform;
			((Object)gameObject).name = "FistPersonLegs";
			gameObject.transform.position = new Vector3(0f, 0.197f, 0f);
			gameObject.transform.localScale = new Vector3(13.99568f, 13.99568f, 13.99568f);
			Object.Destroy((Object)(object)val);
		}

		private static void ResetIKWeights(PlayerControllerB player)
		{
			Transform val = ((Component)player.playerBodyAnimator).transform.Find("Rig 1");
			ChainIKConstraint component = ((Component)val.Find("RightArm")).GetComponent<ChainIKConstraint>();
			ChainIKConstraint component2 = ((Component)val.Find("LeftArm")).GetComponent<ChainIKConstraint>();
			TwoBoneIKConstraint component3 = ((Component)val.Find("RightLeg")).GetComponent<TwoBoneIKConstraint>();
			TwoBoneIKConstraint component4 = ((Component)val.Find("LeftLeg")).GetComponent<TwoBoneIKConstraint>();
			Transform val2 = ((Component)player.playerBodyAnimator).transform.Find("ScavengerModelArmsOnly").Find("metarig").Find("spine.003")
				.Find("RigArms");
			ChainIKConstraint component5 = ((Component)val2.Find("RightArm")).GetComponent<ChainIKConstraint>();
			ChainIKConstraint component6 = ((Component)val2.Find("LeftArm")).GetComponent<ChainIKConstraint>();
			((RigConstraint<ChainIKConstraintJob, ChainIKConstraintData, ChainIKConstraintJobBinder<ChainIKConstraintData>>)(object)component).weight = 1f;
			((RigConstraint<ChainIKConstraintJob, ChainIKConstraintData, ChainIKConstraintJobBinder<ChainIKConstraintData>>)(object)component2).weight = 1f;
			((RigConstraint<ChainIKConstraintJob, ChainIKConstraintData, ChainIKConstraintJobBinder<ChainIKConstraintData>>)(object)component).weight = 1f;
			((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)component4).weight = 1f;
			((RigConstraint<ChainIKConstraintJob, ChainIKConstraintData, ChainIKConstraintJobBinder<ChainIKConstraintData>>)(object)component5).weight = 1f;
			((RigConstraint<ChainIKConstraintJob, ChainIKConstraintData, ChainIKConstraintJobBinder<ChainIKConstraintData>>)(object)component6).weight = 1f;
		}

		private static void UpdateLegsMaterial(PlayerControllerB player)
		{
			((Renderer)((Component)s_legsMesh).GetComponent<SkinnedMeshRenderer>()).material = ((Renderer)((Component)((Component)((Component)player.playerBodyAnimator).transform.parent).transform.Find("LOD1")).gameObject.GetComponent<SkinnedMeshRenderer>()).material;
		}

		private static void TogglePlayerBadges(bool enabled)
		{
			if ((Object)(object)s_localPlayerBetaBadge != (Object)null)
			{
				((Renderer)s_localPlayerBetaBadge.GetComponent<MeshRenderer>()).enabled = enabled;
			}
			if ((Object)(object)s_localPlayerLevelBadge != (Object)null)
			{
				((Renderer)s_localPlayerLevelBadge.GetComponent<MeshRenderer>()).enabled = enabled;
			}
			else
			{
				Debug.LogError((object)"[MoreEmotes-Sligili] Couldn't find the level badge");
			}
		}

		private static bool CheckIfTooManyEmotesIsPlaying(PlayerControllerB player)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			Animator playerBodyAnimator = player.playerBodyAnimator;
			AnimatorStateInfo currentAnimatorStateInfo = playerBodyAnimator.GetCurrentAnimatorStateInfo(1);
			return ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Dance1") && player.performingEmote && GetAnimatorEmoteClipName(playerBodyAnimator) != "Dance1";
		}

		private static string GetAnimatorEmoteClipName(Animator animator)
		{
			AnimatorClipInfo[] currentAnimatorClipInfo = animator.GetCurrentAnimatorClipInfo(1);
			return ((Object)((AnimatorClipInfo)(ref currentAnimatorClipInfo[0])).clip).name;
		}

		private static void TurnControllerIntoAnOverrideController(RuntimeAnimatorController controller)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (!(controller is AnimatorOverrideController))
			{
				controller = (RuntimeAnimatorController)new AnimatorOverrideController(controller);
			}
		}

		public static void UpdateWheelKeybinds()
		{
			if (UseConfigFile)
			{
				EmoteWheelKeyboard = ConfigFile_WheelKeybind;
				EmoteWheelController = ConfigFile_WheelKeybind_controller;
				return;
			}
			if (!PlayerPrefs.HasKey("Emote_Wheel_c"))
			{
				PlayerPrefs.SetString("Emote_Wheel_c", ConfigFile_WheelKeybind_controller);
			}
			EmoteWheelController = PlayerPrefs.GetString("Emote_Wheel_c");
			if (!PlayerPrefs.HasKey("Emote_Wheel"))
			{
				PlayerPrefs.SetString("Emote_Wheel", ConfigFile_WheelKeybind);
			}
			EmoteWheelKeyboard = PlayerPrefs.GetString("Emote_Wheel");
			if (!PlayerPrefs.HasKey("InvCheck"))
			{
				PlayerPrefs.SetInt("InvCheck", ConfigFile_InventoryCheck ? 1 : 0);
			}
			ConfigFile_InventoryCheck = PlayerPrefs.GetInt("InvCheck") == 1;
		}

		[HarmonyPatch(typeof(MenuManager), "Start")]
		[HarmonyPostfix]
		private static void MenuStart(MenuManager __instance)
		{
			D.Debug = true;
			try
			{
				InstantiateSettingsMenu(((Component)((Component)__instance).transform.parent).transform.Find("MenuContainer"));
			}
			catch (Exception ex)
			{
				if (!s_isFirstTimeOnMenu)
				{
					s_isFirstTimeOnMenu = true;
				}
				else
				{
					Debug.LogError((object)(ex.Message + "\n[MoreEmotes-Sligili] Couldn't find MenuContainer"));
				}
			}
		}

		[HarmonyPatch(typeof(RoundManager), "Awake")]
		[HarmonyPostfix]
		private static void AwakePost(RoundManager __instance)
		{
			if (!PlayerPrefs.HasKey("InvCheck"))
			{
				PlayerPrefs.SetInt("InvCheck", ConfigFile_InventoryCheck ? 1 : 0);
			}
			UpdateWheelKeybinds();
			GameObject gameObject = ((Component)((Component)GameObject.Find("Systems").gameObject.transform.Find("UI")).gameObject.transform.Find("Canvas")).gameObject;
			InstantiateSettingsMenu(gameObject.transform.Find("QuickMenu"));
			s_selectionWheel = Object.Instantiate<GameObject>(WheelPrefab, gameObject.transform).AddComponent<EmoteWheel>();
			s_customSignInputField = Object.Instantiate<GameObject>(SignUIPrefab, gameObject.transform).AddComponent<SignUI>();
			EmoteWheel.Keybinds = new string[ConfigFile_Keybinds.Length + 1];
			EmoteWheel.Keybinds = ConfigFile_Keybinds;
			s_isPlayerFirstFrame = true;
		}

		[HarmonyPatch(typeof(HUDManager), "EnableChat_performed")]
		[HarmonyPrefix]
		private static bool OpenChatPrefix()
		{
			if (s_customSignInputField.IsSignUIOpen)
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")]
		[HarmonyPrefix]
		private static bool SubmitChatPrefix()
		{
			if (s_customSignInputField.IsSignUIOpen)
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Start")]
		[HarmonyPostfix]
		private static void StartPostfix(PlayerControllerB __instance)
		{
			((Component)((Component)((Component)__instance).gameObject.transform.Find("ScavengerModel")).transform.Find("metarig")).gameObject.AddComponent<MoreEmotesEvents>().Player = __instance;
			s_defaultPlayerSpeed = __instance.movementSpeed;
			((Component)__instance).gameObject.AddComponent<CustomAnimationObjects>();
			SpawnSign(__instance);
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		[HarmonyPostfix]
		private static void UpdatePostfix(PlayerControllerB __instance)
		{
			if (!__instance.isPlayerControlled || !((NetworkBehaviour)__instance).IsOwner)
			{
				__instance.playerBodyAnimator.runtimeAnimatorController = others;
				TurnControllerIntoAnOverrideController(__instance.playerBodyAnimator.runtimeAnimatorController);
				return;
			}
			if ((Object)(object)__instance.playerBodyAnimator != (Object)(object)local)
			{
				if (s_isPlayerFirstFrame)
				{
					SpawnLegs(__instance);
				}
				__instance.playerBodyAnimator.runtimeAnimatorController = local;
				if (s_isPlayerFirstFrame)
				{
					OnFirstLocalPlayerFrameWithNewAnimator(__instance);
				}
				if (s_isPlayerSpawning)
				{
					__instance.SpawnPlayerAnimation();
					s_isPlayerSpawning = false;
				}
			}
			if (!IncompatibleStuff)
			{
				if ((bool)Ref.Method(__instance, "CheckConditionsForEmote") && __instance.performingEmote)
				{
					switch (s_currentEmoteID)
					{
					case 6:
						__instance.movementSpeed = s_defaultPlayerSpeed / 2f;
						break;
					case 9:
						__instance.movementSpeed = s_defaultPlayerSpeed / 3f;
						break;
					}
				}
				else
				{
					__instance.movementSpeed = s_defaultPlayerSpeed;
				}
			}
			__instance.localArmsRotationTarget = (LocalArmsSeparatedFromCamera ? (__instance.localArmsRotationTarget = s_freeArmsTarget) : (__instance.localArmsRotationTarget = s_lockedArmsTarget));
			CheckWheelInput(EmoteWheelKeyboard, EmoteWheelController, __instance);
			if (!__instance.quickMenuManager.isMenuOpen && !IsEmoteWheelOpen)
			{
				CheckEmoteInput(ConfigFile_Keybinds[2], needsEmptyHands: false, 3, __instance);
				CheckEmoteInput(ConfigFile_Keybinds[3], needsEmptyHands: true, 4, __instance);
				CheckEmoteInput(ConfigFile_Keybinds[4], needsEmptyHands: true, 5, __instance);
				CheckEmoteInput(ConfigFile_Keybinds[5], needsEmptyHands: false, 6, __instance);
				CheckEmoteInput(ConfigFile_Keybinds[6], needsEmptyHands: true, 7, __instance);
				CheckEmoteInput(ConfigFile_Keybinds[7], needsEmptyHands: true, 8, __instance);
				CheckEmoteInput(ConfigFile_Keybinds[8], needsEmptyHands: true, 9, __instance);
				CheckEmoteInput(ConfigFile_Keybinds[9], needsEmptyHands: true, 10, __instance);
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		[HarmonyPrefix]
		private static void UpdatePrefix(PlayerControllerB __instance)
		{
			if (__instance.performingEmote)
			{
				s_wasPerformingEmote[__instance.playerClientId] = true;
			}
			if (!__instance.performingEmote && s_wasPerformingEmote[__instance.playerClientId])
			{
				s_wasPerformingEmote[__instance.playerClientId] = false;
				ResetIKWeights(__instance);
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "SpawnPlayerAnimation")]
		[HarmonyPrefix]
		private static void OnLocalPlayerSpawn(PlayerControllerB __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled)
			{
				s_isPlayerSpawning = true;
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "CheckConditionsForEmote")]
		[HarmonyPrefix]
		private static bool CheckConditionsPrefix(ref bool __result, PlayerControllerB __instance)
		{
			bool flag = (bool)Ref.GetInstanceField(typeof(PlayerControllerB), __instance, "isJumping");
			bool flag2 = (bool)Ref.GetInstanceField(typeof(PlayerControllerB), __instance, "isWalking");
			if (s_currentEmoteID == 6 || s_currentEmoteID == 9)
			{
				__result = !__instance.inSpecialInteractAnimation && !__instance.isPlayerDead && !flag && __instance.moveInputVector.x == 0f && !__instance.isSprinting && !__instance.isCrouching && !__instance.isClimbingLadder && !__instance.isGrabbingObjectAnimation && !__instance.inTerminalMenu && !__instance.isTypingChat;
				return false;
			}
			if (s_currentEmoteID == 10 || s_currentEmoteID == 1010)
			{
				__result = !__instance.inSpecialInteractAnimation && !__instance.isPlayerDead && !flag && !flag2 && !__instance.isCrouching && !__instance.isClimbingLadder && !__instance.isGrabbingObjectAnimation && !__instance.inTerminalMenu;
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "PerformEmote")]
		[HarmonyPrefix]
		private static bool PerformEmotePrefix(CallbackContext context, int emoteID, PlayerControllerB __instance)
		{
			if ((emoteID < 0 || CheckIfTooManyEmotesIsPlaying(__instance)) && emoteID > 2)
			{
				return false;
			}
			if ((!((NetworkBehaviour)__instance).IsOwner || !__instance.isPlayerControlled || (((NetworkBehaviour)__instance).IsServer && !__instance.isHostPlayerObject)) && !__instance.isTestingPlayer)
			{
				return false;
			}
			if (s_customSignInputField.IsSignUIOpen && emoteID != 1010)
			{
				return false;
			}
			if (emoteID > 0 && emoteID < 3 && !IsEmoteWheelOpen && !((CallbackContext)(ref context)).performed)
			{
				return false;
			}
			int[] array = s_doubleEmotesIDS;
			foreach (int num in array)
			{
				int num2 = num + _AlternateEmoteIDOffset;
				bool flag = (UseConfigFile ? ConfigFile_InventoryCheck : (PlayerPrefs.GetInt("InvCheck") == 1));
				if (emoteID == num && s_currentEmoteID == emoteID && __instance.performingEmote && (!__instance.isHoldingObject || !flag))
				{
					if (emoteID == num)
					{
						emoteID += _AlternateEmoteIDOffset;
					}
					else
					{
						emoteID -= 1000;
					}
				}
			}
			if ((s_currentEmoteID != emoteID && emoteID < 3) || !__instance.performingEmote)
			{
				ResetIKWeights(__instance);
			}
			if (!(bool)Ref.Method(__instance, "CheckConditionsForEmote"))
			{
				return false;
			}
			if (__instance.timeSinceStartingEmote < 0.5f)
			{
				return false;
			}
			s_currentEmoteID = emoteID;
			Action action = delegate
			{
				__instance.timeSinceStartingEmote = 0f;
				__instance.playerBodyAnimator.SetInteger("emoteNumber", emoteID);
				__instance.performingEmote = true;
				__instance.StartPerformingEmoteServerRpc();
				s_syncAnimator.UpdateEmoteIDForOthers(emoteID);
				TogglePlayerBadges(enabled: false);
			};
			switch (emoteID)
			{
			case 9:
				action = (Action)Delegate.Combine(action, (Action)delegate
				{
					UpdateLegsMaterial(__instance);
				});
				break;
			case 10:
				action = (Action)Delegate.Combine(action, (Action)delegate
				{
					((Component)s_customSignInputField).gameObject.SetActive(true);
				});
				break;
			}
			action();
			return false;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "StopPerformingEmoteServerRpc")]
		[HarmonyPostfix]
		private static void StopPerformingEmoteServerPrefix(PlayerControllerB __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled)
			{
				__instance.playerBodyAnimator.SetInteger("emoteNumber", 0);
			}
			TogglePlayerBadges(enabled: true);
			s_syncAnimator.UpdateEmoteIDForOthers(0);
			s_currentEmoteID = 0;
		}
	}
}
namespace MoreEmotes.Scripts
{
	public class MoreEmotesEvents : MonoBehaviour
	{
		private Animator _playerAnimator;

		private AudioSource _playerAudioSource;

		public static AudioClip[] ClapSounds = (AudioClip[])(object)new AudioClip[2];

		public PlayerControllerB Player;

		private void Start()
		{
			_playerAnimator = ((Component)this).GetComponent<Animator>();
			_playerAudioSource = Player.movementAudio;
		}

		public void PlayClapSound()
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			if (Player.performingEmote)
			{
				int currentEmoteID = GetCurrentEmoteID();
				if (!((NetworkBehaviour)Player).IsOwner || !Player.isPlayerControlled || currentEmoteID == 4)
				{
					bool flag = Player.isInHangarShipRoom && Player.playersManager.hangarDoorsClosed;
					RoundManager.Instance.PlayAudibleNoise(((Component)Player).transform.position, 22f, 0.6f, 0, flag, 6);
					_playerAudioSource.pitch = Random.Range(0.59f, 0.79f);
					_playerAudioSource.PlayOneShot(ClapSounds[Random.Range(0, ClapSounds.Length)]);
				}
			}
		}

		public void PlayFootstepSound()
		{
			if (Player.performingEmote)
			{
				int currentEmoteID = GetCurrentEmoteID();
				if ((!((NetworkBehaviour)Player).IsOwner || !Player.isPlayerControlled || currentEmoteID == 6 || currentEmoteID == 8 || currentEmoteID == 9) && ((Vector2)(ref Player.moveInputVector)).sqrMagnitude == 0f)
				{
					Player.PlayFootstepLocal();
					Player.PlayFootstepServer();
				}
			}
		}

		private int GetCurrentEmoteID()
		{
			int num = _playerAnimator.GetInteger("emoteNumber");
			if (num >= 1000)
			{
				num -= 1000;
			}
			return num;
		}
	}
	public class SignEmoteText : NetworkBehaviour
	{
		private PlayerControllerB _playerInstance;

		private TextMeshPro _signModelText;

		public string Text => ((TMP_Text)_signModelText).text;

		private void Start()
		{
			_playerInstance = ((Component)this).GetComponent<PlayerControllerB>();
			_signModelText = ((Component)((Component)_playerInstance).transform.Find("ScavengerModel").Find("metarig").Find("Sign")
				.Find("Text")).GetComponent<TextMeshPro>();
		}

		public void UpdateSignText(string newText)
		{
			if (((NetworkBehaviour)_playerInstance).IsOwner && _playerInstance.isPlayerControlled)
			{
				UpdateSignTextServerRpc(newText);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void UpdateSignTextServerRpc(string newText)
		{
			UpdateSignTextClientRpc(newText);
		}

		[ClientRpc]
		private void UpdateSignTextClientRpc(string newText)
		{
			((TMP_Text)_signModelText).text = newText;
		}
	}
	public class EmoteWheel : MonoBehaviour
	{
		private RectTransform _graphics_selectedBlock;

		private RectTransform _graphics_selectionArrow;

		private Text _graphics_emoteInformation;

		private Text _graphics_pageInformation;

		private int _blocksNumber = 8;

		private int _selectedBlock = 1;

		private float _changePageCooldown = 0.1f;

		private float _selectionArrowLerpSpeed = 30f;

		private float _angle;

		private GameObject[] _pages;

		public float WheelMovementDeadzone = 3.3f;

		public float WheelMovementDeadzoneController = 0.7f;

		public static string[] Keybinds;

		private Vector2 _wheelCenter;

		private Vector2 _lastMouseCoords;

		public int SelectedPageNumber { get; private set; }

		public int SelectedEmoteID { get; private set; }

		public bool IsUsingController { get; private set; }

		private void Awake()
		{
			GetVanillaKeybinds();
			FindGraphics();
			FindPages(((Component)this).gameObject.transform.Find("FunctionalContent"));
			UpdatePageInfo();
		}

		private void OnEnable()
		{
			//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_0022: Unknown result type (might be due to invalid IL or missing references)
			_wheelCenter = new Vector2((float)(Screen.width / 2), (float)(Screen.height / 2));
			Mouse.current.WarpCursorPosition(_wheelCenter);
		}

		private void GetVanillaKeybinds()
		{
			PlayerInput component = GameObject.Find("PlayerSettingsObject").GetComponent<PlayerInput>();
			if ((Object)(object)component == (Object)null)
			{
				Debug.LogError((object)" MoreEmotes: PlayerSettingsObject is null");
				return;
			}
			Keybinds[0] = InputActionRebindingExtensions.GetBindingDisplayString(component.currentActionMap.FindAction("Emote1", false), 0, (DisplayStringOptions)0);
			Keybinds[1] = InputActionRebindingExtensions.GetBindingDisplayString(component.currentActionMap.FindAction("Emote2", false), 0, (DisplayStringOptions)0);
		}

		private void FindGraphics()
		{
			_graphics_selectionArrow = ((Component)((Component)((Component)this).gameObject.transform.Find("Graphics")).gameObject.transform.Find("SelectionArrow")).gameObject.GetComponent<RectTransform>();
			_graphics_selectedBlock = ((Component)((Component)this).gameObject.transform.Find("SelectedEmote")).gameObject.GetComponent<RectTransform>();
			_graphics_emoteInformation = ((Component)((Component)((Component)this).gameObject.transform.Find("Graphics")).gameObject.transform.Find("EmoteInfo")).GetComponent<Text>();
			_graphics_pageInformation = ((Component)((Component)((Component)this).gameObject.transform.Find("Graphics")).gameObject.transform.Find("PageNumber")).GetComponent<Text>();
		}

		private void FindPages(Transform contentParent)
		{
			_pages = (GameObject[])(object)new GameObject[((Component)contentParent).transform.childCount];
			_graphics_pageInformation.text = "< Page " + (SelectedPageNumber + 1) + "/" + _pages.Length + " >";
			for (int i = 0; i < ((Component)contentParent).transform.childCount; i++)
			{
				_pages[i] = ((Component)((Component)contentParent).transform.GetChild(i)).gameObject;
			}
		}

		private void Update()
		{
			ControllerInput();
			if (!IsUsingController)
			{
				MouseInput();
			}
			Cursor.visible = !IsUsingController;
			UpdateSelectionArrow();
			PageSelection();
			SelectedEmoteID = _selectedBlock + Mathf.RoundToInt((float)(_blocksNumber / 4)) + _blocksNumber * SelectedPageNumber;
			UpdateEmoteInfo();
		}

		private unsafe void ControllerInput()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			if (Gamepad.all.Count == 0)
			{
				IsUsingController = false;
				return;
			}
			float num = ((InputControl<float>)(object)((Vector2Control)Gamepad.current.rightStick).x).ReadUnprocessedValue();
			float num2 = ((InputControl<float>)(object)((Vector2Control)Gamepad.current.rightStick).y).ReadUnprocessedValue();
			if (Mathf.Abs(num) < WheelMovementDeadzoneController && Mathf.Abs(num2) < WheelMovementDeadzoneController)
			{
				if (System.Runtime.CompilerServices.Unsafe.Read<Vector2>((void*)((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).value) != _lastMouseCoords)
				{
					IsUsingController = false;
				}
			}
			else
			{
				IsUsingController = true;
				_lastMouseCoords = System.Runtime.CompilerServices.Unsafe.Read<Vector2>((void*)((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).value);
				WheelSelection(Vector2.zero, num, num2);
			}
		}

		private void MouseInput()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			if (!(Vector2.Distance(_wheelCenter, ((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue()) < WheelMovementDeadzone))
			{
				WheelSelection(_wheelCenter, ((InputControl<float>)(object)((Pointer)Mouse.current).position.x).ReadValue(), ((InputControl<float>)(object)((Pointer)Mouse.current).position.y).ReadValue());
			}
		}

		private void WheelSelection(Vector2 origin, float xAxisValue, float yAxisValue)
		{
			//IL_0002: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
			bool flag = xAxisValue > origin.x;
			bool flag2 = yAxisValue > origin.y;
			int num = ((!flag) ? (flag2 ? 2 : 3) : (flag2 ? 1 : 4));
			float num2 = (yAxisValue - origin.y) / (xAxisValue - origin.x);
			float num3 = 180 * (num - ((num <= 2) ? 1 : 2));
			_angle = Mathf.Atan(num2) * (180f / (float)Math.PI) + num3;
			if (_angle == 90f)
			{
				_angle = 270f;
			}
			else if (_angle == 270f)
			{
				_angle = 90f;
			}
			float num4 = 360 / _blocksNumber;
			_selectedBlock = Mathf.RoundToInt((_angle - num4 * 1.5f) / num4);
			((Transform)_graphics_selectedBlock).localRotation = Quaternion.Euler(((Component)this).transform.rotation.z, ((Component)this).transform.rotation.y, num4 * (float)_selectedBlock);
		}

		private void PageSelection()
		{
			UpdatePageInfo();
			if (_changePageCooldown > 0f)
			{
				_changePageCooldown -= Time.deltaTime;
				return;
			}
			int num;
			if (IsUsingController)
			{
				if (!Gamepad.current.dpad.left.isPressed && !Gamepad.current.dpad.right.isPressed)
				{
					return;
				}
				num = (Gamepad.current.dpad.left.isPressed ? 1 : (-1));
			}
			else
			{
				if (((InputControl<float>)(object)((Vector2Control)Mouse.current.scroll).y).ReadValue() == 0f)
				{
					return;
				}
				num = ((((InputControl<float>)(object)((Vector2Control)Mouse.current.scroll).y).ReadValue() > 0f) ? 1 : (-1));
			}
			GameObject[] pages = _pages;
			foreach (GameObject val in pages)
			{
				val.SetActive(false);
			}
			SelectedPageNumber = (SelectedPageNumber + num + _pages.Length) % _pages.Length;
			_pages[SelectedPageNumber].SetActive(true);
			_changePageCooldown = ((!IsUsingController) ? 0.1f : 0.3f);
		}

		private void UpdatePageInfo()
		{
			_graphics_pageInformation.text = $"<color=#fe6b02><</color> Page {SelectedPageNumber + 1}/{_pages.Length} <color=#fe6b02>></color>";
		}

		private void UpdateEmoteInfo()
		{
			string text = ((SelectedEmoteID > Keybinds.Length) ? "" : Keybinds[SelectedEmoteID - 1]);
			int num = 0;
			foreach (Emotes value in Enum.GetValues(typeof(Emotes)))
			{
				if (value >= Emotes.Dance && value < (Emotes)64)
				{
					num++;
				}
			}
			string text2 = ((SelectedEmoteID > num) ? "EMPTY" : ((Emotes)SelectedEmoteID).ToString().Replace("_", " "));
			if (SelectedEmoteID > 2 && SelectedEmoteID <= Keybinds.Length)
			{
				if (!PlayerPrefs.HasKey(text2.Replace(" ", "_")))
				{
					PlayerPrefs.SetString(text2.Replace(" ", "_"), (SelectedEmoteID > Keybinds.Length) ? "" : Keybinds[SelectedEmoteID - 1]);
				}
				else
				{
					text = PlayerPrefs.GetString(text2.Replace(" ", "_"));
				}
			}
			text = "<size=120>[" + text + "]</size>";
			_graphics_emoteInformation.text = text2 + "\n" + text.ToUpper();
		}

		private void UpdateSelectionArrow()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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)
			float num = 360 / _blocksNumber;
			Quaternion val = Quaternion.Euler(0f, 0f, _angle - num * 2f);
			((Transform)_graphics_selectionArrow).localRotation = Quaternion.Lerp(((Transform)_graphics_selectionArrow).localRotation, val, Time.deltaTime * _selectionArrowLerpSpeed);
		}
	}
	public class RebindButton : MonoBehaviour
	{
		public static string[] ConfigFile_Keybinds;

		private string _defaultKey;

		private string _playerPrefsString;

		private Transform _waitingForInput;

		private Text _keyInfo;

		public bool IsControllerButton { get; private set; } = false;


		private void Start()
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			string text = ((Component)((Component)this).gameObject.transform.Find("Description")).GetComponent<Text>().text;
			IsControllerButton = GetControllerFlag();
			_playerPrefsString = ((Component)((Component)this).gameObject.transform.Find("Description")).GetComponent<Text>().text.Replace(" ", "_") + (IsControllerButton ? "_c" : "");
			_defaultKey = GetDefaultKey(text);
			FindComponents();
			((UnityEvent)((Component)this).GetComponent<Button>().onClick).AddListener(new UnityAction(GetKey));
			if (!PlayerPrefs.HasKey(_playerPrefsString))
			{
				PlayerPrefs.SetString(_playerPrefsString, _defaultKey);
			}
			SetKeybind(PlayerPrefs.GetString(_playerPrefsString));
		}

		private string GetDefaultKey(string emoteName)
		{
			if (Enum.TryParse<Emotes>(emoteName.Replace(" ", "_"), out var result))
			{
				return ConfigFile_Keybinds[(int)(result - 1)];
			}
			return IsControllerButton ? "leftshoulder" : "V";
		}

		private bool GetControllerFlag()
		{
			Transform val = ((Component)this).gameObject.transform.Find("Description").Find("Subtext");
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			Text val2 = default(Text);
			if (((Component)val).TryGetComponent<Text>(ref val2))
			{
				return val2.text.Equals("(Controller)", StringComparison.OrdinalIgnoreCase);
			}
			return false;
		}

		private void FindComponents()
		{
			((Component)((Component)((Component)this).transform.parent).transform.Find("Delete")).gameObject.AddComponent<DeleteButton>();
			_keyInfo = ((Component)((Component)this).transform.Find("InputText")).GetComponent<Text>();
			_waitingForInput = ((Component)this).transform.Find("wait");
		}

		public void SetKeybind(string key)
		{
			List<string> list = new List<string> { "up", "down", "left", "right" };
			if (list.Contains(key.ToLower()) && key.Length < 5)
			{
				key = "dpad/" + key;
			}
			PlayerPrefs.SetString(_playerPrefsString, key);
			_keyInfo.text = key.ToUpper();
			((MonoBehaviour)this).StopAllCoroutines();
			((Component)_waitingForInput).gameObject.SetActive(false);
		}

		private void GetKey()
		{
			((Component)_waitingForInput).gameObject.SetActive(true);
			((MonoBehaviour)this).StartCoroutine(WaitForKey(delegate(string key)
			{
				SetKeybind(key);
			}));
		}

		private IEnumerator WaitForKey(Action<string> callback)
		{
			while (!((ButtonControl)Keyboard.current.anyKey).wasPressedThisFrame || (!((InputDevice)Gamepad.current).wasUpdatedThisFrame && !InputControlExtensions.IsActuated((InputControl)(object)Gamepad.current.leftStick, 0f) && !InputControlExtensions.IsActuated((InputControl)(object)Gamepad.current.rightStick, 0f)))
			{
				yield return (object)new WaitForEndOfFrame();
				Observable.CallOnce<InputControl>(InputSystem.onAnyButtonPress, (Action<InputControl>)delegate(InputControl ctrl)
				{
					callback(((ctrl.device == Gamepad.current && IsControllerButton) || (ctrl.device == Keyboard.current && !IsControllerButton)) ? ctrl.name : _defaultKey);
				});
			}
		}
	}
	public class DeleteButton : MonoBehaviour
	{
		private void Start()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			RebindButton _rebindButton = ((Component)((Component)((Component)this).transform.parent).transform.Find("Button")).GetComponent<RebindButton>();
			((UnityEvent)((Component)this).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				_rebindButton.SetKeybind(string.Empty);
			});
		}
	}
	public class ToggleButton : MonoBehaviour
	{
		private Toggle _toggle;

		public static bool s_InventoryCheck;

		public string PlayerPrefsString;

		private void Start()
		{
			_toggle = ((Component)this).GetComponent<Toggle>();
			_toggle.isOn = s_InventoryCheck;
			((UnityEvent<bool>)(object)_toggle.onValueChanged).AddListener((UnityAction<bool>)SetNewValue);
			if (!PlayerPrefs.HasKey(PlayerPrefsString))
			{
				SetNewValue(s_InventoryCheck);
			}
		}

		public void SetNewValue(bool arg)
		{
			PlayerPrefs.SetInt(PlayerPrefsString, arg ? 1 : 0);
		}
	}
	public class EnableDisableButton : MonoBehaviour
	{
		public GameObject[] ToAlternateUI = (GameObject[])(object)new GameObject[1];

		private void Start()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			((UnityEvent)((Component)this).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				GameObject[] toAlternateUI = ToAlternateUI;
				foreach (GameObject val in toAlternateUI)
				{
					val.SetActive((!val.activeInHierarchy) ? true : false);
				}
			});
			if (((Object)((Component)this).gameObject).name.Equals("BackButton", StringComparison.OrdinalIgnoreCase))
			{
				ToAlternateUI[0] = ((Component)((Component)this).transform.parent).gameObject;
			}
			if (((Object)((Component)this).gameObject).name.Equals("MoreEmotesButton(Clone)", StringComparison.OrdinalIgnoreCase))
			{
				ToAlternateUI[0] = ((Component)((Component)((Component)this).transform.parent).gameObject.transform.Find("MoreEmotesPanel(Clone)")).gameObject;
			}
		}
	}
	public class SetupUI : MonoBehaviour
	{
		public static bool UseConfigFile;

		public static bool InventoryCheck;

		private void Awake()
		{
			Transform settingsUIPanel = ((Component)this).transform.Find("MoreEmotesPanel(Clone)");
			((Component)settingsUIPanel.Find("Version")).GetComponent<Text>().text = "1.3.3 - Sligili";
			SetupOpenSettingsButton();
			SetupBackButton();
			SetupRebindButtons(((Component)settingsUIPanel).transform.Find("KeybindButtons"));
			SetupRebindButtons(((Component)((Component)((Component)settingsUIPanel).transform.Find("Scroll View")).transform.Find("Viewport")).transform.Find("Content"));
			SetupInventoryCheckToggle();
			SetupUseConfigFileToggle();
			void SetupBackButton()
			{
				((Component)((Component)settingsUIPanel).transform.Find("BackButton")).gameObject.AddComponent<EnableDisableButton>();
			}
			void SetupInventoryCheckToggle()
			{
				((Component)((Component)settingsUIPanel).transform.Find("Inv")).gameObject.AddComponent<ToggleButton>().PlayerPrefsString = "InvCheck";
			}
			void SetupOpenSettingsButton()
			{
				((Component)((Component)this).transform.Find("MoreEmotesButton(Clone)")).gameObject.AddComponent<EnableDisableButton>();
			}
			static void SetupRebindButtons(Transform ButtonsParent)
			{
				Transform[] array = (Transform[])(object)new Transform[ButtonsParent.childCount];
				for (int i = 0; i < array.Length; i++)
				{
					array[i] = ButtonsParent.GetChild(i);
				}
				Transform[] array2 = array;
				foreach (Transform val in array2)
				{
					((Component)val.Find("Button")).gameObject.AddComponent<RebindButton>();
				}
			}
			void SetupUseConfigFileToggle()
			{
				((Component)((Component)settingsUIPanel).transform.Find("cfg")).gameObject.GetComponent<Toggle>().isOn = UseConfigFile;
			}
		}

		private void Update()
		{
			EmotePatch.UpdateWheelKeybinds();
		}
	}
	public class SignUI : MonoBehaviour
	{
		public PlayerControllerB Player;

		private TMP_InputField _inputField;

		private Text _charactersLeftText;

		private TMP_Text _previewText;

		private Button _submitButton;

		private Button _cancelButton;

		public bool IsSignUIOpen;

		private void Awake()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			FindComponents();
			((UnityEvent)_submitButton.onClick).AddListener(new UnityAction(SubmitText));
			((UnityEvent)_cancelButton.onClick).AddListener((UnityAction)delegate
			{
				Close(cancelAction: true);
			});
			((UnityEvent<string>)(object)_inputField.onValueChanged).AddListener((UnityAction<string>)delegate(string fieldText)
			{
				UpdatePreviewText(fieldText);
				UpdateCharactersLeftText();
			});
		}

		private void OnEnable()
		{
			Player.isTypingChat = true;
			IsSignUIOpen = true;
			((Selectable)_inputField).Select();
			_inputField.text = string.Empty;
			_previewText.text = "PREVIEW";
			Player.disableLookInput = true;
		}

		private void Update()
		{
			//IL_009e: 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)
			Cursor.visible = true;
			Cursor.lockState = (CursorLockMode)2;
			if (!Player.performingEmote)
			{
				Close(cancelAction: true);
			}
			if (((ButtonControl)Keyboard.current[(Key)2]).wasPressedThisFrame && !((ButtonControl)Keyboard.current[(Key)51]).isPressed)
			{
				SubmitText();
			}
			if (Player.quickMenuManager.isMenuOpen || EmotePatch.IsEmoteWheelOpen || InputControlExtensions.IsPressed(((InputControl)Mouse.current)["rightButton"], 0f))
			{
				Close(cancelAction: true);
			}
			if (Gamepad.all.Count != 0)
			{
				if (Gamepad.current.buttonWest.isPressed || Gamepad.current.startButton.isPressed)
				{
					SubmitText();
				}
				if (Gamepad.current.buttonEast.isPressed || Gamepad.current.selectButton.isPressed)
				{
					Close(cancelAction: true);
				}
			}
		}

		private void FindComponents()
		{
			_inputField = ((Component)((Component)this).transform.Find("InputField")).GetComponent<TMP_InputField>();
			_charactersLeftText = ((Component)((Component)this).transform.Find("CharsLeft")).GetComponent<Text>();
			_submitButton = ((Component)((Component)this).transform.Find("Submit")).GetComponent<Button>();
			_cancelButton = ((Component)((Component)this).transform.Find("Cancel")).GetComponent<Button>();
			_previewText = ((Component)((Component)((Component)this).transform.Find("Sign")).transform.Find("Text")).GetComponent<TMP_Text>();
		}

		private void UpdateCharactersLeftText()
		{
			_charactersLeftText.text = $"CHARACTERS LEFT: <color=yellow>{_inputField.characterLimit - _inputField.text.Length}</color>";
		}

		private void UpdatePreviewText(string text)
		{
			_previewText.text = text;
		}

		private void SubmitText()
		{
			//IL_007c: 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)
			if (_inputField.text.Equals(string.Empty))
			{
				Close(cancelAction: true);
				return;
			}
			D.L("Submitted " + _inputField.text + " to server");
			((Component)Player).GetComponent<SignEmoteText>().UpdateSignText(_inputField.text);
			float num = 0.5f;
			if (Player.timeSinceStartingEmote > num)
			{
				Player.PerformEmote(default(CallbackContext), 1010);
			}
			Close(cancelAction: false);
		}

		private void Close(bool cancelAction)
		{
			Player.isTypingChat = false;
			IsSignUIOpen = false;
			if (cancelAction)
			{
				Player.performingEmote = false;
				Player.StopPerformingEmoteServerRpc();
			}
			if (!Player.quickMenuManager.isMenuOpen)
			{
				Cursor.visible = false;
				Cursor.lockState = (CursorLockMode)1;
			}
			Player.disableLookInput = false;
			((Component)this).gameObject.SetActive(false);
		}
	}
	public class SyncAnimatorToOthers : NetworkBehaviour
	{
		private PlayerControllerB _player;

		private void Start()
		{
			_player = ((Component)this).GetComponent<PlayerControllerB>();
		}

		public void UpdateEmoteIDForOthers(int newID)
		{
			if (((NetworkBehaviour)_player).IsOwner && _player.isPlayerControlled)
			{
				UpdateCurrentEmoteIDServerRpc(newID);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void UpdateCurrentEmoteIDServerRpc(int newID)
		{
			UpdateCurrentEmoteIDClientRpc(newID);
		}

		[ClientRpc]
		private void UpdateCurrentEmoteIDClientRpc(int newID)
		{
			if (!((NetworkBehaviour)_player).IsOwner)
			{
				_player.playerBodyAnimator.SetInteger("emoteNumber", newID);
			}
		}
	}
	public class CustomAnimationObjects : MonoBehaviour
	{
		private PlayerControllerB _player;

		private MeshRenderer _sign;

		private GameObject _signText;

		private SkinnedMeshRenderer _legs;

		private void Start()
		{
			_player = ((Component)this).GetComponent<PlayerControllerB>();
		}

		private void Update()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_sign == (Object)null || (Object)(object)_signText == (Object)null)
			{
				FindSign();
				return;
			}
			((Component)_sign).transform.localPosition = ((Component)_sign).transform.parent.Find("spine").localPosition;
			if ((Object)(object)_legs == (Object)null && ((NetworkBehaviour)_player).IsOwner && _player.isPlayerControlled)
			{
				FindLegs();
				return;
			}
			DisableEverything();
			if (!_player.performingEmote)
			{
				return;
			}
			switch (_player.playerBodyAnimator.GetInteger("emoteNumber"))
			{
			case 10:
			case 1010:
				((Renderer)_sign).enabled = true;
				if (!_signText.activeSelf)
				{
					_signText.SetActive(true);
				}
				if (((NetworkBehaviour)_player).IsOwner)
				{
					EmotePatch.LocalArmsSeparatedFromCamera = true;
				}
				break;
			case 9:
				if ((Object)(object)_legs != (Object)null)
				{
					((Renderer)_legs).enabled = true;
				}
				if (((NetworkBehaviour)_player).IsOwner)
				{
					EmotePatch.LocalArmsSeparatedFromCamera = true;
				}
				break;
			}
		}

		private void DisableEverything()
		{
			if ((Object)(object)_legs != (Object)null)
			{
				((Renderer)_legs).enabled = false;
			}
			((Renderer)_sign).enabled = false;
			if (_signText.activeSelf)
			{
				_signText.SetActive(false);
			}
			if (((NetworkBehaviour)_player).IsOwner && _player.isPlayerControlled)
			{
				EmotePatch.LocalArmsSeparatedFromCamera = false;
			}
		}

		private void FindSign()
		{
			_sign = ((Component)((Component)_player).transform.Find("ScavengerModel").Find("metarig").Find("Sign")).GetComponent<MeshRenderer>();
			_signText = ((Component)((Component)_sign).transform.Find("Text")).gameObject;
		}

		private void FindLegs()
		{
			_legs = ((Component)((Component)_player).transform.Find("ScavengerModel").Find("LEGS")).GetComponent<SkinnedMeshRenderer>();
		}
	}
}

plugins/MoreSuits.dll

Decompiled 9 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("MoreSuits")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A mod that adds more suit options to Lethal Company")]
[assembly: AssemblyFileVersion("1.4.1.0")]
[assembly: AssemblyInformationalVersion("1.4.1")]
[assembly: AssemblyProduct("MoreSuits")]
[assembly: AssemblyTitle("MoreSuits")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.4.1.0")]
[module: UnverifiableCode]
namespace MoreSuits;

[BepInPlugin("x753.More_Suits", "More Suits", "1.4.1")]
public class MoreSuitsMod : BaseUnityPlugin
{
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		private static void StartPatch(ref StartOfRound __instance)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_067c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0681: Unknown result type (might be due to invalid IL or missing references)
			//IL_0687: Unknown result type (might be due to invalid IL or missing references)
			//IL_068c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Expected O, but got Unknown
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Expected O, but got Unknown
			//IL_0598: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Expected O, but got Unknown
			try
			{
				if (SuitsAdded)
				{
					return;
				}
				int count = __instance.unlockablesList.unlockables.Count;
				UnlockableItem val = new UnlockableItem();
				int num = 0;
				for (int i = 0; i < __instance.unlockablesList.unlockables.Count; i++)
				{
					UnlockableItem val2 = __instance.unlockablesList.unlockables[i];
					if (!((Object)(object)val2.suitMaterial != (Object)null) || !val2.alreadyUnlocked)
					{
						continue;
					}
					val = val2;
					List<string> list = Directory.GetDirectories(Paths.PluginPath, "moresuits", SearchOption.AllDirectories).ToList();
					List<string> list2 = new List<string>();
					List<string> list3 = new List<string>();
					List<string> list4 = DisabledSuits.ToLower().Replace(".png", "").Split(',')
						.ToList();
					List<string> list5 = new List<string>();
					if (!LoadAllSuits)
					{
						foreach (string item2 in list)
						{
							if (File.Exists(Path.Combine(item2, "!less-suits.txt")))
							{
								string[] collection = new string[9] { "glow", "kirby", "knuckles", "luigi", "mario", "minion", "skeleton", "slayer", "smile" };
								list5.AddRange(collection);
								break;
							}
						}
					}
					foreach (string item3 in list)
					{
						if (item3 != "")
						{
							string[] files = Directory.GetFiles(item3, "*.png");
							string[] files2 = Directory.GetFiles(item3, "*.matbundle");
							list2.AddRange(files);
							list3.AddRange(files2);
						}
					}
					list3.Sort();
					list2.Sort();
					try
					{
						foreach (string item4 in list3)
						{
							Object[] array = AssetBundle.LoadFromFile(item4).LoadAllAssets();
							foreach (Object val3 in array)
							{
								if (val3 is Material)
								{
									Material item = (Material)val3;
									customMaterials.Add(item);
								}
							}
						}
					}
					catch (Exception ex)
					{
						Debug.Log((object)("Something went wrong with More Suits! Could not load materials from asset bundle(s). Error: " + ex));
					}
					foreach (string item5 in list2)
					{
						if (list4.Contains(Path.GetFileNameWithoutExtension(item5).ToLower()))
						{
							continue;
						}
						string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
						if (list5.Contains(Path.GetFileNameWithoutExtension(item5).ToLower()) && item5.Contains(directoryName))
						{
							continue;
						}
						UnlockableItem val4;
						Material val5;
						if (Path.GetFileNameWithoutExtension(item5).ToLower() == "default")
						{
							val4 = val;
							val5 = val4.suitMaterial;
						}
						else
						{
							val4 = JsonUtility.FromJson<UnlockableItem>(JsonUtility.ToJson((object)val));
							val5 = Object.Instantiate<Material>(val4.suitMaterial);
						}
						byte[] array2 = File.ReadAllBytes(item5);
						Texture2D val6 = new Texture2D(2, 2);
						ImageConversion.LoadImage(val6, array2);
						val5.mainTexture = (Texture)(object)val6;
						val4.unlockableName = Path.GetFileNameWithoutExtension(item5);
						try
						{
							string path = Path.Combine(Path.GetDirectoryName(item5), "advanced", val4.unlockableName + ".json");
							if (File.Exists(path))
							{
								string[] array3 = File.ReadAllLines(path);
								for (int j = 0; j < array3.Length; j++)
								{
									string[] array4 = array3[j].Trim().Split(':');
									if (array4.Length != 2)
									{
										continue;
									}
									string text = array4[0].Trim('"', ' ', ',');
									string text2 = array4[1].Trim('"', ' ', ',');
									if (text2.Contains(".png"))
									{
										byte[] array5 = File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(item5), "advanced", text2));
										Texture2D val7 = new Texture2D(2, 2);
										ImageConversion.LoadImage(val7, array5);
										val5.SetTexture(text, (Texture)(object)val7);
										continue;
									}
									if (text == "PRICE" && int.TryParse(text2, out var result))
									{
										try
										{
											val4 = AddToRotatingShop(val4, result, __instance.unlockablesList.unlockables.Count);
										}
										catch (Exception ex2)
										{
											Debug.Log((object)("Something went wrong with More Suits! Could not add a suit to the rotating shop. Error: " + ex2));
										}
										continue;
									}
									switch (text2)
									{
									case "KEYWORD":
										val5.EnableKeyword(text);
										continue;
									case "DISABLEKEYWORD":
										val5.DisableKeyword(text);
										continue;
									case "SHADERPASS":
										val5.SetShaderPassEnabled(text, true);
										continue;
									case "DISABLESHADERPASS":
										val5.SetShaderPassEnabled(text, false);
										continue;
									}
									float result2;
									Vector4 vector;
									if (text == "SHADER")
									{
										Shader shader = Shader.Find(text2);
										val5.shader = shader;
									}
									else if (text == "MATERIAL")
									{
										foreach (Material customMaterial in customMaterials)
										{
											if (((Object)customMaterial).name == text2)
											{
												val5 = Object.Instantiate<Material>(customMaterial);
												val5.mainTexture = (Texture)(object)val6;
												break;
											}
										}
									}
									else if (float.TryParse(text2, out result2))
									{
										val5.SetFloat(text, result2);
									}
									else if (TryParseVector4(text2, out vector))
									{
										val5.SetVector(text, vector);
									}
								}
							}
						}
						catch (Exception ex3)
						{
							Debug.Log((object)("Something went wrong with More Suits! Error: " + ex3));
						}
						val4.suitMaterial = val5;
						if (val4.unlockableName.ToLower() != "default")
						{
							if (num == MaxSuits)
							{
								Debug.Log((object)"Attempted to add a suit, but you've already reached the max number of suits! Modify the config if you want more.");
								continue;
							}
							__instance.unlockablesList.unlockables.Add(val4);
							num++;
						}
					}
					SuitsAdded = true;
					break;
				}
				UnlockableItem val8 = JsonUtility.FromJson<UnlockableItem>(JsonUtility.ToJson((object)val));
				val8.alreadyUnlocked = false;
				val8.hasBeenMoved = false;
				val8.placedPosition = Vector3.zero;
				val8.placedRotation = Vector3.zero;
				val8.unlockableType = 753;
				while (__instance.unlockablesList.unlockables.Count < count + MaxSuits)
				{
					__instance.unlockablesList.unlockables.Add(val8);
				}
			}
			catch (Exception ex4)
			{
				Debug.Log((object)("Something went wrong with More Suits! Error: " + ex4));
			}
		}

		[HarmonyPatch("PositionSuitsOnRack")]
		[HarmonyPrefix]
		private static bool PositionSuitsOnRackPatch(ref StartOfRound __instance)
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			List<UnlockableSuit> source = Object.FindObjectsOfType<UnlockableSuit>().ToList();
			source = source.OrderBy((UnlockableSuit suit) => suit.syncedSuitID.Value).ToList();
			int num = 0;
			foreach (UnlockableSuit item in source)
			{
				AutoParentToShip component = ((Component)item).gameObject.GetComponent<AutoParentToShip>();
				component.overrideOffset = true;
				float num2 = 0.18f;
				if (MakeSuitsFitOnRack && source.Count > 13)
				{
					num2 /= (float)Math.Min(source.Count, 20) / 12f;
				}
				component.positionOffset = new Vector3(-2.45f, 2.75f, -8.41f) + __instance.rightmostSuitPosition.forward * num2 * (float)num;
				component.rotationOffset = new Vector3(0f, 90f, 0f);
				num++;
			}
			return false;
		}
	}

	private const string modGUID = "x753.More_Suits";

	private const string modName = "More Suits";

	private const string modVersion = "1.4.1";

	private readonly Harmony harmony = new Harmony("x753.More_Suits");

	private static MoreSuitsMod Instance;

	public static bool SuitsAdded = false;

	public static string DisabledSuits;

	public static bool LoadAllSuits;

	public static bool MakeSuitsFitOnRack;

	public static int MaxSuits;

	public static List<Material> customMaterials = new List<Material>();

	private static TerminalNode cancelPurchase;

	private static TerminalKeyword buyKeyword;

	private void Awake()
	{
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		DisabledSuits = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Disabled Suit List", "UglySuit751.png,UglySuit752.png,UglySuit753.png", "Comma-separated list of suits that shouldn't be loaded").Value;
		LoadAllSuits = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Ignore !less-suits.txt", false, "If true, ignores the !less-suits.txt file and will attempt to load every suit, except those in the disabled list. This should be true if you're not worried about having too many suits.").Value;
		MakeSuitsFitOnRack = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Make Suits Fit on Rack", true, "If true, squishes the suits together so more can fit on the rack.").Value;
		MaxSuits = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Max Suits", 100, "The maximum number of suits to load. If you have more, some will be ignored.").Value;
		harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin More Suits is loaded!");
	}

	private static UnlockableItem AddToRotatingShop(UnlockableItem newSuit, int price, int unlockableID)
	{
		//IL_0065: 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)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Expected O, but got Unknown
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Expected O, but got Unknown
		//IL_0298: Unknown result type (might be due to invalid IL or missing references)
		//IL_029f: Expected O, but got Unknown
		Terminal val = Object.FindObjectOfType<Terminal>();
		for (int i = 0; i < val.terminalNodes.allKeywords.Length; i++)
		{
			if (((Object)val.terminalNodes.allKeywords[i]).name == "Buy")
			{
				buyKeyword = val.terminalNodes.allKeywords[i];
				break;
			}
		}
		newSuit.alreadyUnlocked = false;
		newSuit.hasBeenMoved = false;
		newSuit.placedPosition = Vector3.zero;
		newSuit.placedRotation = Vector3.zero;
		newSuit.shopSelectionNode = ScriptableObject.CreateInstance<TerminalNode>();
		((Object)newSuit.shopSelectionNode).name = newSuit.unlockableName + "SuitBuy1";
		newSuit.shopSelectionNode.creatureName = newSuit.unlockableName + " suit";
		newSuit.shopSelectionNode.displayText = "You have requested to order " + newSuit.unlockableName + " suits.\nTotal cost of item: [totalCost].\n\nPlease CONFIRM or DENY.\n\n";
		newSuit.shopSelectionNode.clearPreviousText = true;
		newSuit.shopSelectionNode.shipUnlockableID = unlockableID;
		newSuit.shopSelectionNode.itemCost = price;
		newSuit.shopSelectionNode.overrideOptions = true;
		CompatibleNoun val2 = new CompatibleNoun();
		val2.noun = ScriptableObject.CreateInstance<TerminalKeyword>();
		val2.noun.word = "confirm";
		val2.noun.isVerb = true;
		val2.result = ScriptableObject.CreateInstance<TerminalNode>();
		((Object)val2.result).name = newSuit.unlockableName + "SuitBuyConfirm";
		val2.result.creatureName = "";
		val2.result.displayText = "Ordered " + newSuit.unlockableName + " suits! Your new balance is [playerCredits].\n\n";
		val2.result.clearPreviousText = true;
		val2.result.shipUnlockableID = unlockableID;
		val2.result.buyUnlockable = true;
		val2.result.itemCost = price;
		val2.result.terminalEvent = "";
		CompatibleNoun val3 = new CompatibleNoun();
		val3.noun = ScriptableObject.CreateInstance<TerminalKeyword>();
		val3.noun.word = "deny";
		val3.noun.isVerb = true;
		if ((Object)(object)cancelPurchase == (Object)null)
		{
			cancelPurchase = ScriptableObject.CreateInstance<TerminalNode>();
		}
		val3.result = cancelPurchase;
		((Object)val3.result).name = "MoreSuitsCancelPurchase";
		val3.result.displayText = "Cancelled order.\n";
		newSuit.shopSelectionNode.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[2] { val2, val3 };
		TerminalKeyword val4 = ScriptableObject.CreateInstance<TerminalKeyword>();
		((Object)val4).name = newSuit.unlockableName + "Suit";
		val4.word = newSuit.unlockableName.ToLower() + " suit";
		val4.defaultVerb = buyKeyword;
		CompatibleNoun val5 = new CompatibleNoun();
		val5.noun = val4;
		val5.result = newSuit.shopSelectionNode;
		List<CompatibleNoun> list = buyKeyword.compatibleNouns.ToList();
		list.Add(val5);
		buyKeyword.compatibleNouns = list.ToArray();
		List<TerminalKeyword> list2 = val.terminalNodes.allKeywords.ToList();
		list2.Add(val4);
		list2.Add(val2.noun);
		list2.Add(val3.noun);
		val.terminalNodes.allKeywords = list2.ToArray();
		return newSuit;
	}

	public static bool TryParseVector4(string input, out Vector4 vector)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		vector = Vector4.zero;
		string[] array = input.Split(',');
		if (array.Length == 4 && float.TryParse(array[0], out var result) && float.TryParse(array[1], out var result2) && float.TryParse(array[2], out var result3) && float.TryParse(array[3], out var result4))
		{
			vector = new Vector4(result, result2, result3, result4);
			return true;
		}
		return false;
	}
}

plugins/NavMeshInCompany.dll

Decompiled 9 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[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-CSharp")]
[assembly: AssemblyCompany("Kittenji")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NavMeshInCompany")]
[assembly: AssemblyTitle("NavMeshInCompany")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Kittenji.NavMeshInCompany
{
	[BepInPlugin("dev.kittenji.NavMeshInCompany", "NavMeshInCompany", "1.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(DepositItemsDesk))]
		internal class DepositItemsDeskPatch
		{
			[HarmonyPatch("Start")]
			[HarmonyPostfix]
			internal static void StartPatch(DepositItemsDesk __instance)
			{
				try
				{
					GameObject[] array = GameObject.FindGameObjectsWithTag("OutsideAINode");
					for (int i = 0; i < array.Length; i++)
					{
						Object.Destroy((Object)(object)array[i]);
					}
					Debug.Log((object)"Instantiating Company Navigation!");
					Object.Instantiate<GameObject>(navPrefab, ((Component)__instance).transform.parent, true);
					RoundManager.Instance.outsideAINodes = GameObject.FindGameObjectsWithTag("OutsideAINode");
					RoundManager.Instance.insideAINodes = GameObject.FindGameObjectsWithTag("AINode");
				}
				catch (Exception ex)
				{
					Debug.LogException(ex);
				}
			}
		}

		public const string pluginGUID = "dev.kittenji.NavMeshInCompany";

		public const string pluginName = "NavMeshInCompany";

		public const string pluginVersion = "1.0.1";

		public static readonly Harmony harmony = new Harmony("dev.kittenji.NavMeshInCompany");

		public static readonly Assets assets = new Assets();

		public static GameObject navPrefab { get; internal set; }

		private void Awake()
		{
			navPrefab = assets.LoadByName<GameObject>("CompanyNavSurface.prefab", nameOnly: false);
			harmony.PatchAll();
		}
	}
	public static class ResourceUtils
	{
		public static Stream Get(string name)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
			if (manifestResourceNames.Length == 0)
			{
				throw new FileNotFoundException("Assembly does not contain any resource stream names.");
			}
			string text = manifestResourceNames.FirstOrDefault((string n) => n.EndsWith(name));
			if (string.IsNullOrEmpty(text))
			{
				throw new FileNotFoundException("Assembly does not contain a resource stream ending with '" + name + "'");
			}
			return executingAssembly.GetManifestResourceStream(text);
		}

		public static string GetString(string name)
		{
			using Stream stream = Get(name);
			using StreamReader streamReader = new StreamReader(stream);
			return streamReader.ReadToEnd();
		}
	}
	public class Assets
	{
		private readonly AssetBundle mainAssetBundle;

		private readonly string[] allAssetNames;

		public Assets(string name = ".bundle")
		{
			mainAssetBundle = AssetBundle.LoadFromStream(ResourceUtils.Get(name));
			allAssetNames = mainAssetBundle.GetAllAssetNames();
		}

		public T Load<T>(string name) where T : Object
		{
			if (name == null)
			{
				return default(T);
			}
			return mainAssetBundle.LoadAsset<T>(name);
		}

		public T LoadByName<T>(string name, bool nameOnly = false) where T : Object
		{
			string name2 = allAssetNames.FirstOrDefault((string x) => (nameOnly ? Path.GetFileNameWithoutExtension(x) : Path.GetFileName(x)).Equals(name, StringComparison.OrdinalIgnoreCase));
			return Load<T>(name2);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "NavMeshInCompany";

		public const string PLUGIN_NAME = "NavMeshInCompany";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

plugins/NicholaScott.BepInEx.RuntimeNetcodeRPCValidator.dll

Decompiled 9 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;

[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("Unity.Netcode.Runtime")]
[assembly: AssemblyCompany("NicholaScott.BepInEx.RuntimeNetcodeRPCValidator")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.5.0")]
[assembly: AssemblyInformationalVersion("0.2.5+6e2f89b3631ae55d2f51a00ccfd3f20fec9d2372")]
[assembly: AssemblyProduct("RuntimeNetcodeRPCValidator")]
[assembly: AssemblyTitle("NicholaScott.BepInEx.RuntimeNetcodeRPCValidator")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace RuntimeNetcodeRPCValidator
{
	public class AlreadyRegisteredException : Exception
	{
		public AlreadyRegisteredException(string PluginGUID)
			: base("Can't register plugin " + PluginGUID + " until the other instance of NetcodeValidator is Disposed of!")
		{
		}
	}
	public class InvalidPluginGuidException : Exception
	{
		public InvalidPluginGuidException(string pluginGUID)
			: base("Can't patch plugin " + pluginGUID + " because it doesn't exist!")
		{
		}
	}
	public class NotNetworkBehaviourException : Exception
	{
		public NotNetworkBehaviourException(Type type)
			: base("Netcode Runtime RPC Validator tried to NetcodeValidator.Patch type " + type.Name + " that doesn't inherit from NetworkBehaviour!")
		{
		}
	}
	public class MustCallFromDeclaredTypeException : Exception
	{
		public MustCallFromDeclaredTypeException()
			: base("Netcode Runtime RPC Validator tried to run NetcodeValidator.PatchAll from a delegate! You must call PatchAll from a declared type.")
		{
		}
	}
	public static class FastBufferExtensions
	{
		private const BindingFlags BindingAll = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		private static void WriteSystemSerializable(this FastBufferWriter fastBufferWriter, object serializable)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream memoryStream = new MemoryStream();
			binaryFormatter.Serialize(memoryStream, serializable);
			byte[] array = memoryStream.ToArray();
			int num = array.Length;
			((FastBufferWriter)(ref fastBufferWriter)).WriteValueSafe<int>(ref num, default(ForPrimitives));
			((FastBufferWriter)(ref fastBufferWriter)).WriteBytes(array, -1, 0);
		}

		private static void ReadSystemSerializable(this FastBufferReader fastBufferReader, out object serializable)
		{
			//IL_0006: 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)
			int num = default(int);
			((FastBufferReader)(ref fastBufferReader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
			byte[] buffer = new byte[num];
			((FastBufferReader)(ref fastBufferReader)).ReadBytes(ref buffer, num, 0);
			using MemoryStream memoryStream = new MemoryStream(buffer);
			memoryStream.Seek(0L, SeekOrigin.Begin);
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			serializable = binaryFormatter.Deserialize(memoryStream);
		}

		private static void WriteNetcodeSerializable(this FastBufferWriter fastBufferWriter, object networkSerializable)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(1024, (Allocator)2, -1);
			try
			{
				BufferSerializer<BufferSerializerWriter> val2 = default(BufferSerializer<BufferSerializerWriter>);
				val2..ctor(new BufferSerializerWriter(val));
				object obj = ((networkSerializable is INetworkSerializable) ? networkSerializable : null);
				if (obj != null)
				{
					((INetworkSerializable)obj).NetworkSerialize<BufferSerializerWriter>(val2);
				}
				byte[] array = ((FastBufferWriter)(ref val)).ToArray();
				int num = array.Length;
				((FastBufferWriter)(ref fastBufferWriter)).WriteValueSafe<int>(ref num, default(ForPrimitives));
				((FastBufferWriter)(ref fastBufferWriter)).WriteBytes(array, -1, 0);
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		private static void ReadNetcodeSerializable(this FastBufferReader fastBufferReader, Type type, out object serializable)
		{
			//IL_0006: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			int num = default(int);
			((FastBufferReader)(ref fastBufferReader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
			byte[] array = new byte[num];
			((FastBufferReader)(ref fastBufferReader)).ReadBytes(ref array, num, 0);
			FastBufferReader val = default(FastBufferReader);
			((FastBufferReader)(ref val))..ctor(array, (Allocator)2, -1, 0);
			try
			{
				BufferSerializer<BufferSerializerReader> val2 = default(BufferSerializer<BufferSerializerReader>);
				val2..ctor(new BufferSerializerReader(val));
				serializable = Activator.CreateInstance(type);
				object obj = serializable;
				object obj2 = ((obj is INetworkSerializable) ? obj : null);
				if (obj2 != null)
				{
					((INetworkSerializable)obj2).NetworkSerialize<BufferSerializerReader>(val2);
				}
			}
			finally
			{
				((IDisposable)(FastBufferReader)(ref val)).Dispose();
			}
		}

		public static void WriteMethodInfoAndParameters(this FastBufferWriter fastBufferWriter, MethodBase methodInfo, object[] args)
		{
			//IL_001f: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			((FastBufferWriter)(ref fastBufferWriter)).WriteValueSafe(methodInfo.Name, false);
			ParameterInfo[] parameters = methodInfo.GetParameters();
			int num = parameters.Length;
			((FastBufferWriter)(ref fastBufferWriter)).WriteValueSafe<int>(ref num, default(ForPrimitives));
			for (int i = 0; i < parameters.Length; i++)
			{
				ParameterInfo parameterInfo = parameters[i];
				object obj = args[i];
				bool flag = obj == null || parameterInfo.ParameterType == typeof(ServerRpcParams) || parameterInfo.ParameterType == typeof(ClientRpcParams);
				((FastBufferWriter)(ref fastBufferWriter)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					continue;
				}
				if (parameterInfo.ParameterType.GetInterfaces().Contains(typeof(INetworkSerializable)))
				{
					fastBufferWriter.WriteNetcodeSerializable(obj);
					continue;
				}
				if (parameterInfo.ParameterType.IsSerializable)
				{
					fastBufferWriter.WriteSystemSerializable(obj);
					continue;
				}
				throw new SerializationException(TextHandler.ObjectNotSerializable(parameterInfo));
			}
		}

		public static MethodInfo ReadMethodInfoAndParameters(this FastBufferReader fastBufferReader, Type methodDeclaringType, ref object[] args)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_00af: 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)
			string name = default(string);
			((FastBufferReader)(ref fastBufferReader)).ReadValueSafe(ref name, false);
			int num = default(int);
			((FastBufferReader)(ref fastBufferReader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
			MethodInfo method = methodDeclaringType.GetMethod(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (num != method?.GetParameters().Length)
			{
				throw new Exception(TextHandler.InconsistentParameterCount(method, num));
			}
			bool flag = default(bool);
			for (int i = 0; i < num; i++)
			{
				((FastBufferReader)(ref fastBufferReader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					continue;
				}
				ParameterInfo parameterInfo = method.GetParameters()[i];
				object serializable;
				if (parameterInfo.ParameterType.GetInterfaces().Contains(typeof(INetworkSerializable)))
				{
					fastBufferReader.ReadNetcodeSerializable(parameterInfo.ParameterType, out serializable);
				}
				else
				{
					if (!parameterInfo.ParameterType.IsSerializable)
					{
						throw new SerializationException(TextHandler.ObjectNotSerializable(parameterInfo));
					}
					fastBufferReader.ReadSystemSerializable(out serializable);
				}
				args[i] = serializable;
			}
			return method;
		}
	}
	public sealed class NetcodeValidator : IDisposable
	{
		private static readonly List<string> AlreadyRegistered = new List<string>();

		internal const string TypeCustomMessageHandlerPrefix = "Net";

		private static List<(NetcodeValidator validator, Type custom, Type native)> BoundNetworkObjects { get; } = new List<(NetcodeValidator, Type, Type)>();


		private List<string> CustomMessageHandlers { get; }

		private Harmony Patcher { get; }

		public string PluginGuid { get; }

		internal static event Action<NetcodeValidator, Type> AddedNewBoundBehaviour;

		private event Action<string> AddedNewCustomMessageHandler;

		public NetcodeValidator(string pluginGuid)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			if (!Chainloader.PluginInfos.TryGetValue(pluginGuid, out var _))
			{
				throw new InvalidPluginGuidException(pluginGuid);
			}
			if (AlreadyRegistered.Contains(pluginGuid))
			{
				throw new AlreadyRegisteredException(pluginGuid);
			}
			AlreadyRegistered.Add(pluginGuid);
			PluginGuid = pluginGuid;
			CustomMessageHandlers = new List<string>();
			Patcher = new Harmony(pluginGuid + "NicholaScott.BepInEx.RuntimeNetcodeRPCValidator");
			Plugin.NetworkManagerInitialized += NetworkManagerInitialized;
			Plugin.NetworkManagerShutdown += NetworkManagerShutdown;
		}

		internal static void TryLoadRelatedComponentsInOrder(NetworkBehaviour __instance, MethodBase __originalMethod)
		{
			foreach (var item in from obj in BoundNetworkObjects
				where obj.native == __originalMethod.DeclaringType
				select obj into it
				orderby it.validator.PluginGuid
				select it)
			{
				Plugin.Logger.LogInfo((object)TextHandler.CustomComponentAddedToExistingObject(item, __originalMethod));
				Component obj2 = ((Component)__instance).gameObject.AddComponent(item.custom);
				((NetworkBehaviour)(object)((obj2 is NetworkBehaviour) ? obj2 : null)).SyncWithNetworkObject();
			}
		}

		private bool Patch(MethodInfo rpcMethod, out bool isServerRpc, out bool isClientRpc)
		{
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Expected O, but got Unknown
			isServerRpc = ((MemberInfo)rpcMethod).GetCustomAttributes<ServerRpcAttribute>().Any();
			isClientRpc = ((MemberInfo)rpcMethod).GetCustomAttributes<ClientRpcAttribute>().Any();
			bool flag = rpcMethod.Name.EndsWith("ServerRpc");
			bool flag2 = rpcMethod.Name.EndsWith("ClientRpc");
			if (!isClientRpc && !isServerRpc && !flag2 && !flag)
			{
				return false;
			}
			if ((!isServerRpc && flag) || (!isClientRpc && flag2))
			{
				Plugin.Logger.LogError((object)TextHandler.MethodLacksRpcAttribute(rpcMethod));
				return false;
			}
			if ((isServerRpc && !flag) || (isClientRpc && !flag2))
			{
				Plugin.Logger.LogError((object)TextHandler.MethodLacksSuffix(rpcMethod));
				return false;
			}
			Patcher.Patch((MethodBase)rpcMethod, new HarmonyMethod(typeof(NetworkBehaviourExtensions), "MethodPatch", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			return true;
		}

		public void BindToPreExistingObjectByBehaviour<TCustomBehaviour, TNativeBehaviour>() where TCustomBehaviour : NetworkBehaviour where TNativeBehaviour : NetworkBehaviour
		{
			if (Object.op_Implicit((Object)(object)NetworkManager.Singleton) && (NetworkManager.Singleton.IsListening || NetworkManager.Singleton.IsConnectedClient))
			{
				Plugin.Logger.LogError((object)TextHandler.PluginTriedToBindToPreExistingObjectTooLate(this, typeof(TCustomBehaviour), typeof(TNativeBehaviour)));
			}
			else
			{
				OnAddedNewBoundBehaviour(this, typeof(TCustomBehaviour), typeof(TNativeBehaviour));
			}
		}

		public void Patch(Type netBehaviourTyped)
		{
			if (netBehaviourTyped.BaseType != typeof(NetworkBehaviour))
			{
				throw new NotNetworkBehaviourException(netBehaviourTyped);
			}
			OnAddedNewCustomMessageHandler("Net." + netBehaviourTyped.Name);
			int num = 0;
			int num2 = 0;
			MethodInfo[] methods = netBehaviourTyped.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (MethodInfo rpcMethod in methods)
			{
				if (Patch(rpcMethod, out var isServerRpc, out var isClientRpc))
				{
					num += (isServerRpc ? 1 : 0);
					num2 += (isClientRpc ? 1 : 0);
				}
			}
			Plugin.Logger.LogInfo((object)TextHandler.SuccessfullyPatchedType(netBehaviourTyped, num, num2));
		}

		public void Patch(Assembly assembly)
		{
			Type[] types = assembly.GetTypes();
			foreach (Type type in types)
			{
				if (type.BaseType == typeof(NetworkBehaviour))
				{
					Patch(type);
				}
			}
		}

		public void PatchAll()
		{
			Assembly assembly = new StackTrace().GetFrame(1).GetMethod().ReflectedType?.Assembly;
			if (assembly == null)
			{
				throw new MustCallFromDeclaredTypeException();
			}
			Patch(assembly);
		}

		public void UnpatchSelf()
		{
			Plugin.Logger.LogInfo((object)TextHandler.PluginUnpatchedAllRPCs(this));
			Patcher.UnpatchSelf();
		}

		private static void RegisterMessageHandlerWithNetworkManager(string handler)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler(handler, new HandleNamedMessageDelegate(NetworkBehaviourExtensions.ReceiveNetworkMessage));
		}

		private void NetworkManagerInitialized()
		{
			AddedNewCustomMessageHandler += RegisterMessageHandlerWithNetworkManager;
			foreach (string customMessageHandler in CustomMessageHandlers)
			{
				RegisterMessageHandlerWithNetworkManager(customMessageHandler);
			}
		}

		private void NetworkManagerShutdown()
		{
			AddedNewCustomMessageHandler -= RegisterMessageHandlerWithNetworkManager;
			foreach (string customMessageHandler in CustomMessageHandlers)
			{
				NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler(customMessageHandler);
			}
		}

		public void Dispose()
		{
			Plugin.NetworkManagerInitialized -= NetworkManagerInitialized;
			Plugin.NetworkManagerShutdown -= NetworkManagerShutdown;
			AlreadyRegistered.Remove(PluginGuid);
			if (Object.op_Implicit((Object)(object)NetworkManager.Singleton))
			{
				NetworkManagerShutdown();
			}
			if (Patcher.GetPatchedMethods().Any())
			{
				UnpatchSelf();
			}
		}

		private void OnAddedNewCustomMessageHandler(string obj)
		{
			CustomMessageHandlers.Add(obj);
			this.AddedNewCustomMessageHandler?.Invoke(obj);
		}

		private static void OnAddedNewBoundBehaviour(NetcodeValidator validator, Type custom, Type native)
		{
			BoundNetworkObjects.Add((validator, custom, native));
			NetcodeValidator.AddedNewBoundBehaviour?.Invoke(validator, native);
		}
	}
	public static class NetworkBehaviourExtensions
	{
		public enum RpcState
		{
			FromUser,
			FromNetworking
		}

		private static RpcState RpcSource;

		public static ClientRpcParams CreateSendToFromReceived(this ServerRpcParams senderId)
		{
			//IL_0002: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			ClientRpcParams result = default(ClientRpcParams);
			result.Send = new ClientRpcSendParams
			{
				TargetClientIds = new ulong[1] { senderId.Receive.SenderClientId }
			};
			return result;
		}

		public static void SyncWithNetworkObject(this NetworkBehaviour networkBehaviour)
		{
			if (!networkBehaviour.NetworkObject.ChildNetworkBehaviours.Contains(networkBehaviour))
			{
				networkBehaviour.NetworkObject.ChildNetworkBehaviours.Add(networkBehaviour);
			}
			networkBehaviour.UpdateNetworkProperties();
		}

		private static bool ValidateRPCMethod(NetworkBehaviour networkBehaviour, MethodBase method, RpcState state, out RpcAttribute rpcAttribute)
		{
			bool flag = ((MemberInfo)method).GetCustomAttributes<ServerRpcAttribute>().Any();
			bool flag2 = ((MemberInfo)method).GetCustomAttributes<ClientRpcAttribute>().Any();
			bool num = flag && ((MemberInfo)method).GetCustomAttribute<ServerRpcAttribute>().RequireOwnership;
			rpcAttribute = (RpcAttribute)(flag ? ((object)((MemberInfo)method).GetCustomAttribute<ServerRpcAttribute>()) : ((object)((MemberInfo)method).GetCustomAttribute<ClientRpcAttribute>()));
			if (num && networkBehaviour.OwnerClientId != NetworkManager.Singleton.LocalClientId)
			{
				Plugin.Logger.LogError((object)TextHandler.NotOwnerOfNetworkObject((state == RpcState.FromUser) ? "We" : "Client", method, networkBehaviour.NetworkObject));
				return false;
			}
			if (state == RpcState.FromUser && flag2 && !NetworkManager.Singleton.IsServer && !NetworkManager.Singleton.IsHost)
			{
				Plugin.Logger.LogError((object)TextHandler.CantRunClientRpcFromClient(method));
				return false;
			}
			if (state == RpcState.FromUser && !flag && !flag2)
			{
				Plugin.Logger.LogError((object)TextHandler.MethodPatchedButLacksAttributes(method));
				return false;
			}
			if (state == RpcState.FromNetworking && !flag && !flag2)
			{
				Plugin.Logger.LogError((object)TextHandler.MethodPatchedAndNetworkCalledButLacksAttributes(method));
				return false;
			}
			if (state == RpcState.FromNetworking && flag && !networkBehaviour.IsServer && !networkBehaviour.IsHost)
			{
				Plugin.Logger.LogError((object)TextHandler.CantRunServerRpcAsClient(method));
				return false;
			}
			return true;
		}

		private static bool MethodPatchInternal(NetworkBehaviour networkBehaviour, MethodBase method, object[] args)
		{
			//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_0098: 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_00a5: 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)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)NetworkManager.Singleton) || (!NetworkManager.Singleton.IsListening && !NetworkManager.Singleton.IsConnectedClient))
			{
				Plugin.Logger.LogError((object)TextHandler.NoNetworkManagerPresentToSendRpc(networkBehaviour));
				return false;
			}
			RpcState rpcSource = RpcSource;
			RpcSource = RpcState.FromUser;
			if (rpcSource == RpcState.FromNetworking)
			{
				return true;
			}
			if (!ValidateRPCMethod(networkBehaviour, method, rpcSource, out var rpcAttribute))
			{
				return false;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor((method.GetParameters().Length + 1) * 128, (Allocator)2, -1);
			ulong networkObjectId = networkBehaviour.NetworkObjectId;
			((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives));
			ushort networkBehaviourId = networkBehaviour.NetworkBehaviourId;
			((FastBufferWriter)(ref val)).WriteValueSafe<ushort>(ref networkBehaviourId, default(ForPrimitives));
			val.WriteMethodInfoAndParameters(method, args);
			string text = new StringBuilder("Net").Append(".").Append(method.DeclaringType.Name).ToString();
			NetworkDelivery val2 = (NetworkDelivery)(((int)rpcAttribute.Delivery == 0) ? 2 : 0);
			if (rpcAttribute is ServerRpcAttribute)
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(text, 0uL, val, val2);
			}
			else
			{
				ParameterInfo[] parameters = method.GetParameters();
				if (parameters.Length != 0 && parameters[^1].ParameterType == typeof(ClientRpcParams))
				{
					NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(text, ((ClientRpcParams)args[^1]).Send.TargetClientIds, val, val2);
				}
				else
				{
					NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll(text, val, val2);
				}
			}
			return false;
		}

		internal static void ReceiveNetworkMessage(ulong sender, FastBufferReader reader)
		{
			//IL_0006: 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_0019: 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_0100: 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_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			ulong key = default(ulong);
			((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref key, default(ForPrimitives));
			ushort num = default(ushort);
			((FastBufferReader)(ref reader)).ReadValueSafe<ushort>(ref num, default(ForPrimitives));
			int position = ((FastBufferReader)(ref reader)).Position;
			string text = default(string);
			((FastBufferReader)(ref reader)).ReadValueSafe(ref text, false);
			((FastBufferReader)(ref reader)).Seek(position);
			if (!NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(key, out var value))
			{
				Plugin.Logger.LogError((object)TextHandler.RpcCalledBeforeObjectSpawned());
				return;
			}
			NetworkBehaviour networkBehaviourAtOrderIndex = value.GetNetworkBehaviourAtOrderIndex(num);
			MethodInfo method = ((object)networkBehaviourAtOrderIndex).GetType().GetMethod(text, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			RpcAttribute rpcAttribute;
			if (method == null)
			{
				Plugin.Logger.LogError((object)TextHandler.NetworkCalledNonExistentMethod(networkBehaviourAtOrderIndex, text));
			}
			else if (ValidateRPCMethod(networkBehaviourAtOrderIndex, method, RpcState.FromNetworking, out rpcAttribute))
			{
				RpcSource = RpcState.FromNetworking;
				ParameterInfo[] parameters = method.GetParameters();
				bool num2 = rpcAttribute is ServerRpcAttribute && parameters.Length != 0 && parameters[^1].ParameterType == typeof(ServerRpcParams);
				object[] args = null;
				if (parameters.Length != 0)
				{
					args = new object[parameters.Length];
				}
				reader.ReadMethodInfoAndParameters(method.DeclaringType, ref args);
				if (num2)
				{
					args[^1] = (object)new ServerRpcParams
					{
						Receive = new ServerRpcReceiveParams
						{
							SenderClientId = sender
						}
					};
				}
				method.Invoke(networkBehaviourAtOrderIndex, args);
			}
		}

		internal static bool MethodPatch(NetworkBehaviour __instance, MethodBase __originalMethod, object[] __args)
		{
			return MethodPatchInternal(__instance, __originalMethod, __args);
		}
	}
	[BepInPlugin("NicholaScott.BepInEx.RuntimeNetcodeRPCValidator", "RuntimeNetcodeRPCValidator", "0.2.5")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("NicholaScott.BepInEx.RuntimeNetcodeRPCValidator");

		private List<Type> AlreadyPatchedNativeBehaviours { get; } = new List<Type>();


		internal static ManualLogSource Logger { get; private set; }

		public static event Action NetworkManagerInitialized;

		public static event Action NetworkManagerShutdown;

		private void Awake()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			NetcodeValidator.AddedNewBoundBehaviour += NetcodeValidatorOnAddedNewBoundBehaviour;
			_harmony.Patch((MethodBase)AccessTools.Method(typeof(NetworkManager), "Initialize", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "OnNetworkManagerInitialized", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			_harmony.Patch((MethodBase)AccessTools.Method(typeof(NetworkManager), "Shutdown", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "OnNetworkManagerShutdown", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		private void NetcodeValidatorOnAddedNewBoundBehaviour(NetcodeValidator validator, Type netBehaviour)
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			if (!AlreadyPatchedNativeBehaviours.Contains(netBehaviour))
			{
				AlreadyPatchedNativeBehaviours.Add(netBehaviour);
				MethodBase methodBase = AccessTools.Method(netBehaviour, "Awake", (Type[])null, (Type[])null);
				if (methodBase == null)
				{
					methodBase = AccessTools.Method(netBehaviour, "Start", (Type[])null, (Type[])null);
				}
				if (methodBase == null)
				{
					methodBase = AccessTools.Constructor(netBehaviour, (Type[])null, false);
				}
				Logger.LogInfo((object)TextHandler.RegisteredPatchForType(validator, netBehaviour, methodBase));
				HarmonyMethod val = new HarmonyMethod(typeof(NetcodeValidator), "TryLoadRelatedComponentsInOrder", (Type[])null);
				_harmony.Patch(methodBase, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
		}

		protected static void OnNetworkManagerInitialized()
		{
			Plugin.NetworkManagerInitialized?.Invoke();
		}

		protected static void OnNetworkManagerShutdown()
		{
			Plugin.NetworkManagerShutdown?.Invoke();
		}
	}
	internal static class TextHandler
	{
		private const string NoNetworkManagerPresentToSendRpcConst = "NetworkBehaviour {0} tried to send a RPC but the NetworkManager is non-existant!";

		private const string MethodLacksAttributeConst = "Can't patch method {0}.{1} because it lacks a [{2}] attribute.";

		private const string MethodLacksSuffixConst = "Can't patch method {0}.{1} because it's name doesn't end with '{2}'!";

		private const string SuccessfullyPatchedTypeConst = "Patched {0} ServerRPC{1} & {2} ClientRPC{3} on NetworkBehaviour {4}.";

		private const string NotOwnerOfNetworkObjectConst = "{0} tried to run ServerRPC {1} but not the owner of NetworkObject {2}";

		private const string CantRunClientRpcFromClientConst = "Tried to run ClientRpc {0} but we're not a host! You should only call ClientRpc(s) from inside a ServerRpc OR if you've checked you're on the server with IsHost!";

		private const string CantRunServerRpcAsClientConst = "Received message to run ServerRPC {0}.{1} but we're a client!";

		private const string MethodPatchedButLacksAttributesConst = "Rpc Method {0} has been patched to attempt networking but lacks any RpcAttributes! This should never happen!";

		private const string MethodPatchedAndNetworkCalledButLacksAttributesConst = "Rpc Method {0} has been patched && even received a network call to execute but lacks any RpcAttributes! This should never happen! Something is VERY fucky!!!";

		private const string RpcCalledBeforeObjectSpawnedConst = "An RPC called on a NetworkObject that is not in the spawned objects list. Please make sure the NetworkObject is spawned before calling RPCs.";

		private const string NetworkCalledNonExistentMethodConst = "NetworkBehaviour {0} received RPC {1} but that method doesn't exist on {2}!";

		private const string ObjectNotSerializableConst = "[Network] Parameter ({0} {1}) is not marked [Serializable] nor does it implement INetworkSerializable!";

		private const string InconsistentParameterCountConst = "[Network] NetworkBehaviour received a RPC {0} but the number of parameters sent {1} != MethodInfo param count {2}";

		private const string PluginTriedToBindToPreExistingObjectTooLateConst = "Plugin '{0}' tried to bind {1} to {2} but it's too late! Make sure you bind to any pre-existing NetworkObjects before NetworkManager.IsListening || IsConnectedClient.";

		private const string RegisteredPatchForTypeConst = "Successfully registered first patch for type {0}.{1} | Triggered by {2}";

		private const string CustomComponentAddedToExistingObjectConst = "Successfully added {0} to {1} via {2}. Triggered by plugin {3}";

		private const string PluginUnpatchedAllRPCsConst = "Plugin {0} has unpatched all RPCs!";

		internal static string NoNetworkManagerPresentToSendRpc(NetworkBehaviour networkBehaviour)
		{
			return $"NetworkBehaviour {networkBehaviour.NetworkBehaviourId} tried to send a RPC but the NetworkManager is non-existant!";
		}

		internal static string MethodLacksRpcAttribute(MethodInfo method)
		{
			return string.Format("Can't patch method {0}.{1} because it lacks a [{2}] attribute.", method.DeclaringType?.Name, method.Name, method.Name.EndsWith("ServerRpc") ? "ServerRpc" : "ClientRpc");
		}

		internal static string MethodLacksSuffix(MethodBase method)
		{
			return string.Format("Can't patch method {0}.{1} because it's name doesn't end with '{2}'!", method.DeclaringType?.Name, method.Name, (((MemberInfo)method).GetCustomAttribute<ServerRpcAttribute>() != null) ? "ServerRpc" : "ClientRpc");
		}

		internal static string SuccessfullyPatchedType(Type networkType, int serverRpcCount, int clientRpcCount)
		{
			return string.Format("Patched {0} ServerRPC{1} & {2} ClientRPC{3} on NetworkBehaviour {4}.", serverRpcCount, (serverRpcCount == 1) ? "" : "s", clientRpcCount, (clientRpcCount == 1) ? "" : "s", networkType.Name);
		}

		internal static string NotOwnerOfNetworkObject(string whoIsNotOwner, MethodBase method, NetworkObject networkObject)
		{
			return $"{whoIsNotOwner} tried to run ServerRPC {method.Name} but not the owner of NetworkObject {networkObject.NetworkObjectId}";
		}

		internal static string CantRunClientRpcFromClient(MethodBase method)
		{
			return $"Tried to run ClientRpc {method.Name} but we're not a host! You should only call ClientRpc(s) from inside a ServerRpc OR if you've checked you're on the server with IsHost!";
		}

		internal static string CantRunServerRpcAsClient(MethodBase method)
		{
			return $"Received message to run ServerRPC {method.DeclaringType?.Name}.{method.Name} but we're a client!";
		}

		internal static string MethodPatchedButLacksAttributes(MethodBase method)
		{
			return $"Rpc Method {method.Name} has been patched to attempt networking but lacks any RpcAttributes! This should never happen!";
		}

		internal static string MethodPatchedAndNetworkCalledButLacksAttributes(MethodBase method)
		{
			return $"Rpc Method {method.Name} has been patched && even received a network call to execute but lacks any RpcAttributes! This should never happen! Something is VERY fucky!!!";
		}

		internal static string RpcCalledBeforeObjectSpawned()
		{
			return "An RPC called on a NetworkObject that is not in the spawned objects list. Please make sure the NetworkObject is spawned before calling RPCs.";
		}

		internal static string NetworkCalledNonExistentMethod(NetworkBehaviour networkBehaviour, string rpcName)
		{
			return $"NetworkBehaviour {networkBehaviour.NetworkBehaviourId} received RPC {rpcName} but that method doesn't exist on {((object)networkBehaviour).GetType().Name}!";
		}

		internal static string ObjectNotSerializable(ParameterInfo paramInfo)
		{
			return $"[Network] Parameter ({paramInfo.ParameterType.Name} {paramInfo.Name}) is not marked [Serializable] nor does it implement INetworkSerializable!";
		}

		internal static string InconsistentParameterCount(MethodBase method, int paramsSent)
		{
			return $"[Network] NetworkBehaviour received a RPC {method.Name} but the number of parameters sent {paramsSent} != MethodInfo param count {method.GetParameters().Length}";
		}

		internal static string PluginTriedToBindToPreExistingObjectTooLate(NetcodeValidator netcodeValidator, Type from, Type to)
		{
			return $"Plugin '{netcodeValidator.PluginGuid}' tried to bind {from.Name} to {to.Name} but it's too late! Make sure you bind to any pre-existing NetworkObjects before NetworkManager.IsListening || IsConnectedClient.";
		}

		internal static string RegisteredPatchForType(NetcodeValidator validator, Type netBehaviour, MethodBase method)
		{
			return $"Successfully registered first patch for type {netBehaviour.Name}.{method.Name} | Triggered by {validator.PluginGuid}";
		}

		internal static string CustomComponentAddedToExistingObject((NetcodeValidator validator, Type custom, Type native) it, MethodBase methodBase)
		{
			return $"Successfully added {it.custom.Name} to {it.native.Name} via {methodBase.Name}. Triggered by plugin {it.validator.PluginGuid}";
		}

		internal static string PluginUnpatchedAllRPCs(NetcodeValidator netcodeValidator)
		{
			return $"Plugin {netcodeValidator.PluginGuid} has unpatched all RPCs!";
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "NicholaScott.BepInEx.RuntimeNetcodeRPCValidator";

		public const string PLUGIN_NAME = "RuntimeNetcodeRPCValidator";

		public const string PLUGIN_VERSION = "0.2.5";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

plugins/Nyxchrono-DoorBreach.dll

Decompiled 9 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Nyxchrono-DoorBreach")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("DoorBreach is a mod for Lethal Company that allows players to hit a locked door many times with a shovel to open it.")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+423a864e5a383142af069a7278a8352f574c8f68")]
[assembly: AssemblyProduct("DoorBreach")]
[assembly: AssemblyTitle("Nyxchrono-DoorBreach")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Nyxchrono.DoorBreach
{
	public class Components
	{
		public class DoorHitInfo : MonoBehaviour
		{
			public int NumOfHits;

			public DoorLock Lock;

			public void Start()
			{
				NumOfHits = 0;
				Lock = ((Component)this).GetComponent<DoorLock>();
				if (Lock != null && Lock.isLocked)
				{
					NumOfHits = new Random().Next(Plugin._configGeneralMinHits.Value, Plugin._configGeneralMaxHits.Value);
					Plugin.LogSource.LogDebug((object)$"Door ({((Object)((Component)Lock).gameObject).GetInstanceID()}) will take {NumOfHits} hits");
				}
			}

			public void OnHit()
			{
				if (--NumOfHits <= 0)
				{
					OpenDoor(Lock);
				}
				else
				{
					Plugin.LogSource.LogDebug((object)string.Format("Door ({0}) has {1} remaining: {2}", ((Object)((Component)Lock).gameObject).GetInstanceID(), "NumOfHits", NumOfHits));
				}
			}

			public void OpenDoor(DoorLock door)
			{
				if (door.isLocked)
				{
					Plugin.LogSource.LogDebug((object)$"Unlocking door ({((Object)((Component)door).gameObject).GetInstanceID()})");
					door.UnlockDoorServerRpc();
				}
				if (!Utils.GetInstanceField<bool>(typeof(DoorLock), door, "isDoorOpened"))
				{
					Plugin.LogSource.LogDebug((object)$"Opening door ({((Object)((Component)door).gameObject).GetInstanceID()})");
					((Component)door).gameObject.GetComponent<AnimatedObjectTrigger>().TriggerAnimationNonPlayer(true, true, false);
					door.OpenDoorAsEnemyServerRpc();
				}
			}
		}
	}
	public class Hooks
	{
		internal static bool IsStartOfRoundLockingDoors;

		internal static void RoundManager_SetLockedDoors(orig_SetLockedDoors orig, RoundManager self, Vector3 mainEntrancePosition)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			IsStartOfRoundLockingDoors = true;
			orig.Invoke(self, mainEntrancePosition);
			IsStartOfRoundLockingDoors = false;
			int num = 0;
			DoorLock[] array = Object.FindObjectsByType<DoorLock>((FindObjectsSortMode)0);
			for (int i = 0; i < array.Length; i++)
			{
				((Component)array[i]).gameObject.AddComponent<Components.DoorHitInfo>();
				num++;
			}
			Plugin.LogSource.LogDebug((object)string.Format("Added {0} to {1} doors", "DoorHitInfo", num));
		}

		internal static void Shovel_HitShovel(orig_HitShovel orig, Shovel self, bool cancel)
		{
			//IL_001a: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, cancel);
			Transform transform = ((Component)((GrabbableObject)self).playerHeldBy.gameplayCamera).transform;
			RaycastHit[] array = Physics.SphereCastAll(transform.position + transform.right * -0.35f, 0.75f, transform.forward, 1f, 512, (QueryTriggerInteraction)2);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val = array[i];
				Components.DoorHitInfo component = ((Component)((RaycastHit)(ref val)).collider).gameObject.GetComponent<Components.DoorHitInfo>();
				if ((Object)(object)component != (Object)null)
				{
					component.OnHit();
					break;
				}
			}
		}

		internal static void DoorLock_LockDoor(orig_LockDoor orig, DoorLock self, float timeToLockPick = 30f)
		{
			orig.Invoke(self, timeToLockPick);
			if (!IsStartOfRoundLockingDoors)
			{
				Plugin.LogSource.LogDebug((object)"Locking door after RoundManager.SetLockedDoors");
				Components.DoorHitInfo component = ((Component)self).GetComponent<Components.DoorHitInfo>();
				if (component != null)
				{
					component.NumOfHits = new Random().Next(Plugin._configGeneralMinHits.Value, Plugin._configGeneralMaxHits.Value);
				}
			}
		}
	}
	[BepInPlugin("Nyxchrono-DoorBreach", "DoorBreach", "1.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_HitShovel <0>__Shovel_HitShovel;

			public static hook_SetLockedDoors <1>__RoundManager_SetLockedDoors;

			public static hook_LockDoor <2>__DoorLock_LockDoor;
		}

		internal static ConfigEntry<bool> _configGeneralEnabled;

		internal static ConfigEntry<int> _configGeneralMinHits;

		internal static ConfigEntry<int> _configGeneralMaxHits;

		internal static ManualLogSource LogSource { get; set; }

		private void LoadConfig()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0039: Expected O, but got Unknown
			//IL_004e: 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)
			//IL_0074: Expected O, but got Unknown
			//IL_0074: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			//IL_00af: Expected O, but got Unknown
			_configGeneralEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("General", "Enabled"), true, new ConfigDescription("Whether to enable the mod or not", (AcceptableValueBase)(object)new AcceptableValueList<bool>(new bool[2] { true, false }), Array.Empty<object>()));
			_configGeneralMinHits = ((BaseUnityPlugin)this).Config.Bind<int>(new ConfigDefinition("General", "MinHits"), 10, new ConfigDescription("The minimum number of hits required to open a locked door", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 999), Array.Empty<object>()));
			_configGeneralMaxHits = ((BaseUnityPlugin)this).Config.Bind<int>(new ConfigDefinition("General", "MaxHits"), 20, new ConfigDescription("The maximum number of hits required to open a locked door\nMAKE SURE THIS VALUE IS GREATER THAN MinHits!!!", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 999), Array.Empty<object>()));
			if (_configGeneralMinHits.Value > _configGeneralMaxHits.Value)
			{
				LogSource.LogWarning((object)"_configGeneralMaxHits was less than _configGeneralMinHits!");
				LogSource.LogWarning((object)"Setting _configGeneralMaxHits to (_configGeneralMinHits * 2)");
				_configGeneralMaxHits.Value = _configGeneralMinHits.Value * 2;
			}
		}

		private void Awake()
		{
			LogSource = ((BaseUnityPlugin)this).Logger;
			LoadConfig();
			LogSource.LogInfo((object)"Nyxchrono-DoorBreach v1.1.0 is initializing");
			if (!_configGeneralEnabled.Value)
			{
				LogSource.LogInfo((object)"Nyxchrono-DoorBreach v1.1.0 is disabled due to config setting");
				return;
			}
			ApplyHooks();
			LogSource.LogInfo((object)"Nyxchrono-DoorBreach v1.1.0 has initialized");
		}

		private void OnDestroy()
		{
			LogSource.LogInfo((object)"Nyxchrono-DoorBreach v1.1.0 was unloaded!");
		}

		public void ApplyHooks()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			object obj = <>O.<0>__Shovel_HitShovel;
			if (obj == null)
			{
				hook_HitShovel val = Hooks.Shovel_HitShovel;
				<>O.<0>__Shovel_HitShovel = val;
				obj = (object)val;
			}
			Shovel.HitShovel += (hook_HitShovel)obj;
			object obj2 = <>O.<1>__RoundManager_SetLockedDoors;
			if (obj2 == null)
			{
				hook_SetLockedDoors val2 = Hooks.RoundManager_SetLockedDoors;
				<>O.<1>__RoundManager_SetLockedDoors = val2;
				obj2 = (object)val2;
			}
			RoundManager.SetLockedDoors += (hook_SetLockedDoors)obj2;
			object obj3 = <>O.<2>__DoorLock_LockDoor;
			if (obj3 == null)
			{
				hook_LockDoor val3 = Hooks.DoorLock_LockDoor;
				<>O.<2>__DoorLock_LockDoor = val3;
				obj3 = (object)val3;
			}
			DoorLock.LockDoor += (hook_LockDoor)obj3;
		}
	}
	public class Utils
	{
		internal const BindingFlags BindFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

		internal static object GetInstanceField(Type type, object instance, string fieldName)
		{
			return type.GetField(fieldName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(instance);
		}

		internal static T GetInstanceField<T>(Type type, object instance, string fieldName)
		{
			return (T)(type.GetField(fieldName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(instance));
		}

		internal static FieldInfo GetInstanceFieldInfo(object instance, string fieldName)
		{
			return instance.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Nyxchrono-DoorBreach";

		public const string PLUGIN_NAME = "DoorBreach";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}

plugins/Peepers.dll

Decompiled 9 months ago
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;
using LCPeeper.Properties;
using Peepers.NetcodePatcher;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Audio;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("Peepers")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Adds a new non-lethal monster to the game with unique mechanics and interactions.")]
[assembly: AssemblyFileVersion("0.9.6.0")]
[assembly: AssemblyInformationalVersion("0.9.6")]
[assembly: AssemblyProduct("Peepers")]
[assembly: AssemblyTitle("Peepers")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.9.6.0")]
[module: UnverifiableCode]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace LCPeeper
{
	[BepInPlugin("x753.Peepers", "Peepers", "0.9.6")]
	public class Peeper : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(GameNetworkManager))]
		internal class GameNetworkManagerPatch
		{
			[HarmonyPatch("Start")]
			[HarmonyPostfix]
			private static void StartPatch()
			{
				((Component)GameNetworkManager.Instance).GetComponent<NetworkManager>().AddNetworkPrefab(PeeperPrefab);
			}
		}

		private const string modGUID = "x753.Peepers";

		private const string modName = "Peepers";

		private const string modVersion = "0.9.6";

		private readonly Harmony harmony = new Harmony("x753.Peepers");

		private static Peeper Instance;

		public static GameObject PeeperPrefab;

		public static EnemyType PeeperType;

		public static TerminalNode PeeperFile;

		public static int PeeperCreatureID = 0;

		public static List<PeeperAI> PeeperList = new List<PeeperAI>();

		public static List<string> ignoreEnemies = new List<string> { "Peeper", "Manticoil", "Docile Locust Bees", "Girl" };

		public static float PeeperSpawnChance;

		public static int PeeperMinGroupSize;

		public static int PeeperMaxGroupSize;

		public static float PeeperWeight;

		private void Awake()
		{
			AssetBundle val = AssetBundle.LoadFromMemory(Resources.peeper);
			PeeperPrefab = val.LoadAsset<GameObject>("Assets/PeeperPrefab.prefab");
			PeeperType = val.LoadAsset<EnemyType>("Assets/PeeperType.asset");
			PeeperFile = val.LoadAsset<TerminalNode>("Assets/PeeperFile.asset");
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Peepers is loaded!");
			PeeperSpawnChance = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Rate", "Hourly Spawn Chance (%)", 10f, "Chance of a group of peepers spawning each hour").Value;
			PeeperMinGroupSize = ((BaseUnityPlugin)this).Config.Bind<int>("Spawn Rate", "Minimum Peeper Group Size", 2, "The minimum number of peepers in a single group").Value;
			PeeperMaxGroupSize = ((BaseUnityPlugin)this).Config.Bind<int>("Spawn Rate", "Maximum Peeper Group Size", 4, "The maximum number of peepers in a single group").Value;
			PeeperWeight = ((BaseUnityPlugin)this).Config.Bind<float>("Peeper Settings", "Peeper Weight (lb)", 10f, "The weight of a single peeper in pounds.").Value / 105f;
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	internal class TerminalPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch(Terminal __instance)
		{
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			Terminal val = Object.FindObjectOfType<Terminal>();
			if (!Object.op_Implicit((Object)(object)val.enemyFiles.Find((TerminalNode node) => node.creatureName == "Peepers")))
			{
				Peeper.PeeperCreatureID = val.enemyFiles.Count;
				Peeper.PeeperFile.creatureFileID = Peeper.PeeperCreatureID;
				val.enemyFiles.Add(Peeper.PeeperFile);
				TerminalKeyword val2 = val.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "info");
				TerminalKeyword val3 = ScriptableObject.CreateInstance<TerminalKeyword>();
				val3.word = "peepers";
				val3.isVerb = false;
				val3.defaultVerb = val2;
				List<CompatibleNoun> list = val2.compatibleNouns.ToList();
				list.Add(new CompatibleNoun
				{
					noun = val3,
					result = Peeper.PeeperFile
				});
				val2.compatibleNouns = list.ToArray();
				List<TerminalKeyword> list2 = val.terminalNodes.allKeywords.ToList();
				list2.Add(val3);
				val.terminalNodes.allKeywords = list2.ToArray();
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatch
	{
		[HarmonyPatch("AdvanceHourAndSpawnNewBatchOfEnemies")]
		[HarmonyPrefix]
		private static void AdvanceHourAndSpawnNewBatchOfEnemiesPatch(RoundManager __instance)
		{
			//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_0041: 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)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//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_00a0: 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_00ae: 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)
			float num = Random.Range(0f, 100f);
			if (num > Peeper.PeeperSpawnChance)
			{
				return;
			}
			GameObject[] array = GameObject.FindGameObjectsWithTag("OutsideAINode");
			Vector3 position = array[__instance.AnomalyRandom.Next(0, array.Length)].transform.position;
			position = __instance.GetRandomNavMeshPositionInRadius(position, 4f, default(NavMeshHit));
			int num2 = 0;
			bool flag = false;
			for (int i = 0; i < array.Length - 1; i++)
			{
				for (int j = 0; j < __instance.spawnDenialPoints.Length; j++)
				{
					flag = true;
					if (Vector3.Distance(position, __instance.spawnDenialPoints[j].transform.position) < 8f)
					{
						num2 = (num2 + 1) % array.Length;
						position = array[num2].transform.position;
						position = __instance.GetRandomNavMeshPositionInRadius(position, 4f, default(NavMeshHit));
						flag = false;
						break;
					}
				}
				if (flag)
				{
					break;
				}
			}
			int num3 = Random.Range(Peeper.PeeperMinGroupSize, Peeper.PeeperMaxGroupSize);
			for (int k = 0; k <= num3; k++)
			{
				RoundManager.Instance.SpawnEnemyGameObject(position, 0f, -1, Peeper.PeeperType);
				EnemyType peeperType = Peeper.PeeperType;
				peeperType.numberSpawned++;
				RoundManager instance = RoundManager.Instance;
				instance.currentDaytimeEnemyPower++;
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void AwakePatch(ref StartOfRound __instance)
		{
			//IL_0044: 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)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			SelectableLevel[] levels = __instance.levels;
			foreach (SelectableLevel val in levels)
			{
				if (!val.DaytimeEnemies.Any((SpawnableEnemyWithRarity e) => (Object)(object)e.enemyType == (Object)(object)Peeper.PeeperType))
				{
					int rarity = 0;
					val.DaytimeEnemies.Add(new SpawnableEnemyWithRarity
					{
						enemyType = Peeper.PeeperType,
						rarity = rarity
					});
					break;
				}
			}
		}

		[HarmonyPatch("EndOfGame")]
		[HarmonyPrefix]
		private static void EndOfGamePatch(StartOfRound __instance, int bodiesInsured = 0, int connectedPlayersOnServer = 0, int scrapCollected = 0)
		{
			foreach (PeeperAI peeper in Peeper.PeeperList)
			{
				if (peeper.isAttached && (Object)(object)peeper.attachedPlayer != (Object)null && !peeper.attachedPlayer.isPlayerDead)
				{
					peeper.IsWeighted = false;
				}
			}
			Peeper.PeeperList = new List<PeeperAI>();
			PeeperAI.UsedAttachTargets = new List<Transform>();
		}
	}
	[HarmonyPatch(typeof(StunGrenadeItem))]
	internal class StunGrenadeItemPatch
	{
		[HarmonyPatch("StunExplosion")]
		[HarmonyPostfix]
		private static void StunExplosion(StunGrenadeItem __instance, Vector3 explosionPosition, bool affectAudio, float flashSeverityMultiplier, float enemyStunTime, float flashSeverityDistanceRolloff = 1f, bool isHeldItem = false, PlayerControllerB playerHeldBy = null, PlayerControllerB playerThrownBy = null, float addToFlashSeverity = 0f)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if (!(Vector3.Distance(((Component)localPlayerController).transform.position, explosionPosition) < 16f) || (Vector3.Distance(((Component)localPlayerController).transform.position, explosionPosition) > 5f && (!isHeldItem || !((Object)(object)playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)) && Physics.Linecast(explosionPosition + Vector3.up * 0.5f, ((Component)localPlayerController.gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1)))
			{
				return;
			}
			List<PeeperAI> list = new List<PeeperAI>(Peeper.PeeperList);
			foreach (PeeperAI item in list)
			{
				if ((Object)(object)item.attachedPlayer == (Object)(object)localPlayerController && ((NetworkBehaviour)item).IsOwner)
				{
					((EnemyAI)item).KillEnemyOnOwnerClient(false);
				}
			}
		}
	}
	[HarmonyPatch(typeof(SpringManAI))]
	internal class SpringManAIPatcher
	{
		[HarmonyPrefix]
		[HarmonyPatch("DoAIInterval")]
		private static void DoAllIntervalPrefix(ref SpringManAI __instance)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			if (PeeperAI.HasLineOfSightToPeeper(((Component)__instance).transform.position))
			{
				((EnemyAI)__instance).currentBehaviourStateIndex = 1;
			}
		}

		[HarmonyTranspiler]
		[HarmonyPatch("Update")]
		private static IEnumerable<CodeInstruction> Update_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Expected O, but got Unknown
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			MethodInfo method = typeof(PeeperAI).GetMethod("HasLineOfSightToPeeper", BindingFlags.Static | BindingFlags.Public);
			MethodInfo method2 = typeof(SpringManAI).GetMethod("get_transform");
			MethodInfo method3 = typeof(Transform).GetMethod("get_position");
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			for (int i = 1; i < list.Count; i++)
			{
				if (!(list[i - 1].opcode != OpCodes.Ldc_I4_0) && !(list[i].opcode != OpCodes.Stloc_1))
				{
					list.Insert(i, new CodeInstruction(OpCodes.Or, (object)null));
					list.Insert(i, new CodeInstruction(OpCodes.Call, (object)method));
					list.Insert(i, new CodeInstruction(OpCodes.Callvirt, (object)method3));
					list.Insert(i, new CodeInstruction(OpCodes.Call, (object)method2));
					list.Insert(i, new CodeInstruction(OpCodes.Ldarg_0, (object)null));
					break;
				}
			}
			return list;
		}
	}
	[HarmonyPatch(typeof(SprayPaintItem))]
	internal class SprayPaintItemPatch
	{
		private static FieldInfo SprayMatIndex = typeof(SprayPaintItem).GetField("sprayCanMatsIndex", BindingFlags.Instance | BindingFlags.NonPublic);

		[HarmonyPatch("SprayPaintClientRpc")]
		[HarmonyPrefix]
		private static void SprayPaintClientRpcPatch(SprayPaintItem __instance, Vector3 sprayPos, Vector3 sprayRot)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Ray val = default(Ray);
				((Ray)(ref val))..ctor(sprayPos, sprayRot);
				RaycastHit val2 = default(RaycastHit);
				if (!Physics.Raycast(val, ref val2, 4f, 524288, (QueryTriggerInteraction)2) || !((Object)(object)((RaycastHit)(ref val2)).collider != (Object)null) || !(((Object)((RaycastHit)(ref val2)).collider).name == "PeeperSprayCollider"))
				{
					return;
				}
				PeeperAI component = ((Component)((Component)((RaycastHit)(ref val2)).collider).transform.parent.parent.parent.parent.parent.parent.parent).GetComponent<PeeperAI>();
				if (!((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)(object)component.attachedPlayer))
				{
					((Renderer)component.peeperMesh).materials[0].color = __instance.sprayCanMats[(int)SprayMatIndex.GetValue(__instance)].color;
					if (component.isAttached)
					{
						component.EjectFromPlayerServerRpc(component.attachedPlayer.actualClientId);
					}
				}
			}
			catch (Exception)
			{
			}
		}
	}
	[HarmonyPatch(typeof(FlashlightItem))]
	internal class FlashlightItemPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePatch(FlashlightItem __instance)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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)
			if (!((NetworkBehaviour)__instance).IsOwner || __instance.flashlightTypeID != 2 || !((GrabbableObject)__instance).isBeingUsed)
			{
				return;
			}
			Transform transform = ((Component)__instance.flashlightBulb).transform;
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(transform.position, transform.forward);
			RaycastHit[] array = Physics.RaycastAll(val, 32f, 1 << LayerMask.NameToLayer("ScanNode"));
			RaycastHit[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				RaycastHit val2 = array2[i];
				if (!(((Object)((RaycastHit)(ref val2)).collider).name == "PeeperScanNode"))
				{
					continue;
				}
				float num = Vector3.Angle(-((Ray)(ref val)).direction, ((RaycastHit)(ref val2)).transform.forward);
				if (num < 55f)
				{
					PeeperAI component = ((Component)((RaycastHit)(ref val2)).transform.parent.parent.parent.parent.parent.parent.parent).GetComponent<PeeperAI>();
					if ((Object)(object)component.attachedPlayer == (Object)(object)GameNetworkManager.Instance.localPlayerController)
					{
						break;
					}
					if (((NetworkBehaviour)component).IsOwner)
					{
						((EnemyAI)component).KillEnemyOnOwnerClient(false);
					}
					else
					{
						component.KillEnemyNetworked();
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("KillPlayer")]
		[HarmonyPrefix]
		private static void KillPlayerPatch(PlayerControllerB __instance, Vector3 bodyVelocity, bool spawnBody = true, CauseOfDeath causeOfDeath = 0, int deathAnimation = 0)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Invalid comparison between Unknown and I4
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Invalid comparison between Unknown and I4
			List<PeeperAI> list = new List<PeeperAI>(Peeper.PeeperList);
			foreach (PeeperAI item in list)
			{
				if ((Object)(object)item.attachedPlayer == (Object)(object)__instance && ((NetworkBehaviour)item).IsOwner)
				{
					if ((int)causeOfDeath == 11 || (int)causeOfDeath == 3)
					{
						((EnemyAI)item).KillEnemyOnOwnerClient(false);
					}
					else
					{
						item.EjectFromPlayerServerRpc(__instance.playerClientId);
					}
				}
			}
		}

		[HarmonyPatch("DamagePlayer")]
		[HarmonyPrefix]
		private static void DamagePlayerPatch(PlayerControllerB __instance, int damageNumber, bool hasDamageSFX = true, bool callRPC = true, CauseOfDeath causeOfDeath = 0, int deathAnimation = 0, bool fallDamage = false, Vector3 force = default(Vector3))
		{
			List<PeeperAI> list = new List<PeeperAI>(Peeper.PeeperList);
			foreach (PeeperAI item in list)
			{
				if ((Object)(object)item.attachedPlayer == (Object)(object)__instance)
				{
					item.EjectFromPlayerServerRpc(__instance.playerClientId);
				}
			}
		}

		[HarmonyPatch("IShockableWithGun.ShockWithGun")]
		[HarmonyPrefix]
		private static void DamagePlayerPatch(PlayerControllerB __instance, PlayerControllerB shockedByPlayer)
		{
			List<PeeperAI> list = new List<PeeperAI>(Peeper.PeeperList);
			foreach (PeeperAI item in list)
			{
				if ((Object)(object)item.attachedPlayer == (Object)(object)__instance && ((NetworkBehaviour)item).IsOwner)
				{
					((EnemyAI)item).KillEnemyOnOwnerClient(false);
				}
			}
		}

		[HarmonyPatch("DropAllHeldItems")]
		[HarmonyPostfix]
		private static void DamagePlayeDropAllHeldItemsPatch(PlayerControllerB __instance, bool itemsFall = true, bool disconnecting = false)
		{
			if (__instance.carryWeight != 1f)
			{
				return;
			}
			List<PeeperAI> list = new List<PeeperAI>(Peeper.PeeperList);
			foreach (PeeperAI item in list)
			{
				if ((Object)(object)item.attachedPlayer == (Object)(object)__instance && item.isAttached && !((EnemyAI)item).isEnemyDead)
				{
					__instance.carryWeight += Peeper.PeeperWeight;
				}
			}
		}
	}
	public class PeeperAI : EnemyAI
	{
		[Header("General")]
		public GameObject creatureModel;

		public SkinnedMeshRenderer peeperMesh;

		public ScanNodeProperties scanNode;

		[Header("AI and Pathfinding")]
		public AISearchRoutine searchForPlayers;

		public float maxSearchAndRoamRadius = 100f;

		public float searchPrecisionValue = 5f;

		private int sightRange = 30;

		[Header("Constraints and Transforms")]
		public Transform attachTargetTransform;

		public static List<Transform> UsedAttachTargets = new List<Transform>();

		public Vector3 attachTargetTranslationOffset;

		public Vector3 attachTargetRotationOffset;

		public Transform eyeTransform;

		public Transform eyeOriginalTransform;

		public bool isAttached;

		public PlayerControllerB attachedPlayer;

		[Header("Colliders and Physics")]
		public SphereCollider attachCollider;

		public SphereCollider physicsCollider;

		public SphereCollider hitboxCollider;

		public Rigidbody physicsRigidbody;

		[Header("State Handling and Sync")]
		public float stateTimer;

		public float stateTimer2;

		public int stateCounter;

		[Header("Audio")]
		public AudioSource AttachSFXSource;

		public AudioClip walkSFX;

		public AudioClip runSFX;

		public AudioClip[] spotSFX;

		public AudioClip[] jumpSFX;

		public AudioClip[] attachSFX;

		public AudioClip[] deathSFX;

		public AudioClip[] ejectSFX;

		public AudioClip[] zapSFX;

		public AudioClip[] whisperSFX;

		public static float NextWhisperTime;

		[Header("Materials")]
		public Material baseMat;

		public Material paintedMat;

		public Material deadMat;

		public ParticleSystem deathParticles;

		[Header("Ragdoll")]
		private bool ragdollFrozen;

		public Rigidbody[] ragdollRigidbodies;

		public Collider[] ragdollColliders;

		private Vector3 agentLocalVelocity;

		private Vector3 previousPosition;

		private float velX;

		private float velZ;

		private float velXZ;

		private float footstepTimer;

		private Vector3 deathDirection = Vector3.zero;

		private float blinkTimer;

		private float blinkInterval;

		private bool isWeightedInternal;

		public bool IsWeighted
		{
			get
			{
				return isWeightedInternal;
			}
			set
			{
				if (value && !isWeightedInternal)
				{
					PlayerControllerB obj = attachedPlayer;
					obj.carryWeight += Peeper.PeeperWeight;
				}
				else if (!value && isWeightedInternal)
				{
					PlayerControllerB obj2 = attachedPlayer;
					obj2.carryWeight += 0f - Peeper.PeeperWeight;
					if (attachedPlayer.carryWeight < 1f)
					{
						attachedPlayer.carryWeight = 1f;
					}
				}
				isWeightedInternal = value;
			}
		}

		public override void Start()
		{
			((EnemyAI)this).Start();
			searchForPlayers.searchWidth = maxSearchAndRoamRadius;
			searchForPlayers.searchPrecision = searchPrecisionValue;
			Peeper.PeeperList.Add(this);
			AudioMixer diageticMixer = SoundManager.Instance.diageticMixer;
			base.creatureVoice.outputAudioMixerGroup = diageticMixer.FindMatchingGroups("SFX")[0];
			base.creatureSFX.outputAudioMixerGroup = diageticMixer.FindMatchingGroups("SFX")[0];
			AttachSFXSource.outputAudioMixerGroup = diageticMixer.FindMatchingGroups("SFX")[0];
			scanNode.creatureScanID = Peeper.PeeperCreatureID;
			SwitchBehaviourState(2);
		}

		public override void DoAIInterval()
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			if (base.inSpecialAnimation)
			{
				return;
			}
			((EnemyAI)this).DoAIInterval();
			if (StartOfRound.Instance.livingPlayers == 0 || base.isEnemyDead)
			{
				return;
			}
			if (base.currentBehaviourStateIndex != 0)
			{
				if (searchForPlayers.inProgress)
				{
					((EnemyAI)this).StopSearch(searchForPlayers, true);
					base.movingTowardsTargetPlayer = true;
				}
			}
			else if (!searchForPlayers.inProgress)
			{
				((EnemyAI)this).StartSearch(((Component)this).transform.position, searchForPlayers);
			}
		}

		public override void FinishedCurrentSearchRoutine()
		{
			((EnemyAI)this).FinishedCurrentSearchRoutine();
			searchForPlayers.searchWidth = Mathf.Clamp(searchForPlayers.searchWidth + 20f, 1f, maxSearchAndRoamRadius);
		}

		private void CalculateAnimationDirection()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			agentLocalVelocity = ((Component)this).transform.InverseTransformDirection(Vector3.ClampMagnitude(((Component)this).transform.position - previousPosition, 1f) / (Time.deltaTime * 2f));
			velX = Mathf.Lerp(velX, agentLocalVelocity.x, 5f * Time.deltaTime);
			velZ = Mathf.Lerp(velZ, 0f - agentLocalVelocity.z, 5f * Time.deltaTime);
			previousPosition = ((Component)this).transform.position;
			velXZ = Mathf.Sqrt(velX * velX + velZ * velZ);
			base.creatureAnimator.SetFloat("Speed", velXZ);
			float num = ((base.currentBehaviourStateIndex != 1 && base.currentBehaviourStateIndex != 5) ? 0.3335f : 0.3f);
			footstepTimer += Time.deltaTime;
			if (footstepTimer < num)
			{
				return;
			}
			footstepTimer = 0f;
			if ((double)velXZ > 0.15)
			{
				if (base.currentBehaviourStateIndex == 1)
				{
					PlayCreatureSFX(2);
				}
				else
				{
					PlayCreatureSFX(1);
				}
			}
		}

		private void PutCreatureOnGround()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			if (!(base.agent.velocity.y > 5f))
			{
				base.creatureAnimator.SetBool("Grounded", true);
				base.creatureAnimator.SetBool("Jump", false);
				Ray val = default(Ray);
				((Ray)(ref val))..ctor(((Component)this).transform.position + Vector3.up, Vector3.down);
				RaycastHit val2 = default(RaycastHit);
				if (Physics.Raycast(val, ref val2, 2f, LayerMask.GetMask(new string[2] { "Room", "Colliders" }), (QueryTriggerInteraction)1))
				{
					creatureModel.transform.localPosition = new Vector3(0f, 0f - ((RaycastHit)(ref val2)).distance + 1f, 0f);
				}
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).HitEnemy(force, playerWhoHit, false);
			base.enemyHP -= force;
			if ((Object)(object)playerWhoHit != (Object)null)
			{
				Vector3 val = ((Component)this).transform.position - ((Component)playerWhoHit).transform.position;
				deathDirection = ((Vector3)(ref val)).normalized;
			}
			if (base.enemyHP <= 0 && ((NetworkBehaviour)this).IsOwner)
			{
				((EnemyAI)this).KillEnemyOnOwnerClient(false);
			}
		}

		public override void SetEnemyStunned(bool setToStunned, float setToStunTime = 1f, PlayerControllerB setStunnedByPlayer = null)
		{
			base.enemyHP--;
			if (base.enemyHP <= 0 && ((NetworkBehaviour)this).IsOwner)
			{
				((EnemyAI)this).KillEnemyOnOwnerClient(false);
			}
		}

		public void KillEnemyNetworked()
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				KillEnemyClientRpc();
			}
			else
			{
				KillEnemyServerRpc();
			}
		}

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

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

		public override void KillEnemy(bool destroy = false)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).KillEnemy(false);
			base.creatureVoice.Stop();
			base.creatureSFX.Stop();
			PlayCreatureSFX(5);
			SwitchBehaviourState(7);
			base.isEnemyDead = true;
			Peeper.PeeperList.Remove(this);
			creatureModel.transform.localPosition = Vector3.zero;
			if (isAttached && (Object)(object)attachedPlayer != (Object)null)
			{
				EjectFromPlayer(attachedPlayer);
			}
			Color color = ((Renderer)peeperMesh).material.color;
			((Renderer)peeperMesh).materials = (Material[])(object)new Material[1] { deadMat };
			((Renderer)peeperMesh).materials[0].color = color;
			deathParticles.Play();
			((Behaviour)base.creatureAnimator).enabled = false;
			physicsRigidbody.isKinematic = true;
			Rigidbody[] array = ragdollRigidbodies;
			foreach (Rigidbody val in array)
			{
				val.isKinematic = false;
				if (deathDirection != Vector3.zero)
				{
					val.AddForce(15f * deathDirection, (ForceMode)1);
				}
			}
			Collider[] array2 = ragdollColliders;
			foreach (Collider val2 in array2)
			{
				val2.enabled = true;
			}
			peeperMesh.SetBlendShapeWeight(0, 0f);
			peeperMesh.SetBlendShapeWeight(1, 350f);
		}

		public void SwitchBehaviourState(int state)
		{
			SwitchBehaviourStateLocally(state);
			SwitchBehaviourStateServerRpc(state);
		}

		[ServerRpc(RequireOwnership = false)]
		public void SwitchBehaviourStateServerRpc(int state)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(316864934u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, state);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 316864934u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					SwitchBehaviourStateClientRpc(state);
				}
			}
		}

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

		public void SwitchBehaviourStateLocally(int state)
		{
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: 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_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0604: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0731: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e4: Unknown result type (might be due to invalid IL or missing references)
			stateTimer = 0f;
			stateTimer2 = 0f;
			stateCounter = 0;
			switch (state)
			{
			case 0:
				base.targetPlayer = null;
				base.movingTowardsTargetPlayer = false;
				base.agent.speed = 2f;
				base.creatureAnimator.SetBool("Jump", false);
				base.creatureAnimator.SetBool("Attached", false);
				base.creatureAnimator.SetBool("Dead", false);
				base.inSpecialAnimation = false;
				((Behaviour)base.agent).enabled = true;
				base.enemyType.canBeStunned = true;
				((Collider)attachCollider).enabled = true;
				((Collider)physicsCollider).enabled = false;
				physicsRigidbody.isKinematic = true;
				((Collider)hitboxCollider).enabled = true;
				hitboxCollider.radius = 0.5f;
				hitboxCollider.center = new Vector3(0f, 0.5f, 0f);
				break;
			case 1:
				base.agent.speed = 6f;
				base.creatureAnimator.SetBool("Jump", false);
				base.creatureAnimator.SetBool("Attached", false);
				base.creatureAnimator.SetBool("Dead", false);
				base.inSpecialAnimation = false;
				((Behaviour)base.agent).enabled = true;
				base.enemyType.canBeStunned = true;
				((Collider)attachCollider).enabled = true;
				((Collider)physicsCollider).enabled = false;
				physicsRigidbody.isKinematic = true;
				((Collider)hitboxCollider).enabled = true;
				hitboxCollider.radius = 0.5f;
				hitboxCollider.center = new Vector3(0f, 0.5f, 0f);
				break;
			case 2:
				base.targetPlayer = null;
				base.movingTowardsTargetPlayer = false;
				base.agent.speed = 0f;
				base.creatureAnimator.SetBool("Jump", false);
				base.creatureAnimator.SetBool("Attached", false);
				base.creatureAnimator.SetBool("Dead", false);
				base.creatureAnimator.SetBool("Grounded", true);
				base.inSpecialAnimation = false;
				((Behaviour)base.agent).enabled = true;
				base.enemyType.canBeStunned = true;
				((Collider)attachCollider).enabled = true;
				((Collider)physicsCollider).enabled = false;
				physicsRigidbody.isKinematic = true;
				((Collider)hitboxCollider).enabled = true;
				hitboxCollider.radius = 0.5f;
				hitboxCollider.center = new Vector3(0f, 0.5f, 0f);
				break;
			case 3:
			{
				base.agent.speed = 0f;
				creatureModel.transform.localPosition = Vector3.zero;
				base.creatureAnimator.SetBool("Jump", true);
				base.creatureAnimator.SetBool("Attached", false);
				base.creatureAnimator.SetBool("Dead", false);
				base.creatureAnimator.SetBool("Grounded", false);
				base.inSpecialAnimation = true;
				((Behaviour)base.agent).enabled = false;
				base.enemyType.canBeStunned = true;
				((Collider)attachCollider).enabled = true;
				((Collider)physicsCollider).enabled = true;
				physicsRigidbody.isKinematic = false;
				((Collider)hitboxCollider).enabled = true;
				hitboxCollider.radius = 2f;
				hitboxCollider.center = Vector3.zero;
				SphereCollider obj3 = physicsCollider;
				((Collider)obj3).includeLayers = LayerMask.op_Implicit(LayerMask.op_Implicit(((Collider)obj3).includeLayers) & -524289);
				SphereCollider obj4 = physicsCollider;
				((Collider)obj4).excludeLayers = LayerMask.op_Implicit(LayerMask.op_Implicit(((Collider)obj4).excludeLayers) | 0x80000);
				break;
			}
			case 4:
				base.targetPlayer = null;
				base.movingTowardsTargetPlayer = false;
				creatureModel.transform.localPosition = Vector3.zero;
				base.agent.speed = 0f;
				base.creatureAnimator.SetBool("Jump", true);
				base.creatureAnimator.SetBool("Attached", true);
				base.creatureAnimator.SetBool("Dead", false);
				base.creatureAnimator.SetBool("Grounded", false);
				base.inSpecialAnimation = true;
				((Behaviour)base.agent).enabled = false;
				base.enemyType.canBeStunned = false;
				((Collider)attachCollider).enabled = false;
				((Collider)physicsCollider).enabled = false;
				physicsRigidbody.isKinematic = true;
				((Collider)hitboxCollider).enabled = false;
				hitboxCollider.radius = 0.5f;
				hitboxCollider.center = Vector3.zero;
				NextWhisperTime = Time.time + 10f;
				break;
			case 5:
				base.targetPlayer = null;
				base.movingTowardsTargetPlayer = false;
				base.agent.speed = 0f;
				base.creatureAnimator.SetBool("Jump", false);
				base.creatureAnimator.SetBool("Attached", false);
				base.creatureAnimator.SetBool("Dead", false);
				base.creatureAnimator.SetBool("Grounded", true);
				base.inSpecialAnimation = false;
				((Behaviour)base.agent).enabled = true;
				base.enemyType.canBeStunned = true;
				((Collider)attachCollider).enabled = true;
				((Collider)physicsCollider).enabled = false;
				physicsRigidbody.isKinematic = true;
				((Collider)hitboxCollider).enabled = true;
				hitboxCollider.radius = 0.5f;
				hitboxCollider.center = new Vector3(0f, 0.5f, 0f);
				break;
			case 6:
			{
				stateTimer = Random.Range(0f, 1f);
				base.targetPlayer = null;
				base.movingTowardsTargetPlayer = false;
				base.agent.speed = 0f;
				creatureModel.transform.localPosition = Vector3.zero;
				base.creatureAnimator.SetBool("Jump", true);
				base.creatureAnimator.SetBool("Attached", false);
				base.creatureAnimator.SetBool("Dead", false);
				base.creatureAnimator.SetBool("Grounded", false);
				base.inSpecialAnimation = true;
				((Behaviour)base.agent).enabled = false;
				base.enemyType.canBeStunned = true;
				((Collider)attachCollider).enabled = false;
				((Collider)physicsCollider).enabled = true;
				physicsRigidbody.isKinematic = false;
				((Collider)hitboxCollider).enabled = true;
				hitboxCollider.radius = 0.5f;
				hitboxCollider.center = Vector3.zero;
				SphereCollider obj = physicsCollider;
				((Collider)obj).includeLayers = LayerMask.op_Implicit(LayerMask.op_Implicit(((Collider)obj).includeLayers) | 0x80000);
				SphereCollider obj2 = physicsCollider;
				((Collider)obj2).excludeLayers = LayerMask.op_Implicit(LayerMask.op_Implicit(((Collider)obj2).excludeLayers) & -524289);
				break;
			}
			case 7:
				base.targetPlayer = null;
				base.movingTowardsTargetPlayer = false;
				base.agent.speed = 0f;
				creatureModel.transform.localPosition = Vector3.zero;
				base.creatureAnimator.SetBool("Jump", false);
				base.creatureAnimator.SetBool("Attached", false);
				base.creatureAnimator.SetBool("Dead", true);
				base.creatureAnimator.SetBool("Grounded", false);
				base.inSpecialAnimation = true;
				((Behaviour)base.agent).enabled = false;
				base.enemyType.canBeStunned = false;
				((Collider)attachCollider).enabled = false;
				((Collider)physicsCollider).enabled = false;
				physicsRigidbody.isKinematic = true;
				((Collider)hitboxCollider).enabled = false;
				hitboxCollider.radius = 0.5f;
				hitboxCollider.center = Vector3.zero;
				break;
			}
			((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(state);
		}

		private void LateUpdate()
		{
			//IL_0020: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			if (base.isEnemyDead)
			{
				return;
			}
			if (isAttached)
			{
				((Component)this).transform.position = attachTargetTransform.position;
				((Component)this).transform.rotation = attachTargetTransform.rotation;
				((Component)this).transform.Rotate(attachTargetRotationOffset);
				((Component)this).transform.Translate(0f, 0f, attachTargetTranslationOffset.z, (Space)1);
				((Component)this).transform.Translate(0f, attachTargetTranslationOffset.y, 0f, attachTargetTransform);
			}
			int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
			if (currentBehaviourStateIndex == 4)
			{
				blinkTimer += Time.deltaTime;
				if (blinkTimer > blinkInterval)
				{
					base.creatureAnimator.SetTrigger("Blink");
					blinkInterval = Random.Range(2f, 12f);
					blinkTimer = 0f;
				}
			}
			if (base.isEnemyDead || (Object)(object)attachedPlayer == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				return;
			}
			PlayerControllerB val = null;
			float num = 7f;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val2 in allPlayerScripts)
			{
				if (!((Object)(object)val2 == (Object)(object)attachedPlayer))
				{
					float num2 = Vector3.Distance(eyeTransform.position, ((Component)val2.gameplayCamera).transform.position);
					Vector3 val3 = ((Component)val2).transform.position - eyeTransform.position;
					float num3 = Vector3.Angle(eyeOriginalTransform.forward, val3);
					if (num2 < num && num3 < 70f)
					{
						val = val2;
						num = num2;
					}
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				Transform transform = ((Component)val.gameplayCamera).transform;
				float num4 = Vector3.Distance(eyeTransform.position, transform.position);
				if (num4 < 7f)
				{
					Vector3 val4 = transform.position - eyeTransform.position;
					Quaternion val5 = Quaternion.LookRotation(val4, eyeTransform.up);
					Quaternion val6 = Quaternion.RotateTowards(eyeOriginalTransform.rotation, val5, 40f);
					float num5 = Quaternion.Angle(val5, eyeOriginalTransform.rotation);
					if (num5 < 90f)
					{
						eyeTransform.rotation = Quaternion.RotateTowards(eyeTransform.rotation, val6, 120f * Time.deltaTime);
						return;
					}
				}
			}
			eyeTransform.rotation = Quaternion.RotateTowards(eyeTransform.rotation, eyeOriginalTransform.rotation, 20f * Time.deltaTime);
		}

		public override void Update()
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_062c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0631: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			if (base.isEnemyDead)
			{
				base.currentBehaviourStateIndex = 7;
			}
			else if (base.currentBehaviourStateIndex == 0 || base.currentBehaviourStateIndex == 1 || base.currentBehaviourStateIndex == 5)
			{
				CalculateAnimationDirection();
			}
			if (base.currentBehaviourStateIndex == 0)
			{
				PutCreatureOnGround();
				if (!((NetworkBehaviour)this).IsOwner)
				{
					return;
				}
				stateTimer += Time.deltaTime;
				if (!(stateTimer < 0.15f))
				{
					stateTimer = 0f;
					PlayerControllerB val = ((EnemyAI)this).CheckLineOfSightForClosestPlayer(70f, sightRange, 3, 0f);
					if (!((Object)(object)val == (Object)null) && !(Vector3.Distance(base.eye.position, ((Component)val.gameplayCamera).transform.position) > (float)sightRange))
					{
						PlayCreatureSFXServerRpc(0);
						BeginChasingPlayerServerRpc((int)val.playerClientId);
						SwitchBehaviourState(1);
					}
				}
			}
			else if (base.currentBehaviourStateIndex == 1)
			{
				PutCreatureOnGround();
				if (!((NetworkBehaviour)this).IsOwner)
				{
					return;
				}
				if (stateTimer2 < 0.5f)
				{
					stateTimer2 += Time.deltaTime;
					return;
				}
				if ((Object)(object)base.targetPlayer != (Object)null && Vector3.Distance(((Component)base.targetPlayer.playerGlobalHead).transform.position, base.eye.position) < 8f)
				{
					Vector3 val2 = ((Component)base.targetPlayer.playerGlobalHead).transform.position - base.eye.position;
					val2.y = 0f;
					Vector3 forward = base.eye.forward;
					forward.y = 0f;
					if (Vector3.Angle(forward, val2) < 15f)
					{
						PlayCreatureSFXServerRpc(3);
						SwitchBehaviourState(3);
						JumpAtPlayerServerRpc(base.targetPlayer.playerClientId);
						return;
					}
				}
				stateTimer += Time.deltaTime;
				if (stateTimer < 0.15f)
				{
					return;
				}
				stateTimer = 0f;
				PlayerControllerB val3 = ((EnemyAI)this).CheckLineOfSightForClosestPlayer(70f, sightRange, 3, 0f);
				if ((Object)(object)val3 == (Object)null || Vector3.Distance(base.eye.position, ((Component)val3.gameplayCamera).transform.position) > (float)sightRange)
				{
					stateCounter++;
					if (stateCounter >= 8)
					{
						stateCounter = 0;
						SwitchBehaviourState(0);
					}
				}
				else if ((Object)(object)val3 != (Object)(object)GameNetworkManager.Instance.localPlayerController)
				{
					BeginChasingPlayerServerRpc((int)val3.playerClientId);
				}
			}
			else if (base.currentBehaviourStateIndex == 2)
			{
				PutCreatureOnGround();
				if (!((NetworkBehaviour)this).IsOwner)
				{
					return;
				}
				stateTimer += Time.deltaTime;
				if (stateTimer > 5.5f)
				{
					stateTimer = 0f;
					if ((Object)(object)base.targetPlayer != (Object)null)
					{
						SwitchBehaviourState(1);
					}
					else
					{
						SwitchBehaviourState(0);
					}
				}
				stateTimer2 += Time.deltaTime;
				if (!(stateTimer2 < 0.5f))
				{
					stateTimer2 = 0f;
					PlayerControllerB val4 = ((EnemyAI)this).CheckLineOfSightForClosestPlayer(70f, sightRange, 3, 0f);
					if (!((Object)(object)val4 == (Object)null) && !(Vector3.Distance(base.eye.position, ((Component)val4.gameplayCamera).transform.position) > (float)sightRange))
					{
						BeginChasingPlayerServerRpc((int)val4.playerClientId);
					}
				}
			}
			else if (base.currentBehaviourStateIndex == 3)
			{
				if (!((NetworkBehaviour)this).IsOwner)
				{
					((Component)this).transform.position = base.serverPosition;
					return;
				}
				((EnemyAI)this).SyncPositionToClients();
				if (stateCounter == 0)
				{
					stateTimer += Time.deltaTime;
					if (stateTimer > 2.5f)
					{
						hitboxCollider.radius = 0.5f;
						SphereCollider obj = physicsCollider;
						((Collider)obj).includeLayers = LayerMask.op_Implicit(LayerMask.op_Implicit(((Collider)obj).includeLayers) | 0x80000);
						SphereCollider obj2 = physicsCollider;
						((Collider)obj2).excludeLayers = LayerMask.op_Implicit(LayerMask.op_Implicit(((Collider)obj2).excludeLayers) & -524289);
						stateCounter = 1;
					}
				}
				stateTimer2 += Time.deltaTime;
				if (!(stateTimer2 < 5f))
				{
					stateTimer2 = 0f;
					PlayCreatureSFXServerRpc(0, 0.5f);
					SwitchBehaviourState(5);
				}
			}
			else if (base.currentBehaviourStateIndex == 4)
			{
				if (((NetworkBehaviour)this).IsOwner)
				{
					((EnemyAI)this).SyncPositionToClients();
				}
				stateTimer += Time.deltaTime;
				if (stateTimer < 1f)
				{
					return;
				}
				stateTimer = 0f;
				if (Time.time < NextWhisperTime)
				{
					return;
				}
				NextWhisperTime = Time.time + 10f;
				Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, 16f, LayerMask.GetMask(new string[1] { "Enemies" }), (QueryTriggerInteraction)2);
				Collider[] array2 = array;
				foreach (Collider val5 in array2)
				{
					EnemyAI componentInParent = ((Component)val5).gameObject.GetComponentInParent<EnemyAI>();
					if ((Object)(object)componentInParent != (Object)null && !Peeper.ignoreEnemies.Contains(componentInParent.enemyType.enemyName))
					{
						PlayCreatureSFXServerRpc(7);
						NextWhisperTime = Time.time + Random.Range(6f, 12f);
						return;
					}
				}
				NextWhisperTime = Time.time + 1f;
			}
			else if (base.currentBehaviourStateIndex == 5)
			{
				PutCreatureOnGround();
				if (((NetworkBehaviour)this).IsOwner)
				{
					stateTimer += Time.deltaTime;
					if (!(stateTimer < 1.2f))
					{
						stateTimer = 0f;
						SwitchBehaviourState(0);
					}
				}
			}
			else if (base.currentBehaviourStateIndex == 6)
			{
				if (!((NetworkBehaviour)this).IsOwner)
				{
					((Component)this).transform.position = base.serverPosition;
					return;
				}
				((EnemyAI)this).SyncPositionToClients();
				stateTimer += Time.deltaTime;
				if (!(stateTimer < 5f))
				{
					stateTimer = 4.5f;
					Vector3 velocity = physicsRigidbody.velocity;
					if (!(((Vector3)(ref velocity)).sqrMagnitude > 10f))
					{
						PlayCreatureSFXServerRpc(0, 0.5f);
						SwitchBehaviourState(5);
					}
				}
			}
			else
			{
				if (base.currentBehaviourStateIndex != 7 || ragdollFrozen)
				{
					return;
				}
				stateTimer += Time.deltaTime;
				if (!(stateTimer < 15f))
				{
					stateTimer = 0f;
					Rigidbody[] array3 = ragdollRigidbodies;
					foreach (Rigidbody val6 in array3)
					{
						val6.isKinematic = true;
						ragdollFrozen = true;
					}
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void JumpAtPlayerServerRpc(ulong playerObjectId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3297439372u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerObjectId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3297439372u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					JumpAtPlayerClientRpc(playerObjectId);
				}
			}
		}

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

		private void JumpAtPlayer(PlayerControllerB playerScript)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: 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_0104: 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_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: 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_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			if (!base.isEnemyDead && !isAttached)
			{
				base.agent.speed = 0f;
				creatureModel.transform.localPosition = Vector3.zero;
				base.creatureAnimator.SetBool("Jump", true);
				base.creatureAnimator.SetBool("Attached", false);
				base.creatureAnimator.SetBool("Dead", false);
				isAttached = false;
				base.inSpecialAnimation = true;
				((Behaviour)base.agent).enabled = false;
				base.enemyType.canBeStunned = true;
				((Collider)attachCollider).enabled = true;
				((Collider)physicsCollider).enabled = true;
				physicsRigidbody.isKinematic = false;
				((Collider)hitboxCollider).enabled = true;
				hitboxCollider.radius = 2f;
				Vector3 val = ((Component)playerScript.playerGlobalHead).transform.position;
				if ((Object)(object)base.targetPlayer == (Object)(object)GameNetworkManager.Instance.localPlayerController)
				{
					val += base.targetPlayer.thisController.velocity / 5f;
				}
				else if (base.targetPlayer.timeSincePlayerMoving < 0.25f)
				{
					val += Vector3.Normalize((base.targetPlayer.serverPlayerPosition - base.targetPlayer.oldPlayerPosition) * 100f);
				}
				Rigidbody obj = physicsRigidbody;
				Vector3 val2 = val - ((Component)this).transform.position + Vector3.up;
				obj.velocity = 33f * ((Vector3)(ref val2)).normalized;
				base.creatureAnimator.SetBool("Grounded", false);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void BeginChasingPlayerServerRpc(int playerObjectId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2492932585u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerObjectId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2492932585u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					BeginChasingPlayerClientRpc(playerObjectId);
				}
			}
		}

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

		public void BeginChasingPlayer(int playerObjectId)
		{
			PlayerControllerB movingTowardsTargetPlayer = (base.targetPlayer = StartOfRound.Instance.allPlayerScripts[playerObjectId]);
			if (((NetworkBehaviour)this).OwnerClientId != (ulong)playerObjectId)
			{
				((EnemyAI)this).ChangeOwnershipOfEnemy((ulong)playerObjectId);
			}
			((EnemyAI)this).SetMovingTowardsTargetPlayer(movingTowardsTargetPlayer);
		}

		[ServerRpc(RequireOwnership = false)]
		public void PlayCreatureSFXServerRpc(int index, float volume = 1f)
		{
			//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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1656237277u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, index);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref volume, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1656237277u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					PlayCreatureSFXClientRpc(index, volume);
				}
			}
		}

		[ClientRpc]
		public void PlayCreatureSFXClientRpc(int index, float volume = 1f)
		{
			//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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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(2720121576u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, index);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref volume, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2720121576u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					PlayCreatureSFX(index, volume);
				}
			}
		}

		private void PlayCreatureSFX(int index, float volume = 1f)
		{
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			base.creatureVoice.pitch = Random.Range(0.8f, 1.1f);
			AttachSFXSource.pitch = Random.Range(0.9f, 1.05f);
			switch (index)
			{
			case 0:
			{
				AudioClip val = spotSFX[Random.Range(0, spotSFX.Length)];
				base.creatureVoice.PlayOneShot(val, volume);
				WalkieTalkie.TransmitOneShotAudio(base.creatureVoice, val, volume);
				break;
			}
			case 1:
				base.creatureSFX.PlayOneShot(walkSFX, volume * 0.22f);
				WalkieTalkie.TransmitOneShotAudio(base.creatureSFX, walkSFX, volume * 0.22f);
				break;
			case 2:
				base.creatureSFX.PlayOneShot(runSFX, volume * 0.25f);
				WalkieTalkie.TransmitOneShotAudio(base.creatureSFX, runSFX, volume * 0.25f);
				break;
			case 3:
			{
				AudioClip val = jumpSFX[Random.Range(0, jumpSFX.Length)];
				base.creatureVoice.PlayOneShot(val, volume);
				WalkieTalkie.TransmitOneShotAudio(base.creatureVoice, val, volume);
				break;
			}
			case 4:
			{
				AudioClip val = attachSFX[0];
				AttachSFXSource.PlayOneShot(val, volume);
				WalkieTalkie.TransmitOneShotAudio(AttachSFXSource, val, volume);
				break;
			}
			case 5:
			{
				AudioClip val = deathSFX[Random.Range(0, deathSFX.Length)];
				base.creatureVoice.PlayOneShot(val, volume);
				WalkieTalkie.TransmitOneShotAudio(base.creatureVoice, val, volume);
				break;
			}
			case 6:
			{
				AudioClip val = ejectSFX[Random.Range(0, ejectSFX.Length)];
				base.creatureVoice.PlayOneShot(val, volume);
				WalkieTalkie.TransmitOneShotAudio(base.creatureVoice, val, volume);
				break;
			}
			case 7:
			{
				AudioClip val = whisperSFX[Random.Range(0, whisperSFX.Length)];
				AttachSFXSource.PlayOneShot(val, volume);
				WalkieTalkie.TransmitOneShotAudio(AttachSFXSource, val, volume);
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 18f, 0.6f, 0, false, 0);
				break;
			}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void AttachToPlayerServerRpc(ulong playerObjectId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2592041692u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerObjectId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2592041692u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					AttachToPlayerClientRpc(playerObjectId);
				}
			}
		}

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

		private void AttachToPlayerLocally(PlayerControllerB playerScript)
		{
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: 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_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_041d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_047f: Unknown result type (might be due to invalid IL or missing references)
			//IL_048f: Unknown result type (might be due to invalid IL or missing references)
			if (base.isEnemyDead || isAttached || playerScript.isPlayerDead)
			{
				return;
			}
			int num = 0;
			foreach (PeeperAI peeper in Peeper.PeeperList)
			{
				if ((Object)(object)peeper.attachedPlayer == (Object)(object)playerScript)
				{
					num++;
				}
			}
			if (num >= 10)
			{
				return;
			}
			isAttached = true;
			base.targetPlayer = playerScript;
			attachedPlayer = playerScript;
			if (!playerScript.isPlayerDead)
			{
				IsWeighted = true;
			}
			if ((Object)(object)playerScript == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
			}
			((EnemyAI)this).ChangeOwnershipOfEnemy(playerScript.actualClientId);
			SwitchBehaviourStateLocally(4);
			PlayCreatureSFX(4);
			float num2 = 0f;
			float num3 = 0f;
			float num4 = 0f;
			Transform val = null;
			Random.InitState(base.thisEnemyIndex + StartOfRound.Instance.randomMapSeed);
			int num5 = Random.Range(0, 11);
			for (int i = 0; i < 10; i++)
			{
				if (num5 == 6)
				{
					num5++;
				}
				if (!UsedAttachTargets.Contains(attachedPlayer.bodyParts[num5]))
				{
					val = ((num5 != 0 || !((Object)(object)attachedPlayer == (Object)(object)GameNetworkManager.Instance.localPlayerController)) ? attachedPlayer.bodyParts[num5] : ((Component)attachedPlayer.gameplayCamera).transform);
					UsedAttachTargets.Add(val);
					attachTargetTransform = val;
					break;
				}
				num5 = ((num5 != 10) ? (num5 + 1) : 0);
			}
			if (!((Object)(object)val == (Object)null))
			{
				switch (num5)
				{
				case 0:
					num2 = Random.Range(-30f, -90f);
					num3 = Random.Range(80f, 280f);
					num4 = Random.Range(0f, 360f);
					attachTargetTranslationOffset = new Vector3(0f, 0.35f, 0.2f);
					break;
				case 1:
					num3 = Random.Range(60f, 160f);
					num4 = Random.Range(0f, 360f);
					attachTargetTranslationOffset = new Vector3(0f, 0f, 0.075f);
					break;
				case 2:
					num3 = Random.Range(-60f, -160f);
					num4 = Random.Range(0f, 360f);
					attachTargetTranslationOffset = new Vector3(0f, 0f, 0.075f);
					break;
				case 3:
					num3 = Random.Range(0f, 160f);
					num4 = Random.Range(0f, 360f);
					attachTargetTranslationOffset = new Vector3(0f, 0f, 0.2f);
					break;
				case 4:
					num3 = Random.Range(0f, -160f);
					num4 = Random.Range(0f, 360f);
					attachTargetTranslationOffset = new Vector3(0f, 0f, 0.2f);
					break;
				case 5:
					num3 = Random.Range(-30f, 30f);
					num4 = Random.Range(0f, 360f);
					attachTargetTranslationOffset = new Vector3(0f, 0f, 0.2f);
					break;
				case 7:
					num3 = Random.Range(0f, 160f);
					num4 = Random.Range(0f, 360f);
					attachTargetTranslationOffset = new Vector3(0f, 0f, 0.2f);
					break;
				case 8:
					num3 = Random.Range(0f, -160f);
					num4 = Random.Range(0f, 360f);
					attachTargetTranslationOffset = new Vector3(0f, 0f, 0.2f);
					break;
				case 9:
					num3 = Random.Range(160f, 280f);
					num4 = Random.Range(0f, 360f);
					attachTargetTranslationOffset = new Vector3(0f, 0f, 0.15f);
					break;
				case 10:
					num3 = Random.Range(-20f, 100f);
					num4 = Random.Range(0f, 360f);
					attachTargetTranslationOffset = new Vector3(0f, 0f, 0.15f);
					break;
				default:
					Debug.Log((object)("Peepers have encountered an error when attaching! Report it to the developer! Target Index: " + num5));
					break;
				}
				attachTargetRotationOffset = new Vector3(num2, num3, num4);
				creatureModel.transform.localPosition = Vector3.zero;
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void EjectFromPlayerServerRpc(ulong playerObjectId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1104444428u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerObjectId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1104444428u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					EjectFromPlayerClientRpc(playerObjectId);
				}
			}
		}

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

		public void EjectFromPlayer(PlayerControllerB playerScript)
		{
			//IL_0053: 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)
			//IL_0077: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			if (isAttached)
			{
				isAttached = false;
				if (!playerScript.isPlayerDead)
				{
					IsWeighted = false;
				}
				attachedPlayer = null;
				UsedAttachTargets.Remove(attachTargetTransform);
				attachTargetTransform = null;
				if (!base.isEnemyDead)
				{
					SwitchBehaviourStateLocally(6);
				}
				Vector3 val = ((Component)playerScript).transform.position - ((Component)this).transform.position;
				val.y = 0f;
				val = ((Vector3)(ref val)).normalized;
				val.y = -1f;
				physicsRigidbody.AddForce(-10f * val, (ForceMode)1);
				PlayCreatureSFX(6);
			}
		}

		public static bool HasLineOfSightToPeeper(Vector3 position)
		{
			//IL_001e: 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_002f: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			foreach (PeeperAI peeper in Peeper.PeeperList)
			{
				if ((Object)(object)peeper != (Object)null)
				{
					Vector3 val = position - peeper.eyeTransform.position;
					float num = Vector3.Angle(peeper.eyeOriginalTransform.forward, val);
					if (Vector3.Distance(position, peeper.eyeTransform.position) < 10f && num < 60f && !Physics.Linecast(((Component)peeper.eyeTransform).transform.position, position, StartOfRound.Instance.collidersRoomDefaultAndFoliage, (QueryTriggerInteraction)1))
					{
						return true;
					}
				}
			}
			return false;
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_PeeperAI()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Expected O, but got Unknown
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1087886824u, new RpcReceiveHandler(__rpc_handler_1087886824));
			NetworkManager.__rpc_func_table.Add(2756874777u, new RpcReceiveHandler(__rpc_handler_2756874777));
			NetworkManager.__rpc_func_table.Add(316864934u, new RpcReceiveHandler(__rpc_handler_316864934));
			NetworkManager.__rpc_func_table.Add(4022924503u, new RpcReceiveHandler(__rpc_handler_4022924503));
			NetworkManager.__rpc_func_table.Add(3297439372u, new RpcReceiveHandler(__rpc_handler_3297439372));
			NetworkManager.__rpc_func_table.Add(3646752176u, new RpcReceiveHandler(__rpc_handler_3646752176));
			NetworkManager.__rpc_func_table.Add(2492932585u, new RpcReceiveHandler(__rpc_handler_2492932585));
			NetworkManager.__rpc_func_table.Add(3529258009u, new RpcReceiveHandler(__rpc_handler_3529258009));
			NetworkManager.__rpc_func_table.Add(1656237277u, new RpcReceiveHandler(__rpc_handler_1656237277));
			NetworkManager.__rpc_func_table.Add(2720121576u, new RpcReceiveHandler(__rpc_handler_2720121576));
			NetworkManager.__rpc_func_table.Add(2592041692u, new RpcReceiveHandler(__rpc_handler_2592041692));
			NetworkManager.__rpc_func_table.Add(4096406816u, new RpcReceiveHandler(__rpc_handler_4096406816));
			NetworkManager.__rpc_func_table.Add(1104444428u, new RpcReceiveHandler(__rpc_handler_1104444428));
			NetworkManager.__rpc_func_table.Add(280628075u, new RpcReceiveHandler(__rpc_handler_280628075));
		}

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

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

		private static void __rpc_handler_316864934(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int state = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref state);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PeeperAI)(object)target).SwitchBehaviourStateServerRpc(state);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4022924503(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int state = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref state);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PeeperAI)(object)target).SwitchBehaviourStateClientRpc(state);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3297439372(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong playerObjectId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerObjectId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PeeperAI)(object)target).JumpAtPlayerServerRpc(playerObjectId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3646752176(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong playerObjectId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerObjectId);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PeeperAI)(object)target).JumpAtPlayerClientRpc(playerObjectId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2492932585(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerObjectId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerObjectId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PeeperAI)(object)target).BeginChasingPlayerServerRpc(playerObjectId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3529258009(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerObjectId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerObjectId);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PeeperAI)(object)target).BeginChasingPlayerClientRpc(playerObjectId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1656237277(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int index = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref index);
				float volume = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref volume, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PeeperAI)(object)target).PlayCreatureSFXServerRpc(index, volume);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2720121576(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int index = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref index);
				float volume = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref volume, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PeeperAI)(object)target).PlayCreatureSFXClientRpc(index, volume);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2592041692(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong playerObjectId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerObjectId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PeeperAI)(object)target).AttachToPlayerServerRpc(playerObjectId);
			

plugins/PintoBoy.dll

Decompiled 9 months ago
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Pinto Mod.NetcodePatcher;
using PintoMod;
using PintoMod.Properties;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Pinto_Mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Pinto_Mod")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ff99ad61-38a5-4085-a181-d080e129d86e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyInformationalVersion("1.0.0+ca70f6de36e09a039f2eba21d3c3ef1c418e01a4")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<float>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<float>();
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public enum PintoEnemyType
{
	Spider,
	Slime,
	Lootbug
}
public class JumpanyEnemy : NetworkBehaviour
{
	public PintoEnemyType enemyType;

	public float speed = 5f;

	private float startX;

	private float distance;

	public PintoBoy pintoBoy;

	public UnityEvent<JumpanyEnemy> onDeath = new UnityEvent<JumpanyEnemy>();

	public Animator animator;

	public bool paused = false;

	public bool killedPlayer = false;

	private AudioClip[] movementSounds;

	private float currentMovementSoundTimer = 0f;

	private int currentMovementSoundIndex = 0;

	public NetworkVariable<int> parentNetworkID = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

	private void Awake()
	{
		distance = 10f;
		animator = ((Component)this).GetComponent<Animator>();
	}

	private void Update()
	{
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		if (pintoBoy.isTurnedOff)
		{
			return;
		}
		if (killedPlayer)
		{
			if (enemyType == PintoEnemyType.Spider)
			{
				((Behaviour)animator).enabled = false;
			}
			return;
		}
		float num = speed * Time.deltaTime;
		Transform transform = ((Component)this).transform;
		transform.position += Vector3.left * num;
		distance -= num;
		if (distance < 0f)
		{
			onDeath.Invoke(this);
		}
		currentMovementSoundTimer -= Time.deltaTime;
		if (currentMovementSoundTimer < 0f)
		{
			pintoBoy.PlaySound(movementSounds[currentMovementSoundIndex]);
			currentMovementSoundIndex++;
			if (currentMovementSoundIndex >= movementSounds.Length)
			{
				currentMovementSoundIndex = 0;
			}
			currentMovementSoundTimer = movementSounds[currentMovementSoundIndex].length;
		}
	}

	private void OnTriggerEnter2D(Collider2D collision)
	{
		if (((Component)collision).gameObject.CompareTag("Player") && (Object)(object)pintoBoy != (Object)null)
		{
			pintoBoy.PlayerGotHit();
		}
	}

	public void SetMovementSounds(AudioClip[] audioClips)
	{
		movementSounds = audioClips;
		currentMovementSoundTimer = movementSounds[0].length;
	}

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

	protected internal override string __getTypeName()
	{
		return "JumpanyEnemy";
	}
}
public enum PintoBoyState
{
	MainMenu,
	InGame,
	Paused,
	Lost
}
public enum FadeState
{
	FadeOff,
	FadeOn,
	FadeIn,
	FadeOut
}
public class PintoBoy : GrabbableObject
{
	private PintoBoyState gameState = PintoBoyState.MainMenu;

	private AudioSource audioSource;

	private Animator fadeAnim;

	private Transform mainMenu;

	private Animator mainMenuAnim;

	private float mainmenuTime = 2f;

	private float mainmenuTimer = 0f;

	private float mainmenuWaitTime = 1.5f;

	private float mainmenuWaitTimer = 0f;

	private string SelectedString = "Selected";

	private string FadeString = "Fade";

	private string DoAnimString = "DoAnim";

	private Transform inGame;

	private Vector3 playerStart;

	private GameObject player;

	private Rigidbody2D playerRb;

	private Collider2D playerCol;

	private Animator playerAnim;

	private SpriteRenderer playerSprite;

	private int[] playerPositions = new int[4] { 0, 5, 10, 15 };

	private Vector3 brackenStart;

	private GameObject bracken;

	private Animator brackenAnim;

	private Collider2D groundCol;

	private Animator groundAnim;

	private string InAirString = "InAir";

	private string DeathString = "Death";

	private string ResetString = "Reset";

	private GameObject cam;

	private GameObject modelScreen;

	private Animator buttonAnim;

	private ScanNodeProperties scanNodeProperties;

	public float jumpHeight = 9.75f;

	public float fastFallSpeed = 15f;

	public float rayCastDistance = 0.5f;

	public float rayCastOffset = -0.05f;

	public bool jump = false;

	private bool isGrounded = false;

	private bool doOnce = false;

	private Transform paused;

	private Transform lost;

	private Transform playerSpawnpoint;

	private Transform topSpawnpoint;

	private Transform midSpawnpoint;

	private Transform bottomSpawnpoint;

	private TMP_Text scoreText;

	private TMP_Text endScreenText;

	public GameObject spiderPrefab;

	public GameObject lootbugPrefab;

	public GameObject slimePrefab;

	private float spiderSpeed = 2.5f;

	private float lootbugSpeed = 3f;

	private float slimeSpeed = 2f;

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

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

	private float scoreIncreaseRate = 15f;

	private NetworkVariable<int> lives = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)1);

	public NetworkVariable<int> screenId = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)1);

	private float increaseSpeedAddition = 0.25f;

	private float increaseAdditionRate = 100f;

	private int speedAdditionMultiplier = 1;

	private int speedAdditionMultiplierDefault = 1;

	private int timesIncreased = 0;

	private float spawnEnemyEveryMin = 40f;

	private float spawnEnemyEveryMax = 100f;

	private float lastTimeSpawned = 0f;

	private List<JumpanyEnemy> enemies = new List<JumpanyEnemy>();

	private string camString = "2D Cam/";

	private bool invincible = false;

	private float invincibleTime = 2f;

	private float invincibleTimer = 0f;

	private bool dead;

	private bool deadHitGround;

	private bool deadAnimStarted;

	private bool endScreenShown;

	private float deathAnimTime = 2.5f;

	private float deathAnimTimer = 0f;

	private int deathAnimIndex = 0;

	public AudioClip acPlayerStep1;

	public AudioClip acPlayerStep2;

	public AudioClip acPlayerJump;

	public AudioClip acSnapNeck;

	public AudioClip acSnapNeckLand;

	public AudioClip acSpiderStep1;

	public AudioClip acSpiderStep2;

	public AudioClip acSpiderStep3;

	public AudioClip acSpiderStep4;

	public AudioClip acLootbugStep;

	public AudioClip acSlimeStep;

	public AudioClip acConfirm;

	public AudioClip acNewHighscore;

	public AudioClip acNoHighscore;

	public AudioClip acBackgroundSong;

	private float stepSoundTimer = 0f;

	private float stepSoundTime = 0.25f;

	private int stepSoundIndex = 0;

	private float backgroundMusicTimer = 0f;

	private float backgroundMusicTime = 0f;

	private bool firstPlay = true;

	private bool spawnScreen = true;

	private Material matRenderTex = null;

	private RenderTexture texRenderTex = null;

	public bool isTurnedOff = false;

	public bool isPaused = false;

	private Renderer rendModelScreen;

	private float batteryDischargeRate = 0.002f;

	private void Awake()
	{
		//IL_022a: Unknown result type (might be due to invalid IL or missing references)
		//IL_022f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_0249: Unknown result type (might be due to invalid IL or missing references)
		//IL_0255: Unknown result type (might be due to invalid IL or missing references)
		//IL_025f: Expected O, but got Unknown
		audioSource = ((Component)this).GetComponent<AudioSource>();
		acPlayerStep1 = Pinto_ModBase.GetAudioClip("21_walk1 (player step 1)");
		acPlayerStep2 = Pinto_ModBase.GetAudioClip("22_walk2 (player step 2)");
		acPlayerJump = Pinto_ModBase.GetAudioClip("23_ladder (player land)");
		acSnapNeck = Pinto_ModBase.GetAudioClip("12_exchange (snap neck)");
		acSnapNeckLand = Pinto_ModBase.GetAudioClip("67_knock (fall after neck snap)");
		acSpiderStep1 = Pinto_ModBase.GetAudioClip("52_step1 (spider movement)");
		acSpiderStep2 = Pinto_ModBase.GetAudioClip("53_step2 (spider movement)");
		acSpiderStep3 = Pinto_ModBase.GetAudioClip("54_step3 (spider movement)");
		acSpiderStep4 = Pinto_ModBase.GetAudioClip("55_step4 (spider movement)");
		acLootbugStep = Pinto_ModBase.GetAudioClip("47_grass (lootbug movement)");
		acSlimeStep = Pinto_ModBase.GetAudioClip("30_triangle (slime movement)");
		acConfirm = Pinto_ModBase.GetAudioClip("59_confirm (start game)");
		acNewHighscore = Pinto_ModBase.GetAudioClip("24_levelclear (new highscore)");
		acNoHighscore = Pinto_ModBase.GetAudioClip("64_lose2 (no highscore)");
		acBackgroundSong = Pinto_ModBase.GetAudioClip("danger_streets");
		backgroundMusicTime = acBackgroundSong.length;
		base.mainObjectRenderer = ((Component)((Component)this).transform.Find("Model")).GetComponent<MeshRenderer>();
		spiderPrefab = Pinto_ModBase.spiderPrefab;
		lootbugPrefab = Pinto_ModBase.lootbugPrefab;
		slimePrefab = Pinto_ModBase.slimePrefab;
		scanNodeProperties = ((Component)this).GetComponentInChildren<ScanNodeProperties>();
		base.useCooldown = 0.1f;
		base.grabbable = true;
		base.parentObject = ((Component)this).transform;
		base.grabbableToEnemies = true;
		scanNodeProperties.maxRange = 100;
		scanNodeProperties.minRange = 1;
		scanNodeProperties.requiresLineOfSight = true;
		scanNodeProperties.headerText = "PintoBoy";
		scanNodeProperties.subText = "PintoBoy Subtext";
		scanNodeProperties.creatureScanID = -1;
		scanNodeProperties.nodeType = 2;
		mainmenuWaitTimer = mainmenuWaitTime;
		modelScreen = ((Component)((Component)this).transform.Find("Model/Screen")).gameObject;
		buttonAnim = ((Component)((Component)this).transform.Find("Model/Button")).GetComponent<Animator>();
		base.startFallingPosition = new Vector3(0f, 0f, 0f);
		base.targetFloorPosition = new Vector3(0f, 0f, 0f);
		base.insertedBattery = new Battery(false, 100f);
		((GrabbableObject)this).EnableItemMeshes(true);
	}

	private void LateUpdate()
	{
		try
		{
			((GrabbableObject)this).LateUpdate();
		}
		catch (Exception ex)
		{
			Debug.Log((object)"");
			Debug.Log((object)"");
			Debug.Log((object)"");
			Debug.Log((object)"");
			Debug.Log((object)"");
			Debug.Log((object)("Exception caught in PintoBoy LateUpdate: " + ex.Message));
			Debug.Log((object)$"gameState: {gameState}");
			Debug.Log((object)$"fadeAnim: {fadeAnim}");
			Debug.Log((object)$"mainMenu: {mainMenu}");
			Debug.Log((object)$"mainMenuAnim: {mainMenuAnim}");
			Debug.Log((object)$"mainmenuTime: {mainmenuTime}");
			Debug.Log((object)$"mainmenuTimer: {mainmenuTimer}");
			Debug.Log((object)("SelectedString: " + SelectedString));
			Debug.Log((object)("FadeString: " + FadeString));
			Debug.Log((object)("DoAnimString: " + DoAnimString));
			Debug.Log((object)$"inGame: {inGame}");
			Debug.Log((object)$"player: {player}");
			Debug.Log((object)$"playerRb: {playerRb}");
			Debug.Log((object)$"playerCol: {playerCol}");
			Debug.Log((object)$"groundCol: {groundCol}");
			Debug.Log((object)$"playerAnim: {playerAnim}");
			Debug.Log((object)("InAirString: " + InAirString));
			Debug.Log((object)$"screen: {cam}");
			Debug.Log((object)$"scanNodeProperties: {scanNodeProperties}");
			Debug.Log((object)$"jumpHeight: {jumpHeight}");
			Debug.Log((object)$"fastFallSpeed: {fastFallSpeed}");
			Debug.Log((object)$"rayCastDistance: {rayCastDistance}");
			Debug.Log((object)$"rayCastOffset: {rayCastOffset}");
			Debug.Log((object)$"jump: {jump}");
			Debug.Log((object)$"isGrounded: {isGrounded}");
			Debug.Log((object)$"doOnce: {doOnce}");
			Debug.Log((object)$"paused: {paused}");
			Debug.Log((object)$"lost: {lost}");
			Debug.Log((object)$"playerSpawnpoint: {playerSpawnpoint}");
			Debug.Log((object)$"topSpawnpoint: {topSpawnpoint}");
			Debug.Log((object)$"midSpawnpoint: {midSpawnpoint}");
			Debug.Log((object)$"bottomSpawnpoint: {bottomSpawnpoint}");
			Debug.Log((object)$"scoreText: {scoreText}");
			Debug.Log((object)$"spiderPrefab: {spiderPrefab}");
			Debug.Log((object)$"lootbugPrefab: {lootbugPrefab}");
			Debug.Log((object)$"slimePrefab: {slimePrefab}");
			Debug.Log((object)$"spiderSpeed: {spiderSpeed}");
			Debug.Log((object)$"lootbugSpeed: {lootbugSpeed}");
			Debug.Log((object)$"slimeSpeed: {slimeSpeed}");
			Debug.Log((object)$"highScore: {highScore}");
			Debug.Log((object)$"currentScore: {currentScore}");
			Debug.Log((object)$"scoreIncreaseRate: {scoreIncreaseRate}");
			Debug.Log((object)$"increaseSpeedAddition: {increaseSpeedAddition}");
			Debug.Log((object)$"increaseAdditionRate: {increaseAdditionRate}");
			Debug.Log((object)$"speedAdditionMultiplier: {speedAdditionMultiplier}");
			Debug.Log((object)$"speedAdditionMultiplierDefault: {speedAdditionMultiplierDefault}");
			Debug.Log((object)$"timesIncreased: {timesIncreased}");
			Debug.Log((object)$"spawnEnemyEveryMin: {spawnEnemyEveryMin}");
			Debug.Log((object)$"spawnEnemyEveryMax: {spawnEnemyEveryMax}");
			Debug.Log((object)$"lastTimeSpawned: {lastTimeSpawned}");
			Debug.Log((object)$"enemies Count: {enemies.Count}");
			Debug.Log((object)"");
			Debug.Log((object)"");
			Debug.Log((object)"");
			Debug.Log((object)"");
			Debug.Log((object)"");
		}
	}

	private void VerifyScreen()
	{
		if ((Object)(object)cam != (Object)null)
		{
			Debug.Log((object)"Need to verify screen");
			if (((Object)cam).name != "PintoBoy Screen " + screenId.Value)
			{
				cam = GameObject.Find("PintoBoy Screen " + screenId.Value);
				if ((Object)(object)cam == (Object)null)
				{
					Debug.Log((object)"no cam matching id. Spawning one");
					SpawnScreen();
				}
				if (!isTurnedOff)
				{
					Debug.Log((object)"cam found, setting render texture");
					SetScreenToRenderTexture();
				}
			}
		}
		else
		{
			Debug.Log((object)"verify: cam == null, spawning");
			SpawnScreen();
		}
	}

	private void Update()
	{
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//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_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: 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_00de: 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_0135: Unknown result type (might be due to invalid IL or missing references)
		((GrabbableObject)this).Update();
		if (spawnScreen)
		{
			SpawnScreen();
			spawnScreen = false;
			cam.transform.parent = null;
			cam.GetComponent<Camera>().orthographicSize = 2f;
			cam.transform.position = ((Component)this).transform.position + Vector3.down * 400f;
			cam.transform.rotation = Quaternion.identity;
			cam.transform.localScale = new Vector3(0.25f, 0.25f, 0.25f);
			if (cam.transform.position.x == 0f || cam.transform.position.z == 0f)
			{
				cam.transform.position = new Vector3(Random.Range(-500f, 500f), cam.transform.position.y, Random.Range(-500f, 500f));
			}
		}
		if (isTurnedOff)
		{
			return;
		}
		Battery insertedBattery = base.insertedBattery;
		insertedBattery.charge -= batteryDischargeRate * Time.deltaTime;
		if (fadeAnim.GetBool(DoAnimString))
		{
			fadeAnim.SetBool(DoAnimString, false);
		}
		switch (gameState)
		{
		case PintoBoyState.MainMenu:
			if (mainmenuWaitTimer > 0f)
			{
				mainmenuWaitTimer -= Time.deltaTime;
			}
			if (mainmenuTimer > 0f)
			{
				mainmenuTimer -= Time.deltaTime;
			}
			if (mainmenuTimer > 1f && !doOnce)
			{
				SetFade(FadeState.FadeOut);
				doOnce = true;
			}
			if (mainmenuTimer <= 1f && mainmenuTimer > 0f && doOnce)
			{
				mainmenuTimer = 0f;
				StartGame();
				SetFade(FadeState.FadeIn);
				doOnce = false;
			}
			break;
		case PintoBoyState.InGame:
			InGameUpdate();
			break;
		}
		if (jump)
		{
			ButtonPress();
			jump = false;
		}
	}

	private void InGameUpdate()
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: 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_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0346: Unknown result type (might be due to invalid IL or missing references)
		//IL_036e: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_045e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0487: Unknown result type (might be due to invalid IL or missing references)
		//IL_0496: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
		if (endScreenShown)
		{
			return;
		}
		if (!deadAnimStarted)
		{
			RaycastHit2D val = Physics2D.Raycast(Vector2.op_Implicit(player.transform.position - rayCastOffset * Vector3.down), Vector2.down, rayCastDistance);
			if ((Object)(object)((RaycastHit2D)(ref val)).collider == (Object)(object)groundCol)
			{
				isGrounded = true;
				Debug.DrawRay(player.transform.position - rayCastOffset * Vector3.down, Vector2.op_Implicit(Vector2.down * rayCastDistance), Color.green);
				playerAnim.SetBool(InAirString, false);
				deadHitGround = true;
			}
			else
			{
				isGrounded = false;
				Debug.DrawRay(player.transform.position - rayCastOffset * Vector3.down, Vector2.op_Implicit(Vector2.down * rayCastDistance), Color.red);
				playerAnim.SetBool(InAirString, true);
				deadHitGround = false;
			}
		}
		if (dead)
		{
			if (deadHitGround)
			{
				PlayDeathAnim();
			}
			if (deadAnimStarted)
			{
				deathAnimTimer -= Time.deltaTime;
				if (deathAnimTimer <= 0f)
				{
					deadAnimStarted = false;
					ShowEndScreen();
				}
				else if (deathAnimTimer < deathAnimTime - 0.25f && deathAnimIndex == 0)
				{
					deathAnimIndex++;
					PlaySound(acSnapNeck);
				}
				else if (deathAnimTimer < deathAnimTime - 1.75f && deathAnimIndex == 1)
				{
					deathAnimIndex++;
					PlaySound(acSnapNeckLand);
				}
			}
			return;
		}
		if (((NetworkBehaviour)this).IsOwner)
		{
			NetworkVariable<float> obj = currentScore;
			obj.Value += scoreIncreaseRate * Time.deltaTime;
		}
		if (currentScore.Value > (float)speedAdditionMultiplier * increaseAdditionRate && speedAdditionMultiplier > timesIncreased)
		{
			timesIncreased++;
			speedAdditionMultiplier++;
		}
		if (((NetworkBehaviour)this).IsOwner && currentScore.Value > lastTimeSpawned + Random.Range(spawnEnemyEveryMin, spawnEnemyEveryMax))
		{
			SpawnRandomEnemyServerRpc();
			lastTimeSpawned = currentScore.Value;
		}
		scoreText.text = Mathf.Round(currentScore.Value).ToString();
		if (player.transform.localPosition.y < playerStart.y - 0.5f || player.transform.localPosition.y > playerStart.y + 100f)
		{
			player.transform.localPosition = playerSpawnpoint.localPosition;
		}
		if (invincible)
		{
			invincibleTimer -= Time.deltaTime;
			if (invincibleTimer <= 0f)
			{
				invincible = false;
				((Renderer)playerSprite).enabled = true;
			}
			else if (invincibleTimer % 0.25f < 0.05f)
			{
				((Renderer)playerSprite).enabled = !((Renderer)playerSprite).enabled;
			}
		}
		if (lives.Value > -1)
		{
			player.transform.localPosition = new Vector3(playerSpawnpoint.localPosition.x + (float)playerPositions[lives.Value], player.transform.localPosition.y, 0f);
			bracken.transform.localPosition = new Vector3(playerSpawnpoint.localPosition.x - (float)(playerPositions[lives.Value] * 3), brackenStart.y, 0f);
		}
		else
		{
			Debug.Log((object)$"Lives less than 0: {lives}");
		}
		if (isGrounded)
		{
			PlayStepSound();
		}
		if (backgroundMusicTimer > 0f)
		{
			backgroundMusicTimer -= Time.deltaTime;
			return;
		}
		backgroundMusicTimer = backgroundMusicTime;
		PlaySound(acBackgroundSong);
	}

	[ServerRpc]
	private void SpawnRandomEnemyServerRpc()
	{
		//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(1674945273u, val, (RpcDelivery)0);
			((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1674945273u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			switch (Random.Range(0, 3))
			{
			case 0:
				SpawnSpider();
				break;
			case 1:
				SpawnLootbug();
				break;
			case 2:
				SpawnSlime();
				break;
			}
		}
	}

	public override void ItemInteractLeftRight(bool right)
	{
		((GrabbableObject)this).ItemInteractLeftRight(right);
		if (!right)
		{
			ToggleOnOff();
		}
	}

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

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

	private JumpanyEnemy EnumToJumpanyEnemy(PintoEnemyType enemyType)
	{
		JumpanyEnemy result = new JumpanyEnemy();
		switch (enemyType)
		{
		case PintoEnemyType.Spider:
			result = Pinto_ModBase.spiderPrefab.GetComponent<JumpanyEnemy>();
			break;
		case PintoEnemyType.Slime:
			result = Pinto_ModBase.slimePrefab.GetComponent<JumpanyEnemy>();
			break;
		case PintoEnemyType.Lootbug:
			result = Pinto_ModBase.lootbugPrefab.GetComponent<JumpanyEnemy>();
			break;
		}
		return result;
	}

	private Transform EnumToEnemySpawnPoint(PintoEnemyType enemyType)
	{
		Transform result = null;
		switch (enemyType)
		{
		case PintoEnemyType.Spider:
			result = topSpawnpoint;
			break;
		case PintoEnemyType.Lootbug:
			result = midSpawnpoint;
			break;
		case PintoEnemyType.Slime:
			result = bottomSpawnpoint;
			break;
		}
		return result;
	}

	private AudioClip[] EnumToEnemySounds(PintoEnemyType enemyType)
	{
		AudioClip[] result = null;
		switch (enemyType)
		{
		case PintoEnemyType.Spider:
			result = (AudioClip[])(object)new AudioClip[4] { acSpiderStep1, acSpiderStep2, acSpiderStep3, acSpiderStep4 };
			break;
		case PintoEnemyType.Slime:
			result = (AudioClip[])(object)new AudioClip[1] { acSlimeStep };
			break;
		case PintoEnemyType.Lootbug:
			result = (AudioClip[])(object)new AudioClip[1] { acLootbugStep };
			break;
		}
		return result;
	}

	[ServerRpc]
	private void SpawnEnemyServerRpc(float speed, string enemy)
	{
		//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_00c3: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Invalid comparison between Unknown and I4
		//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(4145081944u, val, (RpcDelivery)0);
			((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref speed, default(ForPrimitives));
			bool flag = enemy != null;
			((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
			if (flag)
			{
				((FastBufferWriter)(ref val2)).WriteValueSafe(enemy, false);
			}
			((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4145081944u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			PintoEnemyType pintoEnemyType = Enum.Parse<PintoEnemyType>(enemy);
			JumpanyEnemy jumpanyEnemy = SpawnEnemy(EnumToJumpanyEnemy(pintoEnemyType), EnumToEnemySpawnPoint(pintoEnemyType), speed, pintoEnemyType, EnumToEnemySounds(pintoEnemyType));
			SpawnEnemyClientRpc(speed, enemy);
		}
	}

	[ClientRpc]
	private void SpawnEnemyClientRpc(float speed, string enemy)
	{
		//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_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_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_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(1642841649u, val, (RpcDelivery)0);
			((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref speed, default(ForPrimitives));
			bool flag = enemy != null;
			((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
			if (flag)
			{
				((FastBufferWriter)(ref val2)).WriteValueSafe(enemy, false);
			}
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1642841649u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
		{
			PintoEnemyType pintoEnemyType = Enum.Parse<PintoEnemyType>(enemy);
			JumpanyEnemy jumpanyEnemy = SpawnEnemy(EnumToJumpanyEnemy(pintoEnemyType), EnumToEnemySpawnPoint(pintoEnemyType), speed, pintoEnemyType, EnumToEnemySounds(pintoEnemyType));
		}
	}

	private JumpanyEnemy SpawnEnemy(JumpanyEnemy prefab, Transform position, float speed, PintoEnemyType enemy, AudioClip[] audioClips)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		JumpanyEnemy jumpanyEnemy = Object.Instantiate<JumpanyEnemy>(prefab, position.position, Quaternion.identity, position);
		jumpanyEnemy.speed = speed + increaseSpeedAddition * (float)speedAdditionMultiplier;
		jumpanyEnemy.pintoBoy = this;
		jumpanyEnemy.onDeath.AddListener((UnityAction<JumpanyEnemy>)OnEnemyDeath);
		jumpanyEnemy.enemyType = enemy;
		jumpanyEnemy.SetMovementSounds(audioClips);
		enemies.Add(jumpanyEnemy);
		return jumpanyEnemy;
	}

	private void OnEnemyDeath(JumpanyEnemy enemy)
	{
		enemies.Remove(enemy);
		enemy.onDeath.RemoveListener((UnityAction<JumpanyEnemy>)OnEnemyDeath);
		Object.Destroy((Object)(object)((Component)enemy).gameObject);
	}

	private void SpawnSpider()
	{
		SpawnEnemyServerRpc(spiderSpeed, PintoEnemyType.Spider.ToString());
	}

	private void SpawnLootbug()
	{
		SpawnEnemyServerRpc(lootbugSpeed, PintoEnemyType.Lootbug.ToString());
	}

	private void SpawnSlime()
	{
		SpawnEnemyServerRpc(slimeSpeed, PintoEnemyType.Slime.ToString());
	}

	private void SetFade(FadeState state)
	{
		switch (state)
		{
		case FadeState.FadeOff:
			fadeAnim.SetInteger(FadeString, 0);
			fadeAnim.SetBool(DoAnimString, true);
			break;
		case FadeState.FadeOn:
			fadeAnim.SetInteger(FadeString, 1);
			fadeAnim.SetBool(DoAnimString, true);
			break;
		case FadeState.FadeIn:
			fadeAnim.SetInteger(FadeString, 2);
			fadeAnim.SetBool(DoAnimString, true);
			break;
		case FadeState.FadeOut:
			fadeAnim.SetInteger(FadeString, 3);
			fadeAnim.SetBool(DoAnimString, true);
			break;
		}
	}

	private void ButtonPress()
	{
		buttonAnim.SetTrigger("Press");
		if (isTurnedOff)
		{
			return;
		}
		switch (gameState)
		{
		case PintoBoyState.MainMenu:
			if (mainmenuWaitTimer <= 0f && mainmenuTimer <= 0f)
			{
				StartFromTitleScreen();
			}
			break;
		case PintoBoyState.InGame:
			if (dead)
			{
				if (!endScreenShown)
				{
					ShowEndScreen();
				}
				else
				{
					ShowTitleScreen();
				}
			}
			else
			{
				Jump();
			}
			break;
		case PintoBoyState.Paused:
			break;
		case PintoBoyState.Lost:
			break;
		}
	}

	private void StartFromTitleScreen()
	{
		mainMenuAnim.SetTrigger(SelectedString);
		mainmenuTimer = mainmenuTime;
		PlaySound(acConfirm);
	}

	private void ShowTitleScreen()
	{
		SwitchState(PintoBoyState.MainMenu);
		mainmenuWaitTimer = mainmenuWaitTime;
	}

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

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

	private void StartGame()
	{
		SwitchState(PintoBoyState.InGame);
		playerRb.bodyType = (RigidbodyType2D)0;
		speedAdditionMultiplier = speedAdditionMultiplierDefault;
		brackenAnim.SetTrigger(ResetString);
		playerAnim.SetTrigger(ResetString);
		ClearEnemies();
		((Behaviour)groundAnim).enabled = true;
		dead = false;
		endScreenText.text = "";
		deadAnimStarted = false;
		endScreenShown = false;
		deathAnimTimer = 0f;
		if (((NetworkBehaviour)this).IsOwner)
		{
			lives.Value = 3;
			currentScore.Value = 0f;
		}
		timesIncreased = 0;
		lastTimeSpawned = 0f;
		deathAnimIndex = 0;
		firstPlay = false;
		backgroundMusicTimer = 0f;
	}

	private void ClearEnemies()
	{
		if (enemies.Count <= 0)
		{
			return;
		}
		foreach (JumpanyEnemy enemy in enemies)
		{
			Object.Destroy((Object)(object)((Component)enemy).gameObject);
		}
		enemies.Clear();
	}

	private void ClearEnemiesExcept(JumpanyEnemy enemy)
	{
		if (enemies.Count <= 0)
		{
			return;
		}
		foreach (JumpanyEnemy enemy2 in enemies)
		{
			if (!((Object)(object)enemy2 == (Object)(object)enemy))
			{
				Object.Destroy((Object)(object)((Component)enemy2).gameObject);
				enemies.Remove(enemy2);
			}
		}
	}

	[ServerRpc]
	private void SwitchStateServerRpc(PintoBoyState newState)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: 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_00c3: 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_00dd: 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(3526165090u, val, (RpcDelivery)0);
			((FastBufferWriter)(ref val2)).WriteValueSafe<PintoBoyState>(ref newState, default(ForEnums));
			((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3526165090u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			SwitchState(newState);
			SwitchStateClientRpc(newState);
		}
	}

	[ClientRpc]
	private void SwitchStateClientRpc(PintoBoyState newState)
	{
		//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(3560071642u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<PintoBoyState>(ref newState, default(ForEnums));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3560071642u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				SwitchState(newState);
			}
		}
	}

	private void SwitchState(PintoBoyState newState)
	{
		switch (newState)
		{
		case PintoBoyState.MainMenu:
			((Component)mainMenu).gameObject.SetActive(true);
			((Component)inGame).gameObject.SetActive(false);
			((Component)paused).gameObject.SetActive(false);
			((Component)lost).gameObject.SetActive(false);
			doOnce = false;
			break;
		case PintoBoyState.InGame:
			((Component)mainMenu).gameObject.SetActive(false);
			((Component)inGame).gameObject.SetActive(true);
			((Component)paused).gameObject.SetActive(false);
			((Component)lost).gameObject.SetActive(false);
			break;
		case PintoBoyState.Paused:
			((Component)mainMenu).gameObject.SetActive(false);
			((Component)inGame).gameObject.SetActive(false);
			((Component)paused).gameObject.SetActive(true);
			((Component)lost).gameObject.SetActive(false);
			break;
		case PintoBoyState.Lost:
			((Component)mainMenu).gameObject.SetActive(false);
			((Component)inGame).gameObject.SetActive(false);
			((Component)paused).gameObject.SetActive(false);
			((Component)lost).gameObject.SetActive(true);
			break;
		}
		gameState = newState;
	}

	private void Jump()
	{
		//IL_004b: 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)
		if (isGrounded)
		{
			playerRb.velocity = new Vector2(0f, jumpHeight);
			PlaySound(acPlayerJump);
		}
		else
		{
			playerRb.velocity = new Vector2(0f, 0f - fastFallSpeed);
			PlaySound(acPlayerJump);
		}
	}

	private void TogglePause()
	{
		if (isTurnedOff)
		{
			UnPause();
		}
		else
		{
			Pause();
		}
	}

	private void Pause()
	{
		if (!isTurnedOff)
		{
			isPaused = true;
			SetScreenToOffTexture();
			DisableAllAnimators();
			audioSource.Stop();
		}
	}

	private void UnPause()
	{
		if (isTurnedOff)
		{
			isPaused = false;
			EnableAllAnimators();
			if (gameState == PintoBoyState.InGame && !dead)
			{
				audioSource.PlayOneShot(acBackgroundSong);
			}
		}
	}

	private void ToggleOnOff()
	{
		if (isTurnedOff)
		{
			TurnOn();
		}
		else
		{
			TurnOff();
		}
	}

	private void TurnOn()
	{
		if (!isTurnedOff)
		{
			isTurnedOff = true;
			SetScreenToOffTexture();
			DisableAllAnimators();
			audioSource.Stop();
		}
	}

	private void TurnOff()
	{
		if (isTurnedOff)
		{
			isTurnedOff = false;
			SetScreenToRenderTexture();
			EnableAllAnimators();
			ClearEnemies();
			ShowTitleScreen();
		}
	}

	private void EnableAllAnimators()
	{
		((Behaviour)groundAnim).enabled = true;
		((Behaviour)brackenAnim).enabled = true;
		((Behaviour)mainMenuAnim).enabled = true;
		((Behaviour)playerAnim).enabled = true;
		((Behaviour)fadeAnim).enabled = true;
		for (int i = 0; i < enemies.Count; i++)
		{
			((Behaviour)enemies[i].animator).enabled = true;
			enemies[i].paused = true;
		}
	}

	private void DisableAllAnimators()
	{
		((Behaviour)groundAnim).enabled = false;
		((Behaviour)brackenAnim).enabled = false;
		((Behaviour)mainMenuAnim).enabled = false;
		((Behaviour)playerAnim).enabled = false;
		((Behaviour)fadeAnim).enabled = false;
		for (int i = 0; i < enemies.Count; i++)
		{
			((Behaviour)enemies[i].animator).enabled = false;
			enemies[i].paused = false;
		}
	}

	public override void ItemActivate(bool used, bool buttonDown = true)
	{
		((GrabbableObject)this).ItemActivate(used, buttonDown);
		ButtonPress();
		Debug.Log((object)"Pinto Button pressed");
	}

	public override void UseUpBatteries()
	{
		((GrabbableObject)this).UseUpBatteries();
		Pause();
	}

	public float Remap(float from, float fromMin, float fromMax, float toMin, float toMax)
	{
		return 0f;
	}

	public void PlayerGotHit()
	{
		if (((NetworkBehaviour)this).IsOwner && !invincible)
		{
			NetworkVariable<int> obj = lives;
			int value = obj.Value;
			obj.Value = value - 1;
			if (lives.Value <= 0)
			{
				DieServerRpc();
				return;
			}
			invincible = true;
			invincibleTimer = invincibleTime;
		}
	}

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

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

	public void Die()
	{
		//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_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		((Behaviour)groundAnim).enabled = false;
		dead = true;
		for (int i = 0; i < enemies.Count; i++)
		{
			enemies[i].killedPlayer = true;
		}
		if (Mathf.Abs(player.transform.localPosition.x - playerSpawnpoint.localPosition.x) < 5f)
		{
			playerRb.velocity = new Vector2(0f, 0f);
			player.transform.localPosition = new Vector3(player.transform.localPosition.x, playerSpawnpoint.localPosition.y, 0f);
		}
	}

	public void PlayDeathAnim()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		player.transform.localPosition = playerSpawnpoint.localPosition;
		brackenAnim.SetTrigger(DeathString);
		playerAnim.SetTrigger(DeathString);
		deathAnimTimer = deathAnimTime;
		deadAnimStarted = true;
		deadHitGround = false;
		deathAnimIndex = 0;
		audioSource.Stop();
	}

	private void ShowEndScreen()
	{
		if (currentScore.Value > highScore.Value)
		{
			endScreenText.text = "New Best!\n" + $"{Mathf.Round(currentScore.Value)}\n" + "Last Best:\n" + $"{Mathf.Round(highScore.Value)}";
			if (((NetworkBehaviour)this).IsOwner)
			{
				highScore.Value = currentScore.Value;
			}
			PlaySound(acNewHighscore);
		}
		else
		{
			endScreenText.text = "Score:\n" + $"{Mathf.Round(currentScore.Value)}\n" + "Best:\n" + $"{Mathf.Round(highScore.Value)}";
			PlaySound(acNoHighscore);
		}
		endScreenShown = true;
	}

	public void PlaySound(AudioClip clip)
	{
		audioSource.PlayOneShot(clip);
	}

	private void PlayStepSound()
	{
		stepSoundTimer -= Time.deltaTime;
		if (stepSoundTimer <= 0f)
		{
			stepSoundTimer = stepSoundTime;
			stepSoundIndex++;
			if (stepSoundIndex > 1)
			{
				stepSoundIndex = 0;
			}
			switch (stepSoundIndex)
			{
			case 0:
				PlaySound(acPlayerStep1);
				break;
			case 1:
				PlaySound(acPlayerStep2);
				break;
			}
		}
	}

	public void MakeScreenNOTSpawnable()
	{
		spawnScreen = false;
	}

	[ServerRpc]
	private void SpawnScreenServerRpc()
	{
		//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(2495713638u, val, (RpcDelivery)0);
			((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2495713638u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			Debug.Log((object)"SpawnScreenServerRpc Called");
			int currentId = Pinto_ModBase.Instance.Value.currentId;
			PintoBoy[] array = (PintoBoy[])(object)Object.FindObjectsOfType(typeof(PintoBoy));
			for (int i = currentId; i < array.Length + currentId; i++)
			{
				Debug.Log((object)"SpawnScreenServerRpc Called");
				array[i].screenId.Value = i;
			}
			Pinto_ModBase.Instance.Value.currentId += array.Length;
			SpawnScreenClientRpc();
		}
	}

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

	private void SpawnScreen()
	{
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)cam != (Object)null))
		{
			Debug.Log((object)"Spawning Screen");
			cam = ((Component)((Component)this).transform.Find("2D Cam")).gameObject;
			if ((Object)(object)cam == (Object)null)
			{
				Debug.Log((object)"Screen in Pintoboy is null even after instantiate");
			}
			SetScreenToRenderTexture();
			fadeAnim = ((Component)cam.transform.Find("2D Scene/Fade")).GetComponent<Animator>();
			mainMenu = cam.transform.Find("2D Scene/Main Menu");
			mainMenuAnim = ((Component)cam.transform.Find("2D Scene/Main Menu/Main Menu Sprite")).GetComponent<Animator>();
			inGame = cam.transform.Find("2D Scene/Game");
			player = ((Component)cam.transform.Find("2D Scene/Game/PintoEmployee")).gameObject;
			playerStart = player.transform.localPosition;
			playerRb = player.GetComponent<Rigidbody2D>();
			playerAnim = player.GetComponent<Animator>();
			playerCol = player.GetComponent<Collider2D>();
			playerSprite = player.GetComponent<SpriteRenderer>();
			bracken = ((Component)cam.transform.Find("2D Scene/Game/Bracken")).gameObject;
			brackenAnim = bracken.GetComponent<Animator>();
			brackenStart = bracken.transform.localPosition;
			groundCol = ((Component)cam.transform.Find("2D Scene/Game/RailingGround")).GetComponent<Collider2D>();
			groundAnim = ((Component)groundCol).gameObject.GetComponent<Animator>();
			scoreText = ((Component)cam.transform.Find("2D Scene/Game/UI/Score")).GetComponent<TMP_Text>();
			endScreenText = ((Component)cam.transform.Find("2D Scene/Game/UI/Death Screen/Text")).GetComponent<TMP_Text>();
			paused = cam.transform.Find("2D Scene/Paused");
			lost = cam.transform.Find("2D Scene/Lost");
			playerRb.bodyType = (RigidbodyType2D)1;
			topSpawnpoint = cam.transform.Find("2D Scene/Game/Top Spawnpoint");
			midSpawnpoint = cam.transform.Find("2D Scene/Game/Mid Spawnpoint");
			bottomSpawnpoint = cam.transform.Find("2D Scene/Game/Bottom Spawnpoint");
			playerSpawnpoint = cam.transform.Find("2D Scene/Game/Player Spawnpoint");
			SwitchState(PintoBoyState.MainMenu);
			((Component)fadeAnim).gameObject.SetActive(true);
			endScreenText.text = "";
			spawnScreen = false;
		}
	}

	private void SetScreenToRenderTexture()
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Expected O, but got Unknown
		Debug.Log((object)"SetScreenRendTex: checking if texRenderTex null");
		if ((Object)(object)texRenderTex == (Object)null)
		{
			Debug.Log((object)"SetScreenRendTex: texRenderTex is null. Setting");
			texRenderTex = new RenderTexture(160, 160, 16);
			((Object)texRenderTex).name = "PintoBoyScreen";
			((Texture)texRenderTex).filterMode = (FilterMode)0;
			cam.GetComponent<Camera>().targetTexture = texRenderTex;
		}
		Debug.Log((object)"SetScreenRendTex: checking if matRenderTex null");
		if ((Object)(object)matRenderTex == (Object)null)
		{
			Debug.Log((object)"SetScreenRendTex: matRenderTex is null. Setting");
			matRenderTex = Object.Instantiate<Material>(Pinto_ModBase.matOnScreen);
			matRenderTex.SetTexture("_MainTex", (Texture)(object)texRenderTex);
			matRenderTex.mainTexture = (Texture)(object)texRenderTex;
		}
		Debug.Log((object)"SetScreenRendTex: checking if rendModelScreen is null");
		if ((Object)(object)rendModelScreen == (Object)null)
		{
			Debug.Log((object)"SetScreenRendTex: rendModelScreen is null");
			rendModelScreen = modelScreen.GetComponent<Renderer>();
		}
		Debug.Log((object)"SetScreenRendTex: setting rendModelScreen to matRenderTex");
		rendModelScreen.material = matRenderTex;
	}

	private void SetScreenToOffTexture()
	{
		if ((Object)(object)rendModelScreen == (Object)null)
		{
			rendModelScreen = modelScreen.GetComponent<Renderer>();
		}
		rendModelScreen.material = Pinto_ModBase.matOffScreen;
	}

	protected override void __initializeVariables()
	{
		if (highScore == null)
		{
			throw new Exception("PintoBoy.highScore cannot be null. All NetworkVariableBase instances must be initialized.");
		}
		((NetworkVariableBase)highScore).Initialize((NetworkBehaviour)(object)this);
		((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)highScore, "highScore");
		((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)highScore);
		if (currentScore == null)
		{
			throw new Exception("PintoBoy.currentScore cannot be null. All NetworkVariableBase instances must be initialized.");
		}
		((NetworkVariableBase)currentScore).Initialize((NetworkBehaviour)(object)this);
		((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)currentScore, "currentScore");
		((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)currentScore);
		if (lives == null)
		{
			throw new Exception("PintoBoy.lives cannot be null. All NetworkVariableBase instances must be initialized.");
		}
		((NetworkVariableBase)lives).Initialize((NetworkBehaviour)(object)this);
		((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)lives, "lives");
		((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)lives);
		if (screenId == null)
		{
			throw new Exception("PintoBoy.screenId cannot be null. All NetworkVariableBase instances must be initialized.");
		}
		((NetworkVariableBase)screenId).Initialize((NetworkBehaviour)(object)this);
		((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)screenId, "screenId");
		((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)screenId);
		((GrabbableObject)this).__initializeVariables();
	}

	[RuntimeInitializeOnLoadMethod]
	internal static void InitializeRPCS_PintoBoy()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Expected O, but got Unknown
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Expected O, but got Unknown
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Expected O, but got Unknown
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Expected O, but got Unknown
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Expected O, but got Unknown
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Expected O, but got Unknown
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Expected O, but got Unknown
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Expected O, but got Unknown
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Expected O, but got Unknown
		NetworkManager.__rpc_func_table.Add(1674945273u, new RpcReceiveHandler(__rpc_handler_1674945273));
		NetworkManager.__rpc_func_table.Add(4145081944u, new RpcReceiveHandler(__rpc_handler_4145081944));
		NetworkManager.__rpc_func_table.Add(1642841649u, new RpcReceiveHandler(__rpc_handler_1642841649));
		NetworkManager.__rpc_func_table.Add(2416390264u, new RpcReceiveHandler(__rpc_handler_2416390264));
		NetworkManager.__rpc_func_table.Add(1138543879u, new RpcReceiveHandler(__rpc_handler_1138543879));
		NetworkManager.__rpc_func_table.Add(3526165090u, new RpcReceiveHandler(__rpc_handler_3526165090));
		NetworkManager.__rpc_func_table.Add(3560071642u, new RpcReceiveHandler(__rpc_handler_3560071642));
		NetworkManager.__rpc_func_table.Add(579636829u, new RpcReceiveHandler(__rpc_handler_579636829));
		NetworkManager.__rpc_func_table.Add(3060544190u, new RpcReceiveHandler(__rpc_handler_3060544190));
		NetworkManager.__rpc_func_table.Add(2495713638u, new RpcReceiveHandler(__rpc_handler_2495713638));
		NetworkManager.__rpc_func_table.Add(491405224u, new RpcReceiveHandler(__rpc_handler_491405224));
	}

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

	private static void __rpc_handler_4145081944(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_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Invalid comparison between Unknown and I4
		//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;
		}
		float speed = default(float);
		((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref speed, default(ForPrimitives));
		bool flag = default(bool);
		((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
		string enemy = null;
		if (flag)
		{
			((FastBufferReader)(ref reader)).ReadValueSafe(ref enemy, false);
		}
		target.__rpc_exec_stage = (__RpcExecStage)1;
		((PintoBoy)(object)target).SpawnEnemyServerRpc(speed, enemy);
		target.__rpc_exec_stage = (__RpcExecStage)0;
	}

	private static void __rpc_handler_1642841649(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_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//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)
		{
			float speed = default(float);
			((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref speed, default(ForPrimitives));
			bool flag = default(bool);
			((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
			string enemy = null;
			if (flag)
			{
				((FastBufferReader)(ref reader)).ReadValueSafe(ref enemy, false);
			}
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((PintoBoy)(object)target).SpawnEnemyClientRpc(speed, enemy);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

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

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

	private static void __rpc_handler_3526165090(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_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Invalid comparison between Unknown and I4
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
		{
			if ((int)networkManager.LogLevel <= 1)
			{
				Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
			}
		}
		else
		{
			PintoBoyState newState = default(PintoBoyState);
			((FastBufferReader)(ref reader)).ReadValueSafe<PintoBoyState>(ref newState, default(ForEnums));
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((PintoBoy)(object)target).SwitchStateServerRpc(newState);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_3560071642(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			PintoBoyState newState = default(PintoBoyState);
			((FastBufferReader)(ref reader)).ReadValueSafe<PintoBoyState>(ref newState, default(ForEnums));
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((PintoBoy)(object)target).SwitchStateClientRpc(newState);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

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

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

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

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

	protected internal override string __getTypeName()
	{
		return "PintoBoy";
	}
}
namespace PintoMod
{
	[BepInPlugin("Pinta.PintoBoy", "PintoBoy", "1.0.2")]
	public class Pinto_ModBase : BaseUnityPlugin
	{
		public const string MODGUID = "Pinta.PintoBoy";

		public const string MODNAME = "PintoBoy";

		public const string MODVERSION = "1.0.2";

		private readonly Harmony harmony = new Harmony("Pinta.PintoBoy");

		public ManualLogSource logger;

		public static ConfigEntry<float> config_PintoboyRarity;

		public static readonly Lazy<Pinto_ModBase> Instance = new Lazy<Pinto_ModBase>(() => new Pinto_ModBase());

		public static GameObject pintoPrefab;

		public static Item pintoGrab;

		public static GameObject spiderPrefab;

		public static GameObject slimePrefab;

		public static GameObject lootbugPrefab;

		public static Material matOffScreen;

		public static Material matOnScreen;

		public static AssetBundle pintoBundle;

		public int currentId = 0;

		private static string audioPath = "assets/pintoboy/audio/";

		private void Awake()
		{
			logger = Logger.CreateLogSource("Pinto Mod");
			ConfigSetup();
			LoadBundle();
			SetVariables();
			harmony.PatchAll(typeof(Pinto_ModBase));
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			Debug.Log((object)"Pintoboy initialized");
		}

		private void ConfigSetup()
		{
			config_PintoboyRarity = ((BaseUnityPlugin)this).Config.Bind<float>("Pintoboy Rarity", "Value", 25f, "How rare is the PintoBoy");
		}

		private void SetVariables()
		{
			//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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			pintoGrab.canBeGrabbedBeforeGameStart = true;
			pintoGrab.isScrap = true;
			pintoGrab.canBeInspected = true;
			pintoGrab.allowDroppingAheadOfPlayer = true;
			pintoGrab.rotationOffset = new Vector3(0f, 0f, 0f);
			pintoGrab.positionOffset = new Vector3(0f, 0f, 0f);
			pintoGrab.restingRotation = new Vector3(-30f, 0f, 0f);
			pintoGrab.verticalOffset = -0.1f;
			pintoGrab.requiresBattery = true;
			pintoGrab.batteryUsage = 600f;
			pintoGrab.syncInteractLRFunction = true;
			NetworkPrefabs.RegisterNetworkPrefab(spiderPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(slimePrefab);
			NetworkPrefabs.RegisterNetworkPrefab(lootbugPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(pintoGrab.spawnPrefab);
			Items.RegisterScrap(pintoGrab, (int)config_PintoboyRarity.Value, (LevelTypes)(-1));
			Debug.Log((object)("Scrapitems: " + Items.scrapItems.Count + ": " + Items.scrapItems[0].modName + " rarity:" + Items.scrapItems[0].rarity));
		}

		private void LoadBundle()
		{
			try
			{
				pintoBundle = AssetBundle.LoadFromMemory(Resources.pintobund);
				if ((Object)(object)pintoBundle == (Object)null)
				{
					throw new Exception("Failed to load Pinto Bundle!");
				}
				pintoPrefab = pintoBundle.LoadAsset<GameObject>("assets/pintoboy/pintoboy.prefab");
				if ((Object)(object)pintoPrefab == (Object)null)
				{
					throw new Exception("Failed to load Pinto Prefab!");
				}
				pintoGrab = pintoBundle.LoadAsset<Item>("assets/pintoboy/pintoboy.asset");
				if ((Object)(object)pintoGrab == (Object)null)
				{
					throw new Exception("Failed to load Pinto Item!");
				}
				PintoBoy pintoBoy = pintoGrab.spawnPrefab.AddComponent<PintoBoy>();
				if ((Object)(object)pintoBoy == (Object)null)
				{
					throw new Exception("Failed to load Pinto Boy!");
				}
				((GrabbableObject)pintoBoy).itemProperties = pintoGrab;
				GameObject val = pintoBundle.LoadAsset<GameObject>("assets/pintoboy/2d/spider/spider.prefab");
				if ((Object)(object)val == (Object)null)
				{
					throw new Exception("Failed to load Spider Prefab Object!");
				}
				val.AddComponent<JumpanyEnemy>();
				spiderPrefab = val;
				if ((Object)(object)spiderPrefab == (Object)null)
				{
					throw new Exception("Failed to load Spider Prefab!");
				}
				GameObject val2 = pintoBundle.LoadAsset<GameObject>("assets/pintoboy/2d/slime/slime.prefab");
				if ((Object)(object)val2 == (Object)null)
				{
					throw new Exception("Failed to load Slime Prefab Object!");
				}
				val2.AddComponent<JumpanyEnemy>();
				slimePrefab = val2;
				if ((Object)(object)slimePrefab == (Object)null)
				{
					throw new Exception("Failed to load Slime Prefab!");
				}
				GameObject val3 = pintoBundle.LoadAsset<GameObject>("assets/pintoboy/2d/loot bug/loot bug.prefab");
				if ((Object)(object)val3 == (Object)null)
				{
					throw new Exception("Failed to load Lootbug Prefab Object!");
				}
				val3.AddComponent<JumpanyEnemy>();
				lootbugPrefab = val3;
				if ((Object)(object)lootbugPrefab == (Object)null)
				{
					throw new Exception("Failed to load Lootbug Prefab!");
				}
				matOffScreen = pintoBundle.LoadAsset<Material>("assets/pintoboy/off screen.mat");
				if ((Object)(object)matOffScreen == (Object)null)
				{
					throw new Exception("Failed to load off screen material!");
				}
				matOnScreen = pintoBundle.LoadAsset<Material>("assets/pintoboy/Screen Mat.mat");
				if ((Object)(object)matOnScreen == (Object)null)
				{
					throw new Exception("Failed to load Screen Mat material!");
				}
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
		}

		public static AudioClip GetAudioClip(string path)
		{
			AudioClip val = pintoBundle.LoadAsset<AudioClip>(audioPath + path + ".wav");
			if ((Object)(object)val == (Object)null)
			{
				val = pintoBundle.LoadAsset<AudioClip>(audioPath + path + ".mp3");
			}
			if ((Object)(object)val == (Object)null)
			{
				throw new Exception("Failed to load Audio Clip " + path + ". Full Path: " + audioPath + path);
			}
			return val;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(RoundManager), "CollectNewScrapForThisRound")]
		public static void PintoBoyAddedToShip(GrabbableObject scrapObject)
		{
			if (scrapObject is PintoBoy)
			{
				PintoBoy pintoBoy = (PintoBoy)(object)scrapObject;
				pintoBoy.MakeScreenNOTSpawnable();
				Debug.Log((object)"PintoBoy added to ship and screen not spawned");
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Pinto Mod";

		public const string PLUGIN_NAME = "Pinto Mod";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace PintoMod.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.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)
				{
					ResourceManager resourceManager = new ResourceManager("PintoMod.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

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

		internal static byte[] pintobund
		{
			get
			{
				object @object = ResourceManager.GetObject("pintobund", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] pintobund1
		{
			get
			{
				object @object = ResourceManager.GetObject("pintobund1", resourceCulture);
				return (byte[])@object;
			}
		}

		internal Resources()
		{
		}
	}
}
namespace PintoMod.Assets.Scripts
{
	[HarmonyPatch(typeof(GrabbableObject))]
	public static class GrabbableObject_Patches
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(GrabbableObject), "Start")]
		private static void Start(GrabbableObject __instance)
		{
			if (((Object)__instance).name == "Pinto")
			{
				Debug.Log((object)"Instance is Pinto");
				PintoBoy pintoBoy = (PintoBoy)(object)__instance;
			}
		}
	}
	[HarmonyPatch]
	public class NetworkHandler
	{
		private static GameObject pintoObject;

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		private static void Init()
		{
			Debug.Log((object)"Pintoboy NetworkHandler Init starting");
			Debug.Log((object)"Pintoboy NetworkHandler Init ending");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		private static void SpawnNetworkPrefab()
		{
			try
			{
				if (!NetworkManager.Singleton.IsServer)
				{
				}
			}
			catch
			{
				Pinto_ModBase.Instance.Value.logger.LogError((object)"Failed to instantiate network prefab!");
			}
		}
	}
}
namespace Pinto Mod.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}

plugins/Scopophobia/Scopophobia.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Scopophobia;
using Scopophobia.NetcodePatcher;
using Scopophobia.Patches;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Scopophobia")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Adds the Shy Guy (SCP-096) to Lethal Company. Fully custom animations and behavior. Model from SCP: Containment Breach..")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1")]
[assembly: AssemblyProduct("Scopophobia")]
[assembly: AssemblyTitle("Scopophobia")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[Serializable]
public class SyncedInstance<T>
{
	[NonSerialized]
	protected static int IntSize = 4;

	internal static CustomMessagingManager MessageManager => NetworkManager.Singleton.CustomMessagingManager;

	internal static bool IsClient => NetworkManager.Singleton.IsClient;

	internal static bool IsHost => NetworkManager.Singleton.IsHost;

	public static T Default { get; private set; }

	public static T Instance { get; private set; }

	public static bool Synced { get; internal set; }

	protected void InitInstance(T instance)
	{
		Default = instance;
		Instance = instance;
		IntSize = 4;
	}

	internal static void SyncInstance(byte[] data)
	{
		Instance = DeserializeFromBytes(data);
		Synced = true;
	}

	internal static void RevertSync()
	{
		Instance = Default;
		Synced = false;
	}

	public static byte[] SerializeToBytes(T val)
	{
		BinaryFormatter binaryFormatter = new BinaryFormatter();
		using MemoryStream memoryStream = new MemoryStream();
		try
		{
			binaryFormatter.Serialize(memoryStream, val);
			return memoryStream.ToArray();
		}
		catch (Exception arg)
		{
			Plugin.logger.LogError((object)$"Error serializing instance: {arg}");
			return null;
		}
	}

	public static T DeserializeFromBytes(byte[] data)
	{
		BinaryFormatter binaryFormatter = new BinaryFormatter();
		using MemoryStream serializationStream = new MemoryStream(data);
		try
		{
			return (T)binaryFormatter.Deserialize(serializationStream);
		}
		catch (Exception arg)
		{
			Plugin.logger.LogError((object)$"Error deserializing instance: {arg}");
			return default(T);
		}
	}
}
namespace ShyGuy.AI
{
	public class ShyGuyAI : EnemyAI
	{
		private Transform localPlayerCamera;

		private Vector3 mainEntrancePosition;

		public Collider mainCollider;

		public AudioSource farAudio;

		public AudioSource footstepSource;

		public AudioClip screamSFX;

		public AudioClip panicSFX;

		public AudioClip crySFX;

		public AudioClip crySittingSFX;

		public AudioClip killPlayerSFX;

		[Header("Containment Breach Sounds")]
		public AudioClip screamSFX_CB;

		public AudioClip panicSFX_CB;

		public AudioClip crySFX_CB;

		public AudioClip killPlayerSFX_CB;

		[Header("Alpha Containment Breach Sounds")]
		public AudioClip screamSFX_ACB;

		public AudioClip panicSFX_ACB;

		public AudioClip crySFX_ACB;

		public AudioClip killPlayerSFX_ACB;

		[Header("Secret Laboratory Sounds")]
		public AudioClip screamSFX_SL;

		public AudioClip panicSFX_SL;

		public AudioClip crySFX_SL;

		public AudioClip killPlayerSFX_SL;

		public Material bloodyMaterial;

		public AISearchRoutine roamMap;

		public Transform shyGuyFace;

		private Vector3 spawnPosition;

		private Vector3 previousPosition;

		private int previousState = -1;

		private float roamWaitTime = 40f;

		private bool roamShouldSit;

		private bool sitting;

		private float lastRunSpeed;

		private float seeFaceTime;

		private float triggerTime;

		private float triggerDuration = 66.4f;

		private float timeToTrigger = 0.5f;

		private float lastInterval = Time.realtimeSinceStartup;

		private bool inKillAnimation;

		public List<PlayerControllerB> SCP096Targets = new List<PlayerControllerB>();

		public override void Start()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Expected O, but got Unknown
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: 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_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0428: Expected O, but got Unknown
			((EnemyAI)this).Start();
			triggerDuration = Config.triggerTime;
			Transform val = null;
			Queue<Transform> queue = new Queue<Transform>();
			queue.Enqueue(((Component)this).transform);
			while (queue.Count > 0)
			{
				Transform val2 = queue.Dequeue();
				if (((Object)val2).name == "lefteye")
				{
					val = val2;
					break;
				}
				foreach (Transform item3 in val2)
				{
					Transform item = item3;
					queue.Enqueue(item);
				}
			}
			Transform val3 = null;
			queue = new Queue<Transform>();
			queue.Enqueue(((Component)this).transform);
			while (queue.Count > 0)
			{
				Transform val4 = queue.Dequeue();
				if (((Object)val4).name == "righteye")
				{
					val3 = val4;
					break;
				}
				foreach (Transform item4 in val4)
				{
					Transform item2 = item4;
					queue.Enqueue(item2);
				}
			}
			if (!Config.hasGlowingEyes && (Object)(object)val != (Object)null && (Object)(object)val3 != (Object)null)
			{
				((Component)val).gameObject.SetActive(false);
				((Component)val3).gameObject.SetActive(false);
			}
			if (Config.bloodyTexture && (Object)(object)bloodyMaterial != (Object)null)
			{
				Transform val5 = ((Component)this).transform.Find("SCP096Model");
				if ((Object)(object)val5 != (Object)null)
				{
					Transform val6 = val5.Find("tsg_placeholder");
					if ((Object)(object)val6 != (Object)null)
					{
						SkinnedMeshRenderer component = ((Component)val6).GetComponent<SkinnedMeshRenderer>();
						if ((Object)(object)component != (Object)null)
						{
							((Renderer)component).material = bloodyMaterial;
						}
					}
				}
			}
			switch (Config.soundPack)
			{
			case "SCPCB":
				screamSFX = screamSFX_CB;
				crySFX = crySFX_CB;
				crySittingSFX = crySFX_CB;
				panicSFX = panicSFX_CB;
				killPlayerSFX = killPlayerSFX_CB;
				break;
			case "SCPCBOld":
				screamSFX = screamSFX_ACB;
				crySFX = crySFX_ACB;
				crySittingSFX = crySFX_ACB;
				panicSFX = panicSFX_ACB;
				killPlayerSFX = killPlayerSFX_ACB;
				break;
			case "SecretLab":
				screamSFX = screamSFX_SL;
				crySFX = crySFX_SL;
				crySittingSFX = crySFX_SL;
				panicSFX = panicSFX_SL;
				killPlayerSFX = killPlayerSFX_SL;
				break;
			}
			localPlayerCamera = ((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).transform;
			spawnPosition = ((Component)this).transform.position;
			base.isOutside = ((Component)this).transform.position.y > -80f;
			mainEntrancePosition = RoundManager.Instance.GetNavMeshPosition(RoundManager.FindMainEntrancePosition(true, base.isOutside), default(NavMeshHit), 5f, -1);
			if (base.isOutside)
			{
				if (base.allAINodes == null || base.allAINodes.Length == 0)
				{
					base.allAINodes = GameObject.FindGameObjectsWithTag("OutsideAINode");
				}
				if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
				{
					((EnemyAI)this).EnableEnemyMesh(!StartOfRound.Instance.hangarDoorsClosed || !GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom, false);
				}
			}
			else if (base.allAINodes == null || base.allAINodes.Length == 0)
			{
				base.allAINodes = GameObject.FindGameObjectsWithTag("AINode");
			}
			base.path1 = new NavMeshPath();
			base.openDoorSpeedMultiplier = 450f;
			SetShyGuyInitialValues();
		}

		private void CalculateAnimationSpeed()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Component)this).transform.position - previousPosition;
			float num = ((Vector3)(ref val)).magnitude;
			if (num > 0f)
			{
				num = 1f;
			}
			lastRunSpeed = Mathf.Lerp(lastRunSpeed, num, 5f * Time.deltaTime);
			base.creatureAnimator.SetFloat("VelocityZ", lastRunSpeed);
			previousPosition = ((Component)this).transform.position;
		}

		public override void DoAIInterval()
		{
			//IL_05c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_051d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0528: Unknown result type (might be due to invalid IL or missing references)
			//IL_0544: Unknown result type (might be due to invalid IL or missing references)
			//IL_054f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0554: Unknown result type (might be due to invalid IL or missing references)
			//IL_0652: Unknown result type (might be due to invalid IL or missing references)
			//IL_0658: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_067b: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			if (StartOfRound.Instance.livingPlayers == 0)
			{
				lastInterval = Time.realtimeSinceStartup;
				return;
			}
			if (base.isEnemyDead)
			{
				lastInterval = Time.realtimeSinceStartup;
				return;
			}
			if (!((NetworkBehaviour)this).IsServer && ((NetworkBehaviour)this).IsOwner && base.currentBehaviourStateIndex != 2)
			{
				((EnemyAI)this).ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
			{
				if (base.stunNormalizedTimer > 0f)
				{
					base.agent.speed = 0f;
				}
				else if (sitting)
				{
					base.agent.speed = 0f;
				}
				else
				{
					roamWaitTime -= Time.realtimeSinceStartup - lastInterval;
					base.openDoorSpeedMultiplier = 1f;
					base.agent.speed = 2.75f * Config.speedDocileMultiplier;
				}
				base.movingTowardsTargetPlayer = false;
				base.agent.stoppingDistance = 4f;
				base.addPlayerVelocityToDestination = 0f;
				PlayerControllerB targetPlayer2 = base.targetPlayer;
				if (roamWaitTime <= 20f && roamMap.inProgress && (Object)(object)base.targetPlayer == (Object)null)
				{
					((EnemyAI)this).StopSearch(roamMap, true);
					lastInterval = Time.realtimeSinceStartup;
				}
				else if (roamWaitTime > 2.5f && roamWaitTime <= 15f && !roamMap.inProgress && (Object)(object)base.targetPlayer == (Object)null && roamShouldSit)
				{
					sitting = true;
					base.creatureAnimator.SetBool("Sitting", true);
					float time = base.creatureVoice.time;
					base.creatureVoice.volume = 0.3f;
					base.creatureVoice.clip = crySittingSFX;
					base.creatureVoice.Play();
					base.creatureVoice.time = time;
					lastInterval = Time.realtimeSinceStartup;
				}
				else if (!((Object)(object)base.targetPlayer != (Object)null) && (Object)(object)base.targetPlayer == (Object)null && !roamMap.inProgress && roamWaitTime <= 0f)
				{
					if (!sitting)
					{
						roamShouldSit = Random.Range(1, 5) == 1;
						roamWaitTime = Random.Range(25f, 32.5f);
						((EnemyAI)this).StartSearch(spawnPosition, roamMap);
						lastInterval = Time.realtimeSinceStartup;
						break;
					}
					sitting = false;
					roamShouldSit = false;
					roamWaitTime = Random.Range(21f, 25f);
					base.creatureAnimator.SetBool("Sitting", false);
					float time2 = base.creatureVoice.time;
					base.creatureVoice.volume = 0.3f;
					base.creatureVoice.clip = crySFX;
					base.creatureVoice.Play();
					base.creatureVoice.time = time2;
					lastInterval = Time.realtimeSinceStartup;
				}
				break;
			}
			case 1:
				base.agent.speed = 0f;
				lastInterval = Time.realtimeSinceStartup;
				base.movingTowardsTargetPlayer = false;
				break;
			case 2:
			{
				base.agent.stoppingDistance = 0f;
				base.agent.avoidancePriority = 60;
				base.openDoorSpeedMultiplier = 450f;
				mainCollider.isTrigger = true;
				base.addPlayerVelocityToDestination = 1f;
				if (inKillAnimation)
				{
					base.agent.speed = 0f;
				}
				else
				{
					base.agent.speed = Mathf.Clamp(base.agent.speed + (Time.realtimeSinceStartup - lastInterval) * Config.speedRageMultiplier * 1.1f, 5f * Config.speedRageMultiplier, 14.75f * Config.speedRageMultiplier);
				}
				if (SCP096Targets.Count <= 0)
				{
					SitDown();
					break;
				}
				PlayerControllerB targetPlayer = base.targetPlayer;
				float num = float.PositiveInfinity;
				foreach (PlayerControllerB sCP096Target in SCP096Targets)
				{
					bool flag = sCP096Target.isInsideFactory == !base.isOutside;
					bool flag2 = true;
					if (!Config.canExitFacility && !flag)
					{
						flag2 = false;
					}
					if (!sCP096Target.isPlayerDead && flag2)
					{
						if (((EnemyAI)this).PlayerIsTargetable(sCP096Target, false, true) && Vector3.Distance(((Component)sCP096Target).transform.position, ((Component)this).transform.position) < num)
						{
							num = Vector3.Magnitude(((Component)sCP096Target).transform.position - ((Component)this).transform.position);
							base.targetPlayer = sCP096Target;
						}
					}
					else
					{
						AddTargetToList((int)sCP096Target.actualClientId, remove: true);
					}
				}
				if ((Object)(object)base.targetPlayer != (Object)null)
				{
					base.creatureAnimator.SetFloat("DistanceToTarget", Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position));
					if (roamMap.inProgress)
					{
						((EnemyAI)this).StopSearch(roamMap, true);
					}
					if ((Object)(object)base.targetPlayer != (Object)(object)targetPlayer)
					{
						((EnemyAI)this).ChangeOwnershipOfEnemy(base.targetPlayer.actualClientId);
					}
					if (base.targetPlayer.isInsideFactory != !base.isOutside)
					{
						if (Vector3.Distance(((Component)this).transform.position, mainEntrancePosition) < 2f)
						{
							TeleportEnemy(RoundManager.FindMainEntrancePosition(true, !base.isOutside), !base.isOutside);
							base.agent.speed = 0f;
						}
						else
						{
							base.movingTowardsTargetPlayer = false;
							((EnemyAI)this).SetDestinationToPosition(mainEntrancePosition, false);
						}
					}
					else
					{
						((EnemyAI)this).SetMovingTowardsTargetPlayer(base.targetPlayer);
					}
				}
				else if (SCP096Targets.Count <= 0)
				{
					SitDown();
				}
				break;
			}
			default:
				lastInterval = Time.realtimeSinceStartup;
				break;
			}
		}

		public void TeleportEnemy(Vector3 pos, bool setOutside)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_0058: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(pos, default(NavMeshHit), 5f, -1);
			if (((NetworkBehaviour)this).IsOwner)
			{
				((Behaviour)base.agent).enabled = false;
				((Component)this).transform.position = navMeshPosition;
				((Behaviour)base.agent).enabled = true;
			}
			else
			{
				((Component)this).transform.position = navMeshPosition;
			}
			base.serverPosition = navMeshPosition;
			SetEnemyOutside(setOutside);
			EntranceTeleport val = RoundManager.FindMainEntranceScript(setOutside);
			if (val.doorAudios != null && val.doorAudios.Length != 0)
			{
				val.entrancePointAudio.PlayOneShot(val.doorAudios[0]);
				WalkieTalkie.TransmitOneShotAudio(val.entrancePointAudio, val.doorAudios[0], 1f);
			}
		}

		public override void Update()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: 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)
			if (base.isEnemyDead || (Object)(object)GameNetworkManager.Instance == (Object)null)
			{
				return;
			}
			CalculateAnimationSpeed();
			bool flag = GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(shyGuyFace.position, Config.faceTriggerRange, 45, -1f);
			if (flag)
			{
				float num = Quaternion.Angle(((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).transform.rotation, shyGuyFace.rotation);
				if (!(num <= 145f))
				{
					flag = false;
				}
			}
			if (flag)
			{
				seeFaceTime += Time.deltaTime;
				if (seeFaceTime >= Config.faceTriggerGracePeriod)
				{
					GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(1.25f, true);
					if (!Config.hasMaxTargets || SCP096Targets.Count < Config.maxTargets)
					{
						AddTargetToList((int)GameNetworkManager.Instance.localPlayerController.playerClientId);
					}
					if (base.currentBehaviourStateIndex == 0)
					{
						((EnemyAI)this).SwitchToBehaviourState(1);
					}
				}
			}
			else
			{
				seeFaceTime = Mathf.Clamp(seeFaceTime - Time.deltaTime, 0f, timeToTrigger);
				if (GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 1f, 30f, 60, -1f) && base.currentBehaviourStateIndex == 0)
				{
					if (!base.thisNetworkObject.IsOwner)
					{
						((EnemyAI)this).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
					}
					if (Vector3.Distance(((Component)this).transform.position, ((Component)GameNetworkManager.Instance.localPlayerController).transform.position) < 10f)
					{
						GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(0.65f, true);
					}
					else
					{
						GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(0.25f, true);
					}
				}
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				if (previousState != 0)
				{
					SetShyGuyInitialValues();
					previousState = 0;
					mainCollider.isTrigger = true;
					farAudio.volume = 0f;
					base.creatureVoice.volume = 0.3f;
					base.creatureVoice.clip = crySFX;
					base.creatureVoice.Play();
				}
				if (!base.creatureVoice.isPlaying)
				{
					base.creatureVoice.volume = 0.3f;
					base.creatureVoice.clip = crySFX;
					base.creatureVoice.Play();
				}
				break;
			case 1:
				if (previousState != 1)
				{
					previousState = 1;
					sitting = false;
					mainCollider.isTrigger = true;
					base.creatureAnimator.SetBool("Rage", false);
					base.creatureAnimator.SetBool("Sitting", false);
					base.creatureAnimator.SetBool("triggered", true);
					base.creatureVoice.Stop();
					farAudio.volume = 0.275f;
					farAudio.PlayOneShot(panicSFX);
					base.agent.speed = 0f;
					triggerTime = triggerDuration;
				}
				triggerTime -= Time.deltaTime;
				if (triggerTime <= 0f)
				{
					((EnemyAI)this).SwitchToBehaviourState(2);
				}
				break;
			case 2:
				mainCollider.isTrigger = true;
				if (previousState != 2)
				{
					mainCollider.isTrigger = true;
					previousState = 2;
					base.creatureAnimator.SetBool("Rage", true);
					base.creatureAnimator.SetBool("triggered", false);
					farAudio.Stop();
					farAudio.volume = 0.4f;
					farAudio.clip = screamSFX;
					farAudio.Play();
				}
				break;
			}
			((EnemyAI)this).Update();
		}

		public void SetEnemyOutside(bool outside = false)
		{
			//IL_0010: 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_001d: 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)
			base.isOutside = outside;
			mainEntrancePosition = RoundManager.Instance.GetNavMeshPosition(RoundManager.FindMainEntrancePosition(true, outside), default(NavMeshHit), 5f, -1);
			if (outside)
			{
				base.allAINodes = GameObject.FindGameObjectsWithTag("OutsideAINode");
			}
			else
			{
				base.allAINodes = GameObject.FindGameObjectsWithTag("AINode");
			}
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			if (!Object.op_Implicit((Object)(object)((Component)other).gameObject.GetComponent<PlayerControllerB>()))
			{
				return;
			}
			((EnemyAI)this).OnCollideWithPlayer(other);
			if (!inKillAnimation && !base.isEnemyDead && base.currentBehaviourStateIndex == 2)
			{
				PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
				if ((Object)(object)val != (Object)null)
				{
					inKillAnimation = true;
					((MonoBehaviour)this).StartCoroutine(killPlayerAnimation((int)val.playerClientId));
					KillPlayerServerRpc((int)val.playerClientId);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void KillPlayerServerRpc(int playerId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2556963367u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2556963367u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					KillPlayerClientRpc(playerId);
				}
			}
		}

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

		private IEnumerator killPlayerAnimation(int playerId)
		{
			inKillAnimation = true;
			PlayerControllerB playerScript = StartOfRound.Instance.allPlayerScripts[playerId];
			if (base.isOutside && ((Component)this).transform.position.y < -80f)
			{
				SetEnemyOutside();
			}
			else if (!base.isOutside && ((Component)this).transform.position.y > -80f)
			{
				SetEnemyOutside(outside: true);
			}
			int preAmount = SCP096Targets.Count;
			playerScript.KillPlayer(Vector3.zero, true, (CauseOfDeath)6, 0);
			AddTargetToList(playerId, remove: true);
			base.creatureSFX.PlayOneShot(killPlayerSFX);
			base.creatureAnimator.SetInteger("TargetsLeft", preAmount - 1);
			base.creatureAnimator.SetTrigger("kill");
			if (preAmount - 1 <= 0)
			{
				SitDown();
			}
			if (Config.deathMakesBloody && (Object)(object)bloodyMaterial != (Object)null)
			{
				Transform model = ((Component)this).transform.Find("SCP096Model");
				if ((Object)(object)model != (Object)null)
				{
					Transform modelMesh = model.Find("tsg_placeholder");
					if ((Object)(object)modelMesh != (Object)null)
					{
						SkinnedMeshRenderer skinnedModel = ((Component)modelMesh).GetComponent<SkinnedMeshRenderer>();
						if ((Object)(object)skinnedModel != (Object)null)
						{
							((Renderer)skinnedModel).material = bloodyMaterial;
						}
					}
				}
			}
			yield return (object)new WaitForSeconds(1f);
			inKillAnimation = false;
		}

		public void SitDown()
		{
			((EnemyAI)this).SwitchToBehaviourState(0);
			SitDownOnLocalClient();
			SitDownServerRpc();
		}

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

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

		public void SitDownOnLocalClient()
		{
			sitting = true;
			roamWaitTime = Random.Range(45f, 50f);
			base.creatureAnimator.SetBool("Rage", false);
			base.creatureAnimator.SetBool("Sitting", true);
		}

		public void AddTargetToList(int playerId, bool remove = false)
		{
			PlayerControllerB item = StartOfRound.Instance.allPlayerScripts[playerId];
			if (remove)
			{
				if (!SCP096Targets.Contains(item))
				{
					return;
				}
			}
			else if (SCP096Targets.Contains(item))
			{
				return;
			}
			AddTargetToListOnLocalClient(playerId, remove);
			AddTargetToListServerRpc(playerId, remove);
		}

		[ServerRpc(RequireOwnership = false)]
		public void AddTargetToListServerRpc(int playerId, bool remove)
		{
			//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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1207108010u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref remove, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1207108010u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					AddTargetToListClientRpc(playerId, remove);
				}
			}
		}

		[ClientRpc]
		public void AddTargetToListClientRpc(int playerId, bool remove)
		{
			//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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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(1413965488u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref remove, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1413965488u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					AddTargetToListOnLocalClient(playerId, remove);
				}
			}
		}

		public void AddTargetToListOnLocalClient(int playerId, bool remove)
		{
			PlayerControllerB item = StartOfRound.Instance.allPlayerScripts[playerId];
			if (remove)
			{
				if (SCP096Targets.Contains(item))
				{
					SCP096Targets.Remove(item);
				}
			}
			else if (!SCP096Targets.Contains(item))
			{
				SCP096Targets.Add(item);
			}
		}

		private void SetShyGuyInitialValues()
		{
			mainCollider = ((Component)this).gameObject.GetComponentInChildren<Collider>();
			farAudio = ((Component)((Component)this).transform.Find("FarAudio")).GetComponent<AudioSource>();
			base.targetPlayer = null;
			inKillAnimation = false;
			SCP096Targets.Clear();
			base.creatureAnimator.SetFloat("VelocityX", 0f);
			base.creatureAnimator.SetFloat("VelocityZ", 0f);
			base.creatureAnimator.SetFloat("DistanceToTarget", 999f);
			base.creatureAnimator.SetInteger("SitActionTimer", 0);
			base.creatureAnimator.SetInteger("TargetsLeft", 0);
			base.creatureAnimator.SetBool("Rage", false);
			base.creatureAnimator.SetBool("Sitting", false);
			base.creatureAnimator.SetBool("triggered", false);
			mainCollider.isTrigger = true;
			farAudio.volume = 0f;
			farAudio.Stop();
			base.creatureVoice.Stop();
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_ShyGuyAI()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2556963367u, new RpcReceiveHandler(__rpc_handler_2556963367));
			NetworkManager.__rpc_func_table.Add(2298532976u, new RpcReceiveHandler(__rpc_handler_2298532976));
			NetworkManager.__rpc_func_table.Add(652446748u, new RpcReceiveHandler(__rpc_handler_652446748));
			NetworkManager.__rpc_func_table.Add(2536632143u, new RpcReceiveHandler(__rpc_handler_2536632143));
			NetworkManager.__rpc_func_table.Add(1207108010u, new RpcReceiveHandler(__rpc_handler_1207108010));
			NetworkManager.__rpc_func_table.Add(1413965488u, new RpcReceiveHandler(__rpc_handler_1413965488));
		}

		private static void __rpc_handler_2556963367(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ShyGuyAI)(object)target).KillPlayerServerRpc(playerId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2298532976(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ShyGuyAI)(object)target).KillPlayerClientRpc(playerId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

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

		private static void __rpc_handler_1207108010(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				bool remove = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref remove, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ShyGuyAI)(object)target).AddTargetToListServerRpc(playerId, remove);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1413965488(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				bool remove = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref remove, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ShyGuyAI)(object)target).AddTargetToListClientRpc(playerId, remove);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "ShyGuyAI";
		}
	}
}
namespace Scopophobia
{
	[Serializable]
	public class Config : SyncedInstance<Config>
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__OnRequestSync;

			public static HandleNamedMessageDelegate <1>__OnReceiveSync;
		}

		public static ConfigEntry<bool> AppearsConfig;

		public static ConfigEntry<bool> HasGlowingEyesConfig;

		public static ConfigEntry<string> SoundPackConfig;

		public static ConfigEntry<bool> BloodyTextureConfig;

		public static ConfigEntry<bool> DeathMakesBloodyConfig;

		public static ConfigEntry<float> SpeedDocileMultiplierConfig;

		public static ConfigEntry<float> SpeedRageMultiplierConfig;

		public static ConfigEntry<int> SpawnRarityConfig;

		public static ConfigEntry<float> TriggerTimeConfig;

		public static ConfigEntry<float> FaceTriggerRangeConfig;

		public static ConfigEntry<float> FaceTriggerGracePeriodConfig;

		public static ConfigEntry<bool> HasMaxTargetsConfig;

		public static ConfigEntry<int> MaxTargetsConfig;

		public static ConfigEntry<bool> CanExitFacilityConfig;

		public static ConfigEntry<int> MaxSpawnCountConfig;

		public static ConfigEntry<bool> CanSpawnOutsideConfig;

		public static ConfigEntry<bool> SpawnOutsideHardPlanetsConfig;

		public static ConfigEntry<float> StartEnemySpawnCurveConfig;

		public static ConfigEntry<float> MidEnemySpawnCurveConfig;

		public static ConfigEntry<float> EndEnemySpawnCurveConfig;

		public static bool appears;

		public static bool hasGlowingEyes;

		public static string soundPack;

		public static bool bloodyTexture;

		public static bool deathMakesBloody;

		public static float speedDocileMultiplier;

		public static float speedRageMultiplier;

		public static int spawnRarity;

		public static float triggerTime;

		public static float faceTriggerRange;

		public static float faceTriggerGracePeriod;

		public static bool hasMaxTargets;

		public static int maxTargets;

		public static bool canExitFacility;

		public static bool canSpawnOutside;

		public static int maxSpawnCount;

		public static bool spawnsOutside;

		public static bool spawnOutsideHardPlanets;

		public static float startEnemySpawnCurve;

		public static float midEnemySpawnCurve;

		public static float endEnemySpawnCurve;

		public Config(ConfigFile cfg)
		{
			InitInstance(this);
			AppearsConfig = cfg.Bind<bool>("General", "Enable the Shy Guy", true, "Allows the Shy Guy to spawn in-game.");
			HasGlowingEyesConfig = cfg.Bind<bool>("Appearance", "Glowing Eyes", true, "Gives the Shy Guy glowing eyes similar to the Bracken/Flowerman.");
			BloodyTextureConfig = cfg.Bind<bool>("Appearance", "Bloody Texture", false, "Gives the Shy Guy his bloodier, original texture from SCP: Containment Breach.");
			DeathMakesBloodyConfig = cfg.Bind<bool>("Appearance", "Bloody Death", true, "Causes the Shy Guy's material to become bloody once getting his first kill. Useless if Bloody Texture is enabled lol");
			SoundPackConfig = cfg.Bind<string>("Appearance", "Sound Pack (Curated, SCPCB, SCPCBOld, SecretLab)", "Curated", "Determines the sounds the Shy Guy uses. (SOME MAY NOT SYNC WELL WITH TRIGGER TIME) (Curated = Default, curated for the Lethal Company experience) (SCPCB = SCP-096 sounds from SCP: Containment Breach) (SCPCBOld = Old alpha SCP-096 sounds from SCP: Containment Breach) (SecretLab = SCP-096 sounds from SCP: Secret Laboratory)");
			SpeedDocileMultiplierConfig = cfg.Bind<float>("Values", "Speed Multiplier (Docile)", 1f, "Determines the speed multiplier of the Shy Guy while docile.");
			SpeedRageMultiplierConfig = cfg.Bind<float>("Values", "Speed Multiplier (Rage)", 1f, "Determines the speed multiplier of the Shy Guy while enraged.");
			SpawnRarityConfig = cfg.Bind<int>("Values", "Spawn Rarity", 15, "Determines the spawn weight of the Shy Guy. Higher weights mean the Shy Guy is more likely appear. (just dont set this astronomically high)");
			TriggerTimeConfig = cfg.Bind<float>("Values.Triggering", "Trigger Time", 66.4f, "Determines how long the Shy Guy must remain in the Triggered state to become fully enraged.");
			FaceTriggerRangeConfig = cfg.Bind<float>("Values.Triggering", "Face Trigger Range", 17.5f, "Determines the face's trigger radius.");
			FaceTriggerGracePeriodConfig = cfg.Bind<float>("Values.Triggering", "Face Trigger Grace Period", 0.5f, "Determines the grace period when you see the face of the Shy Guy before he becomes enraged.");
			HasMaxTargetsConfig = cfg.Bind<bool>("Values.Triggering", "Has Max Targets", false, "Determines if the Shy Guy has a maximum amount of targets.");
			MaxTargetsConfig = cfg.Bind<int>("Values.Triggering", "Max Targets", 32, "Determines the max amount of targets the Shy Guy can have. (requires HasMaxTargets)");
			CanExitFacilityConfig = cfg.Bind<bool>("Values.Triggering", "Can Exit Facility", true, "Determines if the Shy Guy can exit the facility and into the outdoors (and vice versa) to attack its target.");
			MaxSpawnCountConfig = cfg.Bind<int>("Values.Spawning", "Max Spawn Count", 1, "Determines how many Shy Guy can spawn total.");
			CanSpawnOutsideConfig = cfg.Bind<bool>("Values.Spawning", "Can Spawn Outside", true, "Determines if the Shy Guy can spawn outside. ");
			SpawnOutsideHardPlanetsConfig = cfg.Bind<bool>("Values.Spawning", "Spawn Outside Only Hard Moons", true, "If set to true, the Shy Guy will only spawn outside on the highest-difficulty/modded moons.");
			StartEnemySpawnCurveConfig = cfg.Bind<float>("Values.Spawning", "Start Spawn Curve", 0.2f, "Spawn curve for the Shy Guy when the day starts. (typically 0-1)");
			MidEnemySpawnCurveConfig = cfg.Bind<float>("Values.Spawning", "Midday Spawn Curve", 1f, "Spawn curve for the Shy Guy midday. (typically 0-1)");
			EndEnemySpawnCurveConfig = cfg.Bind<float>("Values.Spawning", "End of Day Spawn Curve", 0.75f, "Spawn curve for the Shy Guy at the end of day. (typically 0-1)");
			appears = AppearsConfig.Value;
			hasGlowingEyes = HasGlowingEyesConfig.Value;
			bloodyTexture = BloodyTextureConfig.Value;
			deathMakesBloody = DeathMakesBloodyConfig.Value;
			soundPack = SoundPackConfig.Value;
			speedDocileMultiplier = SpeedDocileMultiplierConfig.Value;
			speedRageMultiplier = SpeedRageMultiplierConfig.Value;
			spawnRarity = SpawnRarityConfig.Value;
			triggerTime = TriggerTimeConfig.Value;
			faceTriggerRange = FaceTriggerRangeConfig.Value;
			faceTriggerGracePeriod = FaceTriggerGracePeriodConfig.Value;
			hasMaxTargets = HasMaxTargetsConfig.Value;
			maxTargets = MaxTargetsConfig.Value;
			canExitFacility = CanExitFacilityConfig.Value;
			maxSpawnCount = MaxSpawnCountConfig.Value;
			canSpawnOutside = CanSpawnOutsideConfig.Value;
			spawnOutsideHardPlanets = SpawnOutsideHardPlanetsConfig.Value;
			startEnemySpawnCurve = StartEnemySpawnCurveConfig.Value;
			midEnemySpawnCurve = MidEnemySpawnCurveConfig.Value;
			endEnemySpawnCurve = EndEnemySpawnCurveConfig.Value;
		}

		public static void RequestSync()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (!SyncedInstance<Config>.IsClient)
			{
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(SyncedInstance<Config>.IntSize, (Allocator)2, -1);
			try
			{
				SyncedInstance<Config>.MessageManager.SendNamedMessage("Scopophobia_OnRequestConfigSync", 0uL, val, (NetworkDelivery)3);
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		public static void OnRequestSync(ulong clientId, FastBufferReader _)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			if (!SyncedInstance<Config>.IsHost)
			{
				return;
			}
			Plugin.logger.LogInfo((object)$"Config sync request received from client: {clientId}");
			byte[] array = SyncedInstance<Config>.SerializeToBytes(SyncedInstance<Config>.Instance);
			int num = array.Length;
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(num + SyncedInstance<Config>.IntSize, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteBytesSafe(array, -1, 0);
				SyncedInstance<Config>.MessageManager.SendNamedMessage("Scopophobia_OnReceiveConfigSync", clientId, val, (NetworkDelivery)3);
			}
			catch (Exception arg)
			{
				Plugin.logger.LogInfo((object)$"Error occurred syncing config with client: {clientId}\n{arg}");
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		public static void OnReceiveSync(ulong _, FastBufferReader reader)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if (!((FastBufferReader)(ref reader)).TryBeginRead(SyncedInstance<Config>.IntSize))
			{
				Plugin.logger.LogError((object)"Config sync error: Could not begin reading buffer.");
				return;
			}
			int num = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
			if (!((FastBufferReader)(ref reader)).TryBeginRead(num))
			{
				Plugin.logger.LogError((object)"Config sync error: Host could not sync.");
				return;
			}
			byte[] data = new byte[num];
			((FastBufferReader)(ref reader)).ReadBytesSafe(ref data, num, 0);
			SyncedInstance<Config>.SyncInstance(data);
			Plugin.logger.LogInfo((object)"Successfully synced config with host.");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		public static void InitializeLocalPlayer()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//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_0030: Expected O, but got Unknown
			if (SyncedInstance<Config>.IsHost)
			{
				CustomMessagingManager messageManager = SyncedInstance<Config>.MessageManager;
				object obj = <>O.<0>__OnRequestSync;
				if (obj == null)
				{
					HandleNamedMessageDelegate val = OnRequestSync;
					<>O.<0>__OnRequestSync = val;
					obj = (object)val;
				}
				messageManager.RegisterNamedMessageHandler("Scopophobia_OnRequestConfigSync", (HandleNamedMessageDelegate)obj);
				SyncedInstance<Config>.Synced = true;
				return;
			}
			SyncedInstance<Config>.Synced = false;
			CustomMessagingManager messageManager2 = SyncedInstance<Config>.MessageManager;
			object obj2 = <>O.<1>__OnReceiveSync;
			if (obj2 == null)
			{
				HandleNamedMessageDelegate val2 = OnReceiveSync;
				<>O.<1>__OnReceiveSync = val2;
				obj2 = (object)val2;
			}
			messageManager2.RegisterNamedMessageHandler("Scopophobia_OnReceiveConfigSync", (HandleNamedMessageDelegate)obj2);
			RequestSync();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")]
		public static void PlayerLeave()
		{
			SyncedInstance<Config>.RevertSync();
		}
	}
	[BepInPlugin("Scopophobia", "Scopophobia", "1.1.1")]
	public class ScopophobiaPlugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("Scopophobia");

		public static EnemyType shyGuy;

		public static AssetBundle Assets;

		public static bool spawnsOutside;

		public static SpawnableEnemyWithRarity maskedPrefab;

		public static ManualLogSource logger;

		public static SpawnableEnemyWithRarity shyPrefab;

		public static Config MyConfig { get; internal set; }

		internal Assembly assembly => Assembly.GetExecutingAssembly();

		internal string GetFilePath(string path)
		{
			return assembly.Location.Replace(assembly.GetName().Name + ".dll", path);
		}

		private void LoadAssets()
		{
			try
			{
				Assets = AssetBundle.LoadFromFile(GetFilePath("scp096"));
			}
			catch (Exception arg)
			{
				logger.LogError((object)$"Failed to load asset bundle! {arg}");
			}
		}

		private void Awake()
		{
			harmony.PatchAll(typeof(Config));
			LoadAssets();
			logger = ((BaseUnityPlugin)this).Logger;
			MyConfig = new Config(((BaseUnityPlugin)this).Config);
			ConfigEntry<bool> val = default(ConfigEntry<bool>);
			((BaseUnityPlugin)this).Config.TryGetEntry<bool>("General", "Enable the Shy Guy", ref val);
			if (!val.Value)
			{
				return;
			}
			ConfigEntry<int> val2 = default(ConfigEntry<int>);
			((BaseUnityPlugin)this).Config.TryGetEntry<int>("Values", "Spawn Rarity", ref val2);
			int num = val2?.Value ?? 15;
			shyGuy = Assets.LoadAsset<EnemyType>("ShyGuyDef.asset");
			TerminalNode val3 = Assets.LoadAsset<TerminalNode>("ShyGuyTerminal.asset");
			TerminalKeyword val4 = Assets.LoadAsset<TerminalKeyword>("ShyGuyKeyword.asset");
			NetworkPrefabs.RegisterNetworkPrefab(shyGuy.enemyPrefab);
			Enemies.RegisterEnemy(shyGuy, num, (LevelTypes)(-1), (SpawnType)0, val3, val4);
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			logger.LogInfo((object)"Scopophobia | SCP-096 has entered the facility. All remaining personnel proceed with caution.");
			harmony.PatchAll(typeof(Plugin));
			harmony.PatchAll(typeof(GetShyGuyPrefabForLaterUse));
			harmony.PatchAll(typeof(ShyGuySpawnSettings));
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Scopophobia";

		public const string PLUGIN_NAME = "Scopophobia";

		public const string PLUGIN_VERSION = "1.1.1";
	}
}
namespace Scopophobia.Patches
{
	[HarmonyPatch]
	internal class GetShyGuyPrefabForLaterUse
	{
		[HarmonyPatch(typeof(Terminal), "Start")]
		[HarmonyPostfix]
		private static void SavesPrefabForLaterUse(ref SelectableLevel[] ___moonsCatalogueList)
		{
			SelectableLevel[] array = ___moonsCatalogueList;
			SelectableLevel[] array2 = array;
			foreach (SelectableLevel val in array2)
			{
				foreach (SpawnableEnemyWithRarity enemy in val.Enemies)
				{
					if (enemy.enemyType.enemyName == "Shy guy")
					{
						ScopophobiaPlugin.shyPrefab = enemy;
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class ShyGuySpawnSettings
	{
		public static string[] nonoOutside = new string[5] { "Level1Experimentation", "Level2Assurance", "Level3Vow", "Level4March", "Level7Offense" };

		[HarmonyPatch("BeginEnemySpawning")]
		[HarmonyPrefix]
		private static void UpdateSpawnRates(ref SelectableLevel ___currentLevel)
		{
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Expected O, but got Unknown
			if (!Config.appears || ScopophobiaPlugin.shyPrefab == null)
			{
				return;
			}
			try
			{
				SpawnableEnemyWithRarity shyPrefab = ScopophobiaPlugin.shyPrefab;
				List<SpawnableEnemyWithRarity> enemies = ___currentLevel.Enemies;
				for (int i = 0; i < ___currentLevel.Enemies.Count; i++)
				{
					SpawnableEnemyWithRarity val = ___currentLevel.Enemies[i];
					if (val.enemyType.enemyName == "Shy guy")
					{
						enemies.Remove(val);
					}
				}
				___currentLevel.Enemies = enemies;
				shyPrefab.enemyType.PowerLevel = 3;
				shyPrefab.rarity = Config.spawnRarity;
				shyPrefab.enemyType.probabilityCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
				{
					new Keyframe(0f, Config.startEnemySpawnCurve),
					new Keyframe(0.5f, Config.midEnemySpawnCurve),
					new Keyframe(1f, Config.endEnemySpawnCurve)
				});
				shyPrefab.enemyType.MaxCount = Config.maxSpawnCount;
				shyPrefab.enemyType.isOutsideEnemy = Config.canSpawnOutside;
				if (Config.canSpawnOutside & (!Config.spawnOutsideHardPlanets || !nonoOutside.Contains(___currentLevel.sceneName)))
				{
					___currentLevel.OutsideEnemies.Add(shyPrefab);
					SelectableLevel val2 = ___currentLevel;
					val2.maxOutsideEnemyPowerCount += shyPrefab.enemyType.MaxCount * shyPrefab.enemyType.PowerLevel;
				}
				___currentLevel.Enemies.Add(shyPrefab);
			}
			catch
			{
			}
		}
	}
}
namespace Scopophobia.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}

plugins/SCPCBDunGen/SCPCBDunGen.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DunGen;
using DunGen.Graph;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLevelLoader;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SCPCBDunGen")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Adds the SCP Foundation Dungeon to Lethal Company.")]
[assembly: AssemblyFileVersion("2.3.0.0")]
[assembly: AssemblyInformationalVersion("2.3.0+7416b5402cf0bbe5e2b8b44e0ac71bc766efcb06")]
[assembly: AssemblyProduct("SCPCBDunGen")]
[assembly: AssemblyTitle("SCPCBDunGen")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.3.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SCPCBDunGen
{
	public struct SCP914Conversion
	{
		public string ItemName;

		public List<string> RoughResults { get; set; }

		public List<string> CoarseResults { get; set; }

		public List<string> OneToOneResults { get; set; }

		public List<string> FineResults { get; set; }

		public List<string> VeryFineResults { get; set; }
	}
	public class SCP914ConversionSet : KeyedCollection<string, SCP914Conversion>
	{
		protected override string GetKeyForItem(SCP914Conversion conversion)
		{
			return conversion.ItemName;
		}
	}
	[BepInPlugin("SCPCBDunGen", "SCPCBDunGen", "2.3.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class SCPCBDunGen : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(RoundManager))]
		internal class RoundManagerPatch
		{
			[HarmonyPatch("SpawnScrapInLevel")]
			[HarmonyPrefix]
			private static bool SetItemSpawnPoints(ref RuntimeDungeon ___dungeonGenerator)
			{
				if (((Object)___dungeonGenerator.Generator.DungeonFlow).name != "SCPFlow")
				{
					return true;
				}
				StartOfRound instance = StartOfRound.Instance;
				if ((Object)(object)instance == (Object)null)
				{
					Instance.mls.LogError((object)"Failed to get start of round instance. Scrap spawns may not work correctly.");
					return true;
				}
				Item val = instance.allItemsList.itemsList.Find((Item x) => x.itemName == "Bottles");
				if ((Object)(object)val == (Object)null)
				{
					Instance.mls.LogError((object)"Failed to find bottle bin item for reference snatching; scrap spawn may be significantly lower than expected.");
					return true;
				}
				Item val2 = instance.allItemsList.itemsList.Find((Item x) => x.itemName == "Golden cup");
				int num = 0;
				int num2 = 0;
				int num3 = 0;
				ItemGroup spawnableItems = val.spawnPositionTypes.Find((ItemGroup x) => ((Object)x).name == "GeneralItemClass");
				ItemGroup val3 = val.spawnPositionTypes.Find((ItemGroup x) => ((Object)x).name == "TabletopItems");
				ItemGroup spawnableItems2 = (ItemGroup)(((Object)(object)val2 == (Object)null) ? ((object)val3) : ((object)val2.spawnPositionTypes.Find((ItemGroup x) => ((Object)x).name == "SmallItems")));
				RandomScrapSpawn[] array = Object.FindObjectsOfType<RandomScrapSpawn>();
				RandomScrapSpawn[] array2 = array;
				foreach (RandomScrapSpawn val4 in array2)
				{
					switch (((Object)val4.spawnableItems).name)
					{
					case "GeneralItemClassDUMMY":
						val4.spawnableItems = spawnableItems;
						num++;
						break;
					case "TabletopItemsDUMMY":
						val4.spawnableItems = val3;
						num2++;
						break;
					case "SmallItemsDUMMY":
						val4.spawnableItems = spawnableItems2;
						num3++;
						break;
					}
				}
				Instance.mls.LogInfo((object)$"Totals for scrap replacement: General: {num}, Tabletop: {num2}, Small: {num3}");
				if (num + num2 + num3 < 10)
				{
					Instance.mls.LogWarning((object)"Unusually low scrap spawn count; scrap may be sparse.");
				}
				return true;
			}

			public static void AddConversions(SCP914Converter SCP914, List<Item> lItems, string sItem, IEnumerable<string> arROUGH, IEnumerable<string> arCOARSE, IEnumerable<string> arONETOONE, IEnumerable<string> arFINE, IEnumerable<string> arVERYFINE)
			{
				IEnumerable<string>[] array = new IEnumerable<string>[5] { arROUGH, arCOARSE, arONETOONE, arFINE, arVERYFINE };
				Item val = lItems.Find((Item x) => x.itemName.ToLowerInvariant() == sItem);
				if ((Object)(object)val == (Object)null)
				{
					Instance.mls.LogError((object)("Failed to find item for conversion \"" + sItem + "\", skipping."));
					return;
				}
				foreach (SCP914Converter.SCP914Setting value in Enum.GetValues(typeof(SCP914Converter.SCP914Setting)))
				{
					List<Item> list = new List<Item>();
					foreach (string sItemName in array[(int)value])
					{
						if (sItemName == "*")
						{
							list.Add(null);
							continue;
						}
						if (sItemName == "@")
						{
							list.Add(val);
							continue;
						}
						list.Add(lItems.Find((Item x) => x.itemName.ToLowerInvariant() == sItemName));
					}
					SCP914.AddConversion(value, val, list);
				}
			}

			[HarmonyPatch("SpawnSyncedProps")]
			[HarmonyPostfix]
			private static void SCP914Configuration()
			{
				SCP914Converter sCP914Converter = Object.FindObjectOfType<SCP914Converter>();
				if ((Object)(object)sCP914Converter == (Object)null)
				{
					Instance.mls.LogInfo((object)"No 914 room found.");
					return;
				}
				StartOfRound instance = StartOfRound.Instance;
				if ((Object)(object)instance == (Object)null)
				{
					Instance.mls.LogError((object)"Failed to find StartOfRound object.");
					return;
				}
				List<Item> list = instance.allItemsList?.itemsList;
				if (list == null)
				{
					Instance.mls.LogError((object)"Failed to get item list from StartOfRound.");
					return;
				}
				if (list.Count == 0)
				{
					Instance.mls.LogError((object)"Item list was empty from StartOfRound.");
					return;
				}
				foreach (SCP914Conversion sCP914Conversion in Instance.SCP914Conversions)
				{
					AddConversions(sCP914Converter, list, sCP914Conversion.ItemName, sCP914Conversion.RoughResults, sCP914Conversion.CoarseResults, sCP914Conversion.OneToOneResults, sCP914Conversion.FineResults, sCP914Conversion.VeryFineResults);
				}
			}
		}

		private readonly Harmony harmony = new Harmony("SCPCBDunGen");

		public static SCPCBDunGen Instance;

		public ManualLogSource mls;

		public static AssetBundle SCPCBAssets;

		private ConfigEntry<int> configSCPRarity;

		private ConfigEntry<string> configMoonsOld;

		private ConfigEntry<string> configMoons;

		private ConfigEntry<bool> configGuaranteedSCP;

		private ConfigEntry<int> configLengthOverride;

		private SCP914ConversionSet SCP914Conversions = new SCP914ConversionSet();

		private void Awake()
		{
			//IL_07e7: Expected O, but got Unknown
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Expected O, but got Unknown
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Expected O, but got Unknown
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Expected O, but got Unknown
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Expected O, but got Unknown
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Expected O, but got Unknown
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Expected O, but got Unknown
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Expected O, but got Unknown
			//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Expected O, but got Unknown
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Expected O, but got Unknown
			//IL_0452: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_0463: Expected O, but got Unknown
			//IL_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04af: Expected O, but got Unknown
			//IL_057b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0585: Expected O, but got Unknown
			//IL_060b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0615: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			mls = Logger.CreateLogSource("SCPCBDunGen");
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			SCPCBAssets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "scpcb_dungeon"));
			if ((Object)(object)SCPCBAssets == (Object)null)
			{
				mls.LogError((object)"Failed to load SCPCB Dungeon assets.");
				return;
			}
			DungeonFlow val = SCPCBAssets.LoadAsset<DungeonFlow>("assets/Mods/SCP/data/SCPFlow.asset");
			if ((Object)(object)val == (Object)null)
			{
				mls.LogError((object)"Failed to load SCP:CB Dungeon Flow.");
				return;
			}
			configSCPRarity = ((BaseUnityPlugin)this).Config.Bind<int>("General", "FoundationRarity", 100, new ConfigDescription("How rare it is for the foundation to be chosen. Higher values increases the chance of spawning the foundation. Vanillas' main dungeons use a value of 300. Google Weighted Random if you don't know how it works, as that's how Lethal Company rarities function.", (AcceptableValueBase)null, Array.Empty<object>()));
			configMoonsOld = ((BaseUnityPlugin)this).Config.Bind<string>("General", "FoundationMoons", "NULL", new ConfigDescription("OLD CONFIG SETTING, HAS NO EFFECT. Only here to clear the legacy config from updating.", (AcceptableValueBase)null, Array.Empty<object>()));
			configMoons = ((BaseUnityPlugin)this).Config.Bind<string>("General", "FoundationMoonsList", "Titan,Secret Labs", new ConfigDescription("The moon(s) that the foundation can spawn on, in the form of a comma separated list of selectable level names and optionally a weight value by using an '@' and weight value after it (e.g. \"Titan@300,Dine,Rend@10,Secret Labs@9999\")\nThe name matching is lenient and should pick it up if you use the terminal name or internal mod name. If no rarity is specified, the FoundationRarity parameter is used.\nThe following strings: \"all\", \"vanilla\", \"modded\", \"paid\", \"free\" are dynamic presets which add the dungeon to that specified group (string must only contain one of these, or a manual moon name list).\n", (AcceptableValueBase)null, Array.Empty<object>()));
			configGuaranteedSCP = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "FoundationGuaranteed", false, new ConfigDescription("OLD CONFIG SETTING, HAS NO EFFECT. Only here to clear the legacy config from updating.\nIf you want to effectively guarantee the foundation, use a weight of something like '99999'", (AcceptableValueBase)null, Array.Empty<object>()));
			configLengthOverride = ((BaseUnityPlugin)this).Config.Bind<int>("General", "FoundationLengthOverride", -1, new ConfigDescription(string.Format("If not -1, overrides the foundation length to whatever you'd like. Adjusts how long/large the dungeon generates.\nBe *EXTREMELY* careful not to set this too high (anything too big on a moon with a high dungeon size multipier can cause catastrophic problems, like crashing your computer or worse)\nFor reference, the default value for the current version [{0}] is {1}. If it's too big, make this lower e.g. 6, if it's too small use something like 10 (or higher, but don't go too crazy with it).", "2.3.0", val.Length.Min), (AcceptableValueBase)null, Array.Empty<object>()));
			if (configMoonsOld.Value != "NULL")
			{
				mls.LogWarning((object)"Old config parameters detected for old moon setting; config has changed since 1.3.1, check the config and set FoundationMoons to NULL to suppress this warning (and change FoundationMoonsList if you want)");
			}
			if (configGuaranteedSCP.Value)
			{
				mls.LogWarning((object)"Old config parameters detected for Guaranteed SCP; config has changed since 2.0.2, check the config and set GuaranteedSCP to false to suppress this warning (see uncapped FoundationRarity)");
			}
			if (configLengthOverride.Value != -1)
			{
				mls.LogInfo((object)$"Foundation length override has been set to {configLengthOverride.Value}. Be careful with this value.");
				val.Length.Min = configLengthOverride.Value;
				val.Length.Max = configLengthOverride.Value;
			}
			ExtendedDungeonFlow val2 = ScriptableObject.CreateInstance<ExtendedDungeonFlow>();
			val2.contentSourceName = "SCP Foundation Dungeon";
			val2.dungeonFlow = val;
			val2.dungeonFirstTimeAudio = SCPCBAssets.LoadAsset<AudioClip>("assets/Mods/SCP/snd/Horror8.ogg");
			val2.dungeonDefaultRarity = 0;
			int num = (configGuaranteedSCP.Value ? 99999 : configSCPRarity.Value);
			switch (configMoons.Value.ToLower())
			{
			case "all":
				val2.manualContentSourceNameReferenceList.Add(new StringWithRarity("Lethal Company", num));
				val2.manualContentSourceNameReferenceList.Add(new StringWithRarity("Custom", num));
				mls.LogInfo((object)"Registered SCP dungeon for all moons.");
				break;
			case "vanilla":
				val2.manualContentSourceNameReferenceList.Add(new StringWithRarity("Lethal Company", num));
				mls.LogInfo((object)"Registered SCP dungeon for all vanilla moons.");
				break;
			case "modded":
				val2.manualContentSourceNameReferenceList.Add(new StringWithRarity("Custom", num));
				mls.LogInfo((object)"Registered SCP dungeon for all modded moons.");
				break;
			case "paid":
				val2.dynamicRoutePricesList.Add(new Vector2WithRarity(new Vector2(1f, 9999f), num));
				mls.LogInfo((object)"Registered SCP dungeon for all paid moons.");
				break;
			case "free":
				val2.dynamicRoutePricesList.Add(new Vector2WithRarity(new Vector2(0f, 0f), num));
				mls.LogInfo((object)"Registered SCP dungeon for all free moons.");
				break;
			default:
			{
				mls.LogInfo((object)"Registering SCP dungeon for predefined moon list.");
				string[] array3 = configMoons.Value.Split(',', StringSplitOptions.RemoveEmptyEntries);
				List<StringWithRarity> list = new List<StringWithRarity>();
				for (int k = 0; k < array3.Length; k++)
				{
					string[] array4 = array3[k].Split('@', StringSplitOptions.RemoveEmptyEntries);
					int num2 = array4.Length;
					int result;
					if (num2 > 2)
					{
						mls.LogError((object)("Invalid setup for moon rarity config: " + array3[k] + ". Skipping."));
					}
					else if (num2 == 1)
					{
						mls.LogInfo((object)$"Registering SCP dungeon for moon {array3[k]} at default rarity {num}");
						list.Add(new StringWithRarity(array3[k], num));
					}
					else if (!int.TryParse(array4[1], out result))
					{
						mls.LogError((object)("Failed to parse rarity value for moon " + array4[0] + ": " + array4[1] + ". Skipping."));
					}
					else
					{
						mls.LogInfo((object)$"Registering SCP dungeon for moon {array3[k]} at default rarity {num}");
						list.Add(new StringWithRarity(array4[0], result));
					}
				}
				val2.manualPlanetNameReferenceList = list;
				break;
			}
			}
			val2.dungeonSizeMin = 1f;
			val2.dungeonSizeMax = 3f;
			val2.dungeonSizeLerpPercentage = 0f;
			AssetBundleLoader.RegisterExtendedDungeonFlow(val2);
			foreach (string item in DiscoverConfiguredRecipeFiles())
			{
				StreamReader streamReader = new StreamReader(item);
				string text = streamReader.ReadToEnd();
				try
				{
					List<SCP914Conversion> list2 = JsonConvert.DeserializeObject<List<SCP914Conversion>>(text);
					foreach (SCP914Conversion item2 in list2)
					{
						if (SCP914Conversions.Contains(item2.ItemName.ToLowerInvariant()))
						{
							SCP914Conversions[item2.ItemName].RoughResults.AddRange(item2.RoughResults);
							SCP914Conversions[item2.ItemName].CoarseResults.AddRange(item2.CoarseResults);
							SCP914Conversions[item2.ItemName].OneToOneResults.AddRange(item2.OneToOneResults);
							SCP914Conversions[item2.ItemName].FineResults.AddRange(item2.FineResults);
							SCP914Conversions[item2.ItemName].VeryFineResults.AddRange(item2.VeryFineResults);
						}
						else
						{
							SCP914Conversions.Add(item2);
						}
					}
					mls.LogInfo((object)("Registed SCP 914 json file successfully: " + item));
				}
				catch (JsonException val3)
				{
					JsonException val4 = val3;
					mls.LogError((object)("Failed to deserialize file: " + item + ". Exception: " + ((Exception)(object)val4).Message));
				}
			}
			harmony.PatchAll(typeof(SCPCBDunGen));
			harmony.PatchAll(typeof(RoundManagerPatch));
			mls.LogInfo((object)"SCP:CB DunGen for Lethal Company [Version 2.3.0] successfully loaded.");
		}

		private IEnumerable<string> DiscoverConfiguredRecipeFiles()
		{
			return from filePath in (from pluginDirectory in Directory.GetDirectories(Paths.PluginPath)
					select Path.Join((ReadOnlySpan<char>)pluginDirectory, (ReadOnlySpan<char>)"badhamknibbs-scp914-recipes")).Where(Directory.Exists).SelectMany(Directory.GetFiles)
				where Path.GetExtension(filePath) == ".json"
				select filePath;
		}
	}
	public class SCP914InputStore : NetworkBehaviour
	{
		public List<GameObject> lContainedItems;

		private void OnTriggerEnter(Collider other)
		{
			if (((NetworkBehaviour)this).NetworkManager.IsServer)
			{
				Debug.Log((object)("SCPCB New thing entered input trigger: " + ((Object)((Component)other).gameObject).name + "."));
				GrabbableObject component = ((Component)other).GetComponent<GrabbableObject>();
				lContainedItems.Add(((Component)other).gameObject);
			}
		}

		private void OnTriggerExit(Collider other)
		{
			if (((NetworkBehaviour)this).NetworkManager.IsServer)
			{
				Debug.Log((object)("SCPCB Thing has left input trigger: " + ((Object)((Component)other).gameObject).name + "."));
				lContainedItems.Remove(((Component)other).gameObject);
			}
		}

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

		protected internal override string __getTypeName()
		{
			return "SCP914InputStore";
		}
	}
	public class SCP914Converter : NetworkBehaviour
	{
		public enum SCP914Setting
		{
			ROUGH,
			COARSE,
			ONETOONE,
			FINE,
			VERYFINE
		}

		public SCP914InputStore InputStore;

		public Collider colliderOutput;

		public InteractTrigger SettingKnobTrigger;

		public GameObject SettingKnobPivot;

		public AudioSource SettingKnobSoundSrc;

		public InteractTrigger ActivateTrigger;

		public AudioSource ActivateAudioSrc;

		public AudioSource RefineAudioSrc;

		public Animator DoorIn;

		public Animator DoorOut;

		private readonly (SCP914Setting, float)[] SCP914SettingRotations = new(SCP914Setting, float)[5]
		{
			(SCP914Setting.ROUGH, 90f),
			(SCP914Setting.COARSE, 45f),
			(SCP914Setting.ONETOONE, 0f),
			(SCP914Setting.FINE, -45f),
			(SCP914Setting.VERYFINE, -90f)
		};

		private Dictionary<Item, List<Item>>[] arItemMappings = new Dictionary<Item, List<Item>>[5]
		{
			new Dictionary<Item, List<Item>>(),
			new Dictionary<Item, List<Item>>(),
			new Dictionary<Item, List<Item>>(),
			new Dictionary<Item, List<Item>>(),
			new Dictionary<Item, List<Item>>()
		};

		private int iCurrentState = 0;

		private bool bActive = false;

		private Transform ScrapTransform;

		private RoundManager roundManager;

		private StartOfRound StartOfRound;

		private EnemyType MaskedType;

		private ManualLogSource mls;

		private void Awake()
		{
			mls = SCPCBDunGen.Instance.mls;
		}

		public void AddConversion(SCP914Setting setting, Item itemInput, List<Item> lItemOutputs)
		{
			Dictionary<Item, List<Item>> dictionary = arItemMappings[(int)setting];
			if (dictionary.TryGetValue(itemInput, out var value))
			{
				value.AddRange(lItemOutputs);
			}
			else
			{
				arItemMappings[(int)setting].Add(itemInput, lItemOutputs);
			}
		}

		private Dictionary<Item, List<Item>> GetItemMapping()
		{
			return arItemMappings[iCurrentState];
		}

		private Vector3 GetRandomNavMeshPositionInCollider(Collider collider)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//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_002c: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			Bounds bounds = collider.bounds;
			Vector3 center = ((Bounds)(ref bounds)).center;
			bounds = collider.bounds;
			float x = ((Bounds)(ref bounds)).extents.x;
			bounds = collider.bounds;
			float num = Math.Min(x, ((Bounds)(ref bounds)).extents.z);
			center.x += Random.Range(0f - num, num);
			center.z += Random.Range(0f - num, num);
			ref float y = ref center.y;
			float num2 = y;
			bounds = collider.bounds;
			y = num2 - ((Bounds)(ref bounds)).extents.y / 2f;
			NavMeshHit val = default(NavMeshHit);
			if (NavMesh.SamplePosition(center, ref val, 10f, -1))
			{
				return ((NavMeshHit)(ref val)).position;
			}
			return center;
		}

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

		[ClientRpc]
		public void TurnStateClientRpc(int iNewState)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(301590527u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, iNewState);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 301590527u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					iCurrentState = iNewState;
					Quaternion rotation = SettingKnobPivot.transform.rotation;
					Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles;
					eulerAngles.z = SCP914SettingRotations[iCurrentState].Item2;
					SettingKnobPivot.transform.rotation = Quaternion.Euler(eulerAngles);
					SettingKnobSoundSrc.Play();
				}
			}
		}

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

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

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

		[ClientRpc]
		public void SpawnItemsClientRpc(NetworkObjectReference[] arNetworkObjectReferences, int[] arScrapValues, bool bChargeBattery)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: 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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4044311993u, val, (RpcDelivery)0);
				bool flag = arNetworkObjectReferences != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(arNetworkObjectReferences, default(ForNetworkSerializable));
				}
				bool flag2 = arScrapValues != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives));
				if (flag2)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe<int>(arScrapValues, default(ForPrimitives));
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref bChargeBattery, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4044311993u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			NetworkObject val3 = default(NetworkObject);
			for (int i = 0; i < arNetworkObjectReferences.Length; i++)
			{
				mls.LogInfo((object)$"Item conversion scrap value {i}: {arScrapValues[i]}");
				if (((NetworkObjectReference)(ref arNetworkObjectReferences[i])).TryGet(ref val3, (NetworkManager)null))
				{
					GrabbableObject component = ((Component)val3).GetComponent<GrabbableObject>();
					if (component.itemProperties.isScrap)
					{
						component.SetScrapValue(arScrapValues[i]);
					}
					if (component.itemProperties.requiresBattery)
					{
						component.insertedBattery.charge = (bChargeBattery ? 1f : 0f);
					}
				}
			}
		}

		private IEnumerator ConversionProcess()
		{
			RefineAudioSrc.Play();
			yield return (object)new WaitForSeconds(7f);
			if ((Object)(object)roundManager == (Object)null)
			{
				mls.LogInfo((object)"Getting round manager");
				roundManager = Object.FindObjectOfType<RoundManager>();
				if ((Object)(object)roundManager == (Object)null)
				{
					mls.LogError((object)"Failed to find round manager.");
					yield break;
				}
			}
			if ((Object)(object)ScrapTransform == (Object)null)
			{
				SCP914Converter sCP914Converter = this;
				GameObject obj = GameObject.FindGameObjectWithTag("MapPropsContainer");
				sCP914Converter.ScrapTransform = ((obj != null) ? obj.transform : null);
				if ((Object)(object)ScrapTransform == (Object)null)
				{
					mls.LogError((object)"SCPCB Failed to find props container.");
					yield break;
				}
			}
			List<NetworkObjectReference> lNetworkObjectReferences = new List<NetworkObjectReference>();
			List<int> lScrapValues = new List<int>();
			bool bChargeBatteries = iCurrentState > 1;
			Dictionary<Item, List<Item>> dcCurrentMapping = GetItemMapping();
			mls.LogInfo((object)$"Contained item count: {InputStore.lContainedItems.Count}");
			foreach (GameObject gameObject in InputStore.lContainedItems)
			{
				GrabbableObject grabbable = gameObject.GetComponent<GrabbableObject>();
				if ((Object)(object)grabbable != (Object)null)
				{
					ConvertItem(lNetworkObjectReferences, lScrapValues, dcCurrentMapping, grabbable);
					continue;
				}
				PlayerControllerB playerController = gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)playerController != (Object)null)
				{
					ConvertPlayer(playerController);
				}
			}
			mls.LogInfo((object)"Finished spawning scrap, syncing with clients");
			SpawnItemsClientRpc(lNetworkObjectReferences.ToArray(), lScrapValues.ToArray(), bChargeBatteries);
			InputStore.lContainedItems.Clear();
			yield return (object)new WaitForSeconds(7f);
			RefineFinishClientRpc();
			bActive = false;
		}

		private void ConvertItem(List<NetworkObjectReference> lNetworkObjectReferences, List<int> lScrapValues, Dictionary<Item, List<Item>> dcCurrentMapping, GrabbableObject grabbable)
		{
			//IL_003c: 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_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			if (grabbable.isHeld)
			{
				return;
			}
			mls.LogInfo((object)("Found grabbable item " + ((Object)grabbable.itemProperties).name));
			Vector3 randomNavMeshPositionInCollider = GetRandomNavMeshPositionInCollider(colliderOutput);
			GameObject val = null;
			NetworkObject val2 = null;
			GrabbableObject val3 = null;
			if (dcCurrentMapping.TryGetValue(grabbable.itemProperties, out var value))
			{
				mls.LogInfo((object)"Mapping found");
				Item val4 = value?[roundManager.AnomalyRandom.Next(value.Count)];
				Object.Destroy((Object)(object)((Component)grabbable).gameObject);
				if ((Object)(object)val4 != (Object)null)
				{
					mls.LogInfo((object)"Conversion found");
					val = Object.Instantiate<GameObject>(val4.spawnPrefab, randomNavMeshPositionInCollider, Quaternion.identity, ScrapTransform);
					val2 = val.GetComponent<NetworkObject>();
					val3 = val.GetComponent<GrabbableObject>();
				}
			}
			else
			{
				mls.LogInfo((object)"No conversion, making new item with new scrap value");
				val = Object.Instantiate<GameObject>(grabbable.itemProperties.spawnPrefab, randomNavMeshPositionInCollider, Quaternion.identity, ScrapTransform);
				Object.Destroy((Object)(object)((Component)grabbable).gameObject);
				val2 = val.GetComponent<NetworkObject>();
				val3 = val.GetComponent<GrabbableObject>();
			}
			mls.LogInfo((object)"Preprocessing done");
			if ((Object)(object)val3 == (Object)null)
			{
				mls.LogInfo((object)"Conversion was null, item is intended to be destroyed in process.");
				return;
			}
			Item itemProperties = val3.itemProperties;
			if (itemProperties.isScrap)
			{
				mls.LogInfo((object)"Item is scrap or null, generating a copy with new value");
				GrabbableObject component = val.GetComponent<GrabbableObject>();
				int num = (int)((float)roundManager.AnomalyRandom.Next(itemProperties.minValue, itemProperties.maxValue) * roundManager.scrapValueMultiplier);
				component.SetScrapValue(num);
				mls.LogInfo((object)$"new scrap value: {num}");
				lScrapValues.Add(num);
			}
			else
			{
				mls.LogInfo((object)"Item is not scrap, adding empty scrap value");
				lScrapValues.Add(0);
			}
			val2.Spawn(true);
			lNetworkObjectReferences.Add(NetworkObjectReference.op_Implicit(val2));
		}

		[ClientRpc]
		private void ConvertPlayerTeleportClientRpc(NetworkBehaviourReference netBehaviourRefPlayer, Vector3 vPosition)
		{
			//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_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Expected O, but got Unknown
			//IL_0118: 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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3018499267u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref netBehaviourRefPlayer, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref vPosition);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3018499267u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				NetworkBehaviour val3 = null;
				((NetworkBehaviourReference)(ref netBehaviourRefPlayer)).TryGet(ref val3, (NetworkManager)null);
				if ((Object)(object)val3 == (Object)null)
				{
					mls.LogError((object)"Failed to get player controller.");
					return;
				}
				PlayerControllerB val4 = (PlayerControllerB)val3;
				val4.TeleportPlayer(vPosition, false, 0f, false, true);
			}
		}

		[ClientRpc]
		private void ConvertPlayerKillClientRpc(NetworkBehaviourReference netBehaviourRefPlayer)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Expected O, but got Unknown
			//IL_010b: 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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1252059581u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref netBehaviourRefPlayer, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1252059581u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				NetworkBehaviour val3 = null;
				((NetworkBehaviourReference)(ref netBehaviourRefPlayer)).TryGet(ref val3, (NetworkManager)null);
				if ((Object)(object)val3 == (Object)null)
				{
					mls.LogError((object)"Failed to get player controller.");
					return;
				}
				PlayerControllerB val4 = (PlayerControllerB)val3;
				val4.KillPlayer(Vector3.zero, true, (CauseOfDeath)6, 0);
			}
		}

		[ClientRpc]
		private void ConvertPlayerAlterHealthClientRpc(NetworkBehaviourReference netBehaviourRefPlayer, int iHealthDelta)
		{
			//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_008c: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Expected O, but got Unknown
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: 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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(527346026u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref netBehaviourRefPlayer, default(ForNetworkSerializable));
				BytePacker.WriteValueBitPacked(val2, iHealthDelta);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 527346026u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				NetworkBehaviour val3 = null;
				((NetworkBehaviourReference)(ref netBehaviourRefPlayer)).TryGet(ref val3, (NetworkManager)null);
				if ((Object)(object)val3 == (Object)null)
				{
					mls.LogError((object)"Failed to get player controller.");
					return;
				}
				PlayerControllerB val4 = (PlayerControllerB)val3;
				val4.DamagePlayer(iHealthDelta, true, true, (CauseOfDeath)8, 0, false, default(Vector3));
			}
		}

		[ClientRpc]
		private void ConvertPlayerRandomSkinClientRpc(NetworkBehaviourReference netBehaviourRefPlayer, int iSuitID)
		{
			//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_008c: 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_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Expected O, but got Unknown
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1669287785u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref netBehaviourRefPlayer, default(ForNetworkSerializable));
				BytePacker.WriteValueBitPacked(val2, iSuitID);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1669287785u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			if ((Object)(object)StartOfRound == (Object)null)
			{
				StartOfRound = Object.FindObjectOfType<StartOfRound>();
				if ((Object)(object)StartOfRound == (Object)null)
				{
					mls.LogError((object)"Failed to find StartOfRound.");
					return;
				}
			}
			NetworkBehaviour val3 = null;
			((NetworkBehaviourReference)(ref netBehaviourRefPlayer)).TryGet(ref val3, (NetworkManager)null);
			if ((Object)(object)val3 == (Object)null)
			{
				mls.LogError((object)"Failed to get player controller.");
				return;
			}
			PlayerControllerB val4 = (PlayerControllerB)val3;
			int num = 0;
			foreach (UnlockableItem unlockable in StartOfRound.unlockablesList.unlockables)
			{
				if ((Object)(object)unlockable.suitMaterial != (Object)null)
				{
					mls.LogInfo((object)$"Found suit at index {num}");
				}
				num++;
			}
			UnlockableItem val5 = StartOfRound.unlockablesList.unlockables[iSuitID];
			if (val5 == null)
			{
				mls.LogError((object)$"Invalid suit ID: {iSuitID}");
				return;
			}
			Material suitMaterial = val5.suitMaterial;
			((Renderer)val4.thisPlayerModel).material = suitMaterial;
			((Renderer)val4.thisPlayerModelLOD1).material = suitMaterial;
			((Renderer)val4.thisPlayerModelLOD2).material = suitMaterial;
			((Renderer)val4.thisPlayerModelArms).material = suitMaterial;
			val4.currentSuitID = iSuitID;
		}

		private void ConvertPlayerRandomSkin(PlayerControllerB playerController)
		{
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)StartOfRound == (Object)null)
			{
				StartOfRound = Object.FindObjectOfType<StartOfRound>();
				if ((Object)(object)StartOfRound == (Object)null)
				{
					mls.LogError((object)"Failed to find StartOfRound.");
					return;
				}
			}
			List<int> list = new List<int>();
			int num = 0;
			foreach (UnlockableItem unlockable in StartOfRound.unlockablesList.unlockables)
			{
				if ((Object)(object)unlockable.suitMaterial != (Object)null && num != playerController.currentSuitID)
				{
					list.Add(num);
				}
				num++;
			}
			int count = list.Count;
			if (count == 0)
			{
				mls.LogError((object)"No suits to swap to found.");
				return;
			}
			int index = roundManager.AnomalyRandom.Next(0, count);
			NetworkBehaviourReference netBehaviourRefPlayer = NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)playerController);
			ConvertPlayerRandomSkinClientRpc(netBehaviourRefPlayer, list[index]);
		}

		private IEnumerator ConvertPlayerMaskedWaitForSpawn(NetworkObjectReference netObjRefMasked, NetworkBehaviourReference netBehaviourRefPlayer)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			NetworkObject netObjMasked = null;
			NetworkBehaviour netBehaviourPlayer = null;
			float fStartTime = Time.realtimeSinceStartup;
			yield return (object)new WaitUntil((Func<bool>)(() => Time.realtimeSinceStartup - fStartTime > 20f || ((NetworkObjectReference)(ref netObjRefMasked)).TryGet(ref netObjMasked, (NetworkManager)null)));
			yield return (object)new WaitUntil((Func<bool>)(() => Time.realtimeSinceStartup - fStartTime > 20f || ((NetworkBehaviourReference)(ref netBehaviourRefPlayer)).TryGet(ref netBehaviourPlayer, (NetworkManager)null)));
			PlayerControllerB playerController = (PlayerControllerB)netBehaviourPlayer;
			if ((Object)(object)playerController.deadBody == (Object)null)
			{
				yield return (object)new WaitUntil((Func<bool>)(() => Time.realtimeSinceStartup - fStartTime > 20f || (Object)(object)playerController.deadBody != (Object)null));
			}
			if ((Object)(object)playerController.deadBody != (Object)null)
			{
				playerController.deadBody.DeactivateBody(false);
				if ((Object)(object)netObjMasked != (Object)null)
				{
					MaskedPlayerEnemy maskedPlayerEnemy = ((Component)netObjMasked).GetComponent<MaskedPlayerEnemy>();
					maskedPlayerEnemy.mimickingPlayer = playerController;
					maskedPlayerEnemy.SetSuit(playerController.currentSuitID);
					maskedPlayerEnemy.SetEnemyOutside(false);
					playerController.redirectToEnemy = (EnemyAI)(object)maskedPlayerEnemy;
				}
			}
		}

		[ClientRpc]
		private void ConvertPlayerMaskedClientRpc(NetworkObjectReference netObjRefMasked, NetworkBehaviourReference netBehaviourRefPlayer)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_0098: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Expected O, but got Unknown
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: 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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(358260797u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref netObjRefMasked, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref netBehaviourRefPlayer, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 358260797u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			NetworkBehaviour val3 = null;
			((NetworkBehaviourReference)(ref netBehaviourRefPlayer)).TryGet(ref val3, (NetworkManager)null);
			if ((Object)(object)val3 == (Object)null)
			{
				mls.LogError((object)"Failed to get player controller.");
				return;
			}
			PlayerControllerB val4 = (PlayerControllerB)val3;
			val4.KillPlayer(Vector3.zero, true, (CauseOfDeath)5, 0);
			if ((Object)(object)val4.deadBody != (Object)null)
			{
				val4.deadBody.DeactivateBody(false);
			}
			((MonoBehaviour)this).StartCoroutine(ConvertPlayerMaskedWaitForSpawn(netObjRefMasked, netBehaviourRefPlayer));
		}

		private void ConvertPlayerMasked(NetworkBehaviourReference netBehaviourRefPlayer, Vector3 vMaskedPosition)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			NetworkBehaviour val = null;
			((NetworkBehaviourReference)(ref netBehaviourRefPlayer)).TryGet(ref val, (NetworkManager)null);
			if ((Object)(object)val == (Object)null)
			{
				mls.LogError((object)"Failed to get player controller.");
				return;
			}
			PlayerControllerB val2 = (PlayerControllerB)val;
			val2.KillPlayer(Vector3.zero, true, (CauseOfDeath)5, 0);
			if ((Object)(object)StartOfRound == (Object)null)
			{
				StartOfRound = Object.FindObjectOfType<StartOfRound>();
				if ((Object)(object)StartOfRound == (Object)null)
				{
					mls.LogError((object)"Failed to find StartOfRound.");
					return;
				}
			}
			if ((Object)(object)MaskedType == (Object)null)
			{
				SelectableLevel val3 = Array.Find(StartOfRound.levels, (SelectableLevel x) => x.PlanetName == "8 Titan");
				if ((Object)(object)val3 == (Object)null)
				{
					mls.LogError((object)"Failed to get Titan level data.");
					return;
				}
				MaskedType = val3.Enemies.Find((SpawnableEnemyWithRarity x) => x.enemyType.enemyName == "Masked")?.enemyType;
				if ((Object)(object)MaskedType == (Object)null)
				{
					mls.LogError((object)"Failed to get masked enemy type.");
					return;
				}
			}
			NetworkObjectReference netObjRefMasked = roundManager.SpawnEnemyGameObject(vMaskedPosition, 0f, -1, MaskedType);
			NetworkObject val4 = default(NetworkObject);
			if (((NetworkObjectReference)(ref netObjRefMasked)).TryGet(ref val4, (NetworkManager)null))
			{
				mls.LogInfo((object)"Got network object for mask enemy");
				MaskedPlayerEnemy component = ((Component)val4).GetComponent<MaskedPlayerEnemy>();
				component.SetSuit(val2.currentSuitID);
				component.mimickingPlayer = val2;
				component.SetEnemyOutside(false);
				val2.redirectToEnemy = (EnemyAI)(object)component;
				if ((Object)(object)val2.deadBody != (Object)null)
				{
					val2.deadBody.DeactivateBody(false);
				}
			}
			ConvertPlayerMaskedClientRpc(netObjRefMasked, netBehaviourRefPlayer);
		}

		private void ConvertPlayer(PlayerControllerB playerController)
		{
			//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)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			mls.LogInfo((object)"Player detected, doing player conversion");
			SCP914Setting sCP914Setting = (SCP914Setting)iCurrentState;
			Vector3 randomNavMeshPositionInCollider = GetRandomNavMeshPositionInCollider(colliderOutput);
			NetworkBehaviourReference netBehaviourRefPlayer = NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)playerController);
			ConvertPlayerTeleportClientRpc(netBehaviourRefPlayer, randomNavMeshPositionInCollider);
			switch (sCP914Setting)
			{
			case SCP914Setting.ROUGH:
				ConvertPlayerKillClientRpc(netBehaviourRefPlayer);
				break;
			case SCP914Setting.COARSE:
				ConvertPlayerAlterHealthClientRpc(netBehaviourRefPlayer, 50);
				break;
			case SCP914Setting.ONETOONE:
				ConvertPlayerRandomSkin(playerController);
				break;
			case SCP914Setting.FINE:
				ConvertPlayerAlterHealthClientRpc(netBehaviourRefPlayer, -50);
				break;
			case SCP914Setting.VERYFINE:
				if (!playerController.AllowPlayerDeath())
				{
					mls.LogInfo((object)"Refined player with Very Fine, but player death is prevented. Doing nothing.");
				}
				else
				{
					ConvertPlayerMasked(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)playerController), randomNavMeshPositionInCollider);
				}
				break;
			default:
				mls.LogError((object)"Invalid SCP 914 setting when attempting to convert player.");
				break;
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_SCP914Converter()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2627837757u, new RpcReceiveHandler(__rpc_handler_2627837757));
			NetworkManager.__rpc_func_table.Add(301590527u, new RpcReceiveHandler(__rpc_handler_301590527));
			NetworkManager.__rpc_func_table.Add(1051910848u, new RpcReceiveHandler(__rpc_handler_1051910848));
			NetworkManager.__rpc_func_table.Add(3833341719u, new RpcReceiveHandler(__rpc_handler_3833341719));
			NetworkManager.__rpc_func_table.Add(4143732333u, new RpcReceiveHandler(__rpc_handler_4143732333));
			NetworkManager.__rpc_func_table.Add(4044311993u, new RpcReceiveHandler(__rpc_handler_4044311993));
			NetworkManager.__rpc_func_table.Add(3018499267u, new RpcReceiveHandler(__rpc_handler_3018499267));
			NetworkManager.__rpc_func_table.Add(1252059581u, new RpcReceiveHandler(__rpc_handler_1252059581));
			NetworkManager.__rpc_func_table.Add(527346026u, new RpcReceiveHandler(__rpc_handler_527346026));
			NetworkManager.__rpc_func_table.Add(1669287785u, new RpcReceiveHandler(__rpc_handler_1669287785));
			NetworkManager.__rpc_func_table.Add(358260797u, new RpcReceiveHandler(__rpc_handler_358260797));
		}

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

		private static void __rpc_handler_301590527(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int iNewState = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref iNewState);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SCP914Converter)(object)target).TurnStateClientRpc(iNewState);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

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

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

		private static void __rpc_handler_4044311993(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_0074: 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_0058: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: 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_00a3: 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));
				NetworkObjectReference[] arNetworkObjectReferences = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref arNetworkObjectReferences, default(ForNetworkSerializable));
				}
				bool flag2 = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
				int[] arScrapValues = null;
				if (flag2)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref arScrapValues, default(ForPrimitives));
				}
				bool bChargeBattery = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref bChargeBattery, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SCP914Converter)(object)target).SpawnItemsClientRpc(arNetworkObjectReferences, arScrapValues, bChargeBattery);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3018499267(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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference netBehaviourRefPlayer = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref netBehaviourRefPlayer, default(ForNetworkSerializable));
				Vector3 vPosition = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref vPosition);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SCP914Converter)(object)target).ConvertPlayerTeleportClientRpc(netBehaviourRefPlayer, vPosition);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1252059581(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference netBehaviourRefPlayer = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref netBehaviourRefPlayer, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SCP914Converter)(object)target).ConvertPlayerKillClientRpc(netBehaviourRefPlayer);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_527346026(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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference netBehaviourRefPlayer = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref netBehaviourRefPlayer, default(ForNetworkSerializable));
				int iHealthDelta = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref iHealthDelta);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SCP914Converter)(object)target).ConvertPlayerAlterHealthClientRpc(netBehaviourRefPlayer, iHealthDelta);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1669287785(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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference netBehaviourRefPlayer = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref netBehaviourRefPlayer, default(ForNetworkSerializable));
				int iSuitID = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref iSuitID);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SCP914Converter)(object)target).ConvertPlayerRandomSkinClientRpc(netBehaviourRefPlayer, iSuitID);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_358260797(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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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)
			//IL_006e: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference netObjRefMasked = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref netObjRefMasked, default(ForNetworkSerializable));
				NetworkBehaviourReference netBehaviourRefPlayer = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref netBehaviourRefPlayer, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SCP914Converter)(object)target).ConvertPlayerMaskedClientRpc(netObjRefMasked, netBehaviourRefPlayer);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "SCP914Converter";
		}
	}
	public class SCPDoorMover : NetworkBehaviour
	{
		public NavMeshObstacle navObstacle;

		public Animator doors;

		public List<AudioClip> doorAudioClips;

		public AudioClip doorAudioClipFast;

		public AudioSource doorSFXSource;

		public InteractTrigger ButtonA;

		public InteractTrigger ButtonB;

		private bool bDoorOpen = false;

		private bool bDoorWaiting = false;

		private List<EnemyAICollisionDetect> EnemiesInCollider = new List<EnemyAICollisionDetect>();

		private void OnTriggerEnter(Collider other)
		{
			if (!((Object)(object)NetworkManager.Singleton == (Object)null) && ((NetworkBehaviour)this).IsServer && ((Component)other).CompareTag("Enemy"))
			{
				EnemyAICollisionDetect component = ((Component)other).GetComponent<EnemyAICollisionDetect>();
				if (!((Object)(object)component == (Object)null))
				{
					SCPCBDunGen.Instance.mls.LogInfo((object)("Enemy entered trigger: " + ((Object)component.mainScript.enemyType).name));
					EnemiesInCollider.Add(component);
				}
			}
		}

		private void OnTriggerExit(Collider other)
		{
			if (!((Object)(object)NetworkManager.Singleton == (Object)null) && ((NetworkBehaviour)this).IsServer && ((Component)other).CompareTag("Enemy"))
			{
				EnemyAICollisionDetect component = ((Component)other).GetComponent<EnemyAICollisionDetect>();
				if (!((Object)(object)component == (Object)null) && !EnemiesInCollider.Remove(component))
				{
					SCPCBDunGen.Instance.mls.LogWarning((object)"Enemy left door trigger but somehow wasn't detected in trigger entry.");
				}
			}
		}

		private void Update()
		{
			if ((Object)(object)NetworkManager.Singleton == (Object)null || !((NetworkBehaviour)this).IsServer || bDoorOpen || bDoorWaiting || EnemiesInCollider.Count == 0)
			{
				return;
			}
			SCPCBDunGen.Instance.mls.LogInfo((object)"Enemy attempting to open door...");
			float num = 0f;
			foreach (EnemyAICollisionDetect item in EnemiesInCollider)
			{
				EnemyAI mainScript = item.mainScript;
				if (!mainScript.isEnemyDead)
				{
					SCPCBDunGen.Instance.mls.LogInfo((object)$"Enemy {((Object)mainScript.enemyType).name} with open mult {mainScript.openDoorSpeedMultiplier}");
					float val = mainScript.openDoorSpeedMultiplier;
					if (((Object)mainScript.enemyType).name == "MaskedPlayerEnemy")
					{
						val = 1f;
					}
					if (((Object)mainScript.enemyType).name == "Crawler")
					{
						val = 2f;
					}
					num = Math.Max(num, val);
				}
			}
			SCPCBDunGen.Instance.mls.LogInfo((object)$"Highest multiplier is {num}.");
			if (num != 0f)
			{
				SCPCBDunGen.Instance.mls.LogInfo((object)"Door being opened.");
				if (num > 1.5f)
				{
					OpenDoorFastServerRpc();
				}
				else
				{
					ToggleDoorServerRpc();
				}
			}
		}

		[ServerRpc]
		public void OpenDoorFastServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(289563691u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 289563691u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				SCPCBDunGen.Instance.mls.LogInfo((object)"Opening door fast [SERVER].");
				bDoorWaiting = true;
				bDoorOpen = true;
				((Behaviour)navObstacle).enabled = false;
				OpenDoorFastClientRpc();
				((MonoBehaviour)this).StartCoroutine(DoorToggleButtonUsable());
			}
		}

		[ClientRpc]
		public void OpenDoorFastClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1678254293u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1678254293u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					SCPCBDunGen.Instance.mls.LogInfo((object)"Opening door fast [CLIENT].");
					bDoorWaiting = true;
					bDoorOpen = true;
					ButtonA.interactable = false;
					ButtonB.interactable = false;
					doorSFXSource.PlayOneShot(doorAudioClipFast);
					doors.SetTrigger("openfast");
				}
			}
		}

		private IEnumerator DoorToggleButtonUsable()
		{
			yield return (object)new WaitForSeconds(1f);
			bDoorWaiting = false;
			yield return (object)new WaitForSeconds(1f);
			EnableDoorButtonClientRpc();
		}

		[ServerRpc(RequireOwnership = false)]
		public void ToggleDoorServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(40313670u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 40313670u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && !bDoorWaiting)
				{
					bool flag = !bDoorOpen;
					string text = (flag ? "opening" : "closing");
					SCPCBDunGen.Instance.mls.LogInfo((object)("Door is " + text + "."));
					bDoorWaiting = true;
					bDoorOpen = flag;
					((Behaviour)navObstacle).enabled = !flag;
					ToggleDoorClientRpc(bDoorOpen);
					((MonoBehaviour)this).StartCoroutine(DoorToggleButtonUsable());
				}
			}
		}

		[ClientRpc]
		public void ToggleDoorClientRpc(bool _bDoorOpen)
		{
			//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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(659555206u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref _bDoorOpen, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 659555206u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					bDoorOpen = _bDoorOpen;
					ButtonA.interactable = false;
					ButtonB.interactable = false;
					doorSFXSource.PlayOneShot(doorAudioClips[Random.Range(0, doorAudioClips.Count)]);
					doors.SetTrigger(bDoorOpen ? "open" : "close");
				}
			}
		}

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

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_SCPDoorMover()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(289563691u, new RpcReceiveHandler(__rpc_handler_289563691));
			NetworkManager.__rpc_func_table.Add(1678254293u, new RpcReceiveHandler(__rpc_handler_1678254293));
			NetworkManager.__rpc_func_table.Add(40313670u, new RpcReceiveHandler(__rpc_handler_40313670));
			NetworkManager.__rpc_func_table.Add(659555206u, new RpcReceiveHandler(__rpc_handler_659555206));
			NetworkManager.__rpc_func_table.Add(1538705838u, new RpcReceiveHandler(__rpc_handler_1538705838));
		}

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

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

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

		private static void __rpc_handler_659555206(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SCPDoorMover)(object)target).ToggleDoorClientRpc(flag);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		protected internal override string __getTypeName()
		{
			return "SCPDoorMover";
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "SCPCBDunGen";

		public const string PLUGIN_NAME = "SCPCBDunGen";

		public const string PLUGIN_VERSION = "2.3.0";
	}
}

plugins/SecretLabs.dll

Decompiled 9 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using SecretLabs.Patches;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SecretLabs")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("SecretLabs")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SecretLabs")]
[assembly: AssemblyTitle("SecretLabs")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SecretLabs
{
	[Serializable]
	public class Config : SyncedInstance<Config>
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__OnRequestSync;

			public static HandleNamedMessageDelegate <1>__OnReceiveSync;
		}

		public bool customPriceEnabled;

		public int moonPrice;

		public Config(ConfigFile cfg)
		{
			InitInstance(this);
			customPriceEnabled = cfg.Bind<bool>("General", "CustomPriceEnabled", false, "Enable this if you wish to configure the moons route price below.").Value;
			moonPrice = cfg.Bind<int>("General", "MoonPrice", 700, "The route price of the Secret Labs moon.").Value;
		}

		public static void RequestSync()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (!SyncedInstance<Config>.IsClient)
			{
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(SyncedInstance<Config>.IntSize, (Allocator)2, -1);
			try
			{
				SyncedInstance<Config>.MessageManager.SendNamedMessage("SecretLabs_OnRequestConfigSync", 0uL, val, (NetworkDelivery)3);
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		public static void OnRequestSync(ulong clientId, FastBufferReader _)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if (!SyncedInstance<Config>.IsHost)
			{
				return;
			}
			byte[] array = SyncedInstance<Config>.SerializeToBytes(SyncedInstance<Config>.Instance);
			int num = array.Length;
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(num + SyncedInstance<Config>.IntSize, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteBytesSafe(array, -1, 0);
				SyncedInstance<Config>.MessageManager.SendNamedMessage("SecretLabs_OnReceiveConfigSync", clientId, val, (NetworkDelivery)3);
			}
			catch (Exception arg)
			{
				Plugin.Logger.LogDebug((object)$"Error occurred syncing config with client: {clientId}\n{arg}");
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		public static void OnReceiveSync(ulong _, FastBufferReader reader)
		{
			//IL_0024: 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)
			if (!((FastBufferReader)(ref reader)).TryBeginRead(SyncedInstance<Config>.IntSize))
			{
				Plugin.Logger.LogError((object)"Config sync error: Could not begin reading buffer.");
				return;
			}
			int num = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
			if (!((FastBufferReader)(ref reader)).TryBeginRead(num))
			{
				Plugin.Logger.LogError((object)"Config sync error: Host could not sync.");
				return;
			}
			byte[] data = new byte[num];
			((FastBufferReader)(ref reader)).ReadBytesSafe(ref data, num, 0);
			SyncedInstance<Config>.SyncInstance(data);
			Plugin.Logger.LogDebug((object)"Successfully synced config with host.");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		public static void InitializeLocalPlayer()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			if (SyncedInstance<Config>.IsHost)
			{
				CustomMessagingManager messageManager = SyncedInstance<Config>.MessageManager;
				object obj = <>O.<0>__OnRequestSync;
				if (obj == null)
				{
					HandleNamedMessageDelegate val = OnRequestSync;
					<>O.<0>__OnRequestSync = val;
					obj = (object)val;
				}
				messageManager.RegisterNamedMessageHandler("SecretLabs_OnRequestConfigSync", (HandleNamedMessageDelegate)obj);
				SyncedInstance<Config>.Synced = true;
				return;
			}
			SyncedInstance<Config>.Synced = false;
			CustomMessagingManager messageManager2 = SyncedInstance<Config>.MessageManager;
			object obj2 = <>O.<1>__OnReceiveSync;
			if (obj2 == null)
			{
				HandleNamedMessageDelegate val2 = OnReceiveSync;
				<>O.<1>__OnReceiveSync = val2;
				obj2 = (object)val2;
			}
			messageManager2.RegisterNamedMessageHandler("SecretLabs_OnReceiveConfigSync", (HandleNamedMessageDelegate)obj2);
			RequestSync();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")]
		public static void PlayerLeave()
		{
			SyncedInstance<Config>.RevertSync();
		}
	}
	[Serializable]
	public class SyncedInstance<T>
	{
		[NonSerialized]
		protected static int IntSize = 4;

		internal static CustomMessagingManager MessageManager => NetworkManager.Singleton.CustomMessagingManager;

		internal static bool IsClient => NetworkManager.Singleton.IsClient;

		internal static bool IsHost => NetworkManager.Singleton.IsHost;

		public static T Default { get; set; }

		public static T Instance { get; set; }

		public static bool Synced { get; internal set; }

		protected void InitInstance(T instance)
		{
			Default = instance;
			Instance = instance;
		}

		internal static void SyncInstance(byte[] data)
		{
			Instance = DeserializeFromBytes(data);
			Synced = true;
		}

		internal static void RevertSync()
		{
			Instance = Default;
			Synced = false;
		}

		public static byte[] SerializeToBytes(T val)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream memoryStream = new MemoryStream();
			try
			{
				binaryFormatter.Serialize(memoryStream, val);
				return memoryStream.ToArray();
			}
			catch (Exception arg)
			{
				Plugin.Logger.LogError((object)$"Error serializing instance: {arg}");
				return null;
			}
		}

		public static T DeserializeFromBytes(byte[] data)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream serializationStream = new MemoryStream(data);
			try
			{
				return (T)binaryFormatter.Deserialize(serializationStream);
			}
			catch (Exception arg)
			{
				Plugin.Logger.LogError((object)$"Error deserializing instance: {arg}");
				return default(T);
			}
		}
	}
	[BepInPlugin("SecretLabs", "SecretLabs", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony _harmony;

		public static ManualLogSource Logger;

		public static Config Config { get; internal set; }

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			_harmony = new Harmony("SecretLabs");
			Config = new Config(((BaseUnityPlugin)this).Config);
			_harmony.PatchAll(typeof(RoutePatches));
			_harmony.PatchAll(typeof(Config));
			Logger.LogDebug((object)"Plugin SecretLabs is loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "SecretLabs";

		public const string PLUGIN_NAME = "SecretLabs";

		public const string PLUGIN_VERSION = "1.0.0";
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "SecretLabs";

		public const string PLUGIN_NAME = "SecretLabs";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace SecretLabs.Patches
{
	[HarmonyPatch(typeof(Terminal))]
	public class RoutePatches
	{
		[HarmonyPatch("LoadNewNode")]
		[HarmonyPrefix]
		private static void LoadNewNodePatchBefore(ref TerminalNode node)
		{
			if (!SyncedInstance<Config>.Instance.customPriceEnabled)
			{
				return;
			}
			Terminal obj = Object.FindObjectOfType<Terminal>();
			Plugin.Logger.LogDebug((object)((Object)node).name);
			CompatibleNoun[] compatibleNouns = obj.terminalNodes.allKeywords.First((TerminalKeyword terminalKeyword) => terminalKeyword.word == "route").compatibleNouns;
			foreach (CompatibleNoun val in compatibleNouns)
			{
				if (!((Object)(object)val.result == (Object)null) && ((Object)val.result).name == "secret labsRoute")
				{
					val.result.itemCost = SyncedInstance<Config>.Instance.moonPrice;
				}
			}
		}

		[HarmonyPatch("LoadNewNodeIfAffordable")]
		[HarmonyPrefix]
		private static void LoadNewNodeIfAffordablePatch(ref TerminalNode node)
		{
			if (SyncedInstance<Config>.Instance.customPriceEnabled)
			{
				Plugin.Logger.LogDebug((object)((Object)node).name);
				if (!((Object)(object)node == (Object)null) && !(((Object)node).name != "secret labsRouteConfirm"))
				{
					node.itemCost = Math.Abs(SyncedInstance<Config>.Instance.moonPrice);
				}
			}
		}
	}
}

plugins/SellBodies/SellBodies.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using CleaningCompany.Misc;
using CleaningCompany.Monos;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SellBodies")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SellBodies")]
[assembly: AssemblyTitle("SellBodies")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace CleaningCompany
{
	[BepInPlugin("Entity378.sellbodies", "Sell Bodies", "1.0.1")]
	[BepInDependency("evaisa.lethallib", "0.10.0")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("Entity378.sellbodies");

		private const string GUID = "Entity378.sellbodies";

		private const string NAME = "Sell Bodies";

		private const string VERSION = "1.0.1";

		private static string root = "Assets/CleaningAssets/";

		private Dictionary<string, int> minBodyValues;

		private Dictionary<string, bool> BodiesToDrop;

		private Dictionary<string, int> maxBodyValues;

		private Dictionary<string, float> bodyWeights;

		private Dictionary<string, string> pathToName = new Dictionary<string, string>
		{
			{
				root + "HoarderItem.asset",
				"Hoarding bug"
			},
			{
				root + "SpiderItem.asset",
				"Bunker Spider"
			},
			{
				root + "ThumperItem.asset",
				"Crawler"
			},
			{
				root + "CentipedeItem.asset",
				"Centipede"
			},
			{
				root + "NutcrackerItem.asset",
				"Nutcracker"
			},
			{
				root + "BrackenBodyItem.asset",
				"Flowerman"
			},
			{
				root + "BaboonItem.asset",
				"Baboon hawk"
			},
			{
				root + "MouthDogItem.asset",
				"MouthDog"
			}
		};

		public Dictionary<string, Item> BodySpawns = new Dictionary<string, Item>();

		public List<GameObject> tools = new List<GameObject>();

		private AssetBundle bundle;

		public static Plugin instance;

		public static PluginConfig cfg { get; private set; }

		private void Awake()
		{
			cfg = new PluginConfig(((BaseUnityPlugin)this).Config);
			cfg.InitBindings();
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "sellbodies");
			bundle = AssetBundle.LoadFromFile(text);
			instance = this;
			ApplyConfig();
			SetupScrap();
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Sell Bodies is patched!");
		}

		private void ApplyConfig()
		{
			bodyWeights = new Dictionary<string, float>
			{
				{
					root + "HoarderItem.asset",
					cfg.HOARDER_WEIGHT
				},
				{
					root + "SpiderItem.asset",
					cfg.SPIDER_WEIGHT
				},
				{
					root + "ThumperItem.asset",
					cfg.THUMPER_WEIGHT
				},
				{
					root + "NutcrackerItem.asset",
					cfg.NUTCRACKER_WEIGHT
				},
				{
					root + "CentipedeItem.asset",
					cfg.CENTIPEDE_WEIGHT
				},
				{
					root + "BrackenBodyItem.asset",
					cfg.BRACKEN_WEIGHT
				},
				{
					root + "BaboonItem.asset",
					cfg.BABOON_WEIGHT
				},
				{
					root + "MouthDogItem.asset",
					cfg.MOUTHDOG_WEIGHT
				}
			};
			maxBodyValues = new Dictionary<string, int>
			{
				{
					root + "HoarderItem.asset",
					cfg.HOARDER_MAX
				},
				{
					root + "SpiderItem.asset",
					cfg.SPIDER_MAX
				},
				{
					root + "ThumperItem.asset",
					cfg.THUMPER_MAX
				},
				{
					root + "NutcrackerItem.asset",
					cfg.NUTCRACKER_MAX
				},
				{
					root + "CentipedeItem.asset",
					cfg.CENTIPEDE_MAX
				},
				{
					root + "BrackenBodyItem.asset",
					cfg.BRACKEN_MAX
				},
				{
					root + "BaboonItem.asset",
					cfg.BABOON_MAX
				},
				{
					root + "MouthDogItem.asset",
					cfg.MOUTHDOG_MAX
				}
			};
			minBodyValues = new Dictionary<string, int>
			{
				{
					root + "HoarderItem.asset",
					cfg.HOARDER_MIN
				},
				{
					root + "SpiderItem.asset",
					cfg.SPIDER_MIN
				},
				{
					root + "ThumperItem.asset",
					cfg.THUMPER_MIN
				},
				{
					root + "NutcrackerItem.asset",
					cfg.NUTCRACKER_MIN
				},
				{
					root + "CentipedeItem.asset",
					cfg.CENTIPEDE_MIN
				},
				{
					root + "BrackenBodyItem.asset",
					cfg.BRACKEN_MIN
				},
				{
					root + "BaboonItem.asset",
					cfg.BABOON_MIN
				},
				{
					root + "MouthDogItem.asset",
					cfg.MOUTHDOG_MIN
				}
			};
			BodiesToDrop = new Dictionary<string, bool>
			{
				{
					root + "HoarderItem.asset",
					cfg.HOARDER
				},
				{
					root + "SpiderItem.asset",
					cfg.SPIDER
				},
				{
					root + "ThumperItem.asset",
					cfg.THUMPER
				},
				{
					root + "NutcrackerItem.asset",
					cfg.NUTCRACKER
				},
				{
					root + "CentipedeItem.asset",
					cfg.CENTIPEDE
				},
				{
					root + "BrackenBodyItem.asset",
					cfg.BRACKEN
				},
				{
					root + "BaboonItem.asset",
					cfg.BABOON
				},
				{
					root + "MouthDogItem.asset",
					cfg.MOUTHDOG
				}
			};
		}

		private void SetupScrap()
		{
			foreach (KeyValuePair<string, string> item in pathToName)
			{
				Item val = bundle.LoadAsset<Item>(item.Key);
				Utilities.FixMixerGroups(val.spawnPrefab);
				val.twoHanded = true;
				val.spawnPrefab.AddComponent<BodySyncer>();
				val.maxValue = maxBodyValues[item.Key];
				val.minValue = minBodyValues[item.Key];
				val.weight = bodyWeights[item.Key];
				NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
				Items.RegisterItem(val);
				if (BodiesToDrop[item.Key])
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)("Set " + item.Value + " to drop " + val.itemName));
					BodySpawns.Add(item.Value, val);
				}
				else
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)("Disregarding " + val.itemName + " - disabled in config"));
				}
			}
		}
	}
}
namespace CleaningCompany.Patches
{
	[HarmonyPatch(typeof(EnemyAI))]
	internal class EnemyAIPatcher
	{
		private static ulong currentEnemy = 9999999uL;

		[HarmonyPostfix]
		[HarmonyPatch("KillEnemyServerRpc")]
		private static void SpawnScrapBody(EnemyAI __instance)
		{
			if (currentEnemy == ((NetworkBehaviour)__instance).NetworkObject.NetworkObjectId || !((NetworkBehaviour)__instance).IsHost)
			{
				return;
			}
			currentEnemy = ((NetworkBehaviour)__instance).NetworkObject.NetworkObjectId;
			string enemyName = __instance.enemyType.enemyName;
			if (Plugin.instance.BodySpawns.ContainsKey(enemyName))
			{
				if (enemyName == "Nutcracker")
				{
					((MonoBehaviour)__instance).StartCoroutine(SpawnNutcrackerBody(__instance, enemyName));
				}
				else
				{
					((MonoBehaviour)__instance).StartCoroutine(SpawnGenericBody(__instance, enemyName));
				}
			}
		}

		private static IEnumerator SpawnGenericBody(EnemyAI __instance, string name)
		{
			yield return (object)new WaitForSeconds(3f);
			GameObject gameObjectCreated = Object.Instantiate<GameObject>(Plugin.instance.BodySpawns[name].spawnPrefab, ((Component)__instance).transform.position + Vector3.up, Quaternion.identity);
			NetworkObject networkObject = gameObjectCreated.GetComponent<NetworkObject>();
			__instance.EnableEnemyMesh(false, false);
			networkObject.Spawn(false);
			yield return (object)new WaitForSeconds(3f);
			((Component)((Component)__instance).GetComponent<NetworkObject>()).transform.position = new Vector3(-10000f, -10000f, -10000f);
			__instance.EnableEnemyMesh(true, false);
		}

		private static IEnumerator SpawnNutcrackerBody(EnemyAI __instance, string name)
		{
			((GrabbableObject)((Component)__instance).GetComponent<NutcrackerEnemyAI>().gun).isHeldByEnemy = true;
			((GrabbableObject)((Component)__instance).GetComponent<NutcrackerEnemyAI>().gun).grabbableToEnemies = false;
			((GrabbableObject)((Component)__instance).GetComponent<NutcrackerEnemyAI>().gun).grabbable = false;
			yield return (object)new WaitForSeconds(3f);
			((GrabbableObject)((Component)__instance).GetComponent<NutcrackerEnemyAI>().gun).EnableItemMeshes(false);
			__instance.EnableEnemyMesh(false, false);
			GameObject shotgun = ((Component)__instance).GetComponent<NutcrackerEnemyAI>().gunPrefab;
			GameObject shotgunItem = Object.Instantiate<GameObject>(shotgun, ((Component)__instance).transform.position + Vector3.up, Quaternion.identity);
			shotgunItem.GetComponent<NetworkObject>().Spawn(false);
			int shotgunScrapValue = ((GrabbableObject)((Component)__instance).GetComponent<NutcrackerEnemyAI>().gun).scrapValue;
			ShotgunItem gun = shotgunItem.GetComponent<ShotgunItem>();
			((GrabbableObject)gun).SetScrapValue(shotgunScrapValue);
			RoundManager instance = RoundManager.Instance;
			instance.totalScrapValueInLevel += (float)((GrabbableObject)gun).scrapValue;
			RoundManager instance2 = RoundManager.Instance;
			instance2.totalScrapValueInLevel -= (float)((GrabbableObject)((Component)__instance).GetComponent<NutcrackerEnemyAI>().gun).scrapValue;
			((GrabbableObject)gun).isHeldByEnemy = false;
			((GrabbableObject)gun).grabbableToEnemies = true;
			((GrabbableObject)gun).grabbable = true;
			gun.shellsLoaded = 2;
			GameObject gameObjectCreated = Object.Instantiate<GameObject>(Plugin.instance.BodySpawns[name].spawnPrefab, ((Component)__instance).transform.position + Vector3.up, Quaternion.identity);
			NetworkObject networkObject = gameObjectCreated.GetComponent<NetworkObject>();
			networkObject.Spawn(false);
			yield return (object)new WaitForSeconds(3f);
			((Component)((Component)__instance).GetComponent<NetworkObject>()).transform.position = new Vector3(-10000f, -10000f, -10000f);
			__instance.EnableEnemyMesh(true, false);
			((GrabbableObject)((Component)__instance).GetComponent<NutcrackerEnemyAI>().gun).EnableItemMeshes(true);
		}
	}
}
namespace CleaningCompany.Monos
{
	internal class BodySyncer : NetworkBehaviour
	{
		public override void OnNetworkSpawn()
		{
			if (((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsServer)
			{
				((MonoBehaviour)this).StartCoroutine(WaitToSync());
			}
			((NetworkBehaviour)this).OnNetworkSpawn();
		}

		private IEnumerator WaitToSync()
		{
			yield return (object)new WaitForSeconds(1f);
			PhysicsProp prop = ((Component)this).GetComponent<PhysicsProp>();
			int price = Random.Range(((GrabbableObject)prop).itemProperties.minValue, ((GrabbableObject)prop).itemProperties.maxValue);
			SyncDetailsClientRpc(price, new NetworkBehaviourReference((NetworkBehaviour)(object)prop));
		}

		[ClientRpc]
		private void SyncDetailsClientRpc(int price, NetworkBehaviourReference netRef)
		{
			PhysicsProp val = default(PhysicsProp);
			((NetworkBehaviourReference)(ref netRef)).TryGet<PhysicsProp>(ref val, (NetworkManager)null);
			if ((Object)(object)val != (Object)null)
			{
				((GrabbableObject)val).scrapValue = price;
				((GrabbableObject)val).itemProperties.creditsWorth = price;
				((Component)val).GetComponentInChildren<ScanNodeProperties>().subText = $"Value: ${price}";
				Debug.Log((object)"Successfully synced body values");
			}
			else
			{
				Debug.LogError((object)"Failed to resolve network reference!");
			}
		}
	}
}
namespace CleaningCompany.Misc
{
	public class PluginConfig
	{
		private readonly ConfigFile configFile;

		public bool SPIDER { get; set; }

		public bool THUMPER { get; set; }

		public bool NUTCRACKER { get; set; }

		public bool CENTIPEDE { get; set; }

		public bool HOARDER { get; set; }

		public bool BRACKEN { get; set; }

		public bool MOUTHDOG { get; set; }

		public bool BABOON { get; set; }

		public int SPIDER_MIN { get; set; }

		public int THUMPER_MIN { get; set; }

		public int NUTCRACKER_MIN { get; set; }

		public int CENTIPEDE_MIN { get; set; }

		public int HOARDER_MIN { get; set; }

		public int BRACKEN_MIN { get; set; }

		public int MOUTHDOG_MIN { get; set; }

		public int BABOON_MIN { get; set; }

		public int NUTCRACKER_MAX { get; set; }

		public int SPIDER_MAX { get; set; }

		public int THUMPER_MAX { get; set; }

		public int CENTIPEDE_MAX { get; set; }

		public int HOARDER_MAX { get; set; }

		public int BRACKEN_MAX { get; set; }

		public int MOUTHDOG_MAX { get; set; }

		public int BABOON_MAX { get; set; }

		public float NUTCRACKER_WEIGHT { get; set; }

		public float SPIDER_WEIGHT { get; set; }

		public float THUMPER_WEIGHT { get; set; }

		public float CENTIPEDE_WEIGHT { get; set; }

		public float HOARDER_WEIGHT { get; set; }

		public float BRACKEN_WEIGHT { get; set; }

		public float MOUTHDOG_WEIGHT { get; set; }

		public float BABOON_WEIGHT { get; set; }

		public PluginConfig(ConfigFile cfg)
		{
			configFile = cfg;
		}

		private T ConfigEntry<T>(string section, string key, T defaultVal, string description)
		{
			return configFile.Bind<T>(section, key, defaultVal, description).Value;
		}

		public void InitBindings()
		{
			CENTIPEDE_MIN = ConfigEntry("Body Values", "Min price of Centipede Bodies", 45, "");
			CENTIPEDE_MAX = ConfigEntry("Body Values", "Max price of Centipede Bodies", 70, "");
			HOARDER_MIN = ConfigEntry("Body Values", "Min price of Hoarding Bug Bodies", 55, "");
			HOARDER_MAX = ConfigEntry("Body Values", "Max price of Hoarding Bug Bodies", 88, "");
			SPIDER_MIN = ConfigEntry("Body Values", "Min price of Spider Bodies", 70, "");
			SPIDER_MAX = ConfigEntry("Body Values", "Max price of Spider Bodies", 110, "");
			THUMPER_MIN = ConfigEntry("Body Values", "Min price of Thumper Bodies", 120, "");
			THUMPER_MAX = ConfigEntry("Body Values", "Max price of Thumper Bodies", 160, "");
			NUTCRACKER_MIN = ConfigEntry("Body Values", "Min price of Nutcracker Bodies", 125, "");
			NUTCRACKER_MAX = ConfigEntry("Body Values", "Max price of Nutcracker Bodies", 150, "");
			BRACKEN_MAX = ConfigEntry("Body Values", "Max price of Bracken Bodies", 140, "");
			BRACKEN_MIN = ConfigEntry("Body Values", "Min price of Bracken Bodies", 100, "");
			BABOON_MAX = ConfigEntry("Body Values", "Max price of Baboon Hawk Bodies", 155, "");
			BABOON_MIN = ConfigEntry("Body Values", "Min price of Baboon Hawk Bodies", 105, "");
			MOUTHDOG_MAX = ConfigEntry("Body Values", "Max price of Eyeless Dog Bodies", 200, "");
			MOUTHDOG_MIN = ConfigEntry("Body Values", "Min price of Eyeless Dog Bodies", 175, "");
			CENTIPEDE = ConfigEntry("Body Weights", "Enable selling of centipede bodies", defaultVal: true, "");
			HOARDER = ConfigEntry("Body Weights", "Enable selling of hoarder bodies", defaultVal: true, "");
			SPIDER = ConfigEntry("Body Weights", "Enable selling of spider bodies", defaultVal: true, "");
			THUMPER = ConfigEntry("Body Weights", "Enable selling of crawler / half / thumper bodies", defaultVal: true, "");
			NUTCRACKER = ConfigEntry("Body Weights", "Enable selling of nutcracker bodies", defaultVal: true, "");
			MOUTHDOG = ConfigEntry("Body Weights", "Enable selling of eyeless dog bodies", defaultVal: true, "");
			BABOON = ConfigEntry("Body Weights", "Enable selling of baboon hawk bodies", defaultVal: true, "");
			BRACKEN = ConfigEntry("Body Weights", "Enable selling of bracken bodies", defaultVal: true, "");
			CENTIPEDE_WEIGHT = ConfigEntry("Body Weights", "Weight of Centipede Bodies", 1.65f, "");
			HOARDER_WEIGHT = ConfigEntry("Body Weights", "Weight of Hoarding Bug Bodies", 1.6f, "");
			SPIDER_WEIGHT = ConfigEntry("Body Weights", "Weight of Spider Bodies", 2.3f, "");
			THUMPER_WEIGHT = ConfigEntry("Body Weights", "Weight of Thumper Bodies", 2.9f, "");
			NUTCRACKER_WEIGHT = ConfigEntry("Body Weights", "Weight of Nutcracker Bodies", 2.9f, "");
			MOUTHDOG_WEIGHT = ConfigEntry("Body Weights", "Weight of Eyeless Dog Bodies", 3f, "");
			BABOON_WEIGHT = ConfigEntry("Body Weights", "Weight of Baboon Hawk Bodies", 2.5f, "");
			BRACKEN_WEIGHT = ConfigEntry("Body Weights", "Weight of Bracken Bodies", 1.9f, "");
		}
	}
}

plugins/Skibidi.AI.dll

Decompiled 9 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Animations.Rigging;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Skibidi.AI")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Skibidi.AI")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("597be394-0d5f-4dbb-ad1d-4d432b1b4802")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Skibidi.AI
{
	public class SkibidiAI : JesterAI
	{
		private int prevState = 0;

		public TwoBoneIKConstraint headIK;

		public AudioClip tauntClip;

		private float flushTime;

		public override void Start()
		{
			((JesterAI)this).Start();
			Debug.Log((object)"Spawning le skibidi. beware.");
		}

		public virtual void EvtFlush()
		{
			Debug.Log((object)"Flushing!");
			((EnemyAI)this).SwitchToBehaviourState(0);
		}

		public override void Update()
		{
			if (((EnemyAI)this).isEnemyDead)
			{
				return;
			}
			switch (((EnemyAI)this).currentBehaviourStateIndex)
			{
			case 0:
				if (prevState != 0)
				{
					((EnemyAI)this).creatureAnimator.SetBool("flushed", true);
					((EnemyAI)this).creatureVoice.Stop(true);
					((EnemyAI)this).creatureVoice.PlayOneShot(((EnemyAI)this).enemyType.stunSFX);
					flushTime = Time.time;
				}
				((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)headIK).weight = Mathf.Lerp(((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)headIK).weight, 0f, Time.deltaTime * 5f);
				break;
			case 1:
				if (prevState != 1)
				{
					((EnemyAI)this).creatureAnimator.SetBool("flushed", false);
					base.farAudio.PlayOneShot(tauntClip);
				}
				((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)headIK).weight = Mathf.Lerp(((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)headIK).weight, 1f, Time.deltaTime * 5f);
				break;
			case 2:
				if (prevState != 2)
				{
					((EnemyAI)this).creatureAnimator.SetBool("flushed", false);
				}
				((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)headIK).weight = Mathf.Lerp(((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)headIK).weight, 1f, Time.deltaTime * 5f);
				break;
			}
			prevState = ((EnemyAI)this).currentBehaviourStateIndex;
			if (((EnemyAI)this).currentBehaviourStateIndex != 0 || !(Time.time - flushTime < 15f))
			{
				((JesterAI)this).Update();
				((EnemyAI)this).agent.speed = Mathf.Clamp(((EnemyAI)this).agent.speed, 0f, 7.5f);
				if (base.popUpTimer > 10f)
				{
					base.popUpTimer = 10f;
				}
			}
		}
	}
	public class SkibidiSFX : MonoBehaviour
	{
		public SkibidiAI enemy;

		public AudioClip brrClip;

		public AudioClip skibidiClip;

		public float skibidiRamp = 0f;

		public virtual void PlayBrrSFX()
		{
			if (skibidiRamp > 1f)
			{
				skibidiRamp = 1f;
			}
			((JesterAI)enemy).farAudio.pitch = 1f + skibidiRamp;
			((JesterAI)enemy).farAudio.PlayOneShot(brrClip);
			skibidiRamp += 0.02f;
		}

		public virtual void PlaySkibidiSFX()
		{
			((JesterAI)enemy).farAudio.pitch = 1f;
			skibidiRamp = 0f;
			((EnemyAI)enemy).creatureVoice.PlayOneShot(skibidiClip);
		}
	}
}

plugins/Skibidi.dll

Decompiled 9 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Skibidi.AI;
using UnityEngine;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Skibidi
{
	public static class Assets
	{
		public static string mainAssetBundleName = "skibidibundle";

		public static AssetBundle MainAssetBundle = null;

		private static string GetAssemblyName()
		{
			return Assembly.GetExecutingAssembly().FullName.Split(',')[0];
		}

		public static void PopulateAssets()
		{
			if ((Object)(object)MainAssetBundle == (Object)null)
			{
				using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetAssemblyName() + "." + mainAssetBundleName))
				{
					MainAssetBundle = AssetBundle.LoadFromStream(stream);
				}
			}
		}
	}
	[BepInPlugin("rileyzzz.Skibidi", "Skibidi Toilet", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private void Awake()
		{
			Assets.PopulateAssets();
			EnemyType val = Assets.MainAssetBundle.LoadAsset<EnemyType>("SkibidiDef");
			TerminalNode val2 = Assets.MainAssetBundle.LoadAsset<TerminalNode>("SkibidiFile");
			TerminalKeyword val3 = Assets.MainAssetBundle.LoadAsset<TerminalKeyword>("Skibidi");
			NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
			Type typeFromHandle = typeof(SkibidiAI);
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"Skibidi AI {typeFromHandle}");
			Enemies.RegisterEnemy(val, 22, (LevelTypes)(-1), (SpawnType)0, val2, val3);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Skibidi is loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "Skibidi";

		public const string PLUGIN_NAME = "Skibidi";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}

plugins/SkinwalkerMod.dll

Decompiled 9 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.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Dissonance;
using Dissonance.Config;
using HarmonyLib;
using SkinwalkerMod.Properties;
using Steamworks;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SkinwalkerMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SkinwalkerMod")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("fd4979a2-cef0-46af-8bf8-97e630b11475")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
internal class <Module>
{
	static <Module>()
	{
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>();
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<float>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<float>();
	}
}
namespace SkinwalkerMod
{
	internal class LogoManager : MonoBehaviour
	{
		private AssetBundle bundle;

		private readonly Logo[] logos = new Logo[6]
		{
			new Logo
			{
				fileName = "Teo",
				playerNames = new string[9] { "SAMMY", "paddy", "Ozias", "Teo", "Rugbug Redfern", "WuluKing", "Boolie", "TeaEditor", "FlashGamesNemesis" }
			},
			new Logo
			{
				fileName = "OfflineTV",
				playerNames = new string[3] { "Masayoshi", "QUARTERJADE", "DisguisedToast" }
			},
			new Logo
			{
				fileName = "Neuro",
				playerNames = new string[1] { "vedal" }
			},
			new Logo
			{
				fileName = "Mogul",
				playerNames = new string[2] { "ludwig", "AirCoots" }
			},
			new Logo
			{
				fileName = "Imp",
				playerNames = new string[1] { "camila" }
			},
			new Logo
			{
				fileName = "Iron",
				playerNames = new string[1] { "ironmouse" }
			}
		};

		private Image cachedHeader;

		private Image cachedLogoHeader;

		private void Awake()
		{
			try
			{
				bundle = AssetBundle.LoadFromMemory(Resources.logos);
				SceneManager.sceneLoaded += OnSceneLoaded;
			}
			catch (Exception ex)
			{
				SkinwalkerLogger.LogError("LogoManager Awake Error: " + ex.Message);
			}
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			try
			{
				if (!(((Scene)(ref scene)).name == "MainMenu"))
				{
					return;
				}
				cachedHeader = GameObject.Find("HeaderImage").GetComponent<Image>();
				cachedLogoHeader = ((Component)GameObject.Find("Canvas/MenuContainer").transform.GetChild(0).GetChild(1)).GetComponent<Image>();
				string value = SteamClient.Name.ToString();
				Logo[] array = logos;
				foreach (Logo logo in array)
				{
					string[] playerNames = logo.playerNames;
					foreach (string text in playerNames)
					{
						if (text.Equals(value, StringComparison.OrdinalIgnoreCase))
						{
							((MonoBehaviour)this).StartCoroutine(I_ChangeLogo(bundle.LoadAsset<Sprite>("Assets/Logos/" + logo.fileName + ".png")));
							return;
						}
					}
				}
			}
			catch (Exception ex)
			{
				SkinwalkerLogger.LogError("LogoManager OnSceneLoaded Error: " + ex.Message + ". If you launched in LAN mode, then this is just gonna happen, it doesn't break anything so don't worry about it.");
			}
		}

		private IEnumerator I_ChangeLogo(Sprite sprite)
		{
			for (int i = 0; i < 20; i++)
			{
				if ((Object)(object)cachedHeader == (Object)null)
				{
					break;
				}
				if ((Object)(object)cachedLogoHeader == (Object)null)
				{
					break;
				}
				SetHeaderImage(sprite);
				yield return null;
			}
		}

		private void SetHeaderImage(Sprite sprite)
		{
			if (!((Object)(object)sprite == (Object)null))
			{
				cachedHeader.sprite = sprite;
				cachedLogoHeader.sprite = sprite;
			}
		}
	}
	internal class Logo
	{
		public string fileName;

		public string[] playerNames;
	}
	[BepInPlugin("RugbugRedfern.SkinwalkerMod", "Skinwalker Mod", "2.0.7")]
	internal class PluginLoader : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("RugbugRedfern.SkinwalkerMod");

		private const string modGUID = "RugbugRedfern.SkinwalkerMod";

		private const string modVersion = "2.0.7";

		private static bool initialized;

		public static PluginLoader Instance { get; private set; }

		private void Awake()
		{
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Expected O, but got Unknown
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Expected O, but got Unknown
			if (initialized)
			{
				return;
			}
			initialized = true;
			Instance = this;
			harmony.PatchAll(Assembly.GetExecutingAssembly());
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			SkinwalkerLogger.Initialize("RugbugRedfern.SkinwalkerMod");
			SkinwalkerLogger.Log("SKINWALKER MOD STARTING UP 2.0.7");
			SkinwalkerConfig.InitConfig();
			SceneManager.sceneLoaded += SkinwalkerNetworkManagerHandler.ClientConnectInitializer;
			GameObject val = new GameObject("Skinwalker Mod");
			val.AddComponent<SkinwalkerModPersistent>();
			((Object)val).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)val);
			Logs.SetLogLevel((LogCategory)1, (LogLevel)4);
			Logs.SetLogLevel((LogCategory)3, (LogLevel)4);
			Logs.SetLogLevel((LogCategory)2, (LogLevel)4);
			GameObject val2 = new GameObject("Logo Manager");
			val2.AddComponent<LogoManager>();
			((Object)val2).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)val2);
		}

		public void BindConfig<T>(ref ConfigEntry<T> config, string section, string key, T defaultValue, string description = "")
		{
			config = ((BaseUnityPlugin)this).Config.Bind<T>(section, key, defaultValue, description);
		}
	}
	internal class SkinwalkerBehaviour : MonoBehaviour
	{
		private AudioSource audioSource;

		public const float PLAY_INTERVAL_MIN = 15f;

		public const float PLAY_INTERVAL_MAX = 40f;

		private const float MAX_DIST = 100f;

		private float nextTimeToPlayAudio;

		private EnemyAI ai;

		public void Initialize(EnemyAI ai)
		{
			this.ai = ai;
			audioSource = ai.creatureVoice;
			SetNextTime();
		}

		private void Update()
		{
			if (Time.time > nextTimeToPlayAudio)
			{
				SetNextTime();
				AttemptPlaySound();
			}
		}

		private void AttemptPlaySound()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_0127: 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_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			float num = -1f;
			if (Object.op_Implicit((Object)(object)ai) && !ai.isEnemyDead)
			{
				if (((Object)((Component)ai).gameObject).name == "DressGirl(Clone)")
				{
					DressGirlAI val = (DressGirlAI)ai;
					if ((Object)(object)val.hauntingPlayer != (Object)(object)StartOfRound.Instance.localPlayerController)
					{
						SkinwalkerLogger.Log(((Object)this).name + " played voice line no (not haunted) EnemyAI: " + (object)ai);
						return;
					}
					if (!val.staringInHaunt && !((EnemyAI)val).moveTowardsDestination)
					{
						SkinwalkerLogger.Log(((Object)this).name + " played voice line no (not visible) EnemyAI: " + (object)ai);
						return;
					}
				}
				Vector3 val2 = (StartOfRound.Instance.localPlayerController.isPlayerDead ? ((Component)StartOfRound.Instance.spectateCamera).transform.position : ((Component)StartOfRound.Instance.localPlayerController).transform.position);
				if ((Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)StartOfRound.Instance.localPlayerController == (Object)null || (num = Vector3.Distance(val2, ((Component)this).transform.position)) < 100f)
				{
					AudioClip sample = SkinwalkerModPersistent.Instance.GetSample();
					if (Object.op_Implicit((Object)(object)sample))
					{
						SkinwalkerLogger.Log(((Object)this).name + " played voice line 1");
						audioSource.PlayOneShot(sample);
					}
					else
					{
						SkinwalkerLogger.Log(((Object)this).name + " played voice line 0");
					}
				}
				else
				{
					SkinwalkerLogger.Log(((Object)this).name + " played voice line no (too far away) " + num);
				}
			}
			else
			{
				SkinwalkerLogger.Log(((Object)this).name + " played voice line no (dead) EnemyAI: " + (object)ai);
			}
		}

		private void SetNextTime()
		{
			if (SkinwalkerNetworkManager.Instance.VoiceLineFrequency.Value <= 0f)
			{
				nextTimeToPlayAudio = Time.time + 100000000f;
			}
			else
			{
				nextTimeToPlayAudio = Time.time + Random.Range(15f, 40f) / SkinwalkerNetworkManager.Instance.VoiceLineFrequency.Value;
			}
		}

		private T CopyComponent<T>(T original, GameObject destination) where T : Component
		{
			Type type = ((object)original).GetType();
			Component val = destination.AddComponent(type);
			FieldInfo[] fields = type.GetFields();
			FieldInfo[] array = fields;
			foreach (FieldInfo fieldInfo in array)
			{
				fieldInfo.SetValue(val, fieldInfo.GetValue(original));
			}
			return (T)(object)((val is T) ? val : null);
		}
	}
	internal class SkinwalkerConfig
	{
		public static ConfigEntry<bool> VoiceEnabled_BaboonHawk;

		public static ConfigEntry<bool> VoiceEnabled_Bracken;

		public static ConfigEntry<bool> VoiceEnabled_BunkerSpider;

		public static ConfigEntry<bool> VoiceEnabled_Centipede;

		public static ConfigEntry<bool> VoiceEnabled_CoilHead;

		public static ConfigEntry<bool> VoiceEnabled_EyelessDog;

		public static ConfigEntry<bool> VoiceEnabled_ForestGiant;

		public static ConfigEntry<bool> VoiceEnabled_GhostGirl;

		public static ConfigEntry<bool> VoiceEnabled_GiantWorm;

		public static ConfigEntry<bool> VoiceEnabled_HoardingBug;

		public static ConfigEntry<bool> VoiceEnabled_Hygrodere;

		public static ConfigEntry<bool> VoiceEnabled_Jester;

		public static ConfigEntry<bool> VoiceEnabled_Masked;

		public static ConfigEntry<bool> VoiceEnabled_Nutcracker;

		public static ConfigEntry<bool> VoiceEnabled_SporeLizard;

		public static ConfigEntry<bool> VoiceEnabled_Thumper;

		public static ConfigEntry<bool> VoiceEnabled_OtherEnemies;

		public static ConfigEntry<float> VoiceLineFrequency;

		public static void InitConfig()
		{
			PluginLoader.Instance.BindConfig(ref VoiceLineFrequency, "Voice Settings", "VoiceLineFrequency", 1f, "1 is the default, and voice lines will occur every " + 15f.ToString("0") + " to " + 40f.ToString("0") + " seconds per enemy. Setting this to 2 means they will occur twice as often, 0.5 means half as often, etc.");
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_BaboonHawk, "Monster Voices", "Baboon Hawk", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_Bracken, "Monster Voices", "Bracken", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_BunkerSpider, "Monster Voices", "Bunker Spider", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_Centipede, "Monster Voices", "Centipede", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_CoilHead, "Monster Voices", "Coil Head", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_EyelessDog, "Monster Voices", "Eyeless Dog", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_ForestGiant, "Monster Voices", "Forest Giant", defaultValue: false);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_GhostGirl, "Monster Voices", "Ghost Girl", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_GiantWorm, "Monster Voices", "Giant Worm", defaultValue: false);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_HoardingBug, "Monster Voices", "Hoarding Bug", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_Hygrodere, "Monster Voices", "Hygrodere", defaultValue: false);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_Jester, "Monster Voices", "Jester", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_Masked, "Monster Voices", "Masked", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_Nutcracker, "Monster Voices", "Nutcracker", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_SporeLizard, "Monster Voices", "Spore Lizard", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_Thumper, "Monster Voices", "Thumper", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_OtherEnemies, "Monster Voices", "Other Enemies (Including Modded)", defaultValue: true);
			SkinwalkerLogger.Log("VoiceEnabled_BaboonHawk" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_BaboonHawk.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_Bracken" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Bracken.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_BunkerSpider" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_BunkerSpider.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_Centipede" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Centipede.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_CoilHead" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_CoilHead.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_EyelessDog" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_EyelessDog.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_ForestGiant" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_ForestGiant.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_GhostGirl" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_GhostGirl.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_GiantWorm" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_GiantWorm.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_HoardingBug" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_HoardingBug.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_Hygrodere" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Hygrodere.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_Jester" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Jester.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_Masked" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Masked.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_Nutcracker" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Nutcracker.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_SporeLizard" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_SporeLizard.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_Thumper" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Thumper.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_OtherEnemies" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_OtherEnemies.Value}]");
			SkinwalkerLogger.Log("VoiceLineFrequency" + $" VALUE LOADED FROM CONFIG: [{VoiceLineFrequency.Value}]");
		}
	}
	internal static class SkinwalkerLogger
	{
		internal static ManualLogSource logSource;

		public static void Initialize(string modGUID)
		{
			logSource = Logger.CreateLogSource(modGUID);
		}

		public static void Log(object message)
		{
			logSource.LogInfo(message);
		}

		public static void LogError(object message)
		{
			logSource.LogError(message);
		}

		public static void LogWarning(object message)
		{
			logSource.LogWarning(message);
		}
	}
	public class SkinwalkerModPersistent : MonoBehaviour
	{
		private string audioFolder;

		private List<AudioClip> cachedAudio = new List<AudioClip>();

		private float nextTimeToCheckFolder = 30f;

		private float nextTimeToCheckEnemies = 30f;

		private const float folderScanInterval = 8f;

		private const float enemyScanInterval = 5f;

		public static SkinwalkerModPersistent Instance { get; private set; }

		private void Awake()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			((Component)this).transform.position = Vector3.zero;
			SkinwalkerLogger.Log("Skinwalker Mod Object Initialized");
			audioFolder = Path.Combine(Application.dataPath, "..", "Dissonance_Diagnostics");
			EnableRecording();
			if (!Directory.Exists(audioFolder))
			{
				Directory.CreateDirectory(audioFolder);
			}
		}

		private void Start()
		{
			try
			{
				if (Directory.Exists(audioFolder))
				{
					Directory.Delete(audioFolder, recursive: true);
				}
			}
			catch (Exception message)
			{
				SkinwalkerLogger.Log(message);
			}
		}

		private void OnApplicationQuit()
		{
			DisableRecording();
		}

		private void EnableRecording()
		{
			DebugSettings.Instance.EnablePlaybackDiagnostics = true;
			DebugSettings.Instance.RecordFinalAudio = true;
		}

		private void Update()
		{
			if (Time.realtimeSinceStartup > nextTimeToCheckFolder)
			{
				nextTimeToCheckFolder = Time.realtimeSinceStartup + 8f;
				if (!Directory.Exists(audioFolder))
				{
					SkinwalkerLogger.Log("Audio folder not present. Don't worry about it, it will be created automatically when you play with friends. (" + audioFolder + ")");
					return;
				}
				string[] files = Directory.GetFiles(audioFolder);
				SkinwalkerLogger.Log($"Got audio file paths ({files.Length})");
				string[] array = files;
				foreach (string path in array)
				{
					((MonoBehaviour)this).StartCoroutine(LoadWavFile(path, delegate(AudioClip audioClip)
					{
						cachedAudio.Add(audioClip);
					}));
				}
			}
			if (!(Time.realtimeSinceStartup > nextTimeToCheckEnemies))
			{
				return;
			}
			nextTimeToCheckEnemies = Time.realtimeSinceStartup + 5f;
			EnemyAI[] array2 = Object.FindObjectsOfType<EnemyAI>(true);
			EnemyAI[] array3 = array2;
			SkinwalkerBehaviour skinwalkerBehaviour = default(SkinwalkerBehaviour);
			foreach (EnemyAI val in array3)
			{
				SkinwalkerLogger.Log("IsEnemyEnabled " + ((Object)val).name + " " + IsEnemyEnabled(val));
				if (IsEnemyEnabled(val) && !((Component)val).TryGetComponent<SkinwalkerBehaviour>(ref skinwalkerBehaviour))
				{
					((Component)val).gameObject.AddComponent<SkinwalkerBehaviour>().Initialize(val);
				}
			}
		}

		private bool IsEnemyEnabled(EnemyAI enemy)
		{
			if ((Object)(object)enemy == (Object)null)
			{
				return false;
			}
			return ((Object)((Component)enemy).gameObject).name switch
			{
				"MaskedPlayerEnemy(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Masked.Value, 
				"NutcrackerEnemy(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Nutcracker.Value, 
				"BaboonHawkEnemy(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_BaboonHawk.Value, 
				"Flowerman(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Bracken.Value, 
				"SandSpider(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_BunkerSpider.Value, 
				"RedLocustBees(Clone)" => false, 
				"Centipede(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Centipede.Value, 
				"SpringMan(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_CoilHead.Value, 
				"MouthDog(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_EyelessDog.Value, 
				"ForestGiant(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_ForestGiant.Value, 
				"DressGirl(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_GhostGirl.Value, 
				"SandWorm(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_GiantWorm.Value, 
				"HoarderBug(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_HoardingBug.Value, 
				"Blob(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Hygrodere.Value, 
				"JesterEnemy(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Jester.Value, 
				"PufferEnemy(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_SporeLizard.Value, 
				"Crawler(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Thumper.Value, 
				"DocileLocustBees(Clone)" => false, 
				"DoublewingedBird(Clone)" => false, 
				_ => SkinwalkerNetworkManager.Instance.VoiceEnabled_OtherEnemies.Value, 
			};
		}

		internal IEnumerator LoadWavFile(string path, Action<AudioClip> callback)
		{
			UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(path, (AudioType)20);
			try
			{
				yield return www.SendWebRequest();
				if ((int)www.result == 1)
				{
					SkinwalkerLogger.Log("Loaded clip from path " + path);
					AudioClip audioClip = DownloadHandlerAudioClip.GetContent(www);
					if (audioClip.length > 0.9f)
					{
						callback(audioClip);
					}
					try
					{
						File.Delete(path);
					}
					catch (Exception e)
					{
						SkinwalkerLogger.LogWarning(e);
					}
				}
			}
			finally
			{
				((IDisposable)www)?.Dispose();
			}
		}

		private void DisableRecording()
		{
			DebugSettings.Instance.EnablePlaybackDiagnostics = false;
			DebugSettings.Instance.RecordFinalAudio = false;
			if (Directory.Exists(audioFolder))
			{
				Directory.Delete(audioFolder, recursive: true);
			}
		}

		public AudioClip GetSample()
		{
			while (cachedAudio.Count > 200)
			{
				cachedAudio.RemoveAt(Random.Range(0, cachedAudio.Count));
			}
			if (cachedAudio.Count > 0)
			{
				int index = Random.Range(0, cachedAudio.Count - 1);
				AudioClip result = cachedAudio[index];
				cachedAudio.RemoveAt(index);
				return result;
			}
			return null;
		}

		public void ClearCache()
		{
			cachedAudio.Clear();
		}
	}
	internal static class SkinwalkerNetworkManagerHandler
	{
		internal static void ClientConnectInitializer(Scene sceneName, LoadSceneMode sceneEnum)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			if (((Scene)(ref sceneName)).name == "SampleSceneRelay")
			{
				GameObject val = new GameObject("SkinwalkerNetworkManager");
				val.AddComponent<NetworkObject>();
				val.AddComponent<SkinwalkerNetworkManager>();
				Debug.Log((object)"Initialized SkinwalkerNetworkManager");
			}
		}
	}
	internal class SkinwalkerNetworkManager : NetworkBehaviour
	{
		public NetworkVariable<bool> VoiceEnabled_BaboonHawk = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_Bracken = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_BunkerSpider = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_Centipede = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_CoilHead = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_EyelessDog = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_ForestGiant = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_GhostGirl = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_GiantWorm = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_HoardingBug = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_Hygrodere = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_Jester = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_Masked = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_Nutcracker = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_SporeLizard = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_Thumper = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_OtherEnemies = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<float> VoiceLineFrequency = new NetworkVariable<float>(1f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public static SkinwalkerNetworkManager Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
			if (GameNetworkManager.Instance.isHostingGame)
			{
				VoiceEnabled_BaboonHawk.Value = SkinwalkerConfig.VoiceEnabled_BaboonHawk.Value;
				VoiceEnabled_Bracken.Value = SkinwalkerConfig.VoiceEnabled_Bracken.Value;
				VoiceEnabled_BunkerSpider.Value = SkinwalkerConfig.VoiceEnabled_BunkerSpider.Value;
				VoiceEnabled_Centipede.Value = SkinwalkerConfig.VoiceEnabled_Centipede.Value;
				VoiceEnabled_CoilHead.Value = SkinwalkerConfig.VoiceEnabled_CoilHead.Value;
				VoiceEnabled_EyelessDog.Value = SkinwalkerConfig.VoiceEnabled_EyelessDog.Value;
				VoiceEnabled_ForestGiant.Value = SkinwalkerConfig.VoiceEnabled_ForestGiant.Value;
				VoiceEnabled_GhostGirl.Value = SkinwalkerConfig.VoiceEnabled_GhostGirl.Value;
				VoiceEnabled_GiantWorm.Value = SkinwalkerConfig.VoiceEnabled_GiantWorm.Value;
				VoiceEnabled_HoardingBug.Value = SkinwalkerConfig.VoiceEnabled_HoardingBug.Value;
				VoiceEnabled_Hygrodere.Value = SkinwalkerConfig.VoiceEnabled_Hygrodere.Value;
				VoiceEnabled_Jester.Value = SkinwalkerConfig.VoiceEnabled_Jester.Value;
				VoiceEnabled_Masked.Value = SkinwalkerConfig.VoiceEnabled_Masked.Value;
				VoiceEnabled_Nutcracker.Value = SkinwalkerConfig.VoiceEnabled_Nutcracker.Value;
				VoiceEnabled_SporeLizard.Value = SkinwalkerConfig.VoiceEnabled_SporeLizard.Value;
				VoiceEnabled_Thumper.Value = SkinwalkerConfig.VoiceEnabled_Thumper.Value;
				VoiceEnabled_OtherEnemies.Value = SkinwalkerConfig.VoiceEnabled_OtherEnemies.Value;
				VoiceLineFrequency.Value = SkinwalkerConfig.VoiceLineFrequency.Value;
				SkinwalkerLogger.Log("HOST SENDING CONFIG TO CLIENTS");
			}
			SkinwalkerLogger.Log("SkinwalkerNetworkManager Awake");
		}

		public override void OnDestroy()
		{
			((NetworkBehaviour)this).OnDestroy();
			SkinwalkerLogger.Log("SkinwalkerNetworkManager OnDestroy");
			SkinwalkerModPersistent.Instance?.ClearCache();
		}

		protected override void __initializeVariables()
		{
			if (VoiceEnabled_BaboonHawk == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_BaboonHawk cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_BaboonHawk).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_BaboonHawk, "VoiceEnabled_BaboonHawk");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_BaboonHawk);
			if (VoiceEnabled_Bracken == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Bracken cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_Bracken).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Bracken, "VoiceEnabled_Bracken");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Bracken);
			if (VoiceEnabled_BunkerSpider == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_BunkerSpider cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_BunkerSpider).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_BunkerSpider, "VoiceEnabled_BunkerSpider");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_BunkerSpider);
			if (VoiceEnabled_Centipede == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Centipede cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_Centipede).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Centipede, "VoiceEnabled_Centipede");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Centipede);
			if (VoiceEnabled_CoilHead == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_CoilHead cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_CoilHead).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_CoilHead, "VoiceEnabled_CoilHead");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_CoilHead);
			if (VoiceEnabled_EyelessDog == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_EyelessDog cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_EyelessDog).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_EyelessDog, "VoiceEnabled_EyelessDog");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_EyelessDog);
			if (VoiceEnabled_ForestGiant == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_ForestGiant cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_ForestGiant).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_ForestGiant, "VoiceEnabled_ForestGiant");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_ForestGiant);
			if (VoiceEnabled_GhostGirl == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_GhostGirl cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_GhostGirl).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_GhostGirl, "VoiceEnabled_GhostGirl");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_GhostGirl);
			if (VoiceEnabled_GiantWorm == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_GiantWorm cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_GiantWorm).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_GiantWorm, "VoiceEnabled_GiantWorm");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_GiantWorm);
			if (VoiceEnabled_HoardingBug == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_HoardingBug cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_HoardingBug).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_HoardingBug, "VoiceEnabled_HoardingBug");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_HoardingBug);
			if (VoiceEnabled_Hygrodere == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Hygrodere cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_Hygrodere).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Hygrodere, "VoiceEnabled_Hygrodere");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Hygrodere);
			if (VoiceEnabled_Jester == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Jester cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_Jester).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Jester, "VoiceEnabled_Jester");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Jester);
			if (VoiceEnabled_Masked == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Masked cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_Masked).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Masked, "VoiceEnabled_Masked");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Masked);
			if (VoiceEnabled_Nutcracker == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Nutcracker cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_Nutcracker).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Nutcracker, "VoiceEnabled_Nutcracker");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Nutcracker);
			if (VoiceEnabled_SporeLizard == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_SporeLizard cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_SporeLizard).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_SporeLizard, "VoiceEnabled_SporeLizard");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_SporeLizard);
			if (VoiceEnabled_Thumper == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Thumper cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_Thumper).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Thumper, "VoiceEnabled_Thumper");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Thumper);
			if (VoiceEnabled_OtherEnemies == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_OtherEnemies cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_OtherEnemies).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_OtherEnemies, "VoiceEnabled_OtherEnemies");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_OtherEnemies);
			if (VoiceLineFrequency == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceLineFrequency cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceLineFrequency).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceLineFrequency, "VoiceLineFrequency");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceLineFrequency);
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected internal override string __getTypeName()
		{
			return "SkinwalkerNetworkManager";
		}
	}
}
namespace SkinwalkerMod.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.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)
				{
					ResourceManager resourceManager = new ResourceManager("SkinwalkerMod.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

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

		internal static byte[] logos
		{
			get
			{
				object @object = ResourceManager.GetObject("logos", resourceCulture);
				return (byte[])@object;
			}
		}

		internal Resources()
		{
		}
	}
}

plugins/SnatchingBracken.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DunGen;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using RuntimeNetcodeRPCValidator;
using SnatchinBracken;
using SnatchinBracken.Patches;
using SnatchinBracken.Patches.data;
using SnatchingBracken;
using SnatchingBracken.Patches.dungeon;
using SnatchingBracken.Patches.network;
using SnatchingBracken.Patches.tasks;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SnatchingBracken")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SnatchingBracken")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("afcd9203-dbdd-4b28-85a1-fb12890f0d98")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SnatchinBracken
{
	[BepInPlugin("Ovchinikov.SnatchinBracken.Main", "SnatchinBracken", "1.3.7")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class SnatchinBrackenBase : BaseUnityPlugin
	{
		private const string modGUID = "Ovchinikov.SnatchinBracken.Main";

		private const string modName = "SnatchinBracken";

		private const string modVersion = "1.3.7";

		private static SnatchinBrackenBase _instance;

		private readonly Harmony harmony = new Harmony("Ovchinikov.SnatchinBracken.Main");

		private static SnatchinBrackenBase instance;

		private NetcodeValidator netcodeValidator;

		internal ManualLogSource mls;

		public static SnatchinBrackenBase Instance => _instance;

		private void Awake()
		{
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Expected O, but got Unknown
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			if ((Object)(object)_instance == (Object)null)
			{
				_instance = this;
			}
			else if ((Object)(object)_instance != (Object)(object)this)
			{
				Object.Destroy((Object)(object)this);
				return;
			}
			mls = Logger.CreateLogSource("Ovchinikov.SnatchinBracken.Main");
			mls.LogInfo((object)"Enabling SnatchinBracken");
			InitializeConfigValues();
			harmony.PatchAll(typeof(SnatchinBrackenBase));
			harmony.PatchAll(typeof(BrackenAIPatch));
			harmony.PatchAll(typeof(EnemyAIPatch));
			harmony.PatchAll(typeof(TeleporterPatch));
			harmony.PatchAll(typeof(LandminePatch));
			harmony.PatchAll(typeof(TurretPatch));
			harmony.PatchAll(typeof(PlayerPatch));
			harmony.PatchAll(typeof(DungeonGenPatch));
			harmony.PatchAll(typeof(StartOfRound));
			netcodeValidator = new NetcodeValidator("Ovchinikov.SnatchinBracken.Main");
			netcodeValidator.PatchAll();
			netcodeValidator.BindToPreExistingObjectByBehaviour<FlowermanBinding, PlayerControllerB>();
			mls.LogInfo((object)"Finished Enabling SnatchinBracken");
		}

		private void InitializeConfigValues()
		{
			mls.LogInfo((object)"Parsing SnatchinBracken config");
			if (AppDomain.CurrentDomain.GetAssemblies().Any((Assembly assembly) => assembly.GetName().Name.Equals("LethalConfig")))
			{
				mls.LogInfo((object)"Found LethalConfigAPI, let's use that.");
				LethalConfigAPIHook.InitializeConfig();
			}
			else
			{
				mls.LogInfo((object)"LethalConfigAPI not found, using built-in BepInEx config stuff.");
				ConfigEntry<bool> dropItemsOption = ((BaseUnityPlugin)this).Config.Bind<bool>("SnatchinBracken Settings", "Drop Items on Snatch", true, "Should players drop their items when a Bracken grabs them?");
				SharedData.Instance.DropItems = dropItemsOption.Value;
				dropItemsOption.SettingChanged += delegate
				{
					if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
					{
						SharedData.Instance.DropItems = dropItemsOption.Value;
					}
				};
				ConfigEntry<bool> turretOption = ((BaseUnityPlugin)this).Config.Bind<bool>("SnatchinBracken Settings", "Ignore Turrets on Snatch", true, "Should players be targetable when dragged?");
				SharedData.Instance.IgnoreTurrets = turretOption.Value;
				turretOption.SettingChanged += delegate
				{
					if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
					{
						SharedData.Instance.IgnoreTurrets = turretOption.Value;
					}
				};
				ConfigEntry<bool> chaoticOption = ((BaseUnityPlugin)this).Config.Bind<bool>("SnatchinBracken Settings", "Brackens Behave More Naturally", false, "If enabled, Brackens will perform kills at unpredictable times after an initial drop. Otherwise, the Bracken either must be in distance of the favorite location, or hit the time limit.");
				SharedData.Instance.ChaoticTendencies = chaoticOption.Value;
				chaoticOption.SettingChanged += delegate
				{
					if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
					{
						SharedData.Instance.ChaoticTendencies = chaoticOption.Value;
					}
				};
				ConfigEntry<bool> allowDraggedTps = ((BaseUnityPlugin)this).Config.Bind<bool>("SnatchinBracken Settings", "Allow teleports to save dragged players", true, "Should players be able to be saved through teleportation?");
				SharedData.Instance.AllowTeleports = allowDraggedTps.Value;
				allowDraggedTps.SettingChanged += delegate
				{
					if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
					{
						SharedData.Instance.AllowTeleports = allowDraggedTps.Value;
					}
				};
				ConfigEntry<bool> monstersIgnorePlayersOption = ((BaseUnityPlugin)this).Config.Bind<bool>("SnatchinBracken Settings", "Enemies Ignore Dragged Players", true, "Should players be ignored by other monsters while being dragged?");
				SharedData.Instance.monstersIgnorePlayers = monstersIgnorePlayersOption.Value;
				monstersIgnorePlayersOption.SettingChanged += delegate
				{
					if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
					{
						SharedData.Instance.monstersIgnorePlayers = monstersIgnorePlayersOption.Value;
					}
				};
				ConfigEntry<bool> stuckForceKillOption = ((BaseUnityPlugin)this).Config.Bind<bool>("SnatchinBracken Settings", "Stuck Force Kill", false, "If enabled, Brackens will force kill when stuck at the same spot for at least 5 seconds.");
				SharedData.Instance.StuckForceKill = stuckForceKillOption.Value;
				stuckForceKillOption.SettingChanged += delegate
				{
					if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
					{
						SharedData.Instance.StuckForceKill = stuckForceKillOption.Value;
					}
				};
				ConfigEntry<bool> brackenRoomOption = ((BaseUnityPlugin)this).Config.Bind<bool>("SnatchinBracken Settings", "Force Set Favorite Location To Bracken Room", true, "If enabled, Brackens' favorite locations will be set to the Bracken room. The room sometimes doesn't spawn, so please don't be alarmed if they don't take you there if this is enabled.");
				SharedData.Instance.BrackenRoom = brackenRoomOption.Value;
				brackenRoomOption.SettingChanged += delegate
				{
					if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
					{
						SharedData.Instance.BrackenRoom = brackenRoomOption.Value;
					}
				};
				ConfigEntry<bool> mineOption = ((BaseUnityPlugin)this).Config.Bind<bool>("SnatchinBracken Settings", "Ignore Mines on Snatch", true, "Should players ignore Landmines while being dragged?");
				SharedData.Instance.IgnoreMines = mineOption.Value;
				mineOption.SettingChanged += delegate
				{
					if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
					{
						SharedData.Instance.IgnoreMines = mineOption.Value;
					}
				};
				ConfigEntry<int> instaKillTimeEntry = ((BaseUnityPlugin)this).Config.Bind<int>("SnatchinBracken Settings", "Chance for Insta Kill", 0, "Percent chance for insta kill, 0 to disable.");
				SharedData.Instance.PercentChanceForInsta = instaKillTimeEntry.Value;
				instaKillTimeEntry.SettingChanged += delegate
				{
					if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
					{
						SharedData.Instance.PercentChanceForInsta = instaKillTimeEntry.Value;
					}
				};
				ConfigEntry<int> brackenKillTimeEntry = ((BaseUnityPlugin)this).Config.Bind<int>("SnatchinBracken Settings", "Seconds Until Auto Kill", 15, "Time in seconds until Bracken automatically kills when grabbed. Range: 1-60 seconds.");
				SharedData.Instance.KillAtTime = brackenKillTimeEntry.Value;
				brackenKillTimeEntry.SettingChanged += delegate
				{
					if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
					{
						SharedData.Instance.KillAtTime = brackenKillTimeEntry.Value;
					}
				};
				ConfigEntry<int> brackenNextAttemptEntry = ((BaseUnityPlugin)this).Config.Bind<int>("SnatchinBracken Settings", "Seconds Until Next Attempt", 5, "Time in seconds until Bracken is allowed to take another victim.");
				SharedData.Instance.SecondsBeforeNextAttempt = brackenNextAttemptEntry.Value;
				brackenNextAttemptEntry.SettingChanged += delegate
				{
					if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
					{
						SharedData.Instance.SecondsBeforeNextAttempt = brackenNextAttemptEntry.Value;
					}
				};
				ConfigEntry<bool> doDamageOnIntervalEntry = ((BaseUnityPlugin)this).Config.Bind<bool>("SnatchinBracken Settings", "Do Gradual Damage", false, "Should players be hurt gradually while being dragged?");
				SharedData.Instance.DoDamageOnInterval = doDamageOnIntervalEntry.Value;
				doDamageOnIntervalEntry.SettingChanged += delegate
				{
					if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
					{
						SharedData.Instance.DoDamageOnInterval = doDamageOnIntervalEntry.Value;
					}
				};
				ConfigEntry<int> damageDealtProgressively = ((BaseUnityPlugin)this).Config.Bind<int>("SnatchinBracken Settings", "Damage Dealt At Interval", 5, "This only applies if you have \"Do Gradual Damage\" enabled. While dragged, every second this configured amount of damage will be dealt to the player.");
				SharedData.Instance.DamageDealtAtInterval = damageDealtProgressively.Value;
				damageDealtProgressively.SettingChanged += delegate
				{
					if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
					{
						SharedData.Instance.DamageDealtAtInterval = damageDealtProgressively.Value;
					}
				};
				ConfigEntry<int> distanceAutoKillerEntry = ((BaseUnityPlugin)this).Config.Bind<int>("SnatchinBracken Settings", "Distance For Kill", 1, "How far should the Bracken be from its favorite spot to initiate a kill?");
				SharedData.Instance.DistanceFromFavorite = distanceAutoKillerEntry.Value;
				distanceAutoKillerEntry.SettingChanged += delegate
				{
					if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
					{
						SharedData.Instance.DistanceFromFavorite = distanceAutoKillerEntry.Value;
					}
				};
				ConfigEntry<bool> instaKillOption = ((BaseUnityPlugin)this).Config.Bind<bool>("SnatchinBracken Settings", "Instakill When Alone", true, "Should players be instantly killed if they're alone?");
				SharedData.Instance.InstantKillIfAlone = instaKillOption.Value;
				instaKillOption.SettingChanged += delegate
				{
					if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
					{
						SharedData.Instance.InstantKillIfAlone = instaKillOption.Value;
					}
				};
			}
			mls.LogInfo((object)"Config finished parsing");
		}
	}
}
namespace SnatchinBracken.Patches
{
	[HarmonyPatch(typeof(FlowermanAI))]
	internal class BrackenAIPatch
	{
		private const string modGUID = "Ovchinikov.SnatchinBracken.FlowermanAI";

		private static ManualLogSource mls;

		private static List<FlowermanAI> JustProcessed;

		static BrackenAIPatch()
		{
			JustProcessed = new List<FlowermanAI>();
			mls = Logger.CreateLogSource("Ovchinikov.SnatchinBracken.FlowermanAI");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(EnemyAI), "ChooseFarthestNodeFromPosition")]
		private static void FarthestNodeAdjustment(EnemyAI __instance, ref Transform __result, Vector3 pos, bool avoidLineOfSight = false, int offset = 0, bool log = false)
		{
			//IL_0049: 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)
			FlowermanAI val = (FlowermanAI)(object)((__instance is FlowermanAI) ? __instance : null);
			if (val != null && Object.op_Implicit((Object)(object)SharedData.Instance.BrackenRoomPosition) && (Object)(object)__result != (Object)null && SharedData.Instance.BrackenRoom)
			{
				if (__instance.SetDestinationToPosition(SharedData.Instance.BrackenRoomPosition.position, true))
				{
					__result = SharedData.Instance.BrackenRoomPosition;
				}
				else if (!__instance.SetDestinationToPosition(__result.position, true))
				{
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void PostfixStart(FlowermanAI __instance)
		{
			if (((NetworkBehaviour)__instance).IsHost || ((NetworkBehaviour)__instance).IsServer)
			{
				((Component)__instance).gameObject.AddComponent<FlowermanLocationTask>();
			}
			if ((Object)(object)SharedData.Instance.BrackenRoomPosition != (Object)null && SharedData.Instance.BrackenRoom)
			{
				((EnemyAI)__instance).favoriteSpot = SharedData.Instance.BrackenRoomPosition;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("KillPlayerAnimationServerRpc")]
		private static bool PrefixKillPlayerAnimationServerRpc(FlowermanAI __instance, int playerObjectId)
		{
			if (!((NetworkBehaviour)__instance).IsHost && !((NetworkBehaviour)__instance).IsServer)
			{
				return true;
			}
			if ((Object)(object)__instance == (Object)null)
			{
				return true;
			}
			if ((CountAlivePlayers() <= 1 && SharedData.Instance.InstantKillIfAlone) || RollForChance(SharedData.Instance.PercentChanceForInsta))
			{
				return true;
			}
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerObjectId];
			if ((Object)(object)val == (Object)null)
			{
				return true;
			}
			if (SharedData.Instance.BindedDrags.ContainsKey(__instance))
			{
				return false;
			}
			if (SharedData.Instance.BindedDrags.ContainsValue(val))
			{
				return false;
			}
			if (SharedData.Instance.LastGrabbedTimeStamp.ContainsKey(__instance) && Time.time - SharedData.Instance.LastGrabbedTimeStamp[__instance] <= SharedData.Instance.SecondsBeforeNextAttempt)
			{
				return false;
			}
			if (SharedData.Instance.DropItems)
			{
				val.DropAllHeldItemsAndSync();
			}
			else
			{
				DropDoubleHandedItem(val);
			}
			((Component)val).GetComponent<FlowermanBinding>().PrepForBindingServerRpc(playerObjectId, ((NetworkBehaviour)__instance).NetworkObjectId);
			((Component)val).GetComponent<FlowermanBinding>().BindPlayerServerRpc(playerObjectId, ((NetworkBehaviour)__instance).NetworkObjectId);
			((Component)val).GetComponent<FlowermanBinding>().UpdateFavoriteSpotServerRpc(playerObjectId, ((NetworkBehaviour)__instance).NetworkObjectId);
			((Component)val).GetComponent<FlowermanBinding>().MufflePlayerVoiceServerRpc(playerObjectId);
			FlowermanLocationTask component = ((Component)__instance).gameObject.GetComponent<FlowermanLocationTask>();
			if ((Object)(object)component != (Object)null && !SharedData.Instance.DoDamageOnInterval)
			{
				component.StartCheckStuckCoroutine(__instance, val);
			}
			if (!SharedData.Instance.CoroutineStarted.ContainsKey(__instance) && SharedData.Instance.DoDamageOnInterval)
			{
				((MonoBehaviour)__instance).StartCoroutine(DoGradualDamage(__instance, val, 1f, SharedData.Instance.DamageDealtAtInterval));
				SharedData.Instance.CoroutineStarted[__instance] = true;
			}
			((EnemyAI)__instance).SwitchToBehaviourStateOnLocalClient(1);
			if (((NetworkBehaviour)__instance).IsServer)
			{
				((EnemyAI)__instance).SwitchToBehaviourState(1);
			}
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(EnemyAI), "SetEnemyStunned")]
		private static void SetEnemyStunnedPrefix(EnemyAI __instance, bool setToStunned, float setToStunTime = 1f, PlayerControllerB setStunnedByPlayer = null)
		{
			FlowermanAI val = (FlowermanAI)(object)((__instance is FlowermanAI) ? __instance : null);
			if (val == null)
			{
				return;
			}
			if (SharedData.Instance.BindedDrags.ContainsKey(val))
			{
				PlayerControllerB valueSafe = GeneralExtensions.GetValueSafe<FlowermanAI, PlayerControllerB>(SharedData.Instance.BindedDrags, val);
				StopGradualDamageCoroutine(val, valueSafe);
			}
			if ((((NetworkBehaviour)val).IsHost || ((NetworkBehaviour)val).IsServer) && SharedData.Instance.BindedDrags.ContainsKey(val))
			{
				mls.LogInfo((object)"Stunned bracken, dropping");
				PlayerControllerB valueSafe2 = GeneralExtensions.GetValueSafe<FlowermanAI, PlayerControllerB>(SharedData.Instance.BindedDrags, val);
				int valueSafe3 = GeneralExtensions.GetValueSafe<PlayerControllerB, int>(SharedData.Instance.PlayerIDs, valueSafe2);
				SharedData.UpdateTimestampNow(val, valueSafe2);
				FlowermanLocationTask component = ((Component)val).gameObject.GetComponent<FlowermanLocationTask>();
				if ((Object)(object)component != (Object)null)
				{
					component.StopCheckStuckCoroutine();
				}
				ManuallyDropPlayerOnHit(val, valueSafe2);
				((Component)valueSafe2).gameObject.GetComponent<FlowermanBinding>().UnbindPlayerServerRpc(valueSafe3, ((NetworkBehaviour)__instance).NetworkObjectId);
				((Component)valueSafe2).gameObject.GetComponent<FlowermanBinding>().ResetEntityStatesServerRpc(valueSafe3, ((NetworkBehaviour)__instance).NetworkObjectId);
				((Component)valueSafe2).gameObject.GetComponent<FlowermanBinding>().UnmufflePlayerVoiceServerRpc(valueSafe3);
				JustProcessed.Add(val);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("HitEnemy")]
		private static void HitEnemyPostPatch(FlowermanAI __instance, int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false)
		{
			if (!((NetworkBehaviour)__instance).IsHost && !((NetworkBehaviour)__instance).IsServer && JustProcessed.Contains(__instance))
			{
				__instance.angerMeter = 0f;
				__instance.isInAngerMode = false;
				__instance.angerCheckInterval = 0f;
				JustProcessed.Remove(__instance);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("HitEnemy")]
		private static void HitEnemyPrePatch(FlowermanAI __instance, int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false)
		{
			if (SharedData.Instance.BindedDrags.ContainsKey(__instance))
			{
				PlayerControllerB valueSafe = GeneralExtensions.GetValueSafe<FlowermanAI, PlayerControllerB>(SharedData.Instance.BindedDrags, __instance);
				StopGradualDamageCoroutine(__instance, valueSafe);
			}
			if ((((NetworkBehaviour)__instance).IsHost || ((NetworkBehaviour)__instance).IsServer) && SharedData.Instance.BindedDrags.ContainsKey(__instance))
			{
				mls.LogInfo((object)"Hit bracken, dropping");
				PlayerControllerB valueSafe2 = GeneralExtensions.GetValueSafe<FlowermanAI, PlayerControllerB>(SharedData.Instance.BindedDrags, __instance);
				int valueSafe3 = GeneralExtensions.GetValueSafe<PlayerControllerB, int>(SharedData.Instance.PlayerIDs, valueSafe2);
				SharedData.UpdateTimestampNow(__instance, valueSafe2);
				FlowermanLocationTask component = ((Component)__instance).gameObject.GetComponent<FlowermanLocationTask>();
				if ((Object)(object)component != (Object)null)
				{
					component.StopCheckStuckCoroutine();
				}
				ManuallyDropPlayerOnHit(__instance, valueSafe2);
				((Component)valueSafe2).gameObject.GetComponent<FlowermanBinding>().UnbindPlayerServerRpc(valueSafe3, ((NetworkBehaviour)__instance).NetworkObjectId);
				((Component)valueSafe2).gameObject.GetComponent<FlowermanBinding>().ResetEntityStatesServerRpc(valueSafe3, ((NetworkBehaviour)__instance).NetworkObjectId);
				((Component)valueSafe2).gameObject.GetComponent<FlowermanBinding>().UnmufflePlayerVoiceServerRpc(valueSafe3);
				JustProcessed.Add(__instance);
			}
		}

		private static IEnumerator DoGradualDamage(FlowermanAI flowermanAI, PlayerControllerB player, float damageInterval, int damageAmount)
		{
			while (!player.isPlayerDead && (Object)(object)flowermanAI != (Object)null && SharedData.Instance.BindedDrags.ContainsKey(flowermanAI))
			{
				yield return (object)new WaitForSeconds(damageInterval);
				if (!player.isPlayerDead && (Object)(object)flowermanAI != (Object)null && SharedData.Instance.BindedDrags.ContainsKey(flowermanAI))
				{
					if (player.health - damageAmount <= 0)
					{
						StopGradualDamageCoroutine(flowermanAI, player);
						int id2 = SharedData.Instance.PlayerIDs[player];
						SharedData.UpdateTimestampNow(flowermanAI, player);
						FinishKillAnimationNormally(flowermanAI, player, id2);
					}
					else
					{
						int id = SharedData.Instance.PlayerIDs[player];
						((Component)player).GetComponent<FlowermanBinding>().DamagePlayerServerRpc(id, damageAmount);
					}
					mls.LogInfo((object)$"Damage applied to player: {damageAmount}");
				}
				else
				{
					StopGradualDamageCoroutine(flowermanAI, player);
				}
			}
		}

		private static void StopGradualDamageCoroutine(FlowermanAI flowermanAI, PlayerControllerB player)
		{
			if (SharedData.Instance.CoroutineStarted.ContainsKey(flowermanAI))
			{
				((MonoBehaviour)flowermanAI).StopCoroutine(DoGradualDamage(flowermanAI, player, 1f, SharedData.Instance.DamageDealtAtInterval));
				SharedData.Instance.CoroutineStarted.Remove(flowermanAI);
			}
		}

		private static int CountAlivePlayers()
		{
			return StartOfRound.Instance.livingPlayers;
		}

		private static void ManuallyDropPlayerOnHit(FlowermanAI __instance, PlayerControllerB player)
		{
			player.inSpecialInteractAnimation = false;
			player.inAnimationWithEnemy = null;
			__instance.carryingPlayerBody = false;
			((EnemyAI)__instance).creatureAnimator.SetBool("killing", false);
			((EnemyAI)__instance).creatureAnimator.SetBool("carryingBody", false);
			__instance.angerMeter = 0f;
			__instance.isInAngerMode = false;
			((EnemyAI)__instance).stunnedByPlayer = null;
			((EnemyAI)__instance).stunNormalizedTimer = 0f;
			__instance.evadeStealthTimer = 0.1f;
			__instance.timesThreatened = 0;
			__instance.FinishKillAnimation(false);
		}

		[HarmonyPrefix]
		[HarmonyPatch("DropPlayerBody")]
		private static bool DropBodyPatch(FlowermanAI __instance)
		{
			if (!((NetworkBehaviour)__instance).IsHost && !((NetworkBehaviour)__instance).IsServer)
			{
				return true;
			}
			if (!SharedData.Instance.BindedDrags.ContainsKey(__instance))
			{
				return true;
			}
			if (!SharedData.Instance.ChaoticTendencies && !PrerequisiteKilling(__instance))
			{
				return false;
			}
			PlayerControllerB valueSafe = GeneralExtensions.GetValueSafe<FlowermanAI, PlayerControllerB>(SharedData.Instance.BindedDrags, __instance);
			int valueSafe2 = GeneralExtensions.GetValueSafe<PlayerControllerB, int>(SharedData.Instance.PlayerIDs, valueSafe);
			if ((Object)(object)valueSafe == (Object)null)
			{
				SharedData.Instance.BindedDrags.Remove(__instance);
				return true;
			}
			if (!SharedData.Instance.DoDamageOnInterval)
			{
				valueSafe.inSpecialInteractAnimation = false;
				((Component)valueSafe).GetComponent<FlowermanBinding>().UnbindPlayerServerRpc(valueSafe2, ((NetworkBehaviour)__instance).NetworkObjectId);
				FlowermanLocationTask component = ((Component)__instance).gameObject.GetComponent<FlowermanLocationTask>();
				if ((Object)(object)component != (Object)null)
				{
					component.StopCheckStuckCoroutine();
				}
				__instance.carryingPlayerBody = false;
				__instance.bodyBeingCarried = null;
				((EnemyAI)__instance).creatureAnimator.SetBool("carryingBody", false);
				FinishKillAnimationNormally(__instance, valueSafe, valueSafe2);
			}
			return false;
		}

		private static bool PrerequisiteKilling(FlowermanAI flowerman)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if (SharedData.Instance.LastGrabbedTimeStamp.ContainsKey(flowerman))
			{
				float num = SharedData.Instance.LastGrabbedTimeStamp[flowerman];
				float num2 = Vector3.Distance(((Component)flowerman).transform.position, ((EnemyAI)flowerman).favoriteSpot.position);
				if (Time.time - num >= SharedData.Instance.KillAtTime || num2 <= SharedData.Instance.DistanceFromFavorite)
				{
					return true;
				}
			}
			return false;
		}

		private static void FinishKillAnimationNormally(FlowermanAI __instance, PlayerControllerB playerControllerB, int playerId)
		{
			mls.LogInfo((object)"Bracken found good spot to kill, killing player.");
			((EnemyAI)__instance).inSpecialAnimationWithPlayer = playerControllerB;
			playerControllerB.inSpecialInteractAnimation = true;
			__instance.KillPlayerAnimationClientRpc(playerId);
		}

		private static bool RollForChance(int percentChance)
		{
			if (percentChance == 0)
			{
				return false;
			}
			if (percentChance < 0 || percentChance > 100)
			{
				throw new ArgumentOutOfRangeException("percentChance", "Percent chance must be between 0 and 100.");
			}
			int num = SharedData.RandomInstance.Next(1, 101);
			return num <= percentChance;
		}

		private static void DropDoubleHandedItem(PlayerControllerB player, bool itemsFall = true, bool disconnecting = false)
		{
			//IL_0011: 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)
			if (player.twoHanded)
			{
				player.DiscardHeldObject(false, (NetworkObject)null, default(Vector3), true);
			}
		}
	}
	[HarmonyPatch(typeof(EnemyAI))]
	internal class EnemyAIPatch
	{
		private const string modGUID = "Ovchinikov.SnatchinBracken.EnemyAI";

		private static readonly ManualLogSource mls;

		static EnemyAIPatch()
		{
			mls = Logger.CreateLogSource("Ovchinikov.SnatchinBracken.EnemyAI");
		}

		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void FlowermanStart(EnemyAI __instance)
		{
			FlowermanAI val = (FlowermanAI)(object)((__instance is FlowermanAI) ? __instance : null);
			if (val != null)
			{
				SharedData.Instance.FlowermanIDs[((NetworkBehaviour)__instance).NetworkObjectId] = val;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("Update")]
		private static void UpdatePatcher(EnemyAI __instance)
		{
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			FlowermanAI val = (FlowermanAI)(object)((__instance is FlowermanAI) ? __instance : null);
			if (val == null || !SharedData.Instance.BindedDrags.ContainsKey(val))
			{
				return;
			}
			PlayerControllerB valueSafe = GeneralExtensions.GetValueSafe<FlowermanAI, PlayerControllerB>(SharedData.Instance.BindedDrags, val);
			if ((Object)(object)valueSafe == (Object)null)
			{
				return;
			}
			if (valueSafe.isPlayerDead)
			{
				UnbindPlayerAndBracken(valueSafe, val);
				return;
			}
			UpdatePosition(val, valueSafe);
			if (!((NetworkBehaviour)__instance).IsHost && !((NetworkBehaviour)__instance).IsServer)
			{
				return;
			}
			int valueSafe2 = GeneralExtensions.GetValueSafe<PlayerControllerB, int>(SharedData.Instance.PlayerIDs, valueSafe);
			float num = SharedData.Instance.LastGrabbedTimeStamp[val];
			float num2 = Vector3.Distance(((Component)__instance).transform.position, __instance.favoriteSpot.position);
			if ((Time.time - num >= SharedData.Instance.KillAtTime || num2 <= SharedData.Instance.DistanceFromFavorite) && !SharedData.Instance.DoDamageOnInterval)
			{
				SharedData.UpdateTimestampNow(val, valueSafe);
				UnbindPlayerAndBracken(valueSafe, val);
				FlowermanLocationTask component = ((Component)__instance).gameObject.GetComponent<FlowermanLocationTask>();
				if ((Object)(object)component != (Object)null)
				{
					component.StopCheckStuckCoroutine();
				}
				FinishKillAnimationNormally(val, valueSafe, valueSafe2);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("MeetsStandardPlayerCollisionConditions")]
		private static bool OverrideCollisionCheck(EnemyAI __instance, Collider other, bool inKillAnimation = false, bool overrideIsInsideFactoryCheck = false)
		{
			if (!((NetworkBehaviour)__instance).IsHost)
			{
				return true;
			}
			FlowermanAI val = (FlowermanAI)(object)((__instance is FlowermanAI) ? __instance : null);
			if (val == null)
			{
				return true;
			}
			if (SharedData.Instance.LastGrabbedTimeStamp.ContainsKey(val) && Time.time - SharedData.Instance.LastGrabbedTimeStamp[val] <= SharedData.Instance.SecondsBeforeNextAttempt)
			{
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("TargetClosestPlayer")]
		private static bool ClosestPlayerPatch(FlowermanAI __instance)
		{
			if (!((NetworkBehaviour)__instance).IsHost && !((NetworkBehaviour)__instance).IsServer)
			{
				return true;
			}
			return !SharedData.Instance.BindedDrags.ContainsKey(__instance);
		}

		[HarmonyPrefix]
		[HarmonyPatch("PlayerIsTargetable")]
		private static bool PlayerIsTargetablePatch(EnemyAI __instance, PlayerControllerB playerScript, bool cannotBeInShip = false)
		{
			if (SharedData.Instance.monstersIgnorePlayers)
			{
				FlowermanAI val = (FlowermanAI)(object)((__instance is FlowermanAI) ? __instance : null);
				if (val != null)
				{
					if (SharedData.Instance.LastGrabbedTimeStamp.ContainsKey(val) && Time.time - SharedData.Instance.LastGrabbedTimeStamp[val] <= SharedData.Instance.SecondsBeforeNextAttempt)
					{
						return false;
					}
					return !SharedData.Instance.BindedDrags.ContainsKey(val);
				}
				return !SharedData.Instance.BindedDrags.ContainsValue(playerScript);
			}
			return true;
		}

		private static void UpdatePosition(FlowermanAI __instance, PlayerControllerB player)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			float num = -0.8f;
			Vector3 position = ((Component)__instance).transform.position + ((Component)__instance).transform.forward * num;
			((Component)player).transform.position = position;
		}

		private static void UnbindPlayerAndBracken(PlayerControllerB player, FlowermanAI __instance)
		{
			if (!SharedData.Instance.PlayerIDs.ContainsKey(player))
			{
				mls.LogInfo((object)"There isn't a player bound to this Bracken. That's strange.");
				return;
			}
			int valueSafe = GeneralExtensions.GetValueSafe<PlayerControllerB, int>(SharedData.Instance.PlayerIDs, player);
			player.inSpecialInteractAnimation = false;
			player.inAnimationWithEnemy = null;
			__instance.carryingPlayerBody = true;
			((EnemyAI)__instance).creatureAnimator.SetBool("killing", false);
			((EnemyAI)__instance).creatureAnimator.SetBool("carryingBody", false);
			((EnemyAI)__instance).stunnedByPlayer = null;
			((EnemyAI)__instance).stunNormalizedTimer = 0f;
			__instance.angerMeter = 0f;
			__instance.isInAngerMode = false;
			__instance.timesThreatened = 0;
			__instance.FinishKillAnimation(false);
			RemoveDictionaryReferences(__instance, player, valueSafe);
		}

		private static IEnumerator DoGradualDamage(FlowermanAI flowermanAI, PlayerControllerB player, float damageInterval, int damageAmount)
		{
			while (!player.isPlayerDead && (Object)(object)flowermanAI != (Object)null && SharedData.Instance.BindedDrags.ContainsKey(flowermanAI))
			{
				yield return (object)new WaitForSeconds(damageInterval);
				if (!player.isPlayerDead && (Object)(object)flowermanAI != (Object)null && SharedData.Instance.BindedDrags.ContainsKey(flowermanAI))
				{
					if (player.health - damageAmount <= 0)
					{
						StopGradualDamageCoroutine(flowermanAI, player);
						int id = SharedData.Instance.PlayerIDs[player];
						SharedData.UpdateTimestampNow(flowermanAI, player);
						FinishKillAnimationNormally(flowermanAI, player, id);
					}
					else
					{
						DoDamage(player, damageAmount);
					}
					mls.LogInfo((object)$"Damage applied to player: {damageAmount}");
				}
			}
		}

		private static void StopGradualDamageCoroutine(FlowermanAI flowermanAI, PlayerControllerB player)
		{
			if (SharedData.Instance.CoroutineStarted.ContainsKey(flowermanAI))
			{
				((MonoBehaviour)flowermanAI).StopCoroutine(DoGradualDamage(flowermanAI, player, 1f, SharedData.Instance.DamageDealtAtInterval));
				SharedData.Instance.CoroutineStarted.Remove(flowermanAI);
			}
		}

		private static void DoDamage(PlayerControllerB player, int damageAmount)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			player.DamagePlayer(damageAmount, true, true, (CauseOfDeath)6, 0, false, default(Vector3));
		}

		private static void RemoveDictionaryReferences(FlowermanAI __instance, PlayerControllerB player, int playerId)
		{
			SharedData.Instance.CoroutineStarted.Remove(__instance);
			((Component)player).gameObject.GetComponent<FlowermanBinding>().UnbindPlayerServerRpc(playerId, ((NetworkBehaviour)__instance).NetworkObjectId);
			((Component)player).gameObject.GetComponent<FlowermanBinding>().ResetEntityStatesServerRpc(playerId, ((NetworkBehaviour)__instance).NetworkObjectId);
		}

		private static void FinishKillAnimationNormally(FlowermanAI __instance, PlayerControllerB playerControllerB, int playerId)
		{
			((EnemyAI)__instance).inSpecialAnimationWithPlayer = playerControllerB;
			playerControllerB.inSpecialInteractAnimation = true;
			__instance.KillPlayerAnimationClientRpc(playerId);
		}
	}
	[HarmonyPatch(typeof(Landmine))]
	internal class LandminePatch
	{
		private const string modGUID = "Ovchinikov.SnatchinBracken.Landmine";

		private static ManualLogSource mls;

		static LandminePatch()
		{
			mls = Logger.CreateLogSource("Ovchinikov.SnatchinBracken.Landmine");
		}

		[HarmonyPrefix]
		[HarmonyPatch("OnTriggerEnter")]
		private static bool PrefixTriggerEntry(Landmine __instance, Collider other)
		{
			if (!((NetworkBehaviour)__instance).IsHost && !((NetworkBehaviour)__instance).IsServer)
			{
				return true;
			}
			if (!SharedData.Instance.IgnoreMines)
			{
				return true;
			}
			FlowermanAI componentInParent = ((Component)other).gameObject.GetComponentInParent<FlowermanAI>();
			if ((Object)(object)componentInParent != (Object)null && SharedData.Instance.BindedDrags.ContainsKey(componentInParent))
			{
				mls.LogInfo((object)"Bracken carrying a body triggered Mine, preventing.");
				return false;
			}
			PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
			if ((Object)(object)component != (Object)null && SharedData.Instance.BindedDrags.ContainsValue(component) && !component.isPlayerDead)
			{
				mls.LogInfo((object)"Player being dragged would've triggered Mine here, preventing.");
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("OnTriggerExit")]
		private static bool PostfixTriggerExit(Landmine __instance, Collider other)
		{
			if (!SharedData.Instance.IgnoreMines)
			{
				return true;
			}
			FlowermanAI componentInParent = ((Component)other).gameObject.GetComponentInParent<FlowermanAI>();
			if ((Object)(object)componentInParent != (Object)null && SharedData.Instance.BindedDrags.ContainsKey(componentInParent))
			{
				mls.LogInfo((object)"Bracken carrying a body triggered Mine, preventing.");
				return false;
			}
			PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
			if ((Object)(object)component != (Object)null && SharedData.Instance.BindedDrags.ContainsValue(component) && !component.isPlayerDead)
			{
				mls.LogInfo((object)"Player being dragged would've triggered Mine here, preventing.");
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class TeleporterPatch
	{
		private const string modGUID = "Ovchinikov.SnatchinBracken.Teleporter";

		private static ManualLogSource mls;

		static TeleporterPatch()
		{
			mls = Logger.CreateLogSource("Ovchinikov.SnatchinBracken.Teleporter");
		}

		[HarmonyPrefix]
		[HarmonyPatch("TeleportPlayer")]
		private static bool PrefixTeleportPlayer(PlayerControllerB __instance, Vector3 pos, bool withRotation = false, float rot = 0f, bool allowInteractTrigger = false, bool enableController = true)
		{
			if (!((NetworkBehaviour)__instance).IsHost && !((NetworkBehaviour)__instance).IsServer)
			{
				return true;
			}
			if ((Object)(object)__instance == (Object)null)
			{
				return true;
			}
			if (SharedData.Instance.BindedDrags.ContainsValue(__instance))
			{
				FlowermanAI val = SearchForCorrelatedFlowerman(__instance);
				if ((Object)(object)val != (Object)null)
				{
					if (!SharedData.Instance.AllowTeleports)
					{
						return false;
					}
					int playerId = SharedData.Instance.PlayerIDs[__instance];
					SharedData.UpdateTimestampNow(val, __instance);
					ManuallyUnbindPlayer(val, __instance);
					((Component)__instance).gameObject.GetComponent<FlowermanBinding>().ResetEntityStatesServerRpc(playerId, ((NetworkBehaviour)val).NetworkObjectId);
					((Component)__instance).gameObject.GetComponent<FlowermanBinding>().UnbindPlayerServerRpc(playerId, ((NetworkBehaviour)val).NetworkObjectId);
					((Component)__instance).gameObject.GetComponent<FlowermanBinding>().UnmufflePlayerVoiceServerRpc(playerId);
				}
			}
			return true;
		}

		private static FlowermanAI SearchForCorrelatedFlowerman(PlayerControllerB player)
		{
			foreach (KeyValuePair<FlowermanAI, PlayerControllerB> bindedDrag in SharedData.Instance.BindedDrags)
			{
				if (bindedDrag.Value.actualClientId == player.actualClientId)
				{
					return bindedDrag.Key;
				}
			}
			return null;
		}

		private static void ManuallyUnbindPlayer(FlowermanAI flowerman, PlayerControllerB player)
		{
			int valueSafe = GeneralExtensions.GetValueSafe<PlayerControllerB, int>(SharedData.Instance.PlayerIDs, player);
			player.inSpecialInteractAnimation = false;
			flowerman.carryingPlayerBody = false;
			((EnemyAI)flowerman).creatureAnimator.SetBool("killing", false);
			((EnemyAI)flowerman).creatureAnimator.SetBool("carryingBody", false);
			flowerman.FinishKillAnimation(false);
			((EnemyAI)flowerman).stunnedByPlayer = null;
			((EnemyAI)flowerman).stunNormalizedTimer = 0f;
			((EnemyAI)flowerman).favoriteSpot = null;
		}
	}
	[HarmonyPatch(typeof(Turret))]
	internal class TurretPatch
	{
		private const string modGUID = "Ovchinikov.SnatchinBracken.Turret";

		private static ManualLogSource mls;

		static TurretPatch()
		{
			mls = Logger.CreateLogSource("Ovchinikov.SnatchinBracken.Turret");
		}

		[HarmonyPostfix]
		[HarmonyPatch("CheckForPlayersInLineOfSight")]
		private static void PostfixCheckForPlayersInLineOfSight(Turret __instance, ref PlayerControllerB __result, float radius, bool angleRangeCheck)
		{
			if (SharedData.Instance.IgnoreTurrets && (Object)(object)__result != (Object)null && SharedData.Instance.BindedDrags.ContainsValue(__result))
			{
				__result = null;
			}
		}
	}
}
namespace SnatchinBracken.Patches.data
{
	internal class SharedData
	{
		private static SharedData _instance;

		private static Random _random = new Random();

		public Dictionary<FlowermanAI, bool> CoroutineStarted = new Dictionary<FlowermanAI, bool>();

		public Dictionary<PlayerControllerB, float> DroppedTimestamp = new Dictionary<PlayerControllerB, float>();

		public static SharedData Instance => _instance ?? (_instance = new SharedData());

		public static Random RandomInstance => _random;

		public Dictionary<FlowermanAI, PlayerControllerB> BindedDrags { get; } = new Dictionary<FlowermanAI, PlayerControllerB>();


		public Dictionary<ulong, FlowermanAI> FlowermanIDs { get; } = new Dictionary<ulong, FlowermanAI>();


		public Dictionary<PlayerControllerB, int> PlayerIDs { get; } = new Dictionary<PlayerControllerB, int>();


		public Dictionary<int, PlayerControllerB> IDsToPlayerController { get; } = new Dictionary<int, PlayerControllerB>();


		public Dictionary<FlowermanAI, float> LastGrabbedTimeStamp { get; } = new Dictionary<FlowermanAI, float>();


		public bool DropItems { get; set; }

		public bool IgnoreTurrets { get; set; }

		public bool InstantKillIfAlone { get; set; }

		public bool IgnoreMines { get; set; }

		public bool AllowTeleports { get; set; }

		public bool ChaoticTendencies { get; set; }

		public bool DoDamageOnInterval { get; set; }

		public bool StuckForceKill { get; set; }

		public bool monstersIgnorePlayers { get; set; }

		public bool BrackenRoom { get; set; }

		public float KillAtTime { get; set; }

		public float SecondsBeforeNextAttempt { get; set; }

		public int DamageDealtAtInterval { get; set; }

		public int PercentChanceForInsta { get; set; }

		public float DistanceFromFavorite { get; set; }

		public Transform BrackenRoomPosition { get; set; }

		public static void UpdateTimestampNow(FlowermanAI flowermanAI, PlayerControllerB player)
		{
			Instance.LastGrabbedTimeStamp[flowermanAI] = Time.time;
			Instance.DroppedTimestamp[player] = Time.time;
		}

		public static void FlushDictionaries()
		{
			Instance.BindedDrags.Clear();
			Instance.FlowermanIDs.Clear();
			Instance.LastGrabbedTimeStamp.Clear();
			Instance.CoroutineStarted.Clear();
			Instance.DroppedTimestamp.Clear();
		}
	}
}
namespace SnatchingBracken
{
	internal class LethalConfigAPIHook
	{
		public static void InitializeConfig()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Expected O, but got Unknown
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Expected O, but got Unknown
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Expected O, but got Unknown
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Expected O, but got Unknown
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Expected O, but got Unknown
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Expected O, but got Unknown
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Expected O, but got Unknown
			//IL_0391: Expected O, but got Unknown
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Expected O, but got Unknown
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0401: Unknown result type (might be due to invalid IL or missing references)
			//IL_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Expected O, but got Unknown
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Expected O, but got Unknown
			//IL_041c: Expected O, but got Unknown
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_042b: 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_0494: Unknown result type (might be due to invalid IL or missing references)
			//IL_049b: Expected O, but got Unknown
			//IL_049c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Expected O, but got Unknown
			//IL_04a7: Expected O, but got Unknown
			//IL_04af: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b6: Expected O, but got Unknown
			//IL_0518: Unknown result type (might be due to invalid IL or missing references)
			//IL_051f: Expected O, but got Unknown
			//IL_057a: Unknown result type (might be due to invalid IL or missing references)
			//IL_057f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0587: Unknown result type (might be due to invalid IL or missing references)
			//IL_058e: Expected O, but got Unknown
			//IL_058f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0597: Expected O, but got Unknown
			//IL_059a: Expected O, but got Unknown
			//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a9: Expected O, but got Unknown
			//IL_0604: Unknown result type (might be due to invalid IL or missing references)
			//IL_0609: Unknown result type (might be due to invalid IL or missing references)
			//IL_0611: Unknown result type (might be due to invalid IL or missing references)
			//IL_0618: Expected O, but got Unknown
			//IL_0619: Unknown result type (might be due to invalid IL or missing references)
			//IL_0621: Expected O, but got Unknown
			//IL_0624: Expected O, but got Unknown
			//IL_062c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0633: Expected O, but got Unknown
			//IL_0695: Unknown result type (might be due to invalid IL or missing references)
			//IL_069c: Expected O, but got Unknown
			LethalConfigManager.SetModDescription("A mod that alters the behavior of the Bracken. The Bracken pulls players into a new spot before performing a kill.");
			ConfigEntry<bool> dropItemsOption = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<bool>("SnatchinBracken Settings", "Drop Items on Snatch", true, "Should players drop their items when a Bracken grabs them?");
			BoolCheckBoxConfigItem val = new BoolCheckBoxConfigItem(dropItemsOption);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val);
			SharedData.Instance.DropItems = dropItemsOption.Value;
			dropItemsOption.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.DropItems = dropItemsOption.Value;
				}
			};
			ConfigEntry<bool> turretOption = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<bool>("SnatchinBracken Settings", "Ignore Turrets on Snatch", true, "Should players be targetable when dragged?");
			BoolCheckBoxConfigItem val2 = new BoolCheckBoxConfigItem(turretOption);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
			SharedData.Instance.IgnoreTurrets = turretOption.Value;
			turretOption.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.IgnoreTurrets = turretOption.Value;
				}
			};
			ConfigEntry<bool> chaoticOption = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<bool>("SnatchinBracken Settings", "Brackens Behave More Naturally", false, "If enabled, Brackens will perform kills at unpredictable times after an initial drop. Otherwise, the Bracken either must be in distance of the favorite location, or hit the time limit.");
			BoolCheckBoxConfigItem val3 = new BoolCheckBoxConfigItem(chaoticOption);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val3);
			SharedData.Instance.ChaoticTendencies = chaoticOption.Value;
			chaoticOption.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.ChaoticTendencies = chaoticOption.Value;
				}
			};
			ConfigEntry<bool> stuckForceKillOption = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<bool>("SnatchinBracken Settings", "Stuck Force Kill", false, "If enabled, Brackens will force kill when stuck at the same spot for at least 5 seconds.");
			BoolCheckBoxConfigItem val4 = new BoolCheckBoxConfigItem(stuckForceKillOption);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val4);
			SharedData.Instance.StuckForceKill = stuckForceKillOption.Value;
			stuckForceKillOption.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.StuckForceKill = stuckForceKillOption.Value;
				}
			};
			ConfigEntry<bool> brackenRoomOption = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<bool>("SnatchinBracken Settings", "Force Set Favorite Location To Bracken Room", true, "If enabled, Brackens' favorite locations will be set to the Bracken room. The room sometimes doesn't spawn, so please don't be alarmed if they don't take you there if this is enabled.");
			BoolCheckBoxConfigItem val5 = new BoolCheckBoxConfigItem(brackenRoomOption);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val5);
			SharedData.Instance.BrackenRoom = brackenRoomOption.Value;
			brackenRoomOption.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.BrackenRoom = brackenRoomOption.Value;
				}
			};
			ConfigEntry<bool> allowDraggedTps = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<bool>("SnatchinBracken Settings", "Allow teleports to save dragged players", true, "Should players be able to be saved through teleportation?");
			BoolCheckBoxConfigItem val6 = new BoolCheckBoxConfigItem(allowDraggedTps);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val6);
			SharedData.Instance.AllowTeleports = allowDraggedTps.Value;
			allowDraggedTps.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.AllowTeleports = allowDraggedTps.Value;
				}
			};
			ConfigEntry<bool> mineOption = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<bool>("SnatchinBracken Settings", "Ignore Mines on Snatch", true, "Should players ignore Landmines while being dragged?");
			BoolCheckBoxConfigItem val7 = new BoolCheckBoxConfigItem(mineOption);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val7);
			SharedData.Instance.IgnoreMines = mineOption.Value;
			mineOption.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.IgnoreMines = mineOption.Value;
				}
			};
			ConfigEntry<bool> monstersIgnorePlayersOption = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<bool>("SnatchinBracken Settings", "Enemies Ignore Dragged Players", true, "Should players be ignored by other monsters while being dragged?");
			BoolCheckBoxConfigItem val8 = new BoolCheckBoxConfigItem(monstersIgnorePlayersOption);
			SharedData.Instance.monstersIgnorePlayers = monstersIgnorePlayersOption.Value;
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val8);
			monstersIgnorePlayersOption.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.monstersIgnorePlayers = monstersIgnorePlayersOption.Value;
				}
			};
			ConfigEntry<int> instaKillTimeEntry = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<int>("SnatchinBracken Settings", "Chance for Insta Kill", 0, "Percent chance for insta kill, 0 to disable.");
			IntSliderOptions val9 = new IntSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<int>)val9).Min = 0;
			((BaseRangeOptions<int>)val9).Max = 100;
			IntSliderOptions val10 = val9;
			IntSliderConfigItem val11 = new IntSliderConfigItem(instaKillTimeEntry, val10);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val11);
			SharedData.Instance.PercentChanceForInsta = instaKillTimeEntry.Value;
			instaKillTimeEntry.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.PercentChanceForInsta = instaKillTimeEntry.Value;
				}
			};
			ConfigEntry<int> brackenKillTimeEntry = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<int>("SnatchinBracken Settings", "Seconds Until Auto Kill", 15, "Time in seconds until Bracken automatically kills when grabbed. Range: 1-60 seconds.");
			IntSliderOptions val12 = new IntSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<int>)val12).Min = 1;
			((BaseRangeOptions<int>)val12).Max = 60;
			IntSliderOptions val13 = val12;
			IntSliderConfigItem val14 = new IntSliderConfigItem(brackenKillTimeEntry, val13);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val14);
			SharedData.Instance.KillAtTime = brackenKillTimeEntry.Value;
			brackenKillTimeEntry.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.KillAtTime = brackenKillTimeEntry.Value;
				}
			};
			ConfigEntry<int> brackenNextAttemptEntry = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<int>("SnatchinBracken Settings", "Seconds Until Next Attempt", 5, "Time in seconds until Bracken is allowed to take another victim.");
			IntSliderOptions val15 = new IntSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<int>)val15).Min = 1;
			((BaseRangeOptions<int>)val15).Max = 60;
			IntSliderOptions val16 = val15;
			IntSliderConfigItem val17 = new IntSliderConfigItem(brackenNextAttemptEntry, val16);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val17);
			SharedData.Instance.SecondsBeforeNextAttempt = brackenNextAttemptEntry.Value;
			brackenNextAttemptEntry.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.SecondsBeforeNextAttempt = brackenNextAttemptEntry.Value;
				}
			};
			ConfigEntry<bool> doDamageOnIntervalEntry = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<bool>("SnatchinBracken Settings", "Do Gradual Damage", false, "Should players be hurt gradually while being dragged?");
			BoolCheckBoxConfigItem val18 = new BoolCheckBoxConfigItem(doDamageOnIntervalEntry);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val18);
			SharedData.Instance.DoDamageOnInterval = doDamageOnIntervalEntry.Value;
			doDamageOnIntervalEntry.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.DoDamageOnInterval = doDamageOnIntervalEntry.Value;
				}
			};
			ConfigEntry<int> damageDealtProgressively = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<int>("SnatchinBracken Settings", "Damage Dealt At Interval", 5, "This only applies if you have \"Do Gradual Damage\" enabled. While dragged, every second this configured amount of damage will be dealt to the player.");
			IntSliderOptions val19 = new IntSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<int>)val19).Min = 1;
			((BaseRangeOptions<int>)val19).Max = 100;
			IntSliderOptions val20 = val19;
			IntSliderConfigItem val21 = new IntSliderConfigItem(damageDealtProgressively, val20);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val21);
			SharedData.Instance.DamageDealtAtInterval = damageDealtProgressively.Value;
			damageDealtProgressively.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.DamageDealtAtInterval = damageDealtProgressively.Value;
				}
			};
			ConfigEntry<int> distanceAutoKillerEntry = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<int>("SnatchinBracken Settings", "Distance For Kill", 1, "How far should the Bracken be from its favorite spot to initiate a kill?");
			IntSliderOptions val22 = new IntSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<int>)val22).Min = 1;
			((BaseRangeOptions<int>)val22).Max = 60;
			IntSliderOptions val23 = val22;
			IntSliderConfigItem val24 = new IntSliderConfigItem(distanceAutoKillerEntry, val23);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val24);
			SharedData.Instance.DistanceFromFavorite = distanceAutoKillerEntry.Value;
			distanceAutoKillerEntry.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.DistanceFromFavorite = distanceAutoKillerEntry.Value;
				}
			};
			ConfigEntry<bool> instaKillOption = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<bool>("SnatchinBracken Settings", "Instakill When Alone", true, "Should players be instantly killed if they're alone?");
			BoolCheckBoxConfigItem val25 = new BoolCheckBoxConfigItem(instaKillOption);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val25);
			SharedData.Instance.InstantKillIfAlone = instaKillOption.Value;
			instaKillOption.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.InstantKillIfAlone = instaKillOption.Value;
				}
			};
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerPatch
	{
		private const string modGUID = "Ovchinikov.SnatchinBracken.Playerpatch";

		private static ManualLogSource mls;

		static PlayerPatch()
		{
			mls = Logger.CreateLogSource("Ovchinikov.SnatchinBracken.Playerpatch");
		}

		[HarmonyPrefix]
		[HarmonyPatch("IHittable.Hit")]
		private static bool HitOverride(PlayerControllerB __instance, int force, Vector3 hitDirection, PlayerControllerB playerWhoHit, bool playHitSFX = false)
		{
			if (SharedData.Instance.BindedDrags.ContainsValue(__instance) || (SharedData.Instance.DroppedTimestamp.ContainsKey(__instance) && SharedData.Instance.DroppedTimestamp[__instance] + 1f >= Time.time))
			{
				return false;
			}
			return true;
		}
	}
}
namespace SnatchingBracken.Patches.tasks
{
	public class FlowermanLocationTask : MonoBehaviour
	{
		private Coroutine checkStuckCoroutine;

		private static ManualLogSource mls;

		static FlowermanLocationTask()
		{
			mls = Logger.CreateLogSource("Bracken Location Task");
		}

		public void StartCheckStuckCoroutine(FlowermanAI flowermanAI, PlayerControllerB player)
		{
			checkStuckCoroutine = ((MonoBehaviour)this).StartCoroutine(CheckIfStuck(flowermanAI, player));
		}

		public void StopCheckStuckCoroutine()
		{
			if (checkStuckCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(checkStuckCoroutine);
				checkStuckCoroutine = null;
			}
		}

		private IEnumerator CheckIfStuck(FlowermanAI flowermanAI, PlayerControllerB player)
		{
			Vector3 lastPosition = ((Component)flowermanAI).transform.position;
			while ((Object)(object)flowermanAI != (Object)null)
			{
				yield return (object)new WaitForSeconds(5f);
				Vector3 currentPosition = ((Component)flowermanAI).transform.position;
				if (Vector3.Distance(lastPosition, currentPosition) <= 1f)
				{
					HandleStuckFlowerman(flowermanAI, player);
				}
				lastPosition = currentPosition;
			}
		}

		private void HandleStuckFlowerman(FlowermanAI flowermanAI, PlayerControllerB player)
		{
			Debug.Log((object)"FlowermanAI is stuck, handling...");
			StopCheckStuckCoroutine();
			SharedData.UpdateTimestampNow(flowermanAI, player);
			int num = SharedData.Instance.PlayerIDs[player];
			((EnemyAI)flowermanAI).inSpecialAnimationWithPlayer = player;
			player.inSpecialInteractAnimation = true;
			flowermanAI.KillPlayerAnimationClientRpc(num);
		}
	}
}
namespace SnatchingBracken.Patches.ship
{
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("ShipLeave")]
		private static void PrefixShipLeave(StartOfRoundPatch __instance)
		{
			SharedData.Instance.BrackenRoomPosition = null;
			SharedData.FlushDictionaries();
		}
	}
}
namespace SnatchingBracken.Patches.network
{
	public class FlowermanBinding : NetworkBehaviour
	{
		[ServerRpc(RequireOwnership = false)]
		public void BindPlayerServerRpc(int playerId, ulong flowermanId)
		{
			AddBindingsClientRpc(playerId, flowermanId);
		}

		[ServerRpc(RequireOwnership = false)]
		public void UnbindPlayerServerRpc(int playerId, ulong flowermanId)
		{
			RemoveBindingsClientRpc(playerId, flowermanId);
		}

		[ServerRpc(RequireOwnership = false)]
		public void ResetEntityStatesServerRpc(int playerId, ulong flowermanId)
		{
			ResetEntityStatesClientRpc(playerId, flowermanId);
		}

		[ServerRpc(RequireOwnership = false)]
		public void PrepForBindingServerRpc(int playerId, ulong flowermanId)
		{
			PrepForBindingClientRpc(playerId, flowermanId);
		}

		[ServerRpc(RequireOwnership = false)]
		public void UpdateFavoriteSpotServerRpc(int playerId, ulong flowermanId)
		{
			UpdateFavoriteSpotClientRpc(playerId, flowermanId);
		}

		[ServerRpc(RequireOwnership = false)]
		public void DamagePlayerServerRpc(int playerId, int damage)
		{
			DamagePlayerClientRpc(playerId, damage);
		}

		[ServerRpc(RequireOwnership = false)]
		public void MufflePlayerVoiceServerRpc(int playerId)
		{
			MufflePlayerVoiceClientRpc(playerId);
		}

		[ServerRpc(RequireOwnership = false)]
		public void UnmufflePlayerVoiceServerRpc(int playerId)
		{
			UnmufflePlayerVoiceClientRpc(playerId);
		}

		[ClientRpc]
		public void MufflePlayerVoiceClientRpc(int playerId)
		{
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerId];
			if ((Object)(object)val.currentVoiceChatAudioSource == (Object)null)
			{
				StartOfRound.Instance.RefreshPlayerVoicePlaybackObjects();
			}
			if ((Object)(object)val.currentVoiceChatAudioSource != (Object)null)
			{
				((Component)val.currentVoiceChatAudioSource).GetComponent<AudioLowPassFilter>().lowpassResonanceQ = 5f;
				OccludeAudio component = ((Component)val.currentVoiceChatAudioSource).GetComponent<OccludeAudio>();
				component.overridingLowPass = true;
				component.lowPassOverride = 500f;
				val.voiceMuffledByEnemy = true;
			}
		}

		[ClientRpc]
		public void UnmufflePlayerVoiceClientRpc(int playerId)
		{
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerId];
			if ((Object)(object)val.currentVoiceChatAudioSource == (Object)null)
			{
				StartOfRound.Instance.RefreshPlayerVoicePlaybackObjects();
			}
			if ((Object)(object)val.currentVoiceChatAudioSource != (Object)null)
			{
				((Component)val.currentVoiceChatAudioSource).GetComponent<AudioLowPassFilter>().lowpassResonanceQ = 1f;
				OccludeAudio component = ((Component)val.currentVoiceChatAudioSource).GetComponent<OccludeAudio>();
				component.overridingLowPass = false;
				component.lowPassOverride = 20000f;
				val.voiceMuffledByEnemy = false;
			}
		}

		[ClientRpc]
		public void DamagePlayerClientRpc(int playerId, int damage)
		{
			//IL_0017: 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)
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerId];
			val.DamagePlayer(damage, true, true, (CauseOfDeath)5, 0, false, default(Vector3));
		}

		[ClientRpc]
		public void ResetEntityStatesClientRpc(int playerId, ulong flowermanId)
		{
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerId];
			FlowermanAI val2 = SharedData.Instance.FlowermanIDs[flowermanId];
			val.inSpecialInteractAnimation = false;
			val.inAnimationWithEnemy = null;
			val2.carryingPlayerBody = false;
			((EnemyAI)val2).creatureAnimator.SetBool("killing", false);
			((EnemyAI)val2).creatureAnimator.SetBool("carryingBody", false);
			((EnemyAI)val2).stunnedByPlayer = null;
			((EnemyAI)val2).stunNormalizedTimer = 0f;
			val2.angerMeter = 0f;
			val2.isInAngerMode = false;
			val2.timesThreatened = 0;
			val2.evadeStealthTimer = 0.1f;
			((EnemyAI)val2).inSpecialAnimationWithPlayer = null;
			((EnemyAI)val2).inSpecialAnimation = false;
			((EnemyAI)val2).isClientCalculatingAI = true;
			((Behaviour)((EnemyAI)val2).agent).enabled = true;
			((EnemyAI)val2).favoriteSpot = null;
			val2.FinishKillAnimation(false);
		}

		[ClientRpc]
		public void PrepForBindingClientRpc(int playerId, ulong flowermanId)
		{
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerId];
			FlowermanAI val2 = SharedData.Instance.FlowermanIDs[flowermanId];
			((EnemyAI)val2).creatureAnimator.SetBool("killing", false);
			((EnemyAI)val2).creatureAnimator.SetBool("carryingBody", true);
			val2.carryingPlayerBody = true;
			val.inSpecialInteractAnimation = true;
			val2.inKillAnimation = false;
			((EnemyAI)val2).targetPlayer = null;
		}

		[ClientRpc]
		public void UpdateFavoriteSpotClientRpc(int playerId, ulong flowermanId)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerId];
			FlowermanAI val2 = SharedData.Instance.FlowermanIDs[flowermanId];
			Transform favoriteSpot = ((EnemyAI)val2).ChooseFarthestNodeFromPosition(((Component)val).transform.position, false, 0, false);
			((EnemyAI)val2).favoriteSpot = favoriteSpot;
		}

		[ClientRpc]
		public void AddBindingsClientRpc(int playerId, ulong flowermanId)
		{
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerId];
			FlowermanAI key = SharedData.Instance.FlowermanIDs[flowermanId];
			SharedData.Instance.BindedDrags[key] = val;
			SharedData.Instance.PlayerIDs[val] = playerId;
			SharedData.Instance.IDsToPlayerController[playerId] = val;
			SharedData.Instance.LastGrabbedTimeStamp[key] = Time.time;
		}

		[ClientRpc]
		public void RemoveBindingsClientRpc(int playerId, ulong flowermanID)
		{
			PlayerControllerB key = StartOfRound.Instance.allPlayerScripts[playerId];
			FlowermanAI key2 = SharedData.Instance.FlowermanIDs[flowermanID];
			SharedData.Instance.BindedDrags.Remove(key2);
			SharedData.Instance.LastGrabbedTimeStamp[key2] = Time.time;
			SharedData.Instance.DroppedTimestamp[key] = Time.time;
		}

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

		public override void OnNetworkDespawn()
		{
			((NetworkBehaviour)this).OnNetworkDespawn();
		}
	}
}
namespace SnatchingBracken.Patches.dungeon
{
	[HarmonyPatch(typeof(DungeonGenerator))]
	internal class DungeonGenPatch
	{
		private const string modGUID = "Ovchinikov.SnatchinBracken.Dungeon";

		private static ManualLogSource logger;

		static DungeonGenPatch()
		{
			logger = Logger.CreateLogSource("Ovchinikov.SnatchinBracken.Dungeon");
		}

		[HarmonyPatch("ChangeStatus")]
		[HarmonyPostfix]
		public static void OnChangeStatus(DungeonGenerator __instance)
		{
			if ((Object)(object)__instance.CurrentDungeon == (Object)null)
			{
				logger.LogInfo((object)"CurrentDungeon is null");
			}
			else if (__instance.CurrentDungeon.AllTiles == null)
			{
				logger.LogInfo((object)"AllTiles is null");
			}
			Tile val = FindTileWithName(__instance.CurrentDungeon, "SmallRoom2");
			if ((Object)(object)val != (Object)null)
			{
				SharedData.Instance.BrackenRoomPosition = ((Component)val).transform;
				logger.LogInfo((object)("We found the Bracken room tile at: " + ((Object)val).name));
			}
		}

		public static Tile FindTileWithName(Dungeon dungeon, string nameContains)
		{
			if ((Object)(object)dungeon == (Object)null)
			{
				logger.LogError((object)"Dungeon is null");
				return null;
			}
			foreach (Tile allTile in dungeon.AllTiles)
			{
				if (((Object)allTile).name.Contains(nameContains))
				{
					return allTile;
				}
			}
			return null;
		}
	}
}

plugins/StrangerThingsMod/StrangerThingsMod.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("StrangerThingsMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A mod that adds stuff from Stranger Things, such as a new Demogoron enemy")]
[assembly: AssemblyFileVersion("0.0.31.0")]
[assembly: AssemblyInformationalVersion("0.0.31+ae62236394be7f66cf555222e16379a9b4ffe3ed")]
[assembly: AssemblyProduct("StrangerThingsMod")]
[assembly: AssemblyTitle("StrangerThingsMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.31.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace StrangerThingsMod
{
	public static class CarriedPlayerManager
	{
		public static PlayerControllerB CarriedPlayer { get; private set; }

		public static bool IsPlayerCarried(PlayerControllerB carriedPlayer)
		{
			return (Object)(object)CarriedPlayer == (Object)(object)carriedPlayer;
		}

		public static void SetCarriedPlayer(PlayerControllerB carriedPlayer)
		{
			CarriedPlayer = carriedPlayer;
		}

		public static void ClearCarriedPlayer()
		{
			CarriedPlayer = null;
		}
	}
	public class Config
	{
		public static ConfigEntry<int> DemogorgonSpawnWeight;

		public static ConfigEntry<bool> EnableFlickeringLights;

		public static ConfigEntry<string> version;

		public static void Load()
		{
			DemogorgonSpawnWeight = Plugin.config.Bind<int>("Enemies", "DemogorgonSpawnWeight", 10, "The weight of the Demogorgon spawning in the level. Higher values mean it will spawn more often.");
			EnableFlickeringLights = Plugin.config.Bind<bool>("General", "FlickeringLights", true, "Enable or disable flickering lights and sound when the Demogorgon is nearby.");
			version = Plugin.config.Bind<string>("Misc", "Version", "1.0.1", "Version of the mod config.");
		}
	}
	public class Content
	{
		public class CustomEnemy
		{
			public string name;

			public string enemyPath;

			public int rarity;

			public LevelTypes levelFlags;

			public SpawnType spawnType;

			public string infoKeyword;

			public string infoNode;

			public bool enabled = true;

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

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

		public static List<CustomEnemy> customEnemies;

		public static AssetBundle MainAssets;

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

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

		public static AudioClip LoadAudioClip(string clipName)
		{
			if ((Object)(object)MainAssets == (Object)null)
			{
				Plugin.logger.LogWarning((object)"MainAssets is null, cannot load audio clip.");
				return null;
			}
			AudioClip val = MainAssets.LoadAsset<AudioClip>(clipName);
			if ((Object)(object)val == (Object)null)
			{
				Plugin.logger.LogWarning((object)("Failed to load audio clip: " + clipName));
			}
			return val;
		}

		public static void Load()
		{
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			TryLoadAssets();
			customEnemies = new List<CustomEnemy> { CustomEnemy.Add("Demogorgon", "Assets/Demogorgon/Demogorgon.asset", Config.DemogorgonSpawnWeight.Value, (LevelTypes)(-1), (SpawnType)0, null, "DemogorgonTN") };
			foreach (CustomEnemy customEnemy in customEnemies)
			{
				if (customEnemy.enabled)
				{
					EnemyType val = MainAssets.LoadAsset<EnemyType>(customEnemy.enemyPath);
					TerminalNode val2 = MainAssets.LoadAsset<TerminalNode>(customEnemy.infoNode);
					TerminalKeyword val3 = null;
					if (customEnemy.infoKeyword != null)
					{
						val3 = MainAssets.LoadAsset<TerminalKeyword>(customEnemy.infoKeyword);
					}
					NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
					Prefabs.Add(customEnemy.name, val.enemyPrefab);
					Enemies.RegisterEnemy(val, customEnemy.rarity, customEnemy.levelFlags, customEnemy.spawnType, val2, val3);
				}
			}
			Plugin.logger.LogInfo((object)"Loaded content");
		}
	}
	public class DemogorgonAI : EnemyAI
	{
		public enum DemogorgonState
		{
			Wandering,
			Chasing,
			CarryingPlayer,
			Fleeing
		}

		private Animator anim;

		private AudioSource audioSource;

		public AudioClip[] sounds;

		public AudioClip hitDemogorgonSFX;

		private AudioClip demogorgonSpawnSound;

		public AudioClip[] screamSounds;

		private float soundTimer;

		public AISearchRoutine roamMap;

		private PlayerControllerB closestSeenPlayer;

		private PlayerControllerB lastSeenPlayer;

		private bool playerIsInLOS;

		private bool isSwitchingToWandering = false;

		private bool isCarryingPlayer = false;

		private PlayerControllerB carriedPlayer = null;

		public Transform carryPoint;

		private Coroutine damageCoroutine;

		private float pickupCooldownTimer = 0f;

		private bool isFleeing = false;

		private float fleeCooldownTimer = 0f;

		private ManualLogSource myLogSource;

		private bool hasStartedChasing = false;

		public AudioClip[] stepSounds;

		private Vector3 lastStepPosition;

		private float stepDistance = 2f;

		private Random enemyRandom;

		public override void Start()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			myLogSource = Logger.CreateLogSource("Demogorgon AI");
			myLogSource.LogInfo((object)"Demogorgon Spawned");
			anim = ((Component)this).GetComponent<Animator>();
			audioSource = ((Component)this).GetComponent<AudioSource>();
			lastStepPosition = ((Component)this).transform.position;
			stepSounds = (AudioClip[])(object)new AudioClip[5];
			for (int i = 0; i < 5; i++)
			{
				stepSounds[i] = Content.LoadAudioClip("Footstep" + (i + 1));
			}
			demogorgonSpawnSound = Content.LoadAudioClip("DemogorgonSpawn");
			audioSource.PlayOneShot(demogorgonSpawnSound);
			if (Config.EnableFlickeringLights.Value)
			{
				LightTriggerScript[] array = Object.FindObjectsOfType<LightTriggerScript>();
				LightTriggerScript[] array2 = array;
				foreach (LightTriggerScript lightTriggerScript in array2)
				{
					lightTriggerScript.AddDemogorgon(((Component)this).gameObject);
				}
			}
			enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
			base.currentBehaviourStateIndex = 0;
			InitializeDemogorgon();
		}

		public void InitializeDemogorgon()
		{
			base.enemyHP = 6;
			soundTimer = 0f;
			isCarryingPlayer = false;
			carriedPlayer = null;
			fleeCooldownTimer = 0f;
			pickupCooldownTimer = 0f;
			base.agent.speed = 4.5f;
			hasStartedChasing = false;
			isFleeing = false;
			isSwitchingToWandering = false;
			closestSeenPlayer = null;
			lastSeenPlayer = null;
			playerIsInLOS = false;
			CarriedPlayerManager.ClearCarriedPlayer();
			base.currentBehaviourStateIndex = 0;
			anim.SetBool("IsWalking", false);
			anim.SetBool("IsRunning", false);
			anim.SetBool("IsCloseRunning", false);
			anim.SetBool("IsCarrying", false);
		}

		public override void Update()
		{
			//IL_0100: 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)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			if (!base.isEnemyDead && !StartOfRound.Instance.allPlayersDead)
			{
				soundTimer += Time.deltaTime;
				if (soundTimer >= 5f)
				{
					PlayRandomSound();
					soundTimer = 0f;
				}
				if (pickupCooldownTimer > 0f)
				{
					pickupCooldownTimer -= Time.deltaTime;
				}
				if (fleeCooldownTimer > 0f)
				{
					fleeCooldownTimer -= Time.deltaTime;
				}
				if (isCarryingPlayer && (Object)(object)carriedPlayer != (Object)null)
				{
					RunAway();
					UpdateCarriedPlayerPositionServerRpc(carryPoint.position, carryPoint.rotation);
					carriedPlayer.ResetFallGravity();
				}
				if (Vector3.Distance(((Component)this).transform.position, lastStepPosition) > stepDistance)
				{
					OnStep();
					lastStepPosition = ((Component)this).transform.position;
				}
				if (base.stunNormalizedTimer > 0f)
				{
					base.agent.speed = 0f;
					ReleasePlayerServerRpc();
				}
			}
		}

		private void OnStep()
		{
			AudioClip val = stepSounds[enemyRandom.Next(0, stepSounds.Length)];
			audioSource.PlayOneShot(val, 0.4f);
		}

		public override void DoAIInterval()
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			PlayerControllerB val = null;
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				base.agent.speed = 4.5f;
				DoAnimationsServerRPC(isWalking: true, isRunning: false, isCloseRunning: false, isCarrying: false);
				if (!roamMap.inProgress && !isCarryingPlayer && !base.isEnemyDead && !isFleeing)
				{
					((EnemyAI)this).StartSearch(((Component)this).transform.position, roamMap);
					myLogSource.LogInfo((object)"Starting search...");
				}
				val = ((EnemyAI)this).CheckLineOfSightForPlayer(140f, 25, 6);
				playerIsInLOS = Object.op_Implicit((Object)(object)val);
				if (playerIsInLOS && !val.isPlayerDead && !isCarryingPlayer && !base.isEnemyDead && (Object)(object)CarriedPlayerManager.CarriedPlayer != (Object)(object)val)
				{
					((EnemyAI)this).ChangeOwnershipOfEnemy(val.actualClientId);
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
				}
				break;
			case 1:
				if (roamMap.inProgress)
				{
					((EnemyAI)this).StopSearch(roamMap, true);
				}
				closestSeenPlayer = ((EnemyAI)this).CheckLineOfSightForClosestPlayer(140f, 25, 6, 0f);
				if ((Object)(object)closestSeenPlayer != (Object)null)
				{
					lastSeenPlayer = closestSeenPlayer;
				}
				playerIsInLOS = Object.op_Implicit((Object)(object)closestSeenPlayer);
				if (playerIsInLOS && !closestSeenPlayer.isPlayerDead && !isCarryingPlayer && !base.isEnemyDead && (Object)(object)CarriedPlayerManager.CarriedPlayer != (Object)(object)closestSeenPlayer)
				{
					base.agent.speed = 7f;
					if (!hasStartedChasing)
					{
						int num = enemyRandom.Next(0, screamSounds.Length);
						audioSource.PlayOneShot(screamSounds[num]);
						WalkieTalkie.TransmitOneShotAudio(audioSource, screamSounds[num], 1f);
						hasStartedChasing = true;
					}
					if ((Object)(object)closestSeenPlayer != (Object)null)
					{
						((EnemyAI)this).SetDestinationToPosition(((Component)closestSeenPlayer).transform.position, false);
					}
					myLogSource.LogInfo((object)("Chasing player! " + ((Object)closestSeenPlayer).name));
					DoAnimationsServerRPC(isWalking: false, isRunning: false, isCloseRunning: true, isCarrying: false);
					isSwitchingToWandering = false;
				}
				else
				{
					if ((Object)(object)lastSeenPlayer != (Object)null)
					{
						((EnemyAI)this).SetDestinationToPosition(((Component)lastSeenPlayer).transform.position, false);
					}
					if (!isSwitchingToWandering)
					{
						myLogSource.LogInfo((object)"Lost sight of player, loosing interest...");
						((MonoBehaviour)this).StartCoroutine(SwitchToWanderingIfLostPlayer(5f));
						isSwitchingToWandering = true;
					}
				}
				break;
			case 2:
				base.agent.speed = 5f;
				if ((Object)(object)carriedPlayer == (Object)null || carriedPlayer.isPlayerDead || base.isEnemyDead)
				{
					myLogSource.LogInfo((object)"Player is dead or enemy is dead or carriedPlayer is null, releasing player...");
					ReleasePlayerServerRpc();
				}
				break;
			case 3:
				if (fleeCooldownTimer <= 0f)
				{
					isFleeing = false;
				}
				if (isFleeing)
				{
					RunAway();
				}
				else
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				}
				break;
			default:
				myLogSource.LogWarning((object)"Demogorgon state not found!");
				break;
			}
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			((EnemyAI)this).OnCollideWithPlayer(other);
			if (!base.isEnemyDead && !isCarryingPlayer)
			{
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if (pickupCooldownTimer <= 0f && !isCarryingPlayer && !component.isPlayerDead && (Object)(object)CarriedPlayerManager.CarriedPlayer != (Object)(object)component)
				{
					myLogSource.LogInfo((object)("Picking up player! " + ((Object)component).name));
					GrabPlayerServerRpc(component.playerClientId);
					((EnemyAI)this).SwitchToBehaviourClientRpc(2);
				}
			}
		}

		private IEnumerator SwitchToWanderingIfLostPlayer(float delay)
		{
			yield return (object)new WaitForSeconds(delay);
			if (isSwitchingToWandering)
			{
				((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				myLogSource.LogInfo((object)"Switching to wandering...");
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void DoAnimationsServerRPC(bool isWalking, bool isRunning, bool isCloseRunning, bool isCarrying)
		{
			SetAnimationState(isWalking, isRunning, isCloseRunning, isCarrying);
			DoAnimationsClientRPC(isWalking, isRunning, isCloseRunning, isCarrying);
		}

		[ClientRpc]
		public void DoAnimationsClientRPC(bool isWalking, bool isRunning, bool isCloseRunning, bool isCarrying)
		{
			SetAnimationState(isWalking, isRunning, isCloseRunning, isCarrying);
		}

		private void SetAnimationState(bool isWalking, bool isRunning, bool isCloseRunning, bool isCarrying)
		{
			anim.SetBool("IsWalking", isWalking);
			anim.SetBool("IsRunning", isRunning);
			anim.SetBool("IsCloseRunning", isCloseRunning);
			anim.SetBool("IsCarrying", isCarrying);
		}

		[ServerRpc(RequireOwnership = false)]
		public void GrabPlayerServerRpc(ulong playerId)
		{
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerId];
			carriedPlayer = val;
			GrabPlayerClientRpc(playerId);
		}

		[ClientRpc]
		public void GrabPlayerClientRpc(ulong playerId)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerId];
			if ((Object)(object)val != (Object)null)
			{
				isCarryingPlayer = true;
				carriedPlayer = val;
				CarriedPlayerManager.SetCarriedPlayer(val);
				MovementActions movement = val.playerActions.Movement;
				((MovementActions)(ref movement)).Move.Disable();
				movement = val.playerActions.Movement;
				((MovementActions)(ref movement)).Jump.Disable();
				movement = val.playerActions.Movement;
				((MovementActions)(ref movement)).Sprint.Disable();
				movement = val.playerActions.Movement;
				((MovementActions)(ref movement)).Crouch.Disable();
				DoAnimationsServerRPC(isWalking: false, isRunning: false, isCloseRunning: false, isCarrying: true);
				damageCoroutine = ((MonoBehaviour)this).StartCoroutine(DamagePlayerOverTime());
				((Component)val).transform.position = carryPoint.position;
				((Component)val).transform.rotation = carryPoint.rotation;
				val.ResetFallGravity();
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void ReleasePlayerServerRpc()
		{
			ReleasePlayer();
			ReleasePlayerClientRpc();
		}

		[ClientRpc]
		public void ReleasePlayerClientRpc()
		{
			ReleasePlayer();
		}

		private void ReleasePlayer()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			if (isCarryingPlayer && (Object)(object)carriedPlayer != (Object)null)
			{
				((Component)carriedPlayer).transform.parent = null;
				MovementActions movement = carriedPlayer.playerActions.Movement;
				((MovementActions)(ref movement)).Move.Enable();
				movement = carriedPlayer.playerActions.Movement;
				((MovementActions)(ref movement)).Jump.Enable();
				movement = carriedPlayer.playerActions.Movement;
				((MovementActions)(ref movement)).Sprint.Enable();
				movement = carriedPlayer.playerActions.Movement;
				((MovementActions)(ref movement)).Crouch.Enable();
				carriedPlayer.takingFallDamage = true;
				DoAnimationsServerRPC(isWalking: true, isRunning: false, isCloseRunning: false, isCarrying: false);
				((MonoBehaviour)this).StopCoroutine(damageCoroutine);
				isCarryingPlayer = false;
				CarriedPlayerManager.ClearCarriedPlayer();
				pickupCooldownTimer = 5f;
				isFleeing = true;
				fleeCooldownTimer = 5f;
				carriedPlayer = null;
				((EnemyAI)this).SwitchToBehaviourClientRpc(3);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void UpdateCarriedPlayerPositionServerRpc(Vector3 position, Quaternion rotation)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			((Component)carriedPlayer).transform.position = position;
			((Component)carriedPlayer).transform.rotation = rotation;
			UpdateCarriedPlayerPositionClientRpc(position, rotation);
		}

		[ClientRpc]
		public void UpdateCarriedPlayerPositionClientRpc(Vector3 position, Quaternion rotation)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			((Component)carriedPlayer).transform.position = position;
			((Component)carriedPlayer).transform.rotation = rotation;
		}

		private void RunAway()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			if (!base.isEnemyDead && !base.agent.hasPath && !base.agent.pathPending && !(fleeCooldownTimer > 0f) && base.agent.isOnNavMesh)
			{
				Transform val = ((EnemyAI)this).ChooseFarthestNodeFromPosition(((Component)this).transform.position, true, 0, false);
				if ((Object)(object)val != (Object)null)
				{
					base.targetNode = val;
					((EnemyAI)this).SetDestinationToPosition(base.targetNode.position, false);
				}
			}
		}

		private IEnumerator DamagePlayerOverTime()
		{
			while (isCarryingPlayer)
			{
				yield return (object)new WaitForSeconds(1f);
				if ((Object)(object)carriedPlayer != (Object)null)
				{
					carriedPlayer.DamagePlayer(15, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				}
			}
		}

		private void PlayRandomSound()
		{
			if (sounds.Length != 0)
			{
				AudioClip val = sounds[Random.Range(0, sounds.Length)];
				audioSource.PlayOneShot(val);
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false)
		{
			((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX);
			if (!base.isEnemyDead)
			{
				base.creatureSFX.PlayOneShot(hitDemogorgonSFX, 1f);
				WalkieTalkie.TransmitOneShotAudio(base.creatureSFX, hitDemogorgonSFX, 1f);
				base.enemyHP -= force;
				if (isCarryingPlayer)
				{
					ReleasePlayerServerRpc();
				}
				if (((NetworkBehaviour)this).IsOwner && base.enemyHP <= 0 && !base.isEnemyDead)
				{
					((EnemyAI)this).KillEnemyOnOwnerClient(false);
				}
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class LightColliderSpawnerPatch
	{
		public static List<GameObject> eligibleLights = new List<GameObject>();

		[HarmonyPatch("FinishGeneratingLevel")]
		[HarmonyPostfix]
		public static void FinishGeneratingLevelPostfix(RoundManager __instance)
		{
			if (!Config.EnableFlickeringLights.Value)
			{
				return;
			}
			Plugin.logger.LogInfo((object)"Adding colliders to lights");
			eligibleLights.Clear();
			Light[] array = Object.FindObjectsOfType<Light>();
			Light[] array2 = array;
			foreach (Light val in array2)
			{
				Transform parent = ((Component)val).transform.parent;
				if ((Object)(object)parent != (Object)null && (((Object)parent).name.StartsWith("HangingLight") || ((Object)parent).name.StartsWith("MansionWallLamp") || ((Object)parent).name.StartsWith("Chandelier")))
				{
					eligibleLights.Add(((Component)val).gameObject);
					LightTriggerScript lightTriggerScript = ((Component)val).gameObject.AddComponent<LightTriggerScript>();
					lightTriggerScript.Init(val);
				}
			}
		}
	}
	public class LightTriggerScript : MonoBehaviour
	{
		private Light lightComponent;

		private AudioSource audioSource;

		private AudioClip[] lightFlickerSounds;

		private List<GameObject> demogorgons = new List<GameObject>();

		private bool isFlickering = false;

		private bool hasExited = true;

		public Vector3 spawnPosition = ((Component)Object.FindAnyObjectByType<PlayerControllerB>()).transform.position;

		public void Init(Light light)
		{
			lightComponent = light;
			audioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
			audioSource.spatialBlend = 1f;
			lightFlickerSounds = (AudioClip[])(object)new AudioClip[4]
			{
				Content.LoadAudioClip("BreakerLever1"),
				Content.LoadAudioClip("BreakerLever2"),
				Content.LoadAudioClip("BreakerLever3"),
				Content.LoadAudioClip("FlashlightFlicker")
			};
		}

		public void AddDemogorgon(GameObject demogorgon)
		{
			demogorgons.Add(demogorgon);
			Debug.Log((object)("Demogorgon added: " + (object)demogorgon));
		}

		private void Update()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			foreach (GameObject demogorgon in demogorgons)
			{
				if ((Object)(object)demogorgon == (Object)null)
				{
					continue;
				}
				float num = Vector3.Distance(((Component)this).transform.position, demogorgon.transform.position);
				if (num < 5f)
				{
					if (!isFlickering && hasExited)
					{
						Debug.Log((object)"Starting FlickerLight coroutine");
						((MonoBehaviour)this).StartCoroutine(FlickerLight());
						break;
					}
				}
				else
				{
					hasExited = true;
				}
			}
		}

		private IEnumerator FlickerLight()
		{
			Debug.Log((object)"In FlickerLight coroutine");
			isFlickering = true;
			hasExited = false;
			int flickerCount = Random.Range(1, 5);
			for (int i = 0; i < flickerCount; i++)
			{
				audioSource.PlayOneShot(lightFlickerSounds[Random.Range(0, lightFlickerSounds.Length)]);
				((Behaviour)lightComponent).enabled = !((Behaviour)lightComponent).enabled;
				yield return (object)new WaitForSeconds(Random.Range(0.08f, 0.3f));
			}
			((Behaviour)lightComponent).enabled = true;
			isFlickering = false;
		}
	}
	[HarmonyPatch]
	public class Patches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "StartGame")]
		public static void ResetAI()
		{
			DemogorgonAI demogorgonAI = Object.FindObjectOfType<DemogorgonAI>();
			if ((Object)(object)demogorgonAI != (Object)null)
			{
				demogorgonAI.InitializeDemogorgon();
			}
		}
	}
	[BepInPlugin("scoliosis.strangerthingsmod", "StrangerThingsMod", "0.0.31")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string ModGUID = "scoliosis.strangerthingsmod";

		public const string ModName = "StrangerThingsMod";

		public const string ModVersion = "0.0.31";

		public static ManualLogSource logger;

		public static ConfigFile config;

		private void Awake()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			logger = ((BaseUnityPlugin)this).Logger;
			config = ((BaseUnityPlugin)this).Config;
			Config.Load();
			Content.Load();
			Harmony val = new Harmony("scoliosis.strangerthingsmod");
			val.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded Stranger Things Mod");
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public class Utilities
	{
		public static void SpawnDemogorgon(Vector3 spawningPosition)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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)
			string text = "Demogorgon";
			if (Content.Prefabs.ContainsKey(text))
			{
				Quaternion identity = Quaternion.identity;
				Plugin.logger.LogInfo((object)("Spawning " + text + " at light"));
				GameObject val = Object.Instantiate<GameObject>(Content.Prefabs[text], spawningPosition, identity);
				val.GetComponent<NetworkObject>().Spawn(false);
			}
			else
			{
				Plugin.logger.LogWarning((object)("Prefab " + text + " not found!"));
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "StrangerThingsMod";

		public const string PLUGIN_NAME = "StrangerThingsMod";

		public const string PLUGIN_VERSION = "0.0.31";
	}
}

plugins/VMechLight.dll

Decompiled 9 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using GameNetcodeStuff;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using VMechLight.MonoBehaviors;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace VMechLight
{
	[BepInPlugin("versus.dynamolight", "Dynamo Flashlight", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "versus.dynamolight";

		private const string NAME = "Dynamo Flashlight";

		private const string VERSION = "1.0.0";

		public static Plugin instance;

		public static AudioClip pull1;

		public static AudioClip pull2;

		private void Awake()
		{
			instance = this;
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "dynamolight");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			pull1 = val.LoadAsset<AudioClip>("Assets/DynamoLight/DynamoLight/pull1.mp3");
			pull2 = val.LoadAsset<AudioClip>("Assets/DynamoLight/DynamoLight/pull2.mp3");
			Item val2 = val.LoadAsset<Item>("Assets/DynamoLight/DynamoLight/DynamoLight.asset");
			DynamoLight dynamoLight = val2.spawnPrefab.AddComponent<DynamoLight>();
			((GrabbableObject)dynamoLight).grabbable = true;
			((GrabbableObject)dynamoLight).grabbableToEnemies = true;
			((GrabbableObject)dynamoLight).itemProperties = val2;
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			Items.RegisterScrap(val2, 5, (LevelTypes)(-1));
			TerminalNode val3 = ScriptableObject.CreateInstance<TerminalNode>();
			Items.RegisterShopItem(val2, (TerminalNode)null, (TerminalNode)null, val3, 25);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Patched Dynamo Flashlight");
		}
	}
}
namespace VMechLight.MonoBehaviors
{
	internal class DynamoLight : GrabbableObject
	{
		public GameObject lightlow;

		public GameObject lightmid;

		public GameObject lighthigh;

		public float battery = 0f;

		public AudioSource source;

		public override void Start()
		{
			((GrabbableObject)this).Start();
			source = ((Component)this).GetComponent<AudioSource>();
			lightlow = ((Component)((Component)this).transform.GetChild(1)).gameObject;
			lightmid = ((Component)((Component)this).transform.GetChild(2)).gameObject;
			lighthigh = ((Component)((Component)this).transform.GetChild(3)).gameObject;
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (buttonDown && base.playerHeldBy.sprintMeter >= 0.1f)
			{
				battery += 10f;
				PlayerControllerB playerHeldBy = base.playerHeldBy;
				playerHeldBy.sprintMeter -= 0.1f;
				pullserver();
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 20f, 3f, 0, base.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
			}
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			flashlightserver();
		}

		[ServerRpc]
		public void pullserver()
		{
			pullclient();
		}

		[ClientRpc]
		public void pullclient()
		{
			if (battery <= 10f)
			{
				source.PlayOneShot(Plugin.pull1, 1f);
			}
			else if (battery > 10f)
			{
				source.PlayOneShot(Plugin.pull2, 1f);
			}
		}

		[ServerRpc]
		public void flashlightserver()
		{
			flashlightclient();
		}

		[ClientRpc]
		public void flashlightclient()
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			if (battery > 0f)
			{
				if (battery <= 20f)
				{
					battery -= 0.015f;
				}
				else if (battery > 20f)
				{
					battery -= 0.0075f;
				}
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 10f, 1f, 0, base.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
			}
			if (battery > 0f && battery < 10f)
			{
				lightlow.SetActive(true);
				lightmid.SetActive(false);
				lighthigh.SetActive(false);
				base.useCooldown = 0.75f;
			}
			else if (battery > 10f && battery < 20f)
			{
				lightlow.SetActive(false);
				lightmid.SetActive(true);
				lighthigh.SetActive(false);
				base.useCooldown = 2f;
			}
			else if (battery > 20f && battery <= 30f)
			{
				lightlow.SetActive(false);
				lightmid.SetActive(false);
				lighthigh.SetActive(true);
				base.useCooldown = 15f;
			}
			else if (battery <= 0f)
			{
				lightlow.SetActive(false);
				lightmid.SetActive(false);
				lighthigh.SetActive(false);
				base.useCooldown = 0f;
			}
			if (battery > 30f)
			{
				battery = 30f;
			}
		}
	}
}

plugins/YippeeMod.dll

Decompiled 9 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using YippeeMod.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("YippeeMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("YippeeMod")]
[assembly: AssemblyTitle("YippeeMod")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace YippeeMod
{
	[BepInPlugin("sunnobunno.YippeeMod", "Yippee tbh mod", "1.2.3")]
	public class YippeeModBase : BaseUnityPlugin
	{
		private const string modGUID = "sunnobunno.YippeeMod";

		private const string modName = "Yippee tbh mod";

		private const string modVersion = "1.2.3";

		private readonly Harmony harmony = new Harmony("sunnobunno.YippeeMod");

		private static YippeeModBase? Instance;

		internal ManualLogSource? mls;

		internal static AudioClip[]? newSFX;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("sunnobunno.YippeeMod");
			mls.LogInfo((object)"sunnobunno.YippeeMod is loading.");
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			string text = "YippeeMod.dll";
			string text2 = location.TrimEnd(text.ToCharArray());
			string text3 = text2 + "yippeesound";
			AssetBundle val = AssetBundle.LoadFromFile(text3);
			if ((Object)(object)val == (Object)null)
			{
				mls.LogError((object)"Failed to load audio assets!");
				return;
			}
			newSFX = val.LoadAssetWithSubAssets<AudioClip>("assets/yippee-tbh.mp3");
			harmony.PatchAll(typeof(HoarderBugPatch));
			mls.LogInfo((object)"sunnobunno.YippeeMod is loaded. Yippee!!!");
		}
	}
}
namespace YippeeMod.Patches
{
	[HarmonyPatch(typeof(HoarderBugAI))]
	internal class HoarderBugPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void hoarderBugAudioPatch(ref AudioClip[] ___chitterSFX)
		{
			AudioClip[] newSFX = YippeeModBase.newSFX;
			___chitterSFX = newSFX;
		}
	}
}