Decompiled source of TheCompanyIsntLethal v1.0.4

TheCompanyIsntLethal.dll

Decompiled 2 years ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using IL;
using IL.GameNetcodeStuff;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod;
using MonoMod.Cil;
using MonoMod.RuntimeDetour.HookGen;
using On;
using On.GameNetcodeStuff;
using TMPro;
using TheCompanyIsntLethal.Behaviors;
using TheCompanyIsntLethal.Modules;
using TheCompanyIsntLethal.NetworkBehaviours;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
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("TheCompanyIsntLethal")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TheCompanyIsntLethal")]
[assembly: AssemblyTitle("TheCompanyIsntLethal")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 TheCompanyIsntLethal
{
	internal static class Config
	{
		internal static ConfigEntry<int> customFOV;

		internal static ConfigEntry<int> customZoomFOV;

		internal static void Initialize(ConfigFile configFile)
		{
			customFOV = configFile.Bind<int>("CustomFOV", "FOV", 60, "Lets you set a custom FOV.");
			customZoomFOV = configFile.Bind<int>("CustomFOV", "Zoom FOV", 35, "Lets you set a custom zoom FOV (Holding C).");
		}
	}
	internal class CoroutineHelper : MonoBehaviour
	{
		internal static CoroutineHelper instance;

		private void Awake()
		{
			instance = this;
		}

		internal void Yield(Action action, YieldInstruction yieldInstruction)
		{
			((MonoBehaviour)this).StartCoroutine(RunInstructionCoroutine(action, yieldInstruction));
		}

		private IEnumerator RunInstructionCoroutine(Action action, YieldInstruction yieldInstruction)
		{
			yield return yieldInstruction;
			action?.Invoke();
		}
	}
	internal static class HarmonyHelper
	{
		internal enum MethodPatchType
		{
			Prefix,
			Postfix,
			IL
		}

		internal enum PropertyPatchType
		{
			Prefix,
			Postfix
		}

		internal enum PropertyMethod
		{
			Getter,
			Setter
		}

		internal static Harmony harmony = new Harmony("Nick.Harmony.TheCompanyIsntLethal");

		internal static void Patch<T, T1>(string originalMethodName, string modifiedPatchName, MethodPatchType methodPatchType)
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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
			MethodInfo methodInfo = AccessTools.Method(typeof(T), originalMethodName, (Type[])null, (Type[])null);
			switch (methodPatchType)
			{
			case MethodPatchType.Prefix:
				harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(T1).GetMethods(AccessTools.all).FirstOrDefault((MethodInfo info) => info.Name == modifiedPatchName && info.GetParameters().All((ParameterInfo info) => info.ParameterType != typeof(ILContext)))), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				break;
			case MethodPatchType.Postfix:
				harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(T1).GetMethods(AccessTools.all).FirstOrDefault((MethodInfo info) => info.Name == modifiedPatchName && info.GetParameters().All((ParameterInfo info) => info.ParameterType != typeof(ILContext)))), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				break;
			case MethodPatchType.IL:
				harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(T1).GetMethods(AccessTools.all).FirstOrDefault((MethodInfo info) => info.Name == modifiedPatchName && info.GetParameters().Any((ParameterInfo info) => info.ParameterType == typeof(ILContext)))));
				break;
			}
		}

		internal static void Patch<T, T1>(string originalPropertyName, string modifiedPatchName, PropertyMethod propertyMethod, PropertyPatchType propertyPatchType)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			MethodInfo methodInfo = ((propertyMethod == PropertyMethod.Setter) ? AccessTools.PropertySetter(typeof(T), originalPropertyName) : AccessTools.PropertyGetter(typeof(T), originalPropertyName));
			switch (propertyPatchType)
			{
			case PropertyPatchType.Prefix:
				harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(T1).GetMethods(AccessTools.all).FirstOrDefault((MethodInfo info) => info.Name == modifiedPatchName && info.GetParameters().All((ParameterInfo info) => info.ParameterType != typeof(ILContext)))), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				break;
			case PropertyPatchType.Postfix:
				harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(T1).GetMethods(AccessTools.all).FirstOrDefault((MethodInfo info) => info.Name == modifiedPatchName && info.GetParameters().All((ParameterInfo info) => info.ParameterType != typeof(ILContext)))), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				break;
			}
		}
	}
	internal static class HookGen
	{
		private static readonly List<string> assemblyNames = new List<string>();

		internal static void AddInputDLL(string inputDLLPath)
		{
			if (Path.GetExtension(inputDLLPath) != ".dll")
			{
				throw new Exception("\"" + inputDLLPath + "\" is not a dll!");
			}
			assemblyNames.Add(inputDLLPath);
		}

		internal static void StartGen(string outputPath)
		{
			foreach (string item in from name in Assembly.GetExecutingAssembly().GetManifestResourceNames()
				where name.EndsWith(".dll") || name.EndsWith(".exe")
				select name)
			{
				using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(item);
				byte[] array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
				Assembly.Load(array);
			}
			StartGenInternal(outputPath);
		}

		private static void StartGenInternal(string outputPath)
		{
			//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_0079: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			Directory.CreateDirectory(outputPath);
			string[] files = Directory.GetFiles(outputPath, "*.dll");
			IEnumerable<string> enumerable = assemblyNames.Except(files);
			foreach (string item in enumerable)
			{
				string text = Path.Combine(outputPath, "MMHOOK_" + Path.GetFileName(item));
				Environment.SetEnvironmentVariable("MONOMOD_HOOKGEN_PRIVATE", "1");
				Environment.SetEnvironmentVariable("MONOMOD_DEPENDENCY_MISSING_THROW", "0");
				MonoModder val = new MonoModder
				{
					InputPath = item,
					OutputPath = text,
					ReadingMode = (ReadingMode)2
				};
				try
				{
					IAssemblyResolver assemblyResolver = val.AssemblyResolver;
					((BaseAssemblyResolver)((assemblyResolver is BaseAssemblyResolver) ? assemblyResolver : null)).AddSearchDirectory(Paths.BepInExAssemblyDirectory);
					val.Read();
					val.MapDependencies();
					HookGenerator val2 = new HookGenerator(val, Path.GetFileName(text));
					val2.Generate();
					ModuleDefinition outputModule = val2.OutputModule;
					try
					{
						outputModule.Write(text);
					}
					finally
					{
						((IDisposable)outputModule)?.Dispose();
					}
				}
				finally
				{
					((IDisposable)val)?.Dispose();
				}
			}
		}
	}
	[BepInPlugin("Nick.TheCompanyIsntLethal", "The Company Isn't Lethal", "1.0.0")]
	public class Loader : BaseUnityPlugin
	{
		private void Awake()
		{
			try
			{
				HookGen.AddInputDLL(Path.Combine(Paths.ManagedPath, "Assembly-CSharp.dll"));
				HookGen.StartGen(Path.Combine(Paths.GameRootPath, "MMHOOKS"));
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)ex);
			}
			ModuleBase.Load(invokePatchEventAndStartEvent: false);
			NetworkHelper.InitializeRPCs();
			ModuleBase.onPatchEvent?.Invoke();
			SceneManager.sceneLoaded += OnSceneWasLoaded;
			((Component)this).gameObject.AddComponent<CoroutineHelper>();
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Config.Initialize(((BaseUnityPlugin)this).Config);
		}

		private void Start()
		{
			ModuleBase.onStartEvent?.Invoke();
		}

		private void OnSceneWasLoaded(Scene scene, LoadSceneMode loadSceneMode)
		{
			ModuleBase.onSceneWasLoadedEvent?.Invoke(((Scene)(ref scene)).buildIndex, ((Scene)(ref scene)).name);
		}

		private void Update()
		{
			ModuleBase.onUpdateEvent?.Invoke();
		}

		private void OnGUI()
		{
			ModuleBase.onGUIEvent?.Invoke();
		}
	}
	internal class NetworkHelper
	{
		internal static void InitializeRPCs()
		{
			foreach (Type item in from type in Assembly.GetExecutingAssembly().GetTypes()
				where type.IsSubclassOf(typeof(NetworkBehaviour))
				select type)
			{
				item.GetMethod("InitializeRPCS_" + item.Name, BindingFlags.Static | BindingFlags.NonPublic)?.Invoke(null, null);
			}
		}

		internal static GameObject CreateNetworkedObject(string name)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			GameObject val = new GameObject("[Networked] " + name);
			val.AddComponent<NetworkObject>();
			return val;
		}
	}
	internal static class ReflectionHelper
	{
		internal static T CreateInstance<T>(this Type type)
		{
			return (T)Activator.CreateInstance(type);
		}

		internal static object CreateInstance(this Type type)
		{
			return Activator.CreateInstance(type);
		}

		internal static T CreateWithoutConstructor<T>()
		{
			return (T)FormatterServices.GetUninitializedObject(typeof(T));
		}

		internal static object GetField(this object script, string field)
		{
			try
			{
				return (!(script is Type)) ? script?.GetType().GetField(field, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(script) : ((Type)script).GetField(field, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null);
			}
			catch (Exception value)
			{
				Console.WriteLine(value);
				throw;
			}
		}

		internal static T GetField<T>(this object script, string field)
		{
			try
			{
				if (script is Type)
				{
					return (T)(((Type)script).GetField(field, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null));
				}
				return (T)(script?.GetType().GetField(field, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(script));
			}
			catch (Exception value)
			{
				Console.WriteLine(value);
				throw;
			}
		}

		internal static void SetField(this object script, string field, object value)
		{
			try
			{
				if (script is Type)
				{
					((Type)script).GetField(field, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.SetValue(null, value);
				}
				else
				{
					script?.GetType().GetField(field, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.SetValue(script, value);
				}
			}
			catch (Exception value2)
			{
				Console.WriteLine(value2);
				throw;
			}
		}

		internal static void SetField<T>(this object script, string field, T value)
		{
			try
			{
				if (script is Type)
				{
					((Type)script).GetField(field, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.SetValue(null, value);
				}
				else
				{
					script?.GetType().GetField(field, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.SetValue(script, value);
				}
			}
			catch (Exception value2)
			{
				Console.WriteLine(value2);
				throw;
			}
		}

		internal static object CallMethod(this object script, string methodName, object[] parameters = null)
		{
			try
			{
				return (!(script is Type)) ? script?.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(script, parameters) : ((Type)script).GetMethod(methodName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(null, parameters);
			}
			catch (Exception value)
			{
				Console.WriteLine(value);
				throw;
			}
		}

		internal static T CallMethod<T>(this object script, string methodName, object[] parameters = null)
		{
			try
			{
				if (script is Type)
				{
					return (T)(((Type)script).GetMethod(methodName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(null, parameters));
				}
				return (T)(script?.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(script, parameters));
			}
			catch (Exception value)
			{
				Console.WriteLine(value);
				throw;
			}
		}

		internal static object GetProperty(this object script, string property)
		{
			try
			{
				return (!(script is Type)) ? script?.GetType().GetProperty(property, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(script) : ((Type)script).GetProperty(property, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null);
			}
			catch (Exception value)
			{
				Console.WriteLine(value);
				throw;
			}
		}

		internal static T GetProperty<T>(this object script, string property)
		{
			try
			{
				if (script is Type)
				{
					return (T)(((Type)script).GetProperty(property, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null));
				}
				return (T)(script?.GetType().GetProperty(property, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(script));
			}
			catch (Exception value)
			{
				Console.WriteLine(value);
				throw;
			}
		}

		internal static void SetProperty(this object script, string property, string value)
		{
			try
			{
				if (script is Type)
				{
					((Type)script).GetProperty(property, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.SetValue(null, value);
				}
				else
				{
					script?.GetType().GetProperty(property, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.SetValue(script, value);
				}
			}
			catch (Exception value2)
			{
				Console.WriteLine(value2);
				throw;
			}
		}

		internal static void SetProperty<T>(this object script, string property, T value)
		{
			try
			{
				if (script is Type)
				{
					((Type)script).GetProperty(property, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.SetValue(null, value);
				}
				else
				{
					script?.GetType().GetProperty(property, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.SetValue(script, value);
				}
			}
			catch (Exception value2)
			{
				Console.WriteLine(value2);
				throw;
			}
		}
	}
}
namespace TheCompanyIsntLethal.NetworkBehaviours
{
	public class PingSystem : NetworkBehaviour
	{
		internal static GameObject _referencePingObject;

		private static readonly float pingCooldown = 0.1f;

		private readonly LayerMask raycastLayerMask = LayerMask.op_Implicit(LayerMask.GetMask(new string[9] { "Default", "Water", "Room", "InteractableObject", "Colliders", "Anamoly", "MiscLevelGeometry", "Terrain", "Railing" }));

		private readonly LayerMask raycastEnemyLayerMask = LayerMask.op_Implicit(LayerMask.GetMask(new string[2] { "Enemies", "MapHazards" }));

		private readonly Dictionary<string, Ping> playerPings = new Dictionary<string, Ping>();

		private float timeSinceLastPingLocal = pingCooldown;

		internal static GameObject referencePingObject
		{
			get
			{
				if (Object.op_Implicit((Object)(object)_referencePingObject))
				{
					return _referencePingObject;
				}
				return _referencePingObject = Object.Instantiate<GameObject>(((Component)HUDManager.Instance.scanElements.FirstOrDefault()).gameObject);
			}
		}

		private void Update()
		{
			//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_0067: 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)
			//IL_007c: 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_01a4: 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_016f: 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_0182: 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_0122: 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_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: 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_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: 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_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: 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_0228: Unknown result type (might be due to invalid IL or missing references)
			timeSinceLastPingLocal += Time.deltaTime;
			if (!Mouse.current.middleButton.wasPressedThisFrame || GameNetworkManager.Instance.localPlayerController.isPlayerDead)
			{
				return;
			}
			Transform transform = ((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).transform;
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(transform.position + transform.forward * 1.15f, transform.forward);
			RaycastHit val2 = default(RaycastHit);
			NetworkObject val3 = default(NetworkObject);
			RaycastHit val4 = default(RaycastHit);
			if (Physics.Raycast(val, ref val2, float.PositiveInfinity, LayerMask.op_Implicit(raycastEnemyLayerMask), (QueryTriggerInteraction)2) && ((Object)((Component)((RaycastHit)(ref val2)).transform).gameObject).name != "UnderwaterBubblesAudio" && ((Component)((RaycastHit)(ref val2)).transform.root).TryGetComponent<NetworkObject>(ref val3))
			{
				if (!(timeSinceLastPingLocal <= pingCooldown))
				{
					timeSinceLastPingLocal = pingCooldown;
					if (((NetworkBehaviour)this).IsServer)
					{
						RegisterHitClientRPC(GameNetworkManager.Instance.username, new NetworkObjectReference(((Component)((RaycastHit)(ref val2)).transform.root).gameObject), ((RaycastHit)(ref val2)).point.x, ((RaycastHit)(ref val2)).point.y, ((RaycastHit)(ref val2)).point.z);
					}
					else
					{
						RegisterHitServerRPC(GameNetworkManager.Instance.username, new NetworkObjectReference(((Component)((RaycastHit)(ref val2)).transform.root).gameObject), ((RaycastHit)(ref val2)).point.x, ((RaycastHit)(ref val2)).point.y, ((RaycastHit)(ref val2)).point.z);
					}
				}
			}
			else if (Physics.Raycast(val, ref val4, float.PositiveInfinity, LayerMask.op_Implicit(raycastLayerMask), (QueryTriggerInteraction)1) && !(timeSinceLastPingLocal <= 2f))
			{
				timeSinceLastPingLocal = 0f;
				if (((NetworkBehaviour)this).IsServer)
				{
					RegisterHitClientRPC(GameNetworkManager.Instance.username, default(NetworkObjectReference), ((RaycastHit)(ref val4)).point.x, ((RaycastHit)(ref val4)).point.y, ((RaycastHit)(ref val4)).point.z);
				}
				else
				{
					RegisterHitServerRPC(GameNetworkManager.Instance.username, default(NetworkObjectReference), ((RaycastHit)(ref val4)).point.x, ((RaycastHit)(ref val4)).point.y, ((RaycastHit)(ref val4)).point.z);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void RegisterHitServerRPC(string username, NetworkObjectReference enemy, float x, float y, float z)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: 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_0167: 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_00f1: 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_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)
			//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 != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2554622604u, val, (RpcDelivery)0);
				bool flag = username != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(username, false);
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref enemy, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref x, default(ForPrimitives));
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref y, default(ForPrimitives));
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref z, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2554622604u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				RegisterHitClientRPC(username, enemy, x, y, z);
			}
		}

		[ClientRpc]
		public void RegisterHitClientRPC(string username, NetworkObjectReference enemy, float x, float y, float z)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: 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_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_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_00f1: 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_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)
			//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(3318724530u, val, (RpcDelivery)0);
				bool flag = username != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(username, false);
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref enemy, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref x, default(ForPrimitives));
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref y, default(ForPrimitives));
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref z, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3318724530u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			GameObject val3 = Object.Instantiate<GameObject>(referencePingObject, GameObject.Find("Systems").transform.Find("UI/Canvas"), true);
			((Object)val3).name = "[Ping] " + username;
			Ping ping = val3.AddComponent<Ping>();
			ping.username = username;
			ping.pingPoint = new Vector3(x, y, z);
			val3.SetActive(true);
			if (!playerPings.ContainsKey(username))
			{
				playerPings.Add(username, ping);
			}
			else
			{
				Ping ping2 = playerPings[username];
				if (Object.op_Implicit((Object)(object)ping2))
				{
					playerPings[username].Delete();
				}
				playerPings[username] = ping;
			}
			NetworkObject val4 = default(NetworkObject);
			if (((NetworkObjectReference)(ref enemy)).TryGet(ref val4, (NetworkManager)null))
			{
				ping.target = ((Component)val4).transform;
			}
			HUDManager.Instance.UIAudio.PlayOneShot(HUDManager.Instance.scanSFX);
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_PingSystem()
		{
			//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(2554622604u, new RpcReceiveHandler(__rpc_handler_2554622604));
			NetworkManager.__rpc_func_table.Add(3318724530u, new RpcReceiveHandler(__rpc_handler_3318724530));
		}

		private static void __rpc_handler_2554622604(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_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)
			//IL_00b8: 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_00cd: 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_00f7: 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 username = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref username, false);
				}
				NetworkObjectReference enemy = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref enemy, default(ForNetworkSerializable));
				float x = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref x, default(ForPrimitives));
				float y = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref y, default(ForPrimitives));
				float z = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref z, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PingSystem)(object)target).RegisterHitServerRPC(username, enemy, x, y, z);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3318724530(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_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)
			//IL_00b8: 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_00cd: 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_00f7: 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 username = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref username, false);
				}
				NetworkObjectReference enemy = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref enemy, default(ForNetworkSerializable));
				float x = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref x, default(ForPrimitives));
				float y = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref y, default(ForPrimitives));
				float z = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref z, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PingSystem)(object)target).RegisterHitClientRPC(username, enemy, x, y, z);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "PingSystem";
		}
	}
}
namespace TheCompanyIsntLethal.Modules
{
	internal class BetterConsole : ModuleBase
	{
		private static Type consoleManager = Type.GetType("BepInEx.ConsoleManager, BepInEx");

		private static TextWriter _consoleStream;

		private static bool reinitializedConsole;

		private static TextWriter consoleStream
		{
			get
			{
				if (_consoleStream != null)
				{
					return _consoleStream;
				}
				_consoleStream = consoleManager.GetProperty<TextWriter>("ConsoleStream");
				return _consoleStream;
			}
		}

		internal override void OnPatch()
		{
			HarmonyHelper.Patch<ConsoleLogListener, BetterConsole>("LogEvent", "LogEventPatch", HarmonyHelper.MethodPatchType.Prefix);
			Console.Clear();
			WriteColoredWord("YouAlreadyKnow Console Rewrite ", endLine: false, ConsoleColor.Magenta);
			WriteColoredWord("(Doesn't this look familiar?)", endLine: true, ConsoleColor.Cyan);
			WriteColoredWord(string.Empty, endLine: true, ConsoleColor.White);
		}

		internal override void OnStart()
		{
			IEnumerable<PluginInfo> source = TypeLoader.FindPluginTypes<PluginInfo>(Paths.PluginPath, (Func<TypeDefinition, PluginInfo>)Chainloader.ToPluginInfo, (Func<AssemblyDefinition, bool>)((AssemblyDefinition assemblyDef) => !((IEnumerable<AssemblyNameReference>)assemblyDef.MainModule.AssemblyReferences).All((AssemblyNameReference r) => r.Name != typeof(Chainloader).GetField<string>("CurrentAssemblyName")) && !assemblyDef.MainModule.GetTypeReferences().All((TypeReference r) => ((MemberReference)r).FullName != typeof(BepInPlugin).FullName)), "chainloader").SelectMany((KeyValuePair<string, List<PluginInfo>> pluginPair) => pluginPair.Value);
			reinitializedConsole = true;
			WriteColoredBrackets($"{DateTime.Now:HH:mm:ss.fff}", ConsoleColor.Green);
			WriteColoredBrackets("BepInEx", ConsoleColor.Magenta);
			WriteColoredWord("Currently Loaded Plugins:", endLine: true, ConsoleColor.White);
			int length = (from @string in source.Select((PluginInfo plugin) => plugin.Metadata.Name).ToList()
				orderby @string.Length descending
				select @string).FirstOrDefault().Length;
			foreach (PluginInfo item in from plugin in source
				orderby plugin.Metadata.Version.Major descending, plugin.Metadata.Version.Minor descending, plugin.Metadata.Version.Build descending, plugin.Metadata.Version.Revision descending
				select plugin)
			{
				WriteColoredBrackets($"{DateTime.Now:HH:mm:ss.fff}", ConsoleColor.Green);
				WriteColoredBrackets("BepInEx", ConsoleColor.Magenta);
				WriteColoredWord(item.Metadata.Name.PadRight(length + 1) + " [" + item.Metadata.Version.ToString() + "]", endLine: true, ConsoleColor.Cyan);
			}
			WriteColoredWord(string.Empty, endLine: true, ConsoleColor.White);
		}

		private static bool LogEventPatch(LogEventArgs __1)
		{
			//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_0076: 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_0079: 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_0091: Expected I4, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			if (!reinitializedConsole)
			{
				return false;
			}
			WriteColoredBrackets($"{DateTime.Now:HH:mm:ss.fff}", ConsoleColor.Green);
			if (__1.Source != null && !string.IsNullOrEmpty(__1.Source.SourceName))
			{
				WriteColoredBrackets(__1.Source.SourceName ?? "", ConsoleColor.Magenta);
			}
			LogLevel level = __1.Level;
			LogLevel val = level;
			switch (val - 1)
			{
			default:
				if ((int)val != 32)
				{
					goto case 2;
				}
				WriteColoredWord($"DEBUG -> {__1.Data}", endLine: true, ConsoleColor.DarkYellow);
				break;
			case 1:
				WriteColoredWord($"{__1.Data}", endLine: true, ConsoleColor.Red);
				break;
			case 3:
				WriteColoredWord($"{__1.Data}", endLine: true, ConsoleColor.Yellow);
				break;
			case 0:
				WriteColoredWord($"FATAL -> {__1.Data}", endLine: true, ConsoleColor.DarkRed);
				break;
			case 2:
				WriteColoredWord($"{__1.Data}", endLine: true, ConsoleColor.White);
				break;
			}
			return false;
		}

		private static void SetConsoleColor(ConsoleColor consoleColor)
		{
			consoleManager.CallMethod("SetConsoleColor", new object[1] { consoleColor });
		}

		private static void WriteColoredBrackets(string text, ConsoleColor consoleColor)
		{
			SetConsoleColor(ConsoleColor.White);
			consoleStream.Write("[");
			SetConsoleColor(consoleColor);
			consoleStream.Write(text ?? "");
			SetConsoleColor(ConsoleColor.White);
			consoleStream.Write("] ");
		}

		private static void WriteColoredWord(string text, bool endLine, ConsoleColor consoleColor)
		{
			ConsoleColor foregroundColor = Console.ForegroundColor;
			SetConsoleColor(consoleColor);
			consoleStream.Write(text + (endLine ? Environment.NewLine : string.Empty));
			SetConsoleColor(foregroundColor);
		}
	}
	internal class ButtonAPI : ModuleBase
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__14_0;

			internal void <CreateModsPanelMenu>b__14_0()
			{
				((Selectable)modsButtonButtonComponent).Select();
			}
		}

		private static Transform modsPanel;

		private static Button modsButtonButtonComponent;

		private static Transform sliderReference;

		private static Transform toggleReference;

		private static Action buildSettings;

		private static Dictionary<string, bool> cachedBoolPositions = new Dictionary<string, bool>();

		internal override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			//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_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_011a: 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_0152: Expected O, but got Unknown
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Expected O, but got Unknown
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: 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
			switch (sceneName)
			{
			case "InitScene":
			{
				Time.timeScale = 0.65f;
				MenuManager val5 = Object.FindObjectOfType<MenuManager>();
				((TMP_Text)val5.logText).text = "      BG IG, A System-Act Ally\r\n      Copyright (C) 2084-2108, Halden Electronics Inc.\r\n\r\nCPU Type:           BORSON 300 CPU at 2500 MHz\r\nMemory test:        4521586K OK\r\n\r\nFetching Players\r\n11 Accounts Fetched\r\nInitializing Players\r\nSorting IDs\r\nPrinting\r\n\r\nID      Name      Data\r\n---------------------------------------------\r\n0001    Nick      >\r\n0002    Danny     KRIMZON\r\n0003    Smiley    DOOMSHOP\r\n1091    Parr      AWOOGA\r\n4818    Sun-Hae   BAAAAR\r\n5672    Kyle      VASHSA\r\n6658    Neon      HLSL\r\n6969    Mixer     MixersManor\r\n9067    Birb      GOOB\r\n9223    Lincoln   OOF\r\n9602    Modz      COSMIC";
				break;
			}
			case "MainMenu":
			{
				Time.timeScale = 1f;
				MenuManager mainMenuMenuManager = Object.FindObjectOfType<MenuManager>();
				Vector2 offsetMax = ((TMP_Text)mainMenuMenuManager.versionNumberText).rectTransform.offsetMax;
				((TMP_Text)mainMenuMenuManager.versionNumberText).rectTransform.offsetMax = new Vector2(1000f, offsetMax.y);
				TextMeshProUGUI versionNumberText = mainMenuMenuManager.versionNumberText;
				((TMP_Text)versionNumberText).text = ((TMP_Text)versionNumberText).text + " <color=#00FFFF>[Modded by nickklmao]</color>";
				CreateModsPanelMenu();
				Transform val3 = mainMenuMenuManager.menuButtons.transform.Find("HostButton");
				Transform val4 = Object.Instantiate<Transform>(val3, val3.parent);
				val4.localPosition = new Vector3(-257.7366f, -4.1154f, -1.2f);
				((TMP_Text)((Component)val4).GetComponentInChildren<TextMeshProUGUI>()).text = "> ???";
				modsButtonButtonComponent = ((Component)val4).GetComponentInChildren<Button>();
				modsButtonButtonComponent.onClick = new ButtonClickedEvent();
				((UnityEvent)modsButtonButtonComponent.onClick).AddListener((UnityAction)delegate
				{
					mainMenuMenuManager.EnableUIPanel(((Component)modsPanel).gameObject);
					mainMenuMenuManager.DisableUIPanel(mainMenuMenuManager.menuButtons);
					((Selectable)modsButtonButtonComponent).Select();
					mainMenuMenuManager.PlayConfirmSFX();
				});
				break;
			}
			case "SampleSceneRelay":
			{
				QuickMenuManager quickMenuManager = Object.FindObjectOfType<QuickMenuManager>();
				CreateModsPanelInGame();
				Transform val = quickMenuManager.mainButtonsPanel.transform.Find("Resume");
				Transform val2 = Object.Instantiate<Transform>(val, val.parent);
				val2.localPosition = new Vector3(-379.4956f, 25.6134f, 0.0101f);
				Object.Destroy((Object)(object)((Component)val2).GetComponentInChildren<SelectUIForGamepad>());
				((TMP_Text)((Component)val2).GetComponentInChildren<TextMeshProUGUI>()).text = "> ???";
				modsButtonButtonComponent = ((Component)val2).GetComponent<Button>();
				modsButtonButtonComponent.onClick = new ButtonClickedEvent();
				((UnityEvent)modsButtonButtonComponent.onClick).AddListener((UnityAction)delegate
				{
					quickMenuManager.EnableUIPanel(((Component)modsPanel).gameObject);
					quickMenuManager.DisableUIPanel(quickMenuManager.mainButtonsPanel);
				});
				break;
			}
			}
		}

		internal override void OnPatch()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			QuickMenuManager.CloseQuickMenuPanels += new hook_CloseQuickMenuPanels(QuickMenuManagerOnCloseQuickMenuPanels);
		}

		private void QuickMenuManagerOnCloseQuickMenuPanels(orig_CloseQuickMenuPanels orig, QuickMenuManager self)
		{
			orig.Invoke(self);
			((Component)modsPanel).gameObject.SetActive(false);
		}

		internal static void AddSlider(string name, float min, float max, Action<float> onValueChanged, Vector2 position, ConfigEntry<float> entry)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			buildSettings = (Action)Delegate.Combine(buildSettings, (Action)delegate
			{
				//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: Expected O, but got Unknown
				//IL_0119: 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_0187: Unknown result type (might be due to invalid IL or missing references)
				//IL_0198: 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)
				Transform val = Object.Instantiate<Transform>(sliderReference, modsPanel);
				Transform transform = ((Component)((Component)val).GetComponentInChildren<Image>()).transform;
				TextMeshProUGUI titleTMP = ((Component)val).GetComponentInChildren<TextMeshProUGUI>();
				((TMP_Text)titleTMP).text = $"{name} [{entry.Value:F2}]";
				Slider sliderComponent = ((Component)val).GetComponentInChildren<Slider>();
				sliderComponent.minValue = min;
				sliderComponent.maxValue = max;
				sliderComponent.wholeNumbers = false;
				sliderComponent.onValueChanged = new SliderEvent();
				((UnityEvent<float>)(object)sliderComponent.onValueChanged).AddListener((UnityAction<float>)delegate(float f)
				{
					((TMP_Text)titleTMP).text = $"{name} [{f:F2}]";
				});
				((UnityEvent<float>)(object)sliderComponent.onValueChanged).AddListener((UnityAction<float>)onValueChanged.Invoke);
				Object.Destroy((Object)(object)((Component)sliderComponent).GetComponent<SettingsOption>());
				CoroutineHelper.instance.Yield(delegate
				{
					sliderComponent.SetValueWithoutNotify(entry.Value);
				}, null);
				transform.localPosition = Vector3.right * (-70f + ((float)((ConfigEntryBase)entry).DefaultValue - min) * 140f / (max - min));
				((Component)val).transform.localPosition = new Vector3(-410f + position.x, -200f + position.y, 14f);
				((Component)val).transform.localScale = Vector3.one * 1.25f;
			});
		}

		internal static void AddSlider(string name, float min, float max, Action<int> onValueChanged, Vector2 position, ConfigEntry<int> entry)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			buildSettings = (Action)Delegate.Combine(buildSettings, (Action)delegate
			{
				//IL_0098: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: Expected O, but got Unknown
				//IL_011a: 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_0189: Unknown result type (might be due to invalid IL or missing references)
				//IL_019a: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
				Transform val = Object.Instantiate<Transform>(sliderReference, modsPanel);
				Transform transform = ((Component)((Component)val).GetComponentInChildren<Image>()).transform;
				TextMeshProUGUI titleTMP = ((Component)val).GetComponentInChildren<TextMeshProUGUI>();
				((TMP_Text)titleTMP).text = $"{name} [{entry.Value}]";
				Slider sliderComponent = ((Component)val).GetComponentInChildren<Slider>();
				sliderComponent.minValue = min;
				sliderComponent.maxValue = max;
				sliderComponent.onValueChanged = new SliderEvent();
				((UnityEvent<float>)(object)sliderComponent.onValueChanged).AddListener((UnityAction<float>)delegate(float f)
				{
					((TMP_Text)titleTMP).text = $"{name} [{f}]";
				});
				((UnityEvent<float>)(object)sliderComponent.onValueChanged).AddListener((UnityAction<float>)delegate(float f)
				{
					onValueChanged?.Invoke(Convert.ToInt32(f));
				});
				Object.Destroy((Object)(object)((Component)sliderComponent).GetComponent<SettingsOption>());
				CoroutineHelper.instance.Yield(delegate
				{
					sliderComponent.SetValueWithoutNotify((float)entry.Value);
				}, null);
				transform.localPosition = Vector3.right * (-70f + ((float)(int)((ConfigEntryBase)entry).DefaultValue - min) * 140f / (max - min));
				((Component)val).transform.localPosition = new Vector3(-410f + position.x, -200f + position.y, 14f);
				((Component)val).transform.localScale = Vector3.one * 1.25f;
			});
		}

		internal static void AddToggle(string name, Action<bool> onValueChanged, Vector2 position, ConfigEntry<bool> entry)
		{
			//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)
			buildSettings = (Action)Delegate.Combine(buildSettings, (Action)delegate
			{
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: Expected O, but got Unknown
				//IL_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_0093: Expected O, but got Unknown
				//IL_00d9: 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)
				Transform val = Object.Instantiate<Transform>(toggleReference, modsPanel);
				TextMeshProUGUI componentInChildren = ((Component)val).GetComponentInChildren<TextMeshProUGUI>();
				((TMP_Text)componentInChildren).text = name;
				Button componentInChildren2 = ((Component)val).GetComponentInChildren<Button>();
				SettingsOption component = ((Component)componentInChildren2).GetComponent<SettingsOption>();
				Sprite enabledSprite = component.enabledImage;
				Sprite disabledSprite = component.disabledImage;
				Image checkmarkImage = component.toggleImage;
				Object.Destroy((Object)(object)component);
				componentInChildren2.onClick = new ButtonClickedEvent();
				((UnityEvent)componentInChildren2.onClick).AddListener((UnityAction)delegate
				{
					entry.Value = !entry.Value;
					checkmarkImage.sprite = (entry.Value ? enabledSprite : disabledSprite);
					onValueChanged?.Invoke(entry.Value);
				});
				CoroutineHelper.instance.Yield(delegate
				{
					checkmarkImage.sprite = (entry.Value ? enabledSprite : disabledSprite);
				}, null);
				((Component)val).transform.localPosition = new Vector3(-410f + position.x, -200f + position.y, 14f);
				((Component)val).transform.localScale = Vector3.one * 1.25f;
			});
		}

		internal static void AddToggle(string name, Action<bool> onValueChanged, Vector2 position, bool defaultValue)
		{
			//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)
			buildSettings = (Action)Delegate.Combine(buildSettings, (Action)delegate
			{
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: 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_00f0: 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)
				Transform val = Object.Instantiate<Transform>(toggleReference, modsPanel);
				cachedBoolPositions.TryAdd(name, defaultValue);
				TextMeshProUGUI componentInChildren = ((Component)val).GetComponentInChildren<TextMeshProUGUI>();
				((TMP_Text)componentInChildren).text = name;
				Button componentInChildren2 = ((Component)val).GetComponentInChildren<Button>();
				SettingsOption component = ((Component)componentInChildren2).GetComponent<SettingsOption>();
				Sprite enabledSprite = component.enabledImage;
				Sprite disabledSprite = component.disabledImage;
				Image checkmarkImage = component.toggleImage;
				Object.Destroy((Object)(object)component);
				componentInChildren2.onClick = new ButtonClickedEvent();
				((UnityEvent)componentInChildren2.onClick).AddListener((UnityAction)delegate
				{
					cachedBoolPositions[name] = !cachedBoolPositions[name];
					checkmarkImage.sprite = (cachedBoolPositions[name] ? enabledSprite : disabledSprite);
					onValueChanged?.Invoke(cachedBoolPositions[name]);
				});
				CoroutineHelper.instance.Yield(delegate
				{
					checkmarkImage.sprite = (cachedBoolPositions[name] ? enabledSprite : disabledSprite);
				}, null);
				((Component)val).transform.localPosition = new Vector3(-410f + position.x, -200f + position.y, 14f);
				((Component)val).transform.localScale = Vector3.one * 1.25f;
			});
		}

		internal static void ShowNewsPage(string title, string content)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			Transform val = GameObject.Find("MenuContainer").transform.Find("NewsPanel");
			TextMeshProUGUI[] componentsInChildren = ((Component)val).GetComponentsInChildren<TextMeshProUGUI>();
			TextMeshProUGUI val2 = componentsInChildren[0];
			TextMeshProUGUI val3 = componentsInChildren[2];
			((TMP_Text)val2).text = title;
			((TMP_Text)val3).fontSize = 10f;
			((Component)val3).GetComponent<RectTransform>().offsetMax = new Vector2(420f, 85f);
			((TMP_Text)val3).text = content;
			((Component)val).gameObject.SetActive(true);
		}

		private static void CreateModsPanelMenu()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			Transform val = GameObject.Find("Canvas").transform.Find("MenuContainer/SettingsPanel");
			modsPanel = Object.Instantiate<Transform>(val, val.parent);
			sliderReference = val.Find("MasterVolume");
			toggleReference = val.Find("ControlsOptions/InvertYAxis");
			foreach (Transform item in modsPanel)
			{
				Transform val2 = item;
				if (((Object)val2).name == "BackButton")
				{
					Button component = ((Component)val2).GetComponent<Button>();
					ButtonClickedEvent onClick = component.onClick;
					object obj = <>c.<>9__14_0;
					if (obj == null)
					{
						UnityAction val3 = delegate
						{
							((Selectable)modsButtonButtonComponent).Select();
						};
						<>c.<>9__14_0 = val3;
						obj = (object)val3;
					}
					((UnityEvent)onClick).AddListener((UnityAction)obj);
				}
				else
				{
					Object.Destroy((Object)(object)((Component)val2).gameObject);
				}
			}
			buildSettings?.Invoke();
		}

		private static void CreateModsPanelInGame()
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			//IL_00b4: 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_00bc: Expected O, but got Unknown
			//IL_00c1: Expected O, but got Unknown
			QuickMenuManager quickMenuManager = Object.FindObjectOfType<QuickMenuManager>();
			Transform transform = quickMenuManager.settingsPanel.transform;
			modsPanel = Object.Instantiate<Transform>(transform, transform.parent);
			sliderReference = transform.Find("MasterVolume");
			toggleReference = transform.Find("ControlsOptions/InvertYAxis");
			UnityAction val2 = default(UnityAction);
			foreach (Transform item in modsPanel)
			{
				Transform val = item;
				if (((Object)val).name == "BackButton")
				{
					Button component = ((Component)val).GetComponent<Button>();
					component.onClick = new ButtonClickedEvent();
					ButtonClickedEvent onClick = component.onClick;
					UnityAction obj = val2;
					if (obj == null)
					{
						UnityAction val3 = delegate
						{
							quickMenuManager.EnableUIPanel(quickMenuManager.mainButtonsPanel);
							quickMenuManager.DisableUIPanel(((Component)modsPanel).gameObject);
						};
						UnityAction val4 = val3;
						val2 = val3;
						obj = val4;
					}
					((UnityEvent)onClick).AddListener(obj);
				}
				else
				{
					Object.Destroy((Object)(object)((Component)val).gameObject);
				}
			}
			buildSettings?.Invoke();
		}
	}
	internal class CustomFOV : ModuleBase
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__UpdatePatch;

			public static hook_OnEnable <1>__OnEnablePatch;
		}

		private static float customFOV => ((ButtonControl)Keyboard.current[(Key)17]).isPressed ? Config.customZoomFOV.Value : Config.customFOV.Value;

		internal override void OnStart()
		{
			//IL_0039: 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)
			ButtonAPI.AddSlider("Default FOV", 0f, 135f, delegate(int f)
			{
				Config.customFOV.Value = Convert.ToInt32(f);
			}, new Vector2(5f, 450f), Config.customFOV);
			ButtonAPI.AddSlider("Zoom FOV", 0f, 135f, delegate(int f)
			{
				Config.customZoomFOV.Value = Convert.ToInt32(f);
			}, new Vector2(5f, 395f), Config.customZoomFOV);
		}

		internal override void OnPatch()
		{
			//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>__UpdatePatch;
			if (obj == null)
			{
				Manipulator val = UpdatePatch;
				<>O.<0>__UpdatePatch = val;
				obj = (object)val;
			}
			PlayerControllerB.Update += (Manipulator)obj;
			object obj2 = <>O.<1>__OnEnablePatch;
			if (obj2 == null)
			{
				hook_OnEnable val2 = OnEnablePatch;
				<>O.<1>__OnEnablePatch = val2;
				obj2 = (object)val2;
			}
			PlayerControllerB.OnEnable += (hook_OnEnable)obj2;
		}

		private static void UpdatePatch(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0061: 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_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_00e3: 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)
			ILCursor val = new ILCursor(il);
			val.GotoNext(new Func<Instruction, bool>[2]
			{
				(Instruction instruction) => ILPatternMatchingExt.MatchLdcR4(instruction, 68f),
				(Instruction instruction) => ILPatternMatchingExt.MatchStfld<PlayerControllerB>(instruction, "targetFOV")
			});
			val.Remove();
			val.Emit(OpCodes.Call, (MethodBase)typeof(CustomFOV).GetProperty("customFOV", BindingFlags.Static | BindingFlags.NonPublic).GetGetMethod(nonPublic: true));
			val.Emit(OpCodes.Ldc_R4, 1.03f);
			val.Emit(OpCodes.Mul);
			val.Emit(OpCodes.Stfld, typeof(PlayerControllerB).GetField("targetFOV"));
			val.Remove();
			val.Index += 2;
			val.Remove();
			val.Emit(OpCodes.Call, (MethodBase)typeof(CustomFOV).GetProperty("customFOV", BindingFlags.Static | BindingFlags.NonPublic).GetGetMethod(nonPublic: true));
			val.Emit(OpCodes.Stfld, typeof(PlayerControllerB).GetField("targetFOV"));
			val.Remove();
		}

		private static void OnEnablePatch(orig_OnEnable orig, PlayerControllerB self)
		{
			orig.Invoke(self);
			((Component)GameObject.Find("Systems").transform.Find("Rendering/PlayerHUDHelmetModel")).gameObject.SetActive(false);
		}
	}
	internal class LODGroupSolver : ModuleBase
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_TeleportPlayer <0>__TeleportPlayerPatch;

			public static hook_PressTeleportButtonClientRpc <1>__PressTeleportButtonClientRpcPatch;
		}

		internal override void OnPatch()
		{
			//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>__TeleportPlayerPatch;
			if (obj == null)
			{
				hook_TeleportPlayer val = TeleportPlayerPatch;
				<>O.<0>__TeleportPlayerPatch = val;
				obj = (object)val;
			}
			EntranceTeleport.TeleportPlayer += (hook_TeleportPlayer)obj;
			object obj2 = <>O.<1>__PressTeleportButtonClientRpcPatch;
			if (obj2 == null)
			{
				hook_PressTeleportButtonClientRpc val2 = PressTeleportButtonClientRpcPatch;
				<>O.<1>__PressTeleportButtonClientRpcPatch = val2;
				obj2 = (object)val2;
			}
			ShipTeleporter.PressTeleportButtonClientRpc += (hook_PressTeleportButtonClientRpc)obj2;
		}

		private static void TeleportPlayerPatch(orig_TeleportPlayer orig, EntranceTeleport self)
		{
			orig.Invoke(self);
			ForceLODs();
		}

		private static void PressTeleportButtonClientRpcPatch(orig_PressTeleportButtonClientRpc orig, ShipTeleporter self)
		{
			orig.Invoke(self);
			ForceLODs();
		}

		private static void ForceLODs()
		{
			IEnumerable<LODGroup> enumerable = from @group in Object.FindObjectsByType<LODGroup>((FindObjectsSortMode)0)
				where ((Object)((Component)@group).transform).name == "CatwalkStairs"
				select @group;
			foreach (LODGroup item in enumerable)
			{
				item.ForceLOD(0);
			}
		}
	}
	internal class ModuleBase
	{
		internal static Action onStartEvent;

		internal static Action onUpdateEvent;

		internal static Action onGUIEvent;

		internal static Action onPatchEvent;

		internal static Action<int, string> onSceneWasLoadedEvent;

		internal static void Load(bool invokePatchEventAndStartEvent)
		{
			CollectionExtensions.Do<Type>(from type in Assembly.GetExecutingAssembly().GetTypes()
				where type.IsSubclassOf(typeof(ModuleBase))
				select type, (Action<Type>)delegate(Type moduleType)
			{
				(Activator.CreateInstance(moduleType) as ModuleBase).Bind();
			});
			if (invokePatchEventAndStartEvent)
			{
				onPatchEvent?.Invoke();
				onStartEvent?.Invoke();
			}
		}

		internal virtual void OnStart()
		{
		}

		internal virtual void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
		}

		internal virtual void OnUpdate()
		{
		}

		internal virtual void OnGUI()
		{
		}

		internal virtual void OnPatch()
		{
		}

		private void Bind()
		{
			onStartEvent = (Action)Delegate.Combine(onStartEvent, new Action(OnStart));
			onSceneWasLoadedEvent = (Action<int, string>)Delegate.Combine(onSceneWasLoadedEvent, new Action<int, string>(OnSceneWasLoaded));
			onUpdateEvent = (Action)Delegate.Combine(onUpdateEvent, new Action(OnUpdate));
			onGUIEvent = (Action)Delegate.Combine(onGUIEvent, new Action(OnGUI));
			onPatchEvent = (Action)Delegate.Combine(onPatchEvent, new Action(OnPatch));
		}
	}
	internal class NetworkManager : ModuleBase
	{
		internal override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			if (sceneName == "SampleSceneRelay")
			{
				GameObject val = NetworkHelper.CreateNetworkedObject("Custom RPCs");
				val.AddComponent<PingSystem>();
			}
		}
	}
	internal class SpectateEnemies : ModuleBase
	{
		private class SpectateEntityInfo
		{
			internal readonly Transform entityTransform;

			internal Transform entityViewPosition;

			internal string entityName;

			internal bool isPlayer;

			internal bool isEnemy;

			internal bool isMimic;

			internal bool isTurret;

			internal bool isLandmine;

			private GameObject listButtonObject;

			private Transform playerNameTransform;

			public static implicit operator bool(SpectateEntityInfo entity)
			{
				return (Object)(object)entity?.entityTransform != (Object)null;
			}

			internal SpectateEntityInfo(Transform entityTransform)
			{
				this.entityTransform = entityTransform;
				CacheEntityType();
				CacheEntityName();
				CacheEntityView();
				CreateButton();
			}

			internal void ToggleListVisibility(bool visible)
			{
				GameObject obj = listButtonObject;
				if (obj != null)
				{
					obj.SetActive(visible);
				}
			}

			internal void SetIndex(int index)
			{
				//IL_001f: 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_0067: Unknown result type (might be due to invalid IL or missing references)
				playerNameTransform.localPosition = new Vector3(4f, -2f + (float)index * 0.125f, -5f);
				Vector3 localPosition = listButtonObject.transform.localPosition;
				localPosition.x = 245f;
				localPosition.y = 112f - (float)index * 16.5f;
				listButtonObject.transform.localPosition = localPosition;
			}

			internal void DestroyListButton()
			{
				if (Object.op_Implicit((Object)(object)listButtonObject))
				{
					Object.Destroy((Object)(object)listButtonObject);
				}
			}

			private void CacheEntityType()
			{
				if (Object.op_Implicit((Object)(object)((Component)entityTransform).GetComponent<PlayerControllerB>()))
				{
					isPlayer = true;
				}
				else if (Object.op_Implicit((Object)(object)((Component)entityTransform).GetComponent<EnemyAI>()))
				{
					isEnemy = true;
				}
				else if (Object.op_Implicit((Object)(object)((Component)entityTransform).GetComponent<Turret>()))
				{
					isTurret = true;
				}
				else if (Object.op_Implicit((Object)(object)((Component)entityTransform).GetComponent<Landmine>()))
				{
					isLandmine = true;
				}
				else if (Object.op_Implicit((Object)(object)((Component)entityTransform).GetComponent(Type.GetType("Mimics.MimicDoor, Mimics"))))
				{
					isMimic = true;
				}
			}

			private void CacheEntityName()
			{
				if (isPlayer)
				{
					entityName = ((Component)entityTransform).GetComponent<PlayerControllerB>().playerUsername;
				}
				else if (isEnemy)
				{
					string text = ((Object)entityTransform).name.Replace("(Clone)", string.Empty);
					if (1 == 0)
					{
					}
					string text2 = text switch
					{
						"Crawler" => "Thumper", 
						"Flowerman" => "Bracken", 
						"TurretScript" => "Turret", 
						"SpringMan" => "Coil-Head", 
						"ForestGiant" => "Forest Giant", 
						"SandWorm" => "Earth Leviathan", 
						"MouthDog" => "Eyeless Dog", 
						"Centipede" => "Snare Flea", 
						"HoarderBug" => "Hoarder Bug", 
						"RedLocustBees" => "Circuit Bees", 
						"SandSpider" => "Bunker Spider", 
						"PufferEnemy" => "Spore Lizard", 
						"JesterEnemy" => "Jester", 
						"LassoMan" => "Lasso Man", 
						"DressGirl" => "Ghost Girl", 
						"BaboonHawkEnemy" => "Baboon Hawk", 
						"Blob" => "Hygrodere", 
						"MaskedPlayerEnemy" => "Masked Player", 
						"NutcrackerEnemy" => "Nutcracker", 
						_ => text, 
					};
					if (1 == 0)
					{
					}
					entityName = text2;
				}
				else if (isMimic)
				{
					entityName = "Mimic Fire Exit";
				}
				else if (isTurret)
				{
					entityName = "Turret";
				}
				else if (isLandmine)
				{
					entityName = "Landmine";
				}
			}

			private void CacheEntityView()
			{
				if (isPlayer)
				{
					Transform obj = entityTransform;
					entityViewPosition = ((obj == null) ? null : ((Component)obj).GetComponent<PlayerControllerB>()?.playerEye);
				}
				else if (isEnemy)
				{
					Transform obj2 = entityTransform;
					entityViewPosition = ((obj2 == null) ? null : ((Component)obj2).GetComponent<EnemyAI>()?.eye) ?? entityTransform;
				}
				else if (isTurret)
				{
					Transform obj3 = entityTransform;
					entityViewPosition = ((obj3 == null) ? null : ((Component)obj3).GetComponent<Turret>()?.centerPoint);
				}
				else
				{
					entityViewPosition = entityTransform;
				}
			}

			private void CreateButton()
			{
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Expected O, but got Unknown
				listButtonObject = Object.Instantiate<GameObject>(entityListItemPrefab, uiCanvas);
				((UnityEvent)listButtonObject.GetComponentInChildren<Button>().onClick).AddListener((UnityAction)delegate
				{
					currentlySpectatedEntity = this;
					((TMP_Text)HUDManager.Instance.spectatingPlayerText).text = "(Spectating: " + currentlySpectatedEntity.entityName + ")";
				});
				playerNameTransform = listButtonObject.transform.Find("ServerName");
				((TMP_Text)((Component)playerNameTransform).GetComponent<TextMeshProUGUI>()).text = entityName;
				ToggleListVisibility(!isMenuOpen);
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static hook_OpenQuickMenu <0>__OpenQuickMenuPatch;

			public static hook_CloseQuickMenu <1>__CloseQuickMenuPatch;

			public static hook_ReviveDeadPlayers <2>__ReviveDeadPlayersPatch;

			public static Manipulator <3>__ActivateItem_performedPatch;

			public static Manipulator <4>__Interact_performedPatch;

			public static Manipulator <5>__LateUpdatePatch;

			public static hook_SpectateNextPlayer <6>__SpectateNextPlayerPatch;

			public static hook_LateUpdate <7>__LateUpdatePatch;

			public static hook_PlayerLookInput <8>__PlayerLookInputPatch;

			public static hook_KillPlayerClientRpc <9>__KillPlayerClientRpcPatch;

			public static hook_Start <10>__StartPatch;

			public static hook_KillEnemy <11>__KillEnemyPatch;
		}

		private static readonly List<SpectateEntityInfo> spectatableEntityInfo = new List<SpectateEntityInfo>();

		private static SpectateEntityInfo _currentlySpectatedEntity;

		private static GameObject entityListItemPrefab;

		private static Transform ctrlHintMessage;

		private static Transform _uiCanvas;

		private static Transform _spectateCamera;

		private static Light _spectateCameraLight;

		private static bool isMenuOpen;

		private static float spectateZoom;

		private static SpectateEntityInfo currentlySpectatedEntity
		{
			get
			{
				return _currentlySpectatedEntity;
			}
			set
			{
				((Behaviour)spectateCameraLight).enabled = value;
				_currentlySpectatedEntity = value;
			}
		}

		private static Transform uiCanvas
		{
			get
			{
				if (Object.op_Implicit((Object)(object)_uiCanvas))
				{
					return _uiCanvas;
				}
				GameObject obj = GameObject.Find("Systems");
				object result;
				if (obj == null)
				{
					result = null;
				}
				else
				{
					Transform transform = obj.transform;
					result = ((transform != null) ? transform.Find("UI/Canvas") : null);
				}
				_uiCanvas = (Transform)result;
				return (Transform)result;
			}
		}

		private static Transform spectateCamera
		{
			get
			{
				if (Object.op_Implicit((Object)(object)_spectateCamera))
				{
					return _spectateCamera;
				}
				GameObject obj = GameObject.Find("Systems");
				return _spectateCamera = ((obj != null) ? obj.transform.Find("SpectateCameraPivot/SpectateCamera") : null);
			}
		}

		private static Light spectateCameraLight
		{
			get
			{
				if (Object.op_Implicit((Object)(object)_spectateCameraLight))
				{
					return _spectateCameraLight;
				}
				Transform obj = spectateCamera;
				_spectateCameraLight = ((obj != null) ? ((Component)obj).GetComponent<Light>() : null);
				Light obj2 = _spectateCameraLight;
				float intensity = (_spectateCameraLight.spotAngle = 180f);
				obj2.intensity = intensity;
				return _spectateCameraLight;
			}
		}

		private static bool isSpectating => GameNetworkManager.Instance.localPlayerController.isPlayerDead;

		private static bool isHoldingLeftCTRL => ((ButtonControl)Keyboard.current[(Key)55]).isPressed;

		internal override void OnPatch()
		{
			//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
			//IL_0095: 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_00a0: Expected O, but got Unknown
			//IL_00b6: 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: Expected O, but got Unknown
			//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_00e2: Expected O, but got Unknown
			//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
			//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_0145: Expected O, but got Unknown
			//IL_015b: 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_0166: Expected O, but got Unknown
			//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_0187: Expected O, but got Unknown
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Expected O, but got Unknown
			object obj = <>O.<0>__OpenQuickMenuPatch;
			if (obj == null)
			{
				hook_OpenQuickMenu val = OpenQuickMenuPatch;
				<>O.<0>__OpenQuickMenuPatch = val;
				obj = (object)val;
			}
			QuickMenuManager.OpenQuickMenu += (hook_OpenQuickMenu)obj;
			object obj2 = <>O.<1>__CloseQuickMenuPatch;
			if (obj2 == null)
			{
				hook_CloseQuickMenu val2 = CloseQuickMenuPatch;
				<>O.<1>__CloseQuickMenuPatch = val2;
				obj2 = (object)val2;
			}
			QuickMenuManager.CloseQuickMenu += (hook_CloseQuickMenu)obj2;
			object obj3 = <>O.<2>__ReviveDeadPlayersPatch;
			if (obj3 == null)
			{
				hook_ReviveDeadPlayers val3 = ReviveDeadPlayersPatch;
				<>O.<2>__ReviveDeadPlayersPatch = val3;
				obj3 = (object)val3;
			}
			StartOfRound.ReviveDeadPlayers += (hook_ReviveDeadPlayers)obj3;
			object obj4 = <>O.<3>__ActivateItem_performedPatch;
			if (obj4 == null)
			{
				Manipulator val4 = ActivateItem_performedPatch;
				<>O.<3>__ActivateItem_performedPatch = val4;
				obj4 = (object)val4;
			}
			PlayerControllerB.ActivateItem_performed += (Manipulator)obj4;
			object obj5 = <>O.<4>__Interact_performedPatch;
			if (obj5 == null)
			{
				Manipulator val5 = Interact_performedPatch;
				<>O.<4>__Interact_performedPatch = val5;
				obj5 = (object)val5;
			}
			PlayerControllerB.Interact_performed += (Manipulator)obj5;
			object obj6 = <>O.<5>__LateUpdatePatch;
			if (obj6 == null)
			{
				Manipulator val6 = LateUpdatePatch;
				<>O.<5>__LateUpdatePatch = val6;
				obj6 = (object)val6;
			}
			PlayerControllerB.LateUpdate += (Manipulator)obj6;
			object obj7 = <>O.<6>__SpectateNextPlayerPatch;
			if (obj7 == null)
			{
				hook_SpectateNextPlayer val7 = SpectateNextPlayerPatch;
				<>O.<6>__SpectateNextPlayerPatch = val7;
				obj7 = (object)val7;
			}
			PlayerControllerB.SpectateNextPlayer += (hook_SpectateNextPlayer)obj7;
			object obj8 = <>O.<7>__LateUpdatePatch;
			if (obj8 == null)
			{
				hook_LateUpdate val8 = LateUpdatePatch;
				<>O.<7>__LateUpdatePatch = val8;
				obj8 = (object)val8;
			}
			PlayerControllerB.LateUpdate += (hook_LateUpdate)obj8;
			object obj9 = <>O.<8>__PlayerLookInputPatch;
			if (obj9 == null)
			{
				hook_PlayerLookInput val9 = PlayerLookInputPatch;
				<>O.<8>__PlayerLookInputPatch = val9;
				obj9 = (object)val9;
			}
			PlayerControllerB.PlayerLookInput += (hook_PlayerLookInput)obj9;
			object obj10 = <>O.<9>__KillPlayerClientRpcPatch;
			if (obj10 == null)
			{
				hook_KillPlayerClientRpc val10 = KillPlayerClientRpcPatch;
				<>O.<9>__KillPlayerClientRpcPatch = val10;
				obj10 = (object)val10;
			}
			PlayerControllerB.KillPlayerClientRpc += (hook_KillPlayerClientRpc)obj10;
			object obj11 = <>O.<10>__StartPatch;
			if (obj11 == null)
			{
				hook_Start val11 = StartPatch;
				<>O.<10>__StartPatch = val11;
				obj11 = (object)val11;
			}
			EnemyAI.Start += (hook_Start)obj11;
			object obj12 = <>O.<11>__KillEnemyPatch;
			if (obj12 == null)
			{
				hook_KillEnemy val12 = KillEnemyPatch;
				<>O.<11>__KillEnemyPatch = val12;
				obj12 = (object)val12;
			}
			EnemyAI.KillEnemy += (hook_KillEnemy)obj12;
			Type type = Type.GetType("MoreCompany.SpectatePatches, MoreCompany");
			if (type != null)
			{
				HarmonyHelper.harmony.Patch((MethodBase)AccessTools.Method(type, "Prefix", (Type[])null, (Type[])null), new HarmonyMethod(typeof(SpectateEnemies), "SpectatePatchesPrefixPatch", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
		}

		private static void OpenQuickMenuPatch(orig_OpenQuickMenu orig, QuickMenuManager self)
		{
			orig.Invoke(self);
			isMenuOpen = true;
			spectatableEntityInfo.ForEach(delegate(SpectateEntityInfo entityInfo)
			{
				entityInfo.ToggleListVisibility(visible: false);
			});
		}

		private static void CloseQuickMenuPatch(orig_CloseQuickMenu orig, QuickMenuManager self)
		{
			orig.Invoke(self);
			isMenuOpen = false;
			spectatableEntityInfo.ForEach(delegate(SpectateEntityInfo entityInfo)
			{
				entityInfo.ToggleListVisibility(visible: true);
			});
		}

		private static void ReviveDeadPlayersPatch(orig_ReviveDeadPlayers orig, StartOfRound self)
		{
			orig.Invoke(self);
			ClearSpectatatableEntityInfo();
			currentlySpectatedEntity = null;
		}

		private static void ActivateItem_performedPatch(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel val2 = val.DefineLabel();
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction instruction) => ILPatternMatchingExt.MatchLdfld<PlayerControllerB>(instruction, "spectatedPlayerScript")
			});
			int index = val.Index;
			val.Index = index - 1;
			val.RemoveRange(9);
			val.MarkLabel(val2);
			val.Index -= 2;
			val.Remove();
			val.Emit(OpCodes.Brfalse_S, (object)val2);
		}

		private static void Interact_performedPatch(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel val2 = val.DefineLabel();
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction instruction) => ILPatternMatchingExt.MatchLdfld<PlayerControllerB>(instruction, "spectatedPlayerScript")
			});
			int index = val.Index;
			val.Index = index - 1;
			val.RemoveRange(9);
			val.MarkLabel(val2);
			val.Index -= 2;
			val.Remove();
			val.Emit(OpCodes.Brfalse_S, (object)val2);
		}

		private static void LateUpdatePatch(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel val2 = val.DefineLabel();
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction instruction) => ILPatternMatchingExt.MatchCall<PlayerControllerB>(instruction, "SpectateNextPlayer")
			});
			int index = val.Index;
			val.Index = index - 1;
			val.RemoveRange(3);
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction instruction) => ILPatternMatchingExt.MatchCall<PlayerControllerB>(instruction, "SpectateNextPlayer")
			});
			val.Index -= 2;
			val.RemoveRange(3);
			val.MarkLabel(val2);
			val.Index -= 8;
			val.Remove();
			val.Emit(OpCodes.Brfalse_S, (object)val2);
		}

		private static void SpectateNextPlayerPatch(orig_SpectateNextPlayer orig, PlayerControllerB self)
		{
			if (isHoldingLeftCTRL)
			{
				return;
			}
			ClearSpectatatableEntityInfo();
			CacheSpectatatableEntityInfo();
			int num = -1;
			if ((bool)currentlySpectatedEntity)
			{
				num = spectatableEntityInfo.FindIndex((SpectateEntityInfo entityInfo) => (Object)(object)entityInfo.entityTransform == (Object)(object)currentlySpectatedEntity.entityTransform);
			}
			num = ((num != -1 && num < spectatableEntityInfo.Count - 1) ? (num + 1) : 0);
			currentlySpectatedEntity = spectatableEntityInfo[num];
			if (!currentlySpectatedEntity)
			{
				((TMP_Text)HUDManager.Instance.spectatingPlayerText).text = "(You're not spectating anyone)";
				return;
			}
			if (currentlySpectatedEntity.isPlayer)
			{
				self.spectatedPlayerScript = ((Component)currentlySpectatedEntity.entityTransform).GetComponent<PlayerControllerB>();
			}
			StartOfRound.Instance.SetPlayerSafeInShip();
			((TMP_Text)HUDManager.Instance.spectatingPlayerText).text = "(Spectating: " + currentlySpectatedEntity.entityName + ")";
		}

		private static void LateUpdatePatch(orig_LateUpdate 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_0082: 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)
			//IL_00d4: 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)
			orig.Invoke(self);
			if (((NetworkBehaviour)self).IsOwner && (!((NetworkBehaviour)self).IsServer || self.isHostPlayerObject) && !isMenuOpen && isSpectating)
			{
				Cursor.lockState = (CursorLockMode)((!isHoldingLeftCTRL) ? 1 : 0);
				Cursor.visible = isHoldingLeftCTRL;
				if ((bool)currentlySpectatedEntity)
				{
					float num = spectateZoom;
					Vector2 val = ((InputControl<Vector2>)(object)Mouse.current.scroll).ReadValue();
					spectateZoom = num + ((Vector2)(ref val)).normalized.y;
					spectateZoom = Mathf.Clamp(spectateZoom, -5f, 0f);
					self.spectateCameraPivot.position = currentlySpectatedEntity.entityViewPosition.position + ((Component)spectateCamera).transform.forward * spectateZoom;
				}
			}
		}

		private static void PlayerLookInputPatch(orig_PlayerLookInput orig, PlayerControllerB self)
		{
			if (!((NetworkBehaviour)self).IsOwner || !isHoldingLeftCTRL || !isSpectating)
			{
				orig.Invoke(self);
			}
		}

		private static void KillPlayerClientRpcPatch(orig_KillPlayerClientRpc orig, PlayerControllerB self, int playerId, bool spawnBody, Vector3 bodyVelocity, int causeOfDeath, int deathAnimation)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, playerId, spawnBody, bodyVelocity, causeOfDeath, deathAnimation);
			bool flag = (Object)(object)self == (Object)(object)GameNetworkManager.Instance.localPlayerController;
			bool flag2 = (bool)currentlySpectatedEntity && currentlySpectatedEntity.isPlayer && (Object)(object)((Component)self).transform == (Object)(object)currentlySpectatedEntity.entityTransform;
			if (flag || flag2)
			{
				if (flag)
				{
					ClearSpectatatableEntityInfo();
					CacheSpectatatableEntityInfo();
				}
				self.CallMethod("SpectateNextPlayer");
			}
		}

		private static void StartPatch(orig_Start orig, EnemyAI self)
		{
			orig.Invoke(self);
			if (isSpectating)
			{
				ClearSpectatatableEntityInfo();
				CacheSpectatatableEntityInfo();
			}
		}

		private static void KillEnemyPatch(orig_KillEnemy orig, EnemyAI self, bool destroy)
		{
			if (isSpectating)
			{
				ClearSpectatatableEntityInfo();
				CacheSpectatatableEntityInfo();
			}
			orig.Invoke(self, destroy);
		}

		private static bool SpectatePatchesPrefixPatch()
		{
			return !isHoldingLeftCTRL || !isSpectating;
		}

		internal override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			if (!(sceneName == "MainMenu"))
			{
				if (sceneName == "SampleSceneRelay" && !Object.op_Implicit((Object)(object)ctrlHintMessage))
				{
					CacheCTRLHintMessage();
				}
			}
			else if (!Object.op_Implicit((Object)(object)entityListItemPrefab))
			{
				CacheEntityListItemPrefab();
			}
		}

		private static void CacheEntityListItemPrefab()
		{
			//IL_005b: 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_00a1: 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_00be: Expected O, but got Unknown
			//IL_00c2: 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)
			entityListItemPrefab = Object.Instantiate<GameObject>(Object.FindObjectOfType<SteamLobbyManager>(true).LobbySlotPrefab);
			Object.Destroy((Object)(object)entityListItemPrefab.GetComponent<LobbySlot>());
			Object.Destroy((Object)(object)((Component)entityListItemPrefab.transform.Find("NumPlayers")).gameObject);
			RectTransform component = entityListItemPrefab.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(200f, 15f);
			Transform val = entityListItemPrefab.transform.Find("JoinButton");
			val.localScale = Vector3.one * 0.65f;
			val.localPosition = new Vector3(195f, 2f, 0f);
			Button componentInChildren = ((Component)val).GetComponentInChildren<Button>();
			componentInChildren.onClick = new ButtonClickedEvent();
			Navigation navigation = default(Navigation);
			((Navigation)(ref navigation)).mode = (Mode)0;
			((Selectable)componentInChildren).navigation = navigation;
			((TMP_Text)((Component)val).GetComponentInChildren<TextMeshProUGUI>()).text = "Spectate";
			Object.DontDestroyOnLoad((Object)(object)entityListItemPrefab);
		}

		private static void CacheCTRLHintMessage()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			Transform val = GameObject.Find("Systems").transform.Find("UI/Canvas/DeathScreen/SpectateUI/EndGameEarly/Header");
			ctrlHintMessage = Object.Instantiate<Transform>(val, val.parent);
			((TMP_Text)((Component)ctrlHintMessage).GetComponent<TextMeshProUGUI>()).text = "Hold left CTRL to enable mouse!";
			ctrlHintMessage.localPosition = new Vector3(337f, -266f, 0f);
		}

		private static void ClearSpectatatableEntityInfo()
		{
			foreach (SpectateEntityInfo item in spectatableEntityInfo)
			{
				item.DestroyListButton();
			}
			spectatableEntityInfo.Clear();
		}

		private static void CacheSpectatatableEntityInfo()
		{
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			List<Transform> list = new List<Transform>();
			list.AddRange(from player in localPlayerController.playersManager.allPlayerScripts
				where player.isPlayerControlled && !player.isPlayerDead
				select player into controller
				select ((Component)controller).transform);
			list.AddRange(from enemy in Object.FindObjectsByType<EnemyAI>((FindObjectsSortMode)0)
				where !(enemy is DocileLocustBeesAI) && !(enemy is DoublewingAI) && !enemy.isEnemyDead
				select ((Component)enemy).transform);
			list.AddRange(from obj in Object.FindObjectsByType(Type.GetType("Mimics.MimicDoor, Mimics"), (FindObjectsSortMode)0)
				select ((Component)((obj is Component) ? obj : null)).transform);
			list.AddRange(from turret in Object.FindObjectsByType<Turret>((FindObjectsSortMode)0)
				select ((Component)turret).transform);
			list.AddRange(from landmine in Object.FindObjectsByType<Landmine>((FindObjectsSortMode)0)
				where !landmine.hasExploded
				select ((Component)landmine).transform);
			for (int i = 0; i < list.Count; i++)
			{
				Transform val = list[i];
				SpectateEntityInfo spectateEntityInfo = new SpectateEntityInfo(((Component)val).transform);
				spectateEntityInfo.SetIndex(i);
				spectatableEntityInfo.Add(spectateEntityInfo);
			}
		}
	}
	internal class UncappedSignalTranslator : ModuleBase
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__ParsePlayerSentencePatch;

			public static Manipulator <1>__UseSignalTranslatorServerRpcPatch;

			public static Manipulator <2>__UseSignalTranslatorClientRpcPatch;
		}

		internal override void OnPatch()
		{
			//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>__ParsePlayerSentencePatch;
			if (obj == null)
			{
				Manipulator val = ParsePlayerSentencePatch;
				<>O.<0>__ParsePlayerSentencePatch = val;
				obj = (object)val;
			}
			Terminal.ParsePlayerSentence += (Manipulator)obj;
			object obj2 = <>O.<1>__UseSignalTranslatorServerRpcPatch;
			if (obj2 == null)
			{
				Manipulator val2 = UseSignalTranslatorServerRpcPatch;
				<>O.<1>__UseSignalTranslatorServerRpcPatch = val2;
				obj2 = (object)val2;
			}
			HUDManager.UseSignalTranslatorServerRpc += (Manipulator)obj2;
			object obj3 = <>O.<2>__UseSignalTranslatorClientRpcPatch;
			if (obj3 == null)
			{
				Manipulator val3 = UseSignalTranslatorClientRpcPatch;
				<>O.<2>__UseSignalTranslatorClientRpcPatch = val3;
				obj3 = (object)val3;
			}
			HUDManager.UseSignalTranslatorClientRpc += (Manipulator)obj3;
		}

		private static void ParsePlayerSentencePatch(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction instruction) => ILPatternMatchingExt.MatchCallvirt<HUDManager>(instruction, "UseSignalTranslatorServerRpc")
			});
			val.Index -= 6;
			val.RemoveRange(6);
		}

		private static void UseSignalTranslatorServerRpcPatch(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel val2 = val.DefineLabel();
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction instruction) => ILPatternMatchingExt.MatchLdcI4(instruction, 12)
			});
			val.Index -= 2;
			val.RemoveRange(5);
			val.MarkLabel(val2);
			val.Index -= 2;
			val.Remove();
			val.Emit(OpCodes.Brfalse_S, (object)val2);
		}

		private static void UseSignalTranslatorClientRpcPatch(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0074: 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)
			ILCursor val = new ILCursor(il);
			ILLabel val2 = val.DefineLabel();
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction instruction) => ILPatternMatchingExt.MatchLdcI4(instruction, 10)
			});
			val.Index -= 4;
			val.RemoveRange(8);
			val.MarkLabel(val2);
			val.Index -= 5;
			val.Remove();
			val.Emit(OpCodes.Brfalse_S, (object)val2);
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction instruction) => ILPatternMatchingExt.MatchLdloc(instruction, 1)
			});
			val.Remove();
			val.Emit(OpCodes.Ldarg_1);
		}
	}
}
namespace TheCompanyIsntLethal.Behaviors
{
	public class Ping : MonoBehaviour
	{
		internal static Camera _spectateCamera;

		internal string username;

		internal Vector3 pingPoint;

		internal Animator animator;

		internal Transform _target;

		private RectTransform rectTransform;

		private TextMeshProUGUI headerTMP;

		private TextMeshProUGUI subTMP;

		private Coroutine coroutineToken;

		private Vector3 pingSize = Vector3.one * 0.6f;

		private Vector3 positionOffset = new Vector3(-439.48f, -244.8f, 0f);

		internal static Camera spectateCamera
		{
			get
			{
				if (Object.op_Implicit((Object)(object)_spectateCamera))
				{
					return _spectateCamera;
				}
				GameObject obj = GameObject.Find("SpectateCamera");
				return _spectateCamera = ((obj != null) ? obj.GetComponent<Camera>() : null);
			}
		}

		internal Transform target
		{
			get
			{
				return _target;
			}
			set
			{
				animator.SetInteger("colorNumber", 1);
				_target = value;
			}
		}

		private void Awake()
		{
			//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_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_0049: Unknown result type (might be due to invalid IL or missing references)
			if ((double)((float)Screen.width / (float)Screen.height) > 1.8)
			{
				positionOffset = new Vector3(-1920f, -530f, 530f);
				pingSize = Vector3.one * 1.2f;
			}
			animator = ((Component)this).GetComponent<Animator>();
			rectTransform = ((Component)this).GetComponent<RectTransform>();
			TextMeshProUGUI[] componentsInChildren = ((Component)this).GetComponentsInChildren<TextMeshProUGUI>();
			headerTMP = componentsInChildren[0];
			subTMP = componentsInChildren[1];
		}

		private void Start()
		{
			((TMP_Text)headerTMP).text = username;
			((TMP_Text)headerTMP).fontSize = 18f;
			((TMP_Text)subTMP).fontSize = 12f;
			coroutineToken = ((MonoBehaviour)this).StartCoroutine(DestroyAfterTime(10f));
		}

		private void Update()
		{
			//IL_0013: 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_0018: 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_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_004f: 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_005c: 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_0087: 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_00c0: 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)
			Transform obj = target;
			Vector3 val = ((obj != null) ? obj.position : pingPoint);
			Camera val2 = (GameNetworkManager.Instance.localPlayerController.isPlayerDead ? spectateCamera : GameNetworkManager.Instance.localPlayerController.gameplayCamera);
			Vector3 val3 = val2.WorldToScreenPoint(val);
			((Component)this).transform.localScale = ((val3.z > 0f) ? pingSize : Vector3.zero);
			rectTransform.anchoredPosition3D = new Vector3(val3.x + positionOffset.x, val3.y + positionOffset.y, positionOffset.z);
			((TMP_Text)subTMP).text = $"{Vector3.Distance(((Component)val2).transform.position, val):F0}m";
		}

		private IEnumerator DestroyAfterTime(float time)
		{
			yield return (object)new WaitForSeconds(time);
			Delete();
		}

		internal void Delete()
		{
			if (coroutineToken != null)
			{
				((MonoBehaviour)this).StopCoroutine(coroutineToken);
			}
			coroutineToken = null;
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
}