Decompiled source of CrowdControl LethalCompany v1.1.17

BepInEx/plugins/CrowdControl.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using System.Threading;
using BepInEx;
using BepInEx.Logging;
using BepinControl;
using ControlValley;
using GameNetcodeStuff;
using HarmonyLib;
using Newtonsoft.Json;
using TMPro;
using TerminalApi;
using TerminalApi.Classes;
using TerminalApi.Events;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using Zeekerss.Core.Singletons;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Lethal Company Crowd Control")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Lethal Company Crowd Control")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d4f6b961-e8ae-4e4b-950c-37644e42d4ca")]
[assembly: AssemblyFileVersion("1.1.16")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("1.1.16.0")]
namespace BepinControl
{
	[BepInPlugin("WarpWorld.CrowdControl", "Crowd Control", "1.1.17")]
	public class LethalCompanyControl : BaseUnityPlugin
	{
		[CompilerGenerated]
		private sealed class <TriggerTrapTimer>d__59 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public GameObject trapObj;

			public string type;

			private string <>s__1;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <TriggerTrapTimer>d__59(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>s__1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(6f);
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					string text = type;
					<>s__1 = text;
					switch (<>s__1)
					{
					case "SpikeTrap":
						trapObj.GetComponent<SpikeRoofTrap>().ToggleSpikesEnabled(true);
						break;
					case "Landmine":
						trapObj.GetComponent<Landmine>().ToggleMine(true);
						break;
					case "Turret":
						trapObj.GetComponent<Turret>().ToggleTurretEnabled(true);
						break;
					}
					<>s__1 = null;
					return false;
				}
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <getTermVersions>d__54 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <getTermVersions>d__54(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					version.Clear();
					HUDManager.Instance.AddTextToChatOnServer("<size=0>/cc_vercheck</size>", -1);
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <getVersions>d__53 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			private Dictionary<string, (string name, string conn)>.Enumerator <>s__1;

			private KeyValuePair<string, (string name, string conn)> <versionNum>5__2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <getVersions>d__53(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>s__1 = default(Dictionary<string, (string, string)>.Enumerator);
				<versionNum>5__2 = default(KeyValuePair<string, (string, string)>);
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					version.Clear();
					HUDManager.Instance.AddTextToChatOnServer("<size=0>/cc_vercheck</size>", -1);
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>s__1 = version.GetEnumerator();
					try
					{
						while (<>s__1.MoveNext())
						{
							<versionNum>5__2 = <>s__1.Current;
							mls.LogError((object)$"{<versionNum>5__2.Key} is running LC Crowd Control version {<versionNum>5__2.Value}");
							<versionNum>5__2 = default(KeyValuePair<string, (string, string)>);
						}
					}
					finally
					{
						((IDisposable)<>s__1).Dispose();
					}
					<>s__1 = default(Dictionary<string, (string, string)>.Enumerator);
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private const string modGUID = "WarpWorld.CrowdControl";

		private const string modName = "Crowd Control";

		private const string modVersion = "1.1.17";

		public static string tsVersion = "1.1.17";

		public static Dictionary<string, (string name, string conn)> version = new Dictionary<string, (string, string)>();

		private readonly Harmony harmony = new Harmony("WarpWorld.CrowdControl");

		public static Dictionary<SelectableLevel, List<SpawnableEnemyWithRarity>> levelEnemySpawns;

		public static Dictionary<SpawnableEnemyWithRarity, int> enemyRaritys;

		public static Dictionary<SpawnableEnemyWithRarity, AnimationCurve> enemyPropCurves;

		public static Dictionary<string, GameObject> loadedMapHazards;

		public static List<TerminalAccessibleObject> levelSecDoors;

		public static List<SpikeRoofTrap> levelSpikeTraps;

		private static List<GameObject> spawnedHazards = new List<GameObject>();

		public static ManualLogSource mls;

		public static GameObject SpikeHazardObj;

		public static GameObject TurretObj;

		public static GameObject LandminePrefab;

		public static SelectableLevel currentLevel;

		public static EnemyVent[] currentLevelVents;

		public static RoundManager currentRound;

		public static StartOfRound currentStart;

		private static SpawnableEnemyWithRarity jesterRef;

		public static bool noClipEnabled;

		public static bool enableGod;

		public static bool nightVision;

		public static bool infSprint;

		public static PlayerControllerB playerRef;

		public static bool speedHack;

		public static float nightVisionIntensity;

		public static float oldJetpackRefSpeed;

		public static float nightVisionRange;

		public static Color nightVisionColor;

		private static bool hasGUISynced = false;

		internal static bool isHost = false;

		internal static LethalCompanyControl Instance = null;

		private ControlClient client = null;

		public static bool test = false;

		public static uint msgid = 0u;

		public static uint msgid2 = 0u;

		public static uint msgid3 = 0u;

		public static uint verwait = 0u;

		public static uint floodtime = 0u;

		public static Queue<Action> ActionQueue = new Queue<Action>();

		private void Awake()
		{
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			Instance = this;
			mls = Logger.CreateLogSource("Crowd Control");
			mls.LogInfo((object)"Loaded WarpWorld.CrowdControl. Patching.");
			harmony.PatchAll(typeof(LethalCompanyControl));
			mls.LogInfo((object)"Initializing Crowd Control");
			try
			{
				client = new ControlClient();
				new Thread(client.NetworkLoop).Start();
				new Thread(client.RequestLoop).Start();
			}
			catch (Exception ex)
			{
				mls.LogInfo((object)("CC Init Error: " + ex.ToString()));
			}
			mls.LogInfo((object)"Crowd Control Initialized");
			mls = ((BaseUnityPlugin)this).Logger;
			enemyRaritys = new Dictionary<SpawnableEnemyWithRarity, int>();
			levelEnemySpawns = new Dictionary<SelectableLevel, List<SpawnableEnemyWithRarity>>();
			enemyPropCurves = new Dictionary<SpawnableEnemyWithRarity, AnimationCurve>();
			noClipEnabled = false;
			enableGod = false;
			infSprint = false;
			Events.TerminalBeginUsing += new TerminalEventHandler(OnBeginUsing);
		}

		private void OnBeginUsing(object sender, TerminalEventArgs e)
		{
			HUDManager.Instance.AddTextToChatOnServer("<size=0>/cc_vercheck</size>", -1);
		}

		private static string OnCCVersion()
		{
			string text = "Checking Crowd Control Versions...\n\n";
			foreach (KeyValuePair<string, (string, string)> item in version)
			{
				text = text + item.Key + ": version " + item.Value.Item1 + " Live: " + item.Value.Item2 + "\n";
			}
			return text;
		}

		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPrefix]
		private static void startRound()
		{
			PatchMonsterSpawns();
			currentStart = StartOfRound.Instance;
		}

		[HarmonyPatch(typeof(RoundManager), "Start")]
		[HarmonyPriority(300)]
		[HarmonyPrefix]
		public static void PatchMonsterSpawns()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			EnemyAI[] array = Resources.FindObjectsOfTypeAll<EnemyAI>();
			EnemyAI[] array2 = array;
			foreach (EnemyAI val in array2)
			{
				SpawnableEnemyWithRarity val2 = new SpawnableEnemyWithRarity(val.enemyType, 0);
				val2.enemyType.enemyName = val.enemyType.enemyName;
				val2.enemyType.enemyPrefab = val.enemyType.enemyPrefab;
				((Object)val2.enemyType).name = ((Object)val.enemyType).name;
				mls.LogInfo((object)("Enemy Name: " + ((Object)val.enemyType).name + ", Alternate Name: " + val.enemyType.enemyName));
				if (!RoundManager.Instance.currentLevel.Enemies.Contains(val2))
				{
					if (val2.enemyType.isOutsideEnemy)
					{
						RoundManager.Instance.currentLevel.OutsideEnemies.Add(val2);
					}
					else
					{
						RoundManager.Instance.currentLevel.Enemies.Add(val2);
					}
				}
			}
			mls.LogInfo((object)"Crowd Control has Patched Enemy Spawns.");
		}

		[HarmonyPatch(typeof(RoundManager), "Start")]
		[HarmonyPrefix]
		public static void SetIsHost()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			isHost = ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost;
			verwait = 30u;
			CommandInfo val = new CommandInfo();
			val.Category = "other";
			val.Description = "Checks crowd control version.";
			val.DisplayTextSupplier = OnCCVersion;
			TerminalApi.AddCommand("crowdcontrol", val, (string)null, true);
		}

		[HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
		[HarmonyPrefix]
		private static bool ModifyLevel(ref SelectableLevel newLevel)
		{
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Expected O, but got Unknown
			currentRound = RoundManager.Instance;
			PatchMonsterSpawns();
			if (!levelEnemySpawns.ContainsKey(newLevel))
			{
				List<SpawnableEnemyWithRarity> list = new List<SpawnableEnemyWithRarity>();
				foreach (SpawnableEnemyWithRarity enemy in newLevel.Enemies)
				{
					list.Add(enemy);
				}
				levelEnemySpawns.Add(newLevel, list);
			}
			levelEnemySpawns.TryGetValue(newLevel, out var value);
			newLevel.Enemies = value;
			foreach (SpawnableEnemyWithRarity enemy2 in newLevel.Enemies)
			{
				if (!enemyRaritys.ContainsKey(enemy2))
				{
					enemyRaritys.Add(enemy2, enemy2.rarity);
				}
				int value2 = 0;
				enemyRaritys.TryGetValue(enemy2, out value2);
				enemy2.rarity = value2;
			}
			foreach (SpawnableEnemyWithRarity outsideEnemy in newLevel.OutsideEnemies)
			{
				if (!enemyRaritys.ContainsKey(outsideEnemy))
				{
					enemyRaritys.Add(outsideEnemy, outsideEnemy.rarity);
				}
				int value3 = 0;
				enemyRaritys.TryGetValue(outsideEnemy, out value3);
				outsideEnemy.rarity = value3;
			}
			foreach (SpawnableEnemyWithRarity enemy3 in newLevel.Enemies)
			{
				if (!enemyPropCurves.ContainsKey(enemy3))
				{
					enemyPropCurves.Add(enemy3, enemy3.enemyType.probabilityCurve);
				}
				AnimationCurve value4 = new AnimationCurve();
				enemyPropCurves.TryGetValue(enemy3, out value4);
				enemy3.enemyType.probabilityCurve = value4;
			}
			HUDManager.Instance.AddTextToChatOnServer("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", -1);
			return true;
		}

		[HarmonyPatch(typeof(RoundManager), "DespawnPropsAtEndOfRound")]
		[HarmonyPostfix]
		public static void DespawnAllProps(RoundManager __instance)
		{
			foreach (GameObject spawnedHazard in spawnedHazards)
			{
				if ((Object)(object)spawnedHazard != (Object)null && spawnedHazard.gameObject.GetComponent<NetworkObject>().IsSpawned)
				{
					spawnedHazard.gameObject.GetComponent<NetworkObject>().Despawn(true);
				}
				else
				{
					Object.Destroy((Object)(object)spawnedHazard);
				}
			}
			spawnedHazards.Clear();
		}

		[HarmonyPatch(typeof(RoundManager), "AdvanceHourAndSpawnNewBatchOfEnemies")]
		[HarmonyPrefix]
		private static void updateCurrentLevelInfo(ref EnemyVent[] ___allEnemyVents, ref SelectableLevel ___currentLevel)
		{
			currentLevel = ___currentLevel;
			currentLevelVents = ___allEnemyVents;
		}

		[HarmonyPatch(typeof(RoundManager), "Update")]
		[HarmonyPrefix]
		private static void roundUpdate()
		{
			if (CrowdDelegates.givedelay != 0)
			{
				CrowdDelegates.givedelay--;
			}
			if (verwait != 0)
			{
				verwait--;
			}
			if (ActionQueue.Count > 0)
			{
				Action action = ActionQueue.Dequeue();
				action();
			}
			lock (BuffThread.threads)
			{
				foreach (BuffThread thread in BuffThread.threads)
				{
					if (!thread.paused)
					{
						thread.buff.tick();
					}
				}
			}
		}

		[IteratorStateMachine(typeof(<getVersions>d__53))]
		private static IEnumerator getVersions()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <getVersions>d__53(0);
		}

		[IteratorStateMachine(typeof(<getTermVersions>d__54))]
		private static IEnumerator getTermVersions()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <getTermVersions>d__54(0);
		}

		[HarmonyPatch(typeof(HUDManager), "AddChatMessage")]
		[HarmonyPrefix]
		private static bool CrowdControlCommands(HUDManager __instance, string chatMessage)
		{
			//IL_1e97: Unknown result type (might be due to invalid IL or missing references)
			//IL_1e9d: Invalid comparison between Unknown and I4
			//IL_1f2d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1f3c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1f42: Invalid comparison between Unknown and I4
			//IL_1ebd: Unknown result type (might be due to invalid IL or missing references)
			//IL_1e0c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1e11: Unknown result type (might be due to invalid IL or missing references)
			//IL_1e18: Unknown result type (might be due to invalid IL or missing references)
			//IL_1e21: Unknown result type (might be due to invalid IL or missing references)
			//IL_1e27: Unknown result type (might be due to invalid IL or missing references)
			//IL_1e31: Unknown result type (might be due to invalid IL or missing references)
			//IL_1e36: Unknown result type (might be due to invalid IL or missing references)
			//IL_1e42: Unknown result type (might be due to invalid IL or missing references)
			//IL_1fca: Unknown result type (might be due to invalid IL or missing references)
			//IL_1fcf: Unknown result type (might be due to invalid IL or missing references)
			//IL_1fd9: Unknown result type (might be due to invalid IL or missing references)
			//IL_1fdf: Invalid comparison between Unknown and I4
			//IL_0946: Unknown result type (might be due to invalid IL or missing references)
			//IL_094c: Unknown result type (might be due to invalid IL or missing references)
			//IL_19a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_19b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_19bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_19c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b5c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0eeb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ef7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f01: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f06: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f12: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f1c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f21: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f26: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f2d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f31: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f37: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f3f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f44: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f46: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f48: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f4a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f4f: Unknown result type (might be due to invalid IL or missing references)
			//IL_11fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_1202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f77: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f88: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f65: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f67: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cf5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d01: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d0b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d10: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d1c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d26: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d2b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d30: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d37: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d3b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d41: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d49: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d4e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d50: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d52: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d54: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d59: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c28: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c32: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c3e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c48: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c4d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c5a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c60: Unknown result type (might be due to invalid IL or missing references)
			//IL_159e: Unknown result type (might be due to invalid IL or missing references)
			//IL_15bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_15c4: Expected O, but got Unknown
			//IL_2018: Unknown result type (might be due to invalid IL or missing references)
			//IL_2027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0afb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b07: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b11: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b16: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b22: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b2c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b31: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b36: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b3d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b41: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b47: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b4f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b54: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b56: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b58: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b5a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b5f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d81: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d92: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d6f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d71: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b87: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b98: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b75: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b77: Unknown result type (might be due to invalid IL or missing references)
			//IL_188b: Unknown result type (might be due to invalid IL or missing references)
			//IL_18aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_18b1: Expected O, but got Unknown
			try
			{
				string text = chatMessage;
				if (chatMessage.ToLower() == "/ccversion" && isHost)
				{
					if (verwait == 0)
					{
						((MonoBehaviour)__instance).StartCoroutine(getVersions());
					}
					return false;
				}
				if (!text.StartsWith("<size=0>"))
				{
					return true;
				}
				text = text.Replace("<size=0>", "");
				text = text.Replace("</size>", "");
				if (!text.StartsWith("/cc_"))
				{
					return true;
				}
				text = text.Replace("/cc_", "");
				string[] values = text.Split('_');
				switch (values[0])
				{
				case "version":
					if (!version.ContainsKey(values[1]))
					{
						version.Add(values[1], (values[2], values[3]));
					}
					return false;
				case "vercheck":
					if (verwait != 0)
					{
						return false;
					}
					verwait = 30u;
					playerRef = StartOfRound.Instance.localPlayerController;
					HUDManager.Instance.AddTextToChatOnServer($"<size=0>/cc_version_{playerRef.playerUsername}_{tsVersion}_{ControlClient.connect}</size>", -1);
					return false;
				case "spawn":
					if (!isHost)
					{
						return true;
					}
					ActionQueue.Enqueue(delegate
					{
						foreach (SpawnableEnemyWithRarity outsideEnemy in StartOfRound.Instance.currentLevel.OutsideEnemies)
						{
							if (outsideEnemy.enemyType.enemyName.ToLower().Contains(values[1]))
							{
								try
								{
									SpawnEnemy(outsideEnemy, 1, inside: false);
									return;
								}
								catch (Exception)
								{
									return;
								}
							}
						}
						foreach (SpawnableEnemyWithRarity enemy in StartOfRound.Instance.currentLevel.Enemies)
						{
							if (enemy.enemyType.enemyName.ToLower().Contains(values[1]))
							{
								try
								{
									SpawnEnemy(enemy, 1, inside: false);
									break;
								}
								catch (Exception)
								{
									break;
								}
							}
						}
					});
					break;
				case "cspawn":
				{
					if (!isHost)
					{
						return true;
					}
					int num12 = int.Parse(values[2]);
					PlayerControllerB player = null;
					PlayerControllerB[] allPlayerScripts3 = StartOfRound.Instance.allPlayerScripts;
					foreach (PlayerControllerB val16 in allPlayerScripts3)
					{
						if ((Object)(object)val16 != (Object)null && ((Behaviour)val16).isActiveAndEnabled && !val16.isPlayerDead && (int)val16.playerClientId == num12 && val16.isPlayerControlled)
						{
							player = val16;
						}
					}
					if ((Object)(object)player == (Object)null)
					{
						return true;
					}
					ActionQueue.Enqueue(delegate
					{
						//IL_0255: Unknown result type (might be due to invalid IL or missing references)
						//IL_0265: Unknown result type (might be due to invalid IL or missing references)
						//IL_026f: Unknown result type (might be due to invalid IL or missing references)
						//IL_0274: Unknown result type (might be due to invalid IL or missing references)
						//IL_0104: Unknown result type (might be due to invalid IL or missing references)
						//IL_0109: 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_014f: Unknown result type (might be due to invalid IL or missing references)
						//IL_0159: Unknown result type (might be due to invalid IL or missing references)
						//IL_015e: Unknown result type (might be due to invalid IL or missing references)
						//IL_0163: Unknown result type (might be due to invalid IL or missing references)
						//IL_0168: Unknown result type (might be due to invalid IL or missing references)
						foreach (SpawnableEnemyWithRarity outsideEnemy2 in StartOfRound.Instance.currentLevel.OutsideEnemies)
						{
							if (values[1] == "mimic")
							{
								GameObject val38 = null;
								SelectableLevel[] levels = StartOfRound.Instance.levels;
								foreach (SelectableLevel val39 in levels)
								{
									if ((Object)(object)val38 == (Object)null)
									{
										foreach (SpawnableItemWithRarity item in val39.spawnableScrap)
										{
											if (((Object)item.spawnableItem).name.ToLower() == "tragedymask")
											{
												val38 = item.spawnableItem.spawnPrefab;
											}
										}
									}
								}
								if (!((Object)(object)val38 == (Object)null))
								{
									GameObject val40 = Object.Instantiate<GameObject>(val38, ((Component)player).transform.position, Quaternion.identity, currentStart.propsContainer);
									HauntedMaskItem component4 = val40.GetComponent<HauntedMaskItem>();
									GameObject val41 = Object.Instantiate<GameObject>(component4.mimicEnemy.enemyPrefab, ((Component)player).transform.position + ((Component)player).transform.forward * 5f, Quaternion.Euler(Vector3.zero));
									val41.gameObject.GetComponentInChildren<NetworkObject>().Spawn(true);
									MaskedPlayerEnemy component5 = val41.GetComponent<MaskedPlayerEnemy>();
									component5.mimickingPlayer = player;
									component5.SetSuit(player.currentSuitID);
									((EnemyAI)component5).SetEnemyOutside(!player.isInsideFactory);
									component5.SetVisibilityOfMaskedEnemy();
									component5.SetMaskType(component4.maskTypeId);
									HUDManager.Instance.AddTextToChatOnServer($"<size=0>/cc_mimic_{((NetworkBehaviour)component5).NetworkObject.NetworkObjectId}</size>", -1);
									val41.gameObject.GetComponentInChildren<EnemyAI>().stunNormalizedTimer = 6f;
									Object.Destroy((Object)(object)val40);
								}
								return;
							}
							if (values[1] == "bush")
							{
								Singleton<MoldSpreadManager>.Instance.GenerateMold(((Component)player).transform.position + ((Component)player).transform.forward * 5f, 2);
							}
							if (outsideEnemy2.enemyType.enemyName.ToLower().Contains(values[1]))
							{
								try
								{
									SpawnCrewEnemy(player, outsideEnemy2, 1, inside: false);
									return;
								}
								catch (Exception)
								{
									return;
								}
							}
						}
						foreach (SpawnableEnemyWithRarity enemy2 in StartOfRound.Instance.currentLevel.Enemies)
						{
							if (enemy2.enemyType.enemyName.ToLower().Contains(values[1]))
							{
								try
								{
									SpawnCrewEnemy(player, enemy2, 1, inside: false);
									break;
								}
								catch (Exception)
								{
									break;
								}
							}
						}
					});
					break;
				}
				case "poweron":
					if (!isHost)
					{
						return true;
					}
					RoundManager.Instance.PowerSwitchOnClientRpc();
					break;
				case "poweroff":
					if (!isHost)
					{
						return true;
					}
					RoundManager.Instance.PowerSwitchOffClientRpc();
					break;
				case "addhour":
				{
					if (!isHost)
					{
						return true;
					}
					TimeOfDay instance2 = TimeOfDay.Instance;
					float lengthOfHours2 = instance2.lengthOfHours;
					instance2.globalTime += lengthOfHours2;
					instance2.timeUntilDeadline -= lengthOfHours2;
					CrowdDelegates.callFunc(instance2, "MoveTimeOfDay", null);
					break;
				}
				case "remhour":
				{
					if (!isHost)
					{
						return true;
					}
					TimeOfDay instance = TimeOfDay.Instance;
					float lengthOfHours = instance.lengthOfHours;
					instance.globalTime -= lengthOfHours;
					instance.timeUntilDeadline += lengthOfHours;
					CrowdDelegates.callFunc(instance, "MoveTimeOfDay", null);
					break;
				}
				case "take":
				{
					int num13 = int.Parse(values[1]);
					playerRef = StartOfRound.Instance.localPlayerController;
					if ((int)StartOfRound.Instance.localPlayerController.playerClientId != num13)
					{
						return true;
					}
					playerRef.DespawnHeldObject();
					break;
				}
				case "damage":
				{
					int num15 = int.Parse(values[1]);
					playerRef = StartOfRound.Instance.localPlayerController;
					if ((int)StartOfRound.Instance.localPlayerController.playerClientId != num15)
					{
						return true;
					}
					int num16 = 25;
					if (playerRef.health < 25)
					{
						num16 = playerRef.health - 1;
					}
					playerRef.DamagePlayer(num16, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
					break;
				}
				case "heal":
				{
					int num29 = int.Parse(values[1]);
					playerRef = StartOfRound.Instance.localPlayerController;
					if ((int)StartOfRound.Instance.localPlayerController.playerClientId != num29)
					{
						return true;
					}
					playerRef.health = Mathf.Clamp(playerRef.health + 25, 0, 100);
					if (playerRef.health >= 20)
					{
						playerRef.MakeCriticallyInjured(false);
					}
					HUDManager.Instance.UpdateHealthUI(playerRef.health, true);
					break;
				}
				case "landmine":
				{
					int num32 = int.Parse(values[1]);
					PlayerControllerB val29 = null;
					PlayerControllerB[] allPlayerScripts7 = StartOfRound.Instance.allPlayerScripts;
					foreach (PlayerControllerB val30 in allPlayerScripts7)
					{
						if ((Object)(object)val30 != (Object)null && ((Behaviour)val30).isActiveAndEnabled && !val30.isPlayerDead && (int)val30.playerClientId == num32 && val30.isPlayerControlled)
						{
							val29 = val30;
						}
					}
					if ((Object)(object)val29 == (Object)null)
					{
						return true;
					}
					GameObject val31 = null;
					GameObject[] array4 = Resources.FindObjectsOfTypeAll<GameObject>();
					GameObject[] array5 = array4;
					GameObject[] array6 = array5;
					foreach (GameObject val32 in array6)
					{
						if (((Object)val32).name == "Landmine")
						{
							val31 = val32;
							LandminePrefab = val32;
							break;
						}
					}
					if ((Object)(object)val31 == (Object)null)
					{
						return true;
					}
					Vector3 val33 = ((Component)val29).transform.position + ((Component)val29).transform.forward * 5f - ((Component)val29).transform.up * 0.5f;
					Vector3 navMeshPosition3 = RoundManager.Instance.GetNavMeshPosition(val33, default(NavMeshHit), 5f, -1);
					Vector3 val34 = navMeshPosition3 - val33;
					if (((Vector3)(ref val34)).magnitude < 6f)
					{
						val33 = navMeshPosition3;
					}
					GameObject val35 = GameObject.FindGameObjectWithTag("MapPropsContainer");
					GameObject val36 = Object.Instantiate<GameObject>(val31, val33, Quaternion.Euler(-90f, 0f, 0f), val35.transform);
					val36.gameObject.GetComponentInChildren<NetworkObject>().Spawn(true);
					val36.GetComponent<Landmine>().ToggleMine(false);
					((MonoBehaviour)Instance).StartCoroutine(TriggerTrapTimer(val36, "Landmine"));
					spawnedHazards.Add(val36);
					break;
				}
				case "turret":
				{
					int num22 = int.Parse(values[1]);
					PlayerControllerB val19 = null;
					PlayerControllerB[] allPlayerScripts5 = StartOfRound.Instance.allPlayerScripts;
					foreach (PlayerControllerB val20 in allPlayerScripts5)
					{
						if ((Object)(object)val20 != (Object)null && ((Behaviour)val20).isActiveAndEnabled && !val20.isPlayerDead && (int)val20.playerClientId == num22 && val20.isPlayerControlled)
						{
							val19 = val20;
						}
					}
					if ((Object)(object)val19 == (Object)null)
					{
						return true;
					}
					GameObject val21 = null;
					GameObject[] array2 = Resources.FindObjectsOfTypeAll<GameObject>();
					GameObject[] array3 = array2;
					foreach (GameObject val22 in array3)
					{
						if (((Object)val22).name.ToLower().Contains("turretcont"))
						{
							val21 = val22;
							TurretObj = val22;
							break;
						}
					}
					if ((Object)(object)val21 == (Object)null)
					{
						return true;
					}
					Vector3 val23 = ((Component)val19).transform.position + ((Component)val19).transform.forward * 5f - ((Component)val19).transform.up * 0.5f;
					Vector3 navMeshPosition2 = RoundManager.Instance.GetNavMeshPosition(val23, default(NavMeshHit), 5f, -1);
					Vector3 val24 = navMeshPosition2 - val23;
					if (((Vector3)(ref val24)).magnitude < 6f)
					{
						val23 = navMeshPosition2;
					}
					GameObject val25 = GameObject.FindGameObjectWithTag("MapPropsContainer");
					GameObject val26 = Object.Instantiate<GameObject>(val21, val23, Quaternion.Euler(0f, 0f, 0f), val25.transform);
					val26.gameObject.GetComponentInChildren<NetworkObject>().Spawn(true);
					val26.GetComponent<Turret>().ToggleTurretEnabled(false);
					((MonoBehaviour)Instance).StartCoroutine(TriggerTrapTimer(val26, "Turret"));
					spawnedHazards.Add(val26);
					break;
				}
				case "spiketrap":
				{
					int num11 = int.Parse(values[1]);
					PlayerControllerB val8 = null;
					PlayerControllerB[] allPlayerScripts2 = StartOfRound.Instance.allPlayerScripts;
					foreach (PlayerControllerB val9 in allPlayerScripts2)
					{
						if ((Object)(object)val9 != (Object)null && ((Behaviour)val9).isActiveAndEnabled && !val9.isPlayerDead && (int)val9.playerClientId == num11 && val9.isPlayerControlled)
						{
							val8 = val9;
						}
					}
					if ((Object)(object)val8 == (Object)null)
					{
						return true;
					}
					GameObject val10 = null;
					GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
					foreach (GameObject val11 in array)
					{
						string name = ((Object)val11).name;
						string text3 = name;
						if (text3 == "SpikeRoofTrapHazard")
						{
							val10 = val11;
							SpikeHazardObj = val11;
						}
					}
					if ((Object)(object)val10 == (Object)null)
					{
						return true;
					}
					Vector3 val12 = ((Component)val8).transform.position + ((Component)val8).transform.forward * 5f - ((Component)val8).transform.up * 0.5f;
					Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(val12, default(NavMeshHit), 5f, -1);
					Vector3 val13 = navMeshPosition - val12;
					if (((Vector3)(ref val13)).magnitude < 6f)
					{
						val12 = navMeshPosition;
					}
					GameObject val14 = GameObject.FindGameObjectWithTag("MapPropsContainer");
					GameObject val15 = Object.Instantiate<GameObject>(val10, val12, Quaternion.Euler(0f, 0f, 0f), val14.transform);
					NetworkObject componentInChildren = val15.GetComponentInChildren<NetworkObject>();
					componentInChildren.Spawn(true);
					val15.GetComponent<SpikeRoofTrap>().ToggleSpikesEnabled(false);
					((MonoBehaviour)Instance).StartCoroutine(TriggerTrapTimer(val15, "SpikeTrap"));
					spawnedHazards.Add(val15);
					break;
				}
				case "credits":
				{
					if (!isHost)
					{
						return true;
					}
					int num28 = int.Parse(values[1]);
					Terminal val28 = Object.FindObjectOfType<Terminal>();
					val28.groupCredits += num28;
					val28.SyncGroupCreditsServerRpc(val28.groupCredits, val28.numberOfItemsInDropship);
					if (num28 > 0)
					{
						HUDManager.Instance.DisplayTip("Crowd Control", "Crowd Control gave " + num28 + " credits", false, false, "LC_Tip1");
					}
					else
					{
						HUDManager.Instance.DisplayTip("Crowd Control", "Crowd Control took " + -1 * num28 + " credits", false, false, "LC_Tip1");
					}
					break;
				}
				case "giver":
				{
					if (!isHost)
					{
						return true;
					}
					CrowdDelegates.givedelay = 20u;
					int num7 = int.Parse(values[1]);
					int num8 = int.Parse(values[2]);
					uint num9 = uint.Parse(values[3]);
					if (num9 == msgid2)
					{
						return true;
					}
					msgid2 = num9;
					PlayerControllerB val4 = null;
					if (num8 != -1)
					{
						PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
						foreach (PlayerControllerB val5 in allPlayerScripts)
						{
							if ((Object)(object)val5 != (Object)null && ((Behaviour)val5).isActiveAndEnabled && !val5.isPlayerDead && (int)val5.playerClientId == num8 && val5.isPlayerControlled)
							{
								val4 = val5;
							}
						}
						if ((Object)(object)val4 == (Object)(object)StartOfRound.Instance.localPlayerController)
						{
							num8 = -1;
						}
					}
					else
					{
						val4 = StartOfRound.Instance.localPlayerController;
					}
					if ((Object)(object)val4 == (Object)null)
					{
						val4 = StartOfRound.Instance.localPlayerController;
						num8 = -1;
					}
					Terminal val6 = Object.FindObjectOfType<Terminal>();
					GameObject val7 = Object.Instantiate<GameObject>(StartOfRound.Instance.allItemsList.itemsList[num7].spawnPrefab, ((Component)val4).transform.position, Quaternion.identity, currentStart.propsContainer);
					val7.GetComponent<GrabbableObject>().fallTime = 0f;
					val7.GetComponent<NetworkObject>().Spawn(false);
					CrowdDelegates.msgid++;
					HUDManager.Instance.AddTextToChatOnServer($"<size=0>/cc_give_{num7}_{num8}_{val7.GetComponent<NetworkObject>().NetworkObjectId}_{CrowdDelegates.msgid}</size>", -1);
					break;
				}
				case "mimic":
				{
					ulong key3 = ulong.Parse(values[1]);
					GameObject gameObject3 = ((Component)NetworkManager.Singleton.SpawnManager.SpawnedObjects[key3]).gameObject;
					MaskedPlayerEnemy component3 = gameObject3.GetComponent<MaskedPlayerEnemy>();
					CrowdDelegates.setProperty(component3, "enemyEnabled", true);
					break;
				}
				case "give":
				{
					int num2 = int.Parse(values[1]);
					int num3 = int.Parse(values[2]);
					ulong key = ulong.Parse(values[3]);
					uint num4 = uint.Parse(values[4]);
					if (num4 == msgid3)
					{
						return true;
					}
					msgid3 = num4;
					playerRef = StartOfRound.Instance.localPlayerController;
					if (num3 == -1)
					{
						if (!isHost)
						{
							return true;
						}
					}
					else
					{
						if (isHost)
						{
							return true;
						}
						if ((int)StartOfRound.Instance.localPlayerController.playerClientId != num3)
						{
							return true;
						}
					}
					GameObject gameObject = ((Component)NetworkManager.Singleton.SpawnManager.SpawnedObjects[key]).gameObject;
					GrabbableObject component = gameObject.GetComponent<GrabbableObject>();
					CrowdDelegates.setProperty(playerRef, "currentlyGrabbingObject", component);
					CrowdDelegates.setProperty(playerRef, "grabInvalidated", false);
					NetworkObject networkObject = ((NetworkBehaviour)component).NetworkObject;
					if ((Object)(object)networkObject == (Object)null || !networkObject.IsSpawned)
					{
						return true;
					}
					component.InteractItem();
					playerRef.playerBodyAnimator.SetBool("GrabInvalidated", false);
					playerRef.playerBodyAnimator.SetBool("GrabValidated", false);
					playerRef.playerBodyAnimator.SetBool("cancelHolding", false);
					playerRef.playerBodyAnimator.ResetTrigger("Throw");
					playerRef.playerBodyAnimator.ResetTrigger("SwitchHoldAnimation");
					playerRef.playerBodyAnimator.ResetTrigger("SwitchHoldAnimationTwoHanded");
					CrowdDelegates.callFunc(playerRef, "SetSpecialGrabAnimationBool", new object[2] { true, null });
					playerRef.isGrabbingObjectAnimation = true;
					((Behaviour)playerRef.cursorIcon).enabled = false;
					((TMP_Text)playerRef.cursorTip).text = "";
					playerRef.twoHanded = component.itemProperties.twoHanded;
					PlayerControllerB obj = playerRef;
					obj.carryWeight += Mathf.Clamp(component.itemProperties.weight - 1f, 0f, 10f);
					if (component.itemProperties.grabAnimationTime > 0f)
					{
						playerRef.grabObjectAnimationTime = component.itemProperties.grabAnimationTime;
					}
					else
					{
						playerRef.grabObjectAnimationTime = 0.4f;
					}
					CrowdDelegates.callFunc(playerRef, "GrabObjectServerRpc", (object)new NetworkObjectReference(networkObject));
					Coroutine val2 = (Coroutine)CrowdDelegates.getProperty(playerRef, "grabObjectCoroutine");
					if (val2 != null)
					{
						((MonoBehaviour)playerRef).StopCoroutine(val2);
					}
					CrowdDelegates.setProperty(playerRef, "grabObjectCoroutine", ((MonoBehaviour)playerRef).StartCoroutine("GrabObject"));
					break;
				}
				case "mgive":
				{
					string text2 = values[1];
					int num5 = int.Parse(values[2]);
					ulong key2 = ulong.Parse(values[3]);
					uint num6 = uint.Parse(values[4]);
					if (num6 == msgid3)
					{
						return true;
					}
					msgid3 = num6;
					playerRef = StartOfRound.Instance.localPlayerController;
					if (num5 == -1)
					{
						if (!isHost)
						{
							return true;
						}
					}
					else
					{
						if (isHost)
						{
							return true;
						}
						if ((int)StartOfRound.Instance.localPlayerController.playerClientId != num5)
						{
							return true;
						}
					}
					GameObject gameObject2 = ((Component)NetworkManager.Singleton.SpawnManager.SpawnedObjects[key2]).gameObject;
					GrabbableObject component2 = gameObject2.GetComponent<GrabbableObject>();
					CrowdDelegates.setProperty(playerRef, "currentlyGrabbingObject", component2);
					CrowdDelegates.setProperty(playerRef, "grabInvalidated", false);
					NetworkObject networkObject2 = ((NetworkBehaviour)component2).NetworkObject;
					if ((Object)(object)networkObject2 == (Object)null || !networkObject2.IsSpawned)
					{
						return true;
					}
					component2.InteractItem();
					playerRef.playerBodyAnimator.SetBool("GrabInvalidated", false);
					playerRef.playerBodyAnimator.SetBool("GrabValidated", false);
					playerRef.playerBodyAnimator.SetBool("cancelHolding", false);
					playerRef.playerBodyAnimator.ResetTrigger("Throw");
					CrowdDelegates.callFunc(playerRef, "SetSpecialGrabAnimationBool", new object[2] { true, null });
					playerRef.isGrabbingObjectAnimation = true;
					((Behaviour)playerRef.cursorIcon).enabled = false;
					((TMP_Text)playerRef.cursorTip).text = "";
					playerRef.twoHanded = component2.itemProperties.twoHanded;
					PlayerControllerB obj2 = playerRef;
					obj2.carryWeight += Mathf.Clamp(component2.itemProperties.weight - 1f, 0f, 10f);
					if (component2.itemProperties.grabAnimationTime > 0f)
					{
						playerRef.grabObjectAnimationTime = component2.itemProperties.grabAnimationTime;
					}
					else
					{
						playerRef.grabObjectAnimationTime = 0.4f;
					}
					CrowdDelegates.callFunc(playerRef, "GrabObjectServerRpc", (object)new NetworkObjectReference(networkObject2));
					Coroutine val3 = (Coroutine)CrowdDelegates.getProperty(playerRef, "grabObjectCoroutine");
					if (val3 != null)
					{
						((MonoBehaviour)playerRef).StopCoroutine(val3);
					}
					CrowdDelegates.setProperty(playerRef, "grabObjectCoroutine", ((MonoBehaviour)playerRef).StartCoroutine("GrabObject"));
					break;
				}
				case "ship":
				{
					int num10 = int.Parse(values[1]);
					if ((int)StartOfRound.Instance.localPlayerController.playerClientId == num10)
					{
						StartOfRound.Instance.ForcePlayerIntoShip();
						StartOfRound.Instance.localPlayerController.isInsideFactory = false;
					}
					break;
				}
				case "kill":
				{
					int num35 = int.Parse(values[1]);
					PlayerControllerB[] allPlayerScripts8 = StartOfRound.Instance.allPlayerScripts;
					foreach (PlayerControllerB val37 in allPlayerScripts8)
					{
						if ((Object)(object)val37 != (Object)null && ((Behaviour)val37).isActiveAndEnabled && !val37.isPlayerDead && (int)val37.playerClientId == num35 && val37.isPlayerControlled)
						{
							val37.KillPlayer(((Component)val37).transform.up * 100f, true, (CauseOfDeath)16, 0, default(Vector3), false);
						}
					}
					break;
				}
				case "pitch":
				{
					float num30 = float.Parse(values[1]);
					for (int num31 = 0; num31 < StartOfRound.Instance.allPlayerScripts.Length; num31++)
					{
						try
						{
							SoundManager.Instance.playerVoicePitchTargets[num31] = num30;
							SoundManager.Instance.playerVoicePitches[num31] = num30;
							if ((Object)(object)StartOfRound.Instance.allPlayerScripts[num31] != (Object)null)
							{
								if ((Object)(object)StartOfRound.Instance.allPlayerScripts[num31].currentVoiceChatAudioSource != (Object)null)
								{
									StartOfRound.Instance.allPlayerScripts[num31].currentVoiceChatAudioSource.pitch = num30;
								}
								SoundManager.Instance.SetPlayerPitch(num30, num31);
							}
						}
						catch (Exception ex2)
						{
							mls.LogError((object)ex2.ToString());
						}
					}
					break;
				}
				case "tele":
				{
					int num25 = int.Parse(values[1]);
					int num26 = int.Parse(values[2]);
					if ((int)StartOfRound.Instance.localPlayerController.playerClientId != num25)
					{
						break;
					}
					PlayerControllerB[] allPlayerScripts6 = StartOfRound.Instance.allPlayerScripts;
					foreach (PlayerControllerB val27 in allPlayerScripts6)
					{
						if ((Object)(object)val27 != (Object)null && ((Behaviour)val27).isActiveAndEnabled && !val27.isPlayerDead && (int)val27.playerClientId == num26 && val27.isPlayerControlled)
						{
							StartOfRound.Instance.localPlayerController.TeleportPlayer(((Component)val27).transform.position, false, 0f, false, true);
						}
					}
					break;
				}
				case "body":
				{
					int num20 = int.Parse(values[1]);
					uint num21 = uint.Parse(values[2]);
					if (num21 == msgid)
					{
						return true;
					}
					msgid = num21;
					PlayerControllerB[] allPlayerScripts4 = StartOfRound.Instance.allPlayerScripts;
					foreach (PlayerControllerB val18 in allPlayerScripts4)
					{
						if ((Object)(object)val18 != (Object)null && ((Behaviour)val18).isActiveAndEnabled && !val18.isPlayerDead && (int)val18.actualClientId == num20 && val18.isPlayerControlled)
						{
							val18.SpawnDeadBody((int)val18.actualClientId, ((Component)val18).transform.up * 2f + ((Component)val18).transform.forward * 5f, 0, val18, 0, (Transform)null, (Transform)null, default(Vector3));
						}
					}
					break;
				}
				case "deadline":
				{
					float timeUntilDeadline = float.Parse(values[1]);
					TimeOfDay.Instance.timeUntilDeadline = timeUntilDeadline;
					TimeOfDay.Instance.UpdateProfitQuotaCurrentTime();
					HUDManager.Instance.DisplayDaysLeft((int)Mathf.Floor(TimeOfDay.Instance.timeUntilDeadline / TimeOfDay.Instance.totalTime));
					Object.FindObjectOfType<Terminal>().SetItemSales();
					break;
				}
				case "revive":
					StartOfRound.Instance.ReviveDeadPlayers();
					HUDManager.Instance.HideHUD(false);
					break;
				case "doors":
				{
					int num19 = int.Parse(values[1]);
					HangarShipDoor val17 = Object.FindObjectOfType<HangarShipDoor>();
					val17.PlayDoorAnimation(num19 == 1);
					break;
				}
				case "quota":
				{
					int num17 = int.Parse(values[1]);
					int num18 = int.Parse(values[2]);
					TimeOfDay.Instance.quotaFulfilled = num17;
					TimeOfDay.Instance.profitQuota = num18;
					((TMP_Text)StartOfRound.Instance.profitQuotaMonitorText).text = $"PROFIT QUOTA:\n${num17} / ${num18}";
					break;
				}
				case "inverse":
				{
					int num14 = int.Parse(values[1]);
					if ((int)StartOfRound.Instance.localPlayerController.playerClientId == num14)
					{
						PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
						Random random = new Random(StartOfRound.Instance.randomMapSeed + 17 + (int)GameNetworkManager.Instance.localPlayerController.playerClientId);
						Vector3 position = RoundManager.Instance.insideAINodes[random.Next(0, RoundManager.Instance.insideAINodes.Length)].transform.position;
						Vector3 randomNavMeshPositionInBoxPredictable = RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(position, 10f, default(NavMeshHit), random, -1, 1f);
						StartOfRound.Instance.localPlayerController.TeleportPlayer(randomNavMeshPositionInBoxPredictable, false, 0f, false, true);
						localPlayerController.isInsideFactory = true;
						localPlayerController.isInHangarShipRoom = false;
						localPlayerController.isInElevator = false;
					}
					break;
				}
				case "weather":
				{
					int num = int.Parse(values[1]);
					TimeOfDay.Instance.DisableAllWeather(true);
					if ((int)StartOfRound.Instance.currentLevel.currentWeather >= 0)
					{
						WeatherEffect val = TimeOfDay.Instance.effects[StartOfRound.Instance.currentLevel.currentWeather];
						if (val != null)
						{
							val.effectEnabled = false;
							if ((Object)(object)val.effectPermanentObject != (Object)null)
							{
								val.effectPermanentObject.SetActive(false);
							}
							if ((Object)(object)val.effectObject != (Object)null)
							{
								val.effectObject.SetActive(false);
							}
						}
					}
					StartOfRound.Instance.currentLevel.currentWeather = (LevelWeatherType)num;
					if ((int)StartOfRound.Instance.currentLevel.currentWeather >= 0)
					{
						WeatherEffect val = TimeOfDay.Instance.effects[num];
						if (val != null)
						{
							val.effectEnabled = true;
							if ((Object)(object)val.effectPermanentObject != (Object)null)
							{
								val.effectPermanentObject.SetActive(true);
							}
							if ((Object)(object)val.effectObject != (Object)null)
							{
								val.effectObject.SetActive(true);
							}
						}
					}
					try
					{
						TimeOfDay.Instance.currentLevelWeather = RoundManager.Instance.currentLevel.currentWeather;
						if ((int)TimeOfDay.Instance.currentLevelWeather == -1 || RoundManager.Instance.currentLevel.randomWeathers == null)
						{
							break;
						}
						for (int i = 0; i < RoundManager.Instance.currentLevel.randomWeathers.Length; i++)
						{
							if (RoundManager.Instance.currentLevel.randomWeathers[i].weatherType == RoundManager.Instance.currentLevel.currentWeather)
							{
								TimeOfDay.Instance.currentWeatherVariable = RoundManager.Instance.currentLevel.randomWeathers[i].weatherVariable;
								TimeOfDay.Instance.currentWeatherVariable2 = RoundManager.Instance.currentLevel.randomWeathers[i].weatherVariable2;
							}
						}
					}
					catch (Exception ex)
					{
						mls.LogError((object)ex.ToString());
					}
					break;
				}
				}
			}
			catch (Exception ex3)
			{
				mls.LogError((object)ex3.ToString());
			}
			return false;
		}

		public static void SpawnEnemyWithConfigManager(string enemyName)
		{
			if (!isHost)
			{
				return;
			}
			bool flag = false;
			string text = "";
			foreach (SpawnableEnemyWithRarity enemy in currentLevel.Enemies)
			{
				if (enemy.enemyType.enemyName.ToLower().Contains(enemyName.ToLower()))
				{
					try
					{
						flag = true;
						text = enemy.enemyType.enemyName;
						SpawnEnemy(enemy, 1, inside: true);
					}
					catch
					{
					}
					break;
				}
				SelectableLevel[] levels = currentStart.levels;
				foreach (SelectableLevel val in levels)
				{
					SpawnableEnemyWithRarity val2 = val.Enemies.Find((SpawnableEnemyWithRarity x) => x.enemyType.enemyName.ToLower().Contains(enemyName.ToLower()));
					if (val2 != null)
					{
						try
						{
							flag = true;
							text = val2.enemyType.enemyName;
							SpawnEnemy(val2, 1, inside: true);
						}
						catch
						{
						}
						break;
					}
				}
			}
			if (flag)
			{
				return;
			}
			foreach (SpawnableEnemyWithRarity outsideEnemy in currentLevel.OutsideEnemies)
			{
				mls.LogInfo((object)("outside enemy: " + outsideEnemy.enemyType.enemyName));
				if (outsideEnemy.enemyType.enemyName.ToLower().Contains(enemyName.ToLower()))
				{
					try
					{
						flag = true;
						text = outsideEnemy.enemyType.enemyName;
						SpawnEnemy(outsideEnemy, 1, inside: false);
						break;
					}
					catch (Exception ex)
					{
						mls.LogInfo((object)("The game tossed an error: " + ex.Message));
						break;
					}
				}
				SelectableLevel[] levels2 = currentStart.levels;
				foreach (SelectableLevel val3 in levels2)
				{
					SpawnableEnemyWithRarity val4 = val3.OutsideEnemies.Find((SpawnableEnemyWithRarity x) => x.enemyType.enemyName.ToLower().Contains(enemyName.ToLower()));
					if (val4 != null)
					{
						try
						{
							flag = true;
							text = val4.enemyType.enemyName;
							SpawnEnemy(val4, 1, inside: false);
						}
						catch
						{
						}
					}
				}
			}
		}

		public static void SpawnEnemy(SpawnableEnemyWithRarity enemy, int amount, bool inside)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
			GameObject val = Object.Instantiate<GameObject>(enemy.enemyType.enemyPrefab, ((Component)localPlayerController).transform.position + ((Component)localPlayerController).transform.forward * 5f, Quaternion.Euler(Vector3.zero));
			val.gameObject.GetComponentInChildren<NetworkObject>().Spawn(true);
			val.gameObject.GetComponentInChildren<EnemyAI>().SetEnemyStunned(true, 6f, (PlayerControllerB)null);
		}

		public static void SpawnCrewEnemy(PlayerControllerB player, SpawnableEnemyWithRarity enemy, int amount, bool inside)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(enemy.enemyType.enemyPrefab, ((Component)player).transform.position + ((Component)player).transform.forward * 5f, Quaternion.Euler(Vector3.zero));
			val.gameObject.GetComponentInChildren<NetworkObject>().Spawn(true);
			val.gameObject.GetComponentInChildren<EnemyAI>().SetEnemyStunned(true, 6f, (PlayerControllerB)null);
		}

		[IteratorStateMachine(typeof(<TriggerTrapTimer>d__59))]
		public static IEnumerator TriggerTrapTimer(GameObject trapObj, string type)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <TriggerTrapTimer>d__59(0)
			{
				trapObj = trapObj,
				type = type
			};
		}
	}
}
namespace BepinControl.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	public class PlayerControllerBPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		private static void getNightVision(ref PlayerControllerB __instance)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			LethalCompanyControl.playerRef = __instance;
			LethalCompanyControl.nightVision = ((Behaviour)LethalCompanyControl.playerRef.nightVision).enabled;
			LethalCompanyControl.nightVisionIntensity = LethalCompanyControl.playerRef.nightVision.intensity;
			LethalCompanyControl.nightVisionColor = LethalCompanyControl.playerRef.nightVision.color;
			LethalCompanyControl.nightVisionRange = LethalCompanyControl.playerRef.nightVision.range;
			LethalCompanyControl.playerRef.nightVision.color = Color.green;
			LethalCompanyControl.playerRef.nightVision.intensity = 1000f;
			LethalCompanyControl.playerRef.nightVision.range = 10000f;
		}

		[HarmonyPatch("SetNightVisionEnabled")]
		[HarmonyPostfix]
		private static void updateNightVision()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (LethalCompanyControl.nightVision)
			{
				LethalCompanyControl.playerRef.nightVision.color = Color.green;
				LethalCompanyControl.playerRef.nightVision.intensity = 1000f;
				LethalCompanyControl.playerRef.nightVision.range = 10000f;
			}
			else
			{
				LethalCompanyControl.playerRef.nightVision.color = LethalCompanyControl.nightVisionColor;
				LethalCompanyControl.playerRef.nightVision.intensity = LethalCompanyControl.nightVisionIntensity;
				LethalCompanyControl.playerRef.nightVision.range = LethalCompanyControl.nightVisionRange;
			}
			((Behaviour)LethalCompanyControl.playerRef.nightVision).enabled = true;
		}

		[HarmonyPatch("AllowPlayerDeath")]
		[HarmonyPrefix]
		private static bool OverrideDeath()
		{
			if (!LethalCompanyControl.isHost)
			{
				return true;
			}
			return !LethalCompanyControl.enableGod;
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void InfiniteSprint(ref float ___sprintMeter)
		{
			if (LethalCompanyControl.infSprint && LethalCompanyControl.isHost)
			{
				Mathf.Clamp(___sprintMeter += 0.02f, 0f, 1f);
			}
		}
	}
}
namespace ControlValley
{
	public enum BuffType
	{
		HYPER_MOVE,
		FAST_MOVE,
		SLOW_MOVE,
		FREEZE,
		ULTRA_JUMP,
		HIGH_JUMP,
		LOW_JUMP,
		OHKO,
		INVUL,
		NOSTAM,
		INFSTAM,
		NIGHT_VISION,
		HIGH_PITCH,
		LOW_PITCH,
		DRUNK,
		FASTJETPACK,
		SLOWJETPACK
	}
	public class Buff
	{
		public BuffType type;

		private float old;

		private static int frames;

		public Buff(BuffType t)
		{
			type = t;
			BuffType buffType = type;
			BuffType buffType2 = buffType;
			if ((uint)(buffType2 - 7) <= 1u)
			{
				PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
				old = localPlayerController.health;
			}
		}

		public void addBuff(int duration)
		{
			switch (type)
			{
			case BuffType.DRUNK:
			{
				PlayerControllerB localPlayerController10 = StartOfRound.Instance.localPlayerController;
				float drunkness = Math.Min((float)duration * 10f, 1200f);
				localPlayerController10.drunkness = drunkness;
				localPlayerController10.drunknessSpeed = 1f;
				localPlayerController10.drunknessInertia = 20f;
				break;
			}
			case BuffType.LOW_PITCH:
				LethalCompanyControl.ActionQueue.Enqueue(delegate
				{
					HUDManager.Instance.AddTextToChatOnServer("<size=0>/cc_pitch_0.65</size>", -1);
				});
				break;
			case BuffType.HIGH_PITCH:
				LethalCompanyControl.ActionQueue.Enqueue(delegate
				{
					HUDManager.Instance.AddTextToChatOnServer("<size=0>/cc_pitch_1.5</size>", -1);
				});
				break;
			case BuffType.NIGHT_VISION:
			{
				PlayerControllerB localPlayerController9 = StartOfRound.Instance.localPlayerController;
				LethalCompanyControl.nightVision = true;
				break;
			}
			case BuffType.FREEZE:
			{
				PlayerControllerB localPlayerController8 = StartOfRound.Instance.localPlayerController;
				localPlayerController8.movementSpeed = 0f;
				break;
			}
			case BuffType.HYPER_MOVE:
			{
				PlayerControllerB localPlayerController7 = StartOfRound.Instance.localPlayerController;
				localPlayerController7.movementSpeed = 18f;
				break;
			}
			case BuffType.FAST_MOVE:
			{
				PlayerControllerB localPlayerController6 = StartOfRound.Instance.localPlayerController;
				localPlayerController6.movementSpeed = 9f;
				break;
			}
			case BuffType.SLOW_MOVE:
			{
				PlayerControllerB localPlayerController5 = StartOfRound.Instance.localPlayerController;
				localPlayerController5.movementSpeed = 1.25f;
				break;
			}
			case BuffType.ULTRA_JUMP:
			{
				PlayerControllerB localPlayerController4 = StartOfRound.Instance.localPlayerController;
				localPlayerController4.jumpForce = 50f;
				break;
			}
			case BuffType.HIGH_JUMP:
			{
				PlayerControllerB localPlayerController3 = StartOfRound.Instance.localPlayerController;
				localPlayerController3.jumpForce = 35f;
				break;
			}
			case BuffType.LOW_JUMP:
			{
				PlayerControllerB localPlayerController2 = StartOfRound.Instance.localPlayerController;
				localPlayerController2.jumpForce = 5f;
				break;
			}
			case BuffType.FASTJETPACK:
			{
				PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
				JetpackItem[] array = Object.FindObjectsByType<JetpackItem>((FindObjectsSortMode)0);
				foreach (JetpackItem val in array)
				{
					if ((Object)(object)val != (Object)null && (Object)(object)((GrabbableObject)val).playerHeldBy == (Object)(object)localPlayerController)
					{
						LethalCompanyControl.oldJetpackRefSpeed = val.jetpackAcceleration;
						val.jetpackAcceleration *= 3f;
					}
				}
				break;
			}
			case BuffType.OHKO:
			case BuffType.INVUL:
			case BuffType.NOSTAM:
			case BuffType.INFSTAM:
				break;
			}
		}

		public void removeBuff()
		{
			switch (type)
			{
			case BuffType.DRUNK:
			{
				PlayerControllerB localPlayerController2 = StartOfRound.Instance.localPlayerController;
				localPlayerController2.drunkness = 0f;
				localPlayerController2.drunknessSpeed = 0f;
				localPlayerController2.drunknessInertia = 0f;
				break;
			}
			case BuffType.HIGH_PITCH:
			case BuffType.LOW_PITCH:
				LethalCompanyControl.ActionQueue.Enqueue(delegate
				{
					HUDManager.Instance.AddTextToChatOnServer("<size=0>/cc_pitch_1.0</size>", -1);
				});
				break;
			case BuffType.NIGHT_VISION:
			{
				PlayerControllerB localPlayerController5 = StartOfRound.Instance.localPlayerController;
				LethalCompanyControl.nightVision = false;
				break;
			}
			case BuffType.HYPER_MOVE:
			case BuffType.FAST_MOVE:
			case BuffType.SLOW_MOVE:
			case BuffType.FREEZE:
			{
				PlayerControllerB localPlayerController4 = StartOfRound.Instance.localPlayerController;
				localPlayerController4.movementSpeed = 4.6f;
				break;
			}
			case BuffType.ULTRA_JUMP:
			case BuffType.HIGH_JUMP:
			case BuffType.LOW_JUMP:
			{
				PlayerControllerB localPlayerController3 = StartOfRound.Instance.localPlayerController;
				localPlayerController3.jumpForce = 13f;
				break;
			}
			case BuffType.FASTJETPACK:
			{
				PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
				JetpackItem[] array = Object.FindObjectsByType<JetpackItem>((FindObjectsSortMode)0);
				foreach (JetpackItem val in array)
				{
					if ((Object)(object)val != (Object)null && (Object)(object)((GrabbableObject)val).playerHeldBy == (Object)(object)localPlayerController)
					{
						val.jetpackAcceleration = LethalCompanyControl.oldJetpackRefSpeed;
					}
				}
				break;
			}
			case BuffType.OHKO:
			case BuffType.INVUL:
				LethalCompanyControl.ActionQueue.Enqueue(delegate
				{
					PlayerControllerB localPlayerController6 = StartOfRound.Instance.localPlayerController;
					localPlayerController6.health = (int)old;
					if (localPlayerController6.health >= 20)
					{
						localPlayerController6.MakeCriticallyInjured(false);
					}
					if (localPlayerController6.health < 10)
					{
						localPlayerController6.MakeCriticallyInjured(true);
					}
					HUDManager.Instance.UpdateHealthUI(localPlayerController6.health, true);
				});
				break;
			case BuffType.NOSTAM:
			case BuffType.INFSTAM:
				break;
			}
		}

		public void tick()
		{
			frames++;
			PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
			switch (type)
			{
			case BuffType.HIGH_PITCH:
				if (frames % 16 == 0)
				{
					HUDManager.Instance.AddTextToChatOnServer("<size=0>/cc_pitch_1.5</size>", -1);
				}
				break;
			case BuffType.LOW_PITCH:
				if (frames % 16 == 0)
				{
					HUDManager.Instance.AddTextToChatOnServer("<size=0>/cc_pitch_0.65</size>", -1);
				}
				break;
			case BuffType.OHKO:
				if (localPlayerController.health > 1)
				{
					localPlayerController.health = 1;
				}
				if (localPlayerController.health >= 20)
				{
					localPlayerController.MakeCriticallyInjured(false);
				}
				if (localPlayerController.health < 10)
				{
					localPlayerController.MakeCriticallyInjured(true);
				}
				HUDManager.Instance.UpdateHealthUI(localPlayerController.health, true);
				break;
			case BuffType.INVUL:
				if (localPlayerController.health > 0)
				{
					localPlayerController.health = 100;
				}
				if (localPlayerController.health >= 20)
				{
					localPlayerController.MakeCriticallyInjured(false);
				}
				if (localPlayerController.health < 10)
				{
					localPlayerController.MakeCriticallyInjured(true);
				}
				HUDManager.Instance.UpdateHealthUI(localPlayerController.health, true);
				break;
			case BuffType.INFSTAM:
				localPlayerController.sprintMeter = 1f;
				localPlayerController.isExhausted = false;
				break;
			case BuffType.NOSTAM:
				localPlayerController.sprintMeter = 0f;
				localPlayerController.isExhausted = true;
				break;
			case BuffType.NIGHT_VISION:
				break;
			}
		}
	}
	public class BuffThread
	{
		public static List<BuffThread> threads = new List<BuffThread>();

		public readonly Buff buff;

		public int duration;

		public int remain;

		public int id;

		public bool paused;

		public static bool isRunning(BuffType t)
		{
			foreach (BuffThread thread in threads)
			{
				if (thread.buff.type == t)
				{
					return true;
				}
			}
			return false;
		}

		public static void tick()
		{
			foreach (BuffThread thread in threads)
			{
				if (!thread.paused)
				{
					thread.buff.tick();
				}
			}
		}

		public static void addTime(int duration)
		{
			try
			{
				lock (threads)
				{
					foreach (BuffThread thread in threads)
					{
						Interlocked.Add(ref thread.duration, duration + 5);
						if (!thread.paused)
						{
							int dur = Volatile.Read(ref thread.remain);
							new TimedResponse(thread.id, dur, CrowdResponse.Status.STATUS_PAUSE).Send(ControlClient.Socket);
							thread.paused = true;
						}
					}
				}
			}
			catch (Exception ex)
			{
				LethalCompanyControl.mls.LogInfo((object)ex.ToString());
			}
		}

		public static void tickTime(int duration)
		{
			try
			{
				lock (threads)
				{
					foreach (BuffThread thread in threads)
					{
						int num = Volatile.Read(ref thread.remain);
						num -= duration;
						if (num < 0)
						{
							num = 0;
						}
						Volatile.Write(ref thread.remain, num);
					}
				}
			}
			catch (Exception ex)
			{
				LethalCompanyControl.mls.LogInfo((object)ex.ToString());
			}
		}

		public static void unPause()
		{
			try
			{
				lock (threads)
				{
					foreach (BuffThread thread in threads)
					{
						if (thread.paused)
						{
							int dur = Volatile.Read(ref thread.remain);
							new TimedResponse(thread.id, dur, CrowdResponse.Status.STATUS_RESUME).Send(ControlClient.Socket);
							thread.paused = false;
						}
					}
				}
			}
			catch (Exception ex)
			{
				LethalCompanyControl.mls.LogInfo((object)ex.ToString());
			}
		}

		public BuffThread(int id, BuffType buff, int duration)
		{
			this.buff = new Buff(buff);
			this.duration = duration;
			remain = duration;
			this.id = id;
			paused = false;
			try
			{
				lock (threads)
				{
					threads.Add(this);
				}
			}
			catch (Exception ex)
			{
				LethalCompanyControl.mls.LogInfo((object)ex.ToString());
			}
		}

		public void Run()
		{
			Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
			buff.addBuff(duration);
			try
			{
				for (int num = Volatile.Read(ref duration); num > 0; num = Volatile.Read(ref duration))
				{
					Interlocked.Add(ref duration, -num);
					Thread.Sleep(num);
				}
				buff.removeBuff();
				lock (threads)
				{
					threads.Remove(this);
				}
				new TimedResponse(id, 0, CrowdResponse.Status.STATUS_STOP).Send(ControlClient.Socket);
			}
			catch (Exception ex)
			{
				LethalCompanyControl.mls.LogInfo((object)ex.ToString());
			}
		}
	}
	public class ControlClient
	{
		public static readonly string CV_HOST = "127.0.0.1";

		public static readonly int CV_PORT = 51338;

		private bool paused = false;

		public bool inGame = true;

		public static bool connect = false;

		private Dictionary<string, CrowdDelegate> Delegate { get; set; }

		private IPEndPoint Endpoint { get; set; }

		private Queue<CrowdRequest> Requests { get; set; }

		private bool Running { get; set; }

		private bool Saving { get; set; }

		private bool Spawn { get; set; }

		public static Socket Socket { get; set; }

		public ControlClient()
		{
			Endpoint = new IPEndPoint(IPAddress.Parse(CV_HOST), CV_PORT);
			Requests = new Queue<CrowdRequest>();
			Running = true;
			Saving = false;
			Spawn = true;
			Socket = null;
			connect = false;
			Delegate = new Dictionary<string, CrowdDelegate>
			{
				{
					"heal_full",
					CrowdDelegates.HealFull
				},
				{
					"kill",
					CrowdDelegates.Kill
				},
				{
					"killcrew",
					CrowdDelegates.KillCrewmate
				},
				{
					"damage",
					CrowdDelegates.Damage
				},
				{
					"damagecrew",
					CrowdDelegates.DamageCrew
				},
				{
					"heal",
					CrowdDelegates.Heal
				},
				{
					"healcrew",
					CrowdDelegates.HealCrew
				},
				{
					"fast",
					CrowdDelegates.FastMove
				},
				{
					"slow",
					CrowdDelegates.SlowMove
				},
				{
					"hyper",
					CrowdDelegates.HyperMove
				},
				{
					"freeze",
					CrowdDelegates.Freeze
				},
				{
					"drunk",
					CrowdDelegates.Drunk
				},
				{
					"fastjetpack",
					CrowdDelegates.FastJetpack
				},
				{
					"jumpultra",
					CrowdDelegates.UltraJump
				},
				{
					"jumphigh",
					CrowdDelegates.HighJump
				},
				{
					"jumplow",
					CrowdDelegates.LowJump
				},
				{
					"ohko",
					CrowdDelegates.OHKO
				},
				{
					"invul",
					CrowdDelegates.Invul
				},
				{
					"drain",
					CrowdDelegates.DrainStamins
				},
				{
					"restore",
					CrowdDelegates.RestoreStamins
				},
				{
					"infstam",
					CrowdDelegates.InfiniteStamina
				},
				{
					"nostam",
					CrowdDelegates.NoStamina
				},
				{
					"spawn_pede",
					CrowdDelegates.Spawn
				},
				{
					"spawn_spider",
					CrowdDelegates.Spawn
				},
				{
					"spawn_hoard",
					CrowdDelegates.Spawn
				},
				{
					"spawn_flower",
					CrowdDelegates.Spawn
				},
				{
					"spawn_crawl",
					CrowdDelegates.Spawn
				},
				{
					"spawn_blob",
					CrowdDelegates.Spawn
				},
				{
					"spawn_spring",
					CrowdDelegates.Spawn
				},
				{
					"spawn_puff",
					CrowdDelegates.Spawn
				},
				{
					"spawn_dog",
					CrowdDelegates.Spawn
				},
				{
					"spawn_giant",
					CrowdDelegates.Spawn
				},
				{
					"spawn_levi",
					CrowdDelegates.Spawn
				},
				{
					"spawn_hawk",
					CrowdDelegates.Spawn
				},
				{
					"spawn_girl",
					CrowdDelegates.Spawn
				},
				{
					"spawn_mimic",
					CrowdDelegates.Spawn
				},
				{
					"spawn_cracker",
					CrowdDelegates.Spawn
				},
				{
					"spawn_landmine",
					CrowdDelegates.Spawn
				},
				{
					"spawn_turret",
					CrowdDelegates.Spawn
				},
				{
					"spawn_spiketrap",
					CrowdDelegates.Spawn
				},
				{
					"webs",
					CrowdDelegates.CreateWebs
				},
				{
					"killenemies",
					CrowdDelegates.KillEnemies
				},
				{
					"spawn_radmech",
					CrowdDelegates.Spawn
				},
				{
					"spawn_clay",
					CrowdDelegates.Spawn
				},
				{
					"spawn_butler",
					CrowdDelegates.Spawn
				},
				{
					"spawn_jester",
					CrowdDelegates.Spawn
				},
				{
					"spawn_eater",
					CrowdDelegates.Spawn
				},
				{
					"spawn_snake",
					CrowdDelegates.Spawn
				},
				{
					"spawn_kiwi",
					CrowdDelegates.Spawn
				},
				{
					"spawn_growths",
					CrowdDelegates.Spawn
				},
				{
					"spawn_bloom",
					CrowdDelegates.Spawn
				},
				{
					"spawn_pum",
					CrowdDelegates.Spawn
				},
				{
					"spawn_bush",
					CrowdDelegates.Spawn
				},
				{
					"spawn_ray",
					CrowdDelegates.Spawn
				},
				{
					"cspawn_pede",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_spider",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_hoard",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_flower",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_crawl",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_blob",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_spring",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_puff",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_dog",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_giant",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_levi",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_hawk",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_girl",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_cracker",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_mimic",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_landmine",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_turret",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_spiketrap",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_radmech",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_butler",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_clay",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_jester",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_eater",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_snake",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_kiwi",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_growths",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_bloom",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_pum",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_bush",
					CrowdDelegates.CrewSpawn
				},
				{
					"cspawn_ray",
					CrowdDelegates.CrewSpawn
				},
				{
					"give_binoculars",
					CrowdDelegates.GiveItem
				},
				{
					"give_boombox",
					CrowdDelegates.GiveItem
				},
				{
					"give_flashlight",
					CrowdDelegates.GiveItem
				},
				{
					"give_jetpack",
					CrowdDelegates.GiveItem
				},
				{
					"give_key",
					CrowdDelegates.GiveItem
				},
				{
					"give_lockpicker",
					CrowdDelegates.GiveItem
				},
				{
					"give_lungapparatus",
					CrowdDelegates.GiveItem
				},
				{
					"give_mapdevice",
					CrowdDelegates.GiveItem
				},
				{
					"give_proflashlight",
					CrowdDelegates.GiveItem
				},
				{
					"give_shovel",
					CrowdDelegates.GiveItem
				},
				{
					"give_stungrenade",
					CrowdDelegates.GiveItem
				},
				{
					"give_extensionladder",
					CrowdDelegates.GiveItem
				},
				{
					"give_tzpinhalant",
					CrowdDelegates.GiveItem
				},
				{
					"give_walkietalkie",
					CrowdDelegates.GiveItem
				},
				{
					"give_zapgun",
					CrowdDelegates.GiveItem
				},
				{
					"give_7ball",
					CrowdDelegates.GiveItem
				},
				{
					"give_airhorn",
					CrowdDelegates.GiveItem
				},
				{
					"give_bottlebin",
					CrowdDelegates.GiveItem
				},
				{
					"give_clownhorn",
					CrowdDelegates.GiveItem
				},
				{
					"give_goldbar",
					CrowdDelegates.GiveItem
				},
				{
					"give_stopsign",
					CrowdDelegates.GiveItem
				},
				{
					"give_radarbooster",
					CrowdDelegates.GiveItem
				},
				{
					"give_yieldsign",
					CrowdDelegates.GiveItem
				},
				{
					"give_shotgun",
					CrowdDelegates.GiveItem
				},
				{
					"give_gunAmmo",
					CrowdDelegates.GiveItem
				},
				{
					"give_spraypaint",
					CrowdDelegates.GiveItem
				},
				{
					"give_giftbox",
					CrowdDelegates.GiveItem
				},
				{
					"give_tragedymask",
					CrowdDelegates.GiveItem
				},
				{
					"give_comedymask",
					CrowdDelegates.GiveItem
				},
				{
					"give_knife",
					CrowdDelegates.GiveItem
				},
				{
					"give_easteregg",
					CrowdDelegates.GiveItem
				},
				{
					"give_weedkiller",
					CrowdDelegates.GiveItem
				},
				{
					"cgive_binoculars",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_boombox",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_flashlight",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_jetpack",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_key",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_lockpicker",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_lungapparatus",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_mapdevice",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_proflashlight",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_shovel",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_stungrenade",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_extensionladder",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_tzpinhalant",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_walkietalkie",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_zapgun",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_7ball",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_airhorn",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_bottlebin",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_clownhorn",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_goldbar",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_stopsign",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_radarbooster",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_yieldsign",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_shotgun",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_gunAmmo",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_spraypaint",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_giftbox",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_tragedymask",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_comedymask",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_knife",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_easteregg",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_weedkiller",
					CrowdDelegates.GiveCrewItem
				},
				{
					"weather_-1",
					CrowdDelegates.Weather
				},
				{
					"weather_1",
					CrowdDelegates.Weather
				},
				{
					"weather_2",
					CrowdDelegates.Weather
				},
				{
					"weather_3",
					CrowdDelegates.Weather
				},
				{
					"weather_4",
					CrowdDelegates.Weather
				},
				{
					"weather_5",
					CrowdDelegates.Weather
				},
				{
					"weather_6",
					CrowdDelegates.Weather
				},
				{
					"lightning",
					CrowdDelegates.Lightning
				},
				{
					"takeitem",
					CrowdDelegates.TakeItem
				},
				{
					"dropitem",
					CrowdDelegates.DropItem
				},
				{
					"takecrewitem",
					CrowdDelegates.TakeCrewItem
				},
				{
					"buy_walkie",
					CrowdDelegates.BuyItem
				},
				{
					"buy_flashlight",
					CrowdDelegates.BuyItem
				},
				{
					"buy_shovel",
					CrowdDelegates.BuyItem
				},
				{
					"buy_lockpicker",
					CrowdDelegates.BuyItem
				},
				{
					"buy_proflashlight",
					CrowdDelegates.BuyItem
				},
				{
					"buy_stungrenade",
					CrowdDelegates.BuyItem
				},
				{
					"buy_boombox",
					CrowdDelegates.BuyItem
				},
				{
					"buy_inhaler",
					CrowdDelegates.BuyItem
				},
				{
					"buy_stungun",
					CrowdDelegates.BuyItem
				},
				{
					"buy_jetpack",
					CrowdDelegates.BuyItem
				},
				{
					"buy_extensionladder",
					CrowdDelegates.BuyItem
				},
				{
					"buy_radarbooster",
					CrowdDelegates.BuyItem
				},
				{
					"buy_spraypaint",
					CrowdDelegates.BuyItem
				},
				{
					"buy_weedkiller",
					CrowdDelegates.BuyItem
				},
				{
					"buy_cruiser",
					CrowdDelegates.BuyCruiser
				},
				{
					"turn_off_engine",
					CrowdDelegates.TurnOffEngine
				},
				{
					"destroy_vehicle",
					CrowdDelegates.DestroyVehicle
				},
				{
					"start_vehicle",
					CrowdDelegates.TurnOnVehicle
				},
				{
					"spring_chair",
					CrowdDelegates.SpringChair
				},
				{
					"charge",
					CrowdDelegates.ChargeItem
				},
				{
					"uncharge",
					CrowdDelegates.UnchargeItem
				},
				{
					"breakerson",
					CrowdDelegates.BreakersOn
				},
				{
					"breakersoff",
					CrowdDelegates.BreakersOff
				},
				{
					"toship",
					CrowdDelegates.TeleportToShip
				},
				{
					"crewship",
					CrowdDelegates.TeleportCrewToShip
				},
				{
					"body",
					CrowdDelegates.SpawnBody
				},
				{
					"crewbody",
					CrowdDelegates.SpawnCrewBody
				},
				{
					"nightvision",
					CrowdDelegates.NightVision
				},
				{
					"revive",
					CrowdDelegates.Revive
				},
				{
					"tocrew",
					CrowdDelegates.TeleportToCrew
				},
				{
					"crewto",
					CrowdDelegates.TeleportCrewTo
				},
				{
					"screech",
					CrowdDelegates.Screech
				},
				{
					"footstep",
					CrowdDelegates.Footstep
				},
				{
					"breathing",
					CrowdDelegates.Breathing
				},
				{
					"ghost",
					CrowdDelegates.Ghost
				},
				{
					"horn",
					CrowdDelegates.PlayHorn
				},
				{
					"blob",
					CrowdDelegates.BlobSound
				},
				{
					"highpitch",
					CrowdDelegates.HighPitch
				},
				{
					"lowpitch",
					CrowdDelegates.LowPitch
				},
				{
					"addhour",
					CrowdDelegates.AddHour
				},
				{
					"remhour",
					CrowdDelegates.RemoveHour
				},
				{
					"addday",
					CrowdDelegates.AddDay
				},
				{
					"remday",
					CrowdDelegates.RemoveDay
				},
				{
					"givecred_5",
					CrowdDelegates.AddCredits
				},
				{
					"givecred_50",
					CrowdDelegates.AddCredits
				},
				{
					"givecred_500",
					CrowdDelegates.AddCredits
				},
				{
					"givecred_-5",
					CrowdDelegates.AddCredits
				},
				{
					"givecred_-50",
					CrowdDelegates.AddCredits
				},
				{
					"givecred_-500",
					CrowdDelegates.AddCredits
				},
				{
					"givequota_5",
					CrowdDelegates.AddQuota
				},
				{
					"givequota_50",
					CrowdDelegates.AddQuota
				},
				{
					"givequota_500",
					CrowdDelegates.AddQuota
				},
				{
					"givequota_-5",
					CrowdDelegates.AddQuota
				},
				{
					"givequota_-50",
					CrowdDelegates.AddQuota
				},
				{
					"givequota_-500",
					CrowdDelegates.AddQuota
				},
				{
					"giveprofit_25",
					CrowdDelegates.AddProfit
				},
				{
					"giveprofit_50",
					CrowdDelegates.AddProfit
				},
				{
					"giveprofit_100",
					CrowdDelegates.AddProfit
				},
				{
					"giveprofit_-25",
					CrowdDelegates.AddProfit
				},
				{
					"giveprofit_-50",
					CrowdDelegates.AddProfit
				},
				{
					"giveprofit_-100",
					CrowdDelegates.AddProfit
				},
				{
					"addscrap",
					CrowdDelegates.AddScrap
				},
				{
					"shipleave",
					CrowdDelegates.ShipLeave
				},
				{
					"opendoors",
					CrowdDelegates.OpenDoors
				},
				{
					"closedoors",
					CrowdDelegates.CloseDoors
				},
				{
					"inverse",
					CrowdDelegates.InverseTeleport
				},
				{
					"cinverse",
					CrowdDelegates.InverseTeleportCrew
				}
			};
		}

		public static void HideEffect(string code)
		{
			CrowdResponse crowdResponse = new CrowdResponse(0, CrowdResponse.Status.STATUS_NOTVISIBLE);
			crowdResponse.type = 1;
			crowdResponse.code = code;
			crowdResponse.Send(Socket);
		}

		public static void ShowEffect(string code)
		{
			CrowdResponse crowdResponse = new CrowdResponse(0, CrowdResponse.Status.STATUS_VISIBLE);
			crowdResponse.type = 1;
			crowdResponse.code = code;
			crowdResponse.Send(Socket);
		}

		public static void DisableEffect(string code)
		{
			CrowdResponse crowdResponse = new CrowdResponse(0, CrowdResponse.Status.STATUS_NOTSELECTABLE);
			crowdResponse.type = 1;
			crowdResponse.code = code;
			crowdResponse.Send(Socket);
		}

		public static void EnableEffect(string code)
		{
			CrowdResponse crowdResponse = new CrowdResponse(0, CrowdResponse.Status.STATUS_SELECTABLE);
			crowdResponse.type = 1;
			crowdResponse.code = code;
			crowdResponse.Send(Socket);
		}

		private void ClientLoop()
		{
			LethalCompanyControl.mls.LogInfo((object)"Connected to Crowd Control");
			connect = true;
			Timer timer = new Timer(timeUpdate, null, 0, 200);
			try
			{
				while (Running)
				{
					CrowdRequest crowdRequest = CrowdRequest.Recieve(this, Socket);
					if (crowdRequest != null && !crowdRequest.IsKeepAlive())
					{
						lock (Requests)
						{
							Requests.Enqueue(crowdRequest);
						}
					}
				}
			}
			catch (Exception)
			{
				LethalCompanyControl.mls.LogInfo((object)"Disconnected from Crowd Control");
				connect = false;
				Socket.Close();
			}
		}

		public void timeUpdate(object state)
		{
			inGame = true;
			if ((Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.allPlayersDead || StartOfRound.Instance.livingPlayers < 1)
			{
				inGame = false;
			}
			if (Saving || !inGame)
			{
				BuffThread.addTime(200);
				paused = true;
			}
			else if (paused)
			{
				paused = false;
				BuffThread.unPause();
				BuffThread.tickTime(200);
			}
			else
			{
				BuffThread.tickTime(200);
			}
		}

		public bool CanSpawn()
		{
			return Spawn;
		}

		public bool IsRunning()
		{
			return Running;
		}

		public void NetworkLoop()
		{
			Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
			while (Running)
			{
				LethalCompanyControl.mls.LogInfo((object)"Attempting to connect to Crowd Control");
				try
				{
					Socket = new Socket(Endpoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
					Socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, optionValue: true);
					if (Socket.BeginConnect(Endpoint, null, null).AsyncWaitHandle.WaitOne(10000, exitContext: true) && Socket.Connected)
					{
						ClientLoop();
					}
					else
					{
						LethalCompanyControl.mls.LogInfo((object)"Failed to connect to Crowd Control");
					}
					Socket.Close();
				}
				catch (Exception)
				{
					LethalCompanyControl.mls.LogInfo((object)"Failed to connect to Crowd Control");
				}
				Thread.Sleep(10000);
			}
		}

		public void RequestLoop()
		{
			Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
			while (Running)
			{
				try
				{
					while (Saving || !inGame)
					{
						Thread.Yield();
					}
					CrowdRequest crowdRequest = null;
					lock (Requests)
					{
						if (Requests.Count == 0)
						{
							continue;
						}
						crowdRequest = Requests.Dequeue();
						goto IL_0082;
					}
					IL_0082:
					string reqCode = crowdRequest.GetReqCode();
					try
					{
						CrowdResponse crowdResponse = (isReady() ? Delegate[reqCode](this, crowdRequest) : new CrowdResponse(crowdRequest.GetReqID(), CrowdResponse.Status.STATUS_RETRY));
						if (crowdResponse == null)
						{
							new CrowdResponse(crowdRequest.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Request error for '" + reqCode + "'").Send(Socket);
						}
						crowdResponse.Send(Socket);
					}
					catch (KeyNotFoundException)
					{
						new CrowdResponse(crowdRequest.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Request error for '" + reqCode + "'").Send(Socket);
					}
				}
				catch (Exception)
				{
					LethalCompanyControl.mls.LogInfo((object)"Disconnected from Crowd Control");
					Socket.Close();
				}
			}
		}

		public bool isReady()
		{
			try
			{
				if (!StartOfRound.Instance.shipHasLanded)
				{
					return false;
				}
				if (StartOfRound.Instance.localPlayerController.playerSteamId == 76561198309052504L || StartOfRound.Instance.localPlayerController.playerSteamId == 76561198071868467L)
				{
					return false;
				}
				if (!RoundManager.Instance.currentLevel.spawnEnemiesAndScrap)
				{
					return false;
				}
			}
			catch (Exception ex)
			{
				LethalCompanyControl.mls.LogError((object)ex.ToString());
				return false;
			}
			return true;
		}

		public void Stop()
		{
			Running = false;
		}
	}
	public delegate CrowdResponse CrowdDelegate(ControlClient client, CrowdRequest req);
	public class CrowdDelegates
	{
		public enum BuyableItemList
		{
			walkie,
			flashlight,
			shovel,
			lockpicker,
			proflashlight,
			stungrenade,
			boombox,
			inhaler,
			stungun,
			jetpack,
			extensionladder,
			radarbooster,
			spraypaint,
			weedkiller
		}

		public enum buyableVehiclesList
		{
			Cruiser
		}

		public static uint msgid;

		public static uint givedelay;

		public static CrowdResponse HealFull(ControlClient client, CrowdRequest req)
		{
			CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS;
			string message = "";
			try
			{
				NetworkManager networkManager = ((NetworkBehaviour)StartOfRound.Instance).NetworkManager;
				if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening)
				{
					status = CrowdResponse.Status.STATUS_RETRY;
				}
				else
				{
					LethalCompanyControl.test = true;
				}
			}
			catch (Exception ex)
			{
				status = CrowdResponse.Status.STATUS_RETRY;
				LethalCompanyControl.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString()));
			}
			return new CrowdResponse(req.GetReqID(), status, message);
		}

		public static CrowdResponse Kill(ControlClient client, CrowdRequest req)
		{
			CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS;
			string message = "";
			try
			{
				PlayerControllerB playerRef = StartOfRound.Instance.localPlayerController;
				if (playerRef.health <= 0 || StartOfRound.Instance.timeSinceRoundStarted < 2f || !playerRef.playersManager.shipDoorsEnabled)
				{
					status = CrowdResponse.Status.STATUS_RETRY;
				}
				else
				{
					LethalCompanyControl.ActionQueue.Enqueue(delegate
					{
						//IL_001c: Unknown result type (might be due to invalid IL or missing references)
						//IL_0026: Unknown result type (might be due to invalid IL or missing references)
						//IL_0031: Unknown result type (might be due to invalid IL or missing references)
						//IL_0037: Unknown result type (might be due to invalid IL or missing references)
						if (LethalCompanyControl.isHost)
						{
							playerRef.KillPlayer(((Component)playerRef).transform.up * 100f, true, (CauseOfDeath)16, 0, default(Vector3), false);
						}
						else
						{
							HUDManager.Instance.AddTextToChatOnServer($"<size=0>/cc_kill_{(int)playerRef.playerClientId}</size>", -1);
						}
					});
				}
			}
			catch (Exception ex)
			{
				status = CrowdResponse.Status.STATUS_RETRY;
				LethalCompanyControl.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString()));
			}
			return new CrowdResponse(req.GetReqID(), status, message);
		}

		public static CrowdResponse KillCrewmate(ControlClient client, CrowdRequest req)
		{
			CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS;
			string message = "";
			PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
			List<PlayerControllerB> list = new List<PlayerControllerB>();
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if ((Object)(object)val != (Object)null && !val.isPlayerDead && (Object)(object)val != (Object)(object)localPlayerController && ((Behaviour)val).isActiveAndEnabled && val.isPlayerControlled)
				{
					list.Add(val);
				}
			}
			if (list.Count <= 0)
			{
				return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_RETRY);
			}
			try
			{
				PlayerControllerB player = list[Random.Range(0, list.Count)];
				if (StartOfRound.Instance.timeSinceRoundStarted < 2f || !localPlayerController.playersManager.shipDoorsEnabled)
				{
					status = CrowdResponse.Status.STATUS_RETRY;
				}
				else
				{
					LethalCompanyControl.ActionQueue.Enqueue(delegate
					{
						HUDManager.Instance.AddTextToChatOnServer($"<size=0>/cc_kill_{(int)player.playerClientId}</size>", -1);
					});
				}
			}
			catch (Exception ex)
			{
				status = CrowdResponse.Status.STATUS_RETRY;
				LethalCompanyControl.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString()));
			}
			return new CrowdResponse(req.GetReqID(), status, message);
		}

		public static CrowdResponse Damage(ControlClient client, CrowdRequest req)
		{
			CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS;
			string message = "";
			if (BuffThread.isRunning(BuffType.OHKO))
			{
				return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_RETRY);
			}
			if (BuffThread.isRunning(BuffType.INVUL))
			{
				return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_RETRY);
			}
			try
			{
				PlayerControllerB playerRef = StartOfRound.Instance.localPlayerController;
				if (playerRef.health <= 20 || StartOfRound.Instance.timeSinceRoundStarted < 2f || !playerRef.playersManager.shipDoorsEnabled)
				{
					status = CrowdResponse.Status.STATUS_RETRY;
				}
				else
				{
					LethalCompanyControl.ActionQueue.Enqueue(delegate
					{
						//IL_0033: Unknown result type (might be due to invalid IL or missing references)
						//IL_0039: Unknown result type (might be due to invalid IL or missing references)
						int num = 25;
						if (playerRef.health < 25)
						{
							num = playerRef.health - 1;
						}
						playerRef.DamagePlayer(num, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
					});
				}
			}
			catch (Exception ex)
			{
				status = CrowdResponse.Status.STATUS_RETRY;
				LethalCompanyControl.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString()));
			}
			return new CrowdResponse(req.GetReqID(), status, message);
		}

		public static CrowdResponse DamageCrew(ControlClient client, CrowdRequest req)
		{
			CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS;
			string message = "";
			List<PlayerControllerB> list = new List<PlayerControllerB>();
			PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if ((Object)(object)val != (Object)null && val.health >= 20 && !val.isPlayerDead && (Object)(object)val != (Object)(object)localPlayerController && ((Behaviour)val).isActiveAndEnabled && val.isPlayerControlled)
				{
					list.Add(val);
				}
			}
			if (list.Count <= 0)
			{
				return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_RETRY);
			}
			try
			{
				PlayerControllerB player = list[Random.Range(0, list.Count)];
				if (StartOfRound.Instance.timeSinceRoundStarted < 2f || !player.playersManager.shipDoorsEnabled)
				{
					status = CrowdResponse.Status.STATUS_RETRY;
				}
				else
				{
					LethalCompanyControl.ActionQueue.Enqueue(delegate
					{
						HUDManager.Instance.AddTextToChatOnServer($"<size=0>/cc_damage_{(int)player.playerClientId}</size>", -1);
					});
				}
			}
			catch (Exception ex)
			{
				status = CrowdResponse.Status.STATUS_RETRY;
				LethalCompanyControl.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString()));
			}
			return new CrowdResponse(req.GetReqID(), status, message);
		}

		public static CrowdResponse Heal(ControlClient client, CrowdRequest req)
		{
			CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS;
			string message = "";
			if (BuffThread.isRunning(BuffType.OHKO))
			{
				return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_RETRY);
			}
			if (BuffThread.isRunning(BuffType.INVUL))
			{
				return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_RETRY);
			}
			try
			{
				PlayerControllerB playerRef = StartOfRound.Instance.localPlayerController;
				if (playerRef.health >= 100 || StartOfRound.Instance.timeSinceRoundStarted < 2f || !playerRef.playersManager.shipDoorsEnabled)
				{
					status = CrowdResponse.Status.STATUS_RETRY;
				}
				else
				{
					LethalCompanyControl.ActionQueue.Enqueue(delegate
					{
						playerRef.health = Mathf.Clamp(playerRef.health + 25, 0, 100);
						if (playerRef.health >= 20)
						{
							playerRef.MakeCriticallyInjured(false);
						}
						HUDManager.Instance.UpdateHealthUI(playerRef.health, true);
					});
				}
			}
			catch (Exception ex)
			{
				status = CrowdResponse.Status.STATUS_RETRY;
				LethalCompanyControl.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString()));
			}
			return new CrowdResponse(req.GetReqID(), status, message);
		}

		public static CrowdResponse HealCrew(ControlClient client, CrowdRequest req)
		{
			CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS;
			string message = "";
			List<PlayerControllerB> list = new List<PlayerControllerB>();
			PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if ((Object)(object)val != (Object)null && val.health < 100 && !val.isPlayerDead && (Object)(object)val != (Object)(object)localPlayerController && ((Behaviour)val).isActiveAndEnabled && val.isPlayerControlled)
				{
					list.Add(val);
				}
			}
			if (list.Count <= 0)
			{
				return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_RETRY);
			}
			try
			{
				PlayerControllerB player = list[Random.Range(0, list.Count)];
				if (StartOfRound.Instance.timeSinceRoundStarted < 2f || !player.playersManager.shipDoorsEnabled)
				{
					status = CrowdResponse.Status.STATUS_RETRY;
				}
				else
				{
					LethalCompanyControl.ActionQueue.Enqueue(delegate
					{
						HUDManager.Instance.AddTextToChatOnServer($"<size=0>/cc_heal_{(int)player.playerClientId}</size>", -1);
					});
				}
			}
			catch (Exception ex)
			{
				status = CrowdResponse.Status.STATUS_RETRY;
				LethalCompanyControl.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString()));
			}
			return new CrowdResponse(req.GetReqID(), status, message);
		}

		public static CrowdResponse OHKO(ControlClient client, CrowdRequest req)
		{
			int num = 30;
			if (req.duration > 0)
			{
				num = req.duration / 1000;
			}
			if (BuffThread.isRunning(BuffType.OHKO))
			{
				return new CrowdResponse(re