Decompiled source of CrowdControl LethalCompany v1.1.7

BepInEx/plugins/CrowdControl.dll

Decompiled 2 months 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.Configuration;
using BepInEx.Logging;
using ControlValley;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyTestMod;
using Newtonsoft.Json;
using TMPro;
using TerminalApi;
using TerminalApi.Classes;
using TerminalApi.Events;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: 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.6")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.1.6.0")]
namespace LethalCompanyTestMod
{
	[BepInPlugin("WarpWorld.CrowdControl", "Crowd Control", "1.1.6.0")]
	public class TestMod : BaseUnityPlugin
	{
		private const string modGUID = "WarpWorld.CrowdControl";

		private const string modName = "Crowd Control";

		private const string modVersion = "1.1.6.0";

		public static string tsVersion = "1.1.6";

		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 ManualLogSource mls;

		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 nightVisionRange;

		public static Color nightVisionColor;

		private static bool hasGUISynced = false;

		internal static bool isHost = false;

		internal static TestMod 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(TestMod));
			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()
		{
			currentStart = StartOfRound.Instance;
		}

		[HarmonyPatch(typeof(RoundManager), "Start")]
		[HarmonyPrefix]
		private 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_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Expected O, but got Unknown
			currentRound = RoundManager.Instance;
			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), "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();
					}
				}
			}
		}

		private static IEnumerator getVersions()
		{
			version.Clear();
			HUDManager.Instance.AddTextToChatOnServer("<size=0>/cc_vercheck</size>", -1);
			yield return (object)new WaitForSeconds(0.5f);
			foreach (KeyValuePair<string, (string, string)> versionNum in version)
			{
				mls.LogError((object)$"{versionNum.Key} is running LC Crowd Control version {versionNum.Value}");
			}
		}

		private static IEnumerator getTermVersions()
		{
			version.Clear();
			HUDManager.Instance.AddTextToChatOnServer("<size=0>/cc_vercheck</size>", -1);
			yield return (object)new WaitForSeconds(0.5f);
		}

		[HarmonyPatch(typeof(HUDManager), "AddChatMessage")]
		[HarmonyPrefix]
		private static bool CrowdControlCommands(HUDManager __instance, string chatMessage)
		{
			//IL_0891: Unknown result type (might be due to invalid IL or missing references)
			//IL_0897: Unknown result type (might be due to invalid IL or missing references)
			//IL_1adb: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ae1: Invalid comparison between Unknown and I4
			//IL_1b71: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b80: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b86: Invalid comparison between Unknown and I4
			//IL_1b01: Unknown result type (might be due to invalid IL or missing references)
			//IL_195f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1969: Unknown result type (might be due to invalid IL or missing references)
			//IL_1975: Unknown result type (might be due to invalid IL or missing references)
			//IL_197f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1984: Unknown result type (might be due to invalid IL or missing references)
			//IL_16eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_16f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cf8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cfd: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c0e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c13: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c1d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c23: Invalid comparison between Unknown and I4
			//IL_0f7f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f84: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a3f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a4b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a55: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a5a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a66: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a70: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a75: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a7a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a81: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a85: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a8b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a93: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a98: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a9a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a9c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a9e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa3: Unknown result type (might be due to invalid IL or missing references)
			//IL_1893: Unknown result type (might be due to invalid IL or missing references)
			//IL_0abf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0abb: Unknown result type (might be due to invalid IL or missing references)
			//IL_12f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_1310: Unknown result type (might be due to invalid IL or missing references)
			//IL_1317: Expected O, but got Unknown
			//IL_15de: Unknown result type (might be due to invalid IL or missing references)
			//IL_15fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_1604: Expected O, but got Unknown
			//IL_1c5c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c6b: Unknown result type (might be due to invalid IL or missing references)
			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(new char[1] { '_' });
				string text2 = values[0];
				string text3 = text2;
				if (text3 != null)
				{
					switch (text3.Length)
					{
					case 7:
						switch (text3[0])
						{
						case 'v':
							if (!(text3 == "version"))
							{
								break;
							}
							if (!version.ContainsKey(values[1]))
							{
								version.Add(values[1], (values[2], values[3]));
							}
							return false;
						case 'p':
							if (text3 == "poweron")
							{
								if (!isHost)
								{
									return true;
								}
								RoundManager.Instance.PowerSwitchOnClientRpc();
							}
							break;
						case 'a':
							if (text3 == "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 'r':
							if (text3 == "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 'c':
							if (text3 == "credits")
							{
								if (!isHost)
								{
									return true;
								}
								int num33 = int.Parse(values[1]);
								Terminal val26 = Object.FindObjectOfType<Terminal>();
								val26.groupCredits += num33;
								val26.SyncGroupCreditsServerRpc(val26.groupCredits, val26.numberOfItemsInDropship);
								if (num33 > 0)
								{
									HUDManager.Instance.DisplayTip("Crowd Control", "Crowd Control gave " + num33 + " credits", false, false, "LC_Tip1");
								}
								else
								{
									HUDManager.Instance.DisplayTip("Crowd Control", "Crowd Control took " + -1 * num33 + " credits", false, false, "LC_Tip1");
								}
							}
							break;
						case 'w':
						{
							if (!(text3 == "weather"))
							{
								break;
							}
							int num31 = int.Parse(values[1]);
							TimeOfDay.Instance.DisableAllWeather(true);
							if ((int)StartOfRound.Instance.currentLevel.currentWeather >= 0)
							{
								WeatherEffect val25 = TimeOfDay.Instance.effects[StartOfRound.Instance.currentLevel.currentWeather];
								if (val25 != null)
								{
									val25.effectEnabled = false;
									if ((Object)(object)val25.effectPermanentObject != (Object)null)
									{
										val25.effectPermanentObject.SetActive(false);
									}
									if ((Object)(object)val25.effectObject != (Object)null)
									{
										val25.effectObject.SetActive(false);
									}
								}
							}
							StartOfRound.Instance.currentLevel.currentWeather = (LevelWeatherType)num31;
							if ((int)StartOfRound.Instance.currentLevel.currentWeather >= 0)
							{
								WeatherEffect val25 = TimeOfDay.Instance.effects[num31];
								if (val25 != null)
								{
									val25.effectEnabled = true;
									if ((Object)(object)val25.effectPermanentObject != (Object)null)
									{
										val25.effectPermanentObject.SetActive(true);
									}
									if ((Object)(object)val25.effectObject != (Object)null)
									{
										val25.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 num32 = 0; num32 < RoundManager.Instance.currentLevel.randomWeathers.Length; num32++)
								{
									if (RoundManager.Instance.currentLevel.randomWeathers[num32].weatherType == RoundManager.Instance.currentLevel.currentWeather)
									{
										TimeOfDay.Instance.currentWeatherVariable = RoundManager.Instance.currentLevel.randomWeathers[num32].weatherVariable;
										TimeOfDay.Instance.currentWeatherVariable2 = RoundManager.Instance.currentLevel.randomWeathers[num32].weatherVariable2;
									}
								}
							}
							catch (Exception ex2)
							{
								mls.LogError((object)ex2.ToString());
							}
							break;
						}
						}
						break;
					case 8:
						switch (text3[0])
						{
						case 'v':
							if (!(text3 == "vercheck"))
							{
								break;
							}
							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 'p':
							if (text3 == "poweroff")
							{
								if (!isHost)
								{
									return true;
								}
								RoundManager.Instance.PowerSwitchOffClientRpc();
							}
							break;
						case 'l':
						{
							if (!(text3 == "landmine"))
							{
								break;
							}
							int num28 = int.Parse(values[1]);
							PlayerControllerB val18 = null;
							PlayerControllerB[] allPlayerScripts7 = StartOfRound.Instance.allPlayerScripts;
							foreach (PlayerControllerB val19 in allPlayerScripts7)
							{
								if ((Object)(object)val19 != (Object)null && ((Behaviour)val19).isActiveAndEnabled && !val19.isPlayerDead && (int)val19.playerClientId == num28 && val19.isPlayerControlled)
								{
									val18 = val19;
								}
							}
							if ((Object)(object)val18 == (Object)null)
							{
								return true;
							}
							GameObject val20 = null;
							GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
							GameObject[] array2 = array;
							GameObject[] array3 = array2;
							foreach (GameObject val21 in array3)
							{
								if (((Object)val21).name == "Landmine")
								{
									val20 = val21;
									break;
								}
							}
							if ((Object)(object)val20 == (Object)null)
							{
								return true;
							}
							Vector3 val22 = ((Component)val18).transform.position + ((Component)val18).transform.forward * 5f - ((Component)val18).transform.up * 0.5f;
							Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(val22, default(NavMeshHit), 5f, -1);
							Vector3 val23 = navMeshPosition - val22;
							if (((Vector3)(ref val23)).magnitude < 6f)
							{
								val22 = navMeshPosition;
							}
							GameObject val24 = Object.Instantiate<GameObject>(val20, val22, Quaternion.EulerAngles(-90f, 0f, 0f), currentStart.propsContainer);
							break;
						}
						case 'd':
							if (text3 == "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;
						}
						break;
					case 5:
						switch (text3[3])
						{
						case 'w':
							if (!(text3 == "spawn"))
							{
								break;
							}
							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 'e':
						{
							if (!(text3 == "giver"))
							{
								break;
							}
							if (!isHost)
							{
								return true;
							}
							CrowdDelegates.givedelay = 20u;
							int num22 = int.Parse(values[1]);
							int num23 = int.Parse(values[2]);
							uint num24 = uint.Parse(values[3]);
							if (num24 == msgid2)
							{
								return true;
							}
							msgid2 = num24;
							PlayerControllerB val14 = null;
							if (num23 != -1)
							{
								PlayerControllerB[] allPlayerScripts6 = StartOfRound.Instance.allPlayerScripts;
								foreach (PlayerControllerB val15 in allPlayerScripts6)
								{
									if ((Object)(object)val15 != (Object)null && ((Behaviour)val15).isActiveAndEnabled && !val15.isPlayerDead && (int)val15.playerClientId == num23 && val15.isPlayerControlled)
									{
										val14 = val15;
									}
								}
								if ((Object)(object)val14 == (Object)(object)StartOfRound.Instance.localPlayerController)
								{
									num23 = -1;
								}
							}
							else
							{
								val14 = StartOfRound.Instance.localPlayerController;
							}
							if ((Object)(object)val14 == (Object)null)
							{
								val14 = StartOfRound.Instance.localPlayerController;
								num23 = -1;
							}
							Terminal val16 = Object.FindObjectOfType<Terminal>();
							GameObject val17 = Object.Instantiate<GameObject>(val16.buyableItemsList[num22].spawnPrefab, ((Component)val14).transform.position, Quaternion.identity, currentStart.propsContainer);
							val17.GetComponent<GrabbableObject>().fallTime = 0f;
							val17.GetComponent<NetworkObject>().Spawn(false);
							CrowdDelegates.msgid++;
							HUDManager.Instance.AddTextToChatOnServer($"<size=0>/cc_give_{num22}_{num23}_{val17.GetComponent<NetworkObject>().NetworkObjectId}_{CrowdDelegates.msgid}</size>", -1);
							break;
						}
						case 'i':
							if (text3 == "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 'v':
						{
							if (!(text3 == "mgive"))
							{
								break;
							}
							string text5 = values[1];
							int num19 = int.Parse(values[2]);
							ulong key2 = ulong.Parse(values[3]);
							uint num20 = uint.Parse(values[4]);
							if (num20 == msgid3)
							{
								return true;
							}
							msgid3 = num20;
							playerRef = StartOfRound.Instance.localPlayerController;
							if (num19 == -1)
							{
								if (!isHost)
								{
									return true;
								}
							}
							else
							{
								if (isHost)
								{
									return true;
								}
								if ((int)StartOfRound.Instance.localPlayerController.playerClientId != num19)
								{
									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 val12 = (Coroutine)CrowdDelegates.getProperty(playerRef, "grabObjectCoroutine");
							if (val12 != null)
							{
								((MonoBehaviour)playerRef).StopCoroutine(val12);
							}
							CrowdDelegates.setProperty(playerRef, "grabObjectCoroutine", ((MonoBehaviour)playerRef).StartCoroutine("GrabObject"));
							break;
						}
						case 'c':
						{
							if (!(text3 == "pitch"))
							{
								break;
							}
							float num26 = float.Parse(values[1]);
							for (int num27 = 0; num27 < StartOfRound.Instance.allPlayerScripts.Length; num27++)
							{
								try
								{
									SoundManager.Instance.playerVoicePitchTargets[num27] = num26;
									SoundManager.Instance.playerVoicePitches[num27] = num26;
									if ((Object)(object)StartOfRound.Instance.allPlayerScripts[num27] != (Object)null)
									{
										if ((Object)(object)StartOfRound.Instance.allPlayerScripts[num27].currentVoiceChatAudioSource != (Object)null)
										{
											StartOfRound.Instance.allPlayerScripts[num27].currentVoiceChatAudioSource.pitch = num26;
										}
										SoundManager.Instance.SetPlayerPitch(num26, num27);
									}
								}
								catch (Exception ex)
								{
									mls.LogError((object)ex.ToString());
								}
							}
							break;
						}
						case 'r':
							if (text3 == "doors")
							{
								int num21 = int.Parse(values[1]);
								HangarShipDoor val13 = Object.FindObjectOfType<HangarShipDoor>();
								val13.PlayDoorAnimation(num21 == 1);
							}
							break;
						case 't':
							if (text3 == "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;
						}
						break;
					case 6:
						switch (text3[0])
						{
						case 'c':
						{
							if (!(text3 == "cspawn"))
							{
								break;
							}
							if (!isHost)
							{
								return true;
							}
							int num16 = int.Parse(values[2]);
							PlayerControllerB player = null;
							PlayerControllerB[] allPlayerScripts5 = StartOfRound.Instance.allPlayerScripts;
							foreach (PlayerControllerB val11 in allPlayerScripts5)
							{
								if ((Object)(object)val11 != (Object)null && ((Behaviour)val11).isActiveAndEnabled && !val11.isPlayerDead && (int)val11.playerClientId == num16 && val11.isPlayerControlled)
								{
									player = val11;
								}
							}
							if ((Object)(object)player == (Object)null)
							{
								return true;
							}
							ActionQueue.Enqueue(delegate
							{
								//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 val27 = null;
										SelectableLevel[] levels2 = StartOfRound.Instance.levels;
										foreach (SelectableLevel val28 in levels2)
										{
											if ((Object)(object)val27 == (Object)null)
											{
												foreach (SpawnableItemWithRarity item in val28.spawnableScrap)
												{
													if (((Object)item.spawnableItem).name.ToLower() == "tragedymask")
													{
														val27 = item.spawnableItem.spawnPrefab;
													}
												}
											}
										}
										if (!((Object)(object)val27 == (Object)null))
										{
											GameObject val29 = Object.Instantiate<GameObject>(val27, ((Component)player).transform.position, Quaternion.identity, currentStart.propsContainer);
											HauntedMaskItem component4 = val29.GetComponent<HauntedMaskItem>();
											GameObject val30 = Object.Instantiate<GameObject>(component4.mimicEnemy.enemyPrefab, ((Component)player).transform.position + ((Component)player).transform.forward * 5f, Quaternion.Euler(Vector3.zero));
											val30.gameObject.GetComponentInChildren<NetworkObject>().Spawn(true);
											MaskedPlayerEnemy component5 = val30.GetComponent<MaskedPlayerEnemy>();
											component5.mimickingPlayer = player;
											component5.SetSuit(player.currentSuitID);
											component5.SetEnemyOutside(!player.isInsideFactory);
											component5.SetVisibilityOfMaskedEnemy();
											component5.SetMaskType(component4.maskTypeId);
											HUDManager.Instance.AddTextToChatOnServer($"<size=0>/cc_mimic_{((NetworkBehaviour)component5).NetworkObject.NetworkObjectId}</size>", -1);
											val30.gameObject.GetComponentInChildren<EnemyAI>().stunNormalizedTimer = 6f;
											Object.Destroy((Object)(object)val29);
										}
										return;
									}
									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 'd':
							if (text3 == "damage")
							{
								int num12 = int.Parse(values[1]);
								playerRef = StartOfRound.Instance.localPlayerController;
								if ((int)StartOfRound.Instance.localPlayerController.playerClientId != num12)
								{
									return true;
								}
								int num13 = 25;
								if (playerRef.health < 25)
								{
									num13 = playerRef.health - 1;
								}
								playerRef.DamagePlayer(num13, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
							}
							break;
						case 'm':
						{
							if (!(text3 == "mgiver"))
							{
								break;
							}
							if (!isHost)
							{
								return true;
							}
							CrowdDelegates.givedelay = 20u;
							string text4 = values[1];
							int num14 = int.Parse(values[2]);
							uint num15 = uint.Parse(values[3]);
							if (num15 == msgid2)
							{
								return true;
							}
							msgid2 = num15;
							PlayerControllerB val5 = null;
							if (num14 != -1)
							{
								PlayerControllerB[] allPlayerScripts4 = StartOfRound.Instance.allPlayerScripts;
								foreach (PlayerControllerB val6 in allPlayerScripts4)
								{
									if ((Object)(object)val6 != (Object)null && ((Behaviour)val6).isActiveAndEnabled && !val6.isPlayerDead && (int)val6.playerClientId == num14 && val6.isPlayerControlled)
									{
										val5 = val6;
									}
								}
								if ((Object)(object)val5 == (Object)(object)StartOfRound.Instance.localPlayerController)
								{
									num14 = -1;
								}
							}
							else
							{
								val5 = StartOfRound.Instance.localPlayerController;
							}
							if ((Object)(object)val5 == (Object)null)
							{
								val5 = StartOfRound.Instance.localPlayerController;
								num14 = -1;
							}
							GameObject val7 = null;
							SelectableLevel[] levels = StartOfRound.Instance.levels;
							foreach (SelectableLevel val8 in levels)
							{
								if (!((Object)(object)val7 == (Object)null))
								{
									continue;
								}
								foreach (SpawnableItemWithRarity item2 in val8.spawnableScrap)
								{
									if (((Object)item2.spawnableItem).name.ToLower() == text4)
									{
										val7 = item2.spawnableItem.spawnPrefab;
									}
								}
							}
							if ((Object)(object)val7 == (Object)null)
							{
								return true;
							}
							Terminal val9 = Object.FindObjectOfType<Terminal>();
							GameObject val10 = Object.Instantiate<GameObject>(val7, ((Component)val5).transform.position, Quaternion.identity, currentStart.propsContainer);
							val10.GetComponent<GrabbableObject>().fallTime = 0f;
							val10.GetComponent<NetworkObject>().Spawn(false);
							CrowdDelegates.msgid++;
							HUDManager.Instance.AddTextToChatOnServer($"<size=0>/cc_mgive_{text4}_{num14}_{val10.GetComponent<NetworkObject>().NetworkObjectId}_{CrowdDelegates.msgid}</size>", -1);
							break;
						}
						case 'r':
							if (text3 == "revive")
							{
								StartOfRound.Instance.ReviveDeadPlayers();
								HUDManager.Instance.HideHUD(false);
							}
							break;
						}
						break;
					case 4:
						switch (text3[0])
						{
						case 't':
							if (!(text3 == "take"))
							{
								if (!(text3 == "tele"))
								{
									break;
								}
								int num8 = int.Parse(values[1]);
								int num9 = int.Parse(values[2]);
								if ((int)StartOfRound.Instance.localPlayerController.playerClientId != num8)
								{
									break;
								}
								PlayerControllerB[] allPlayerScripts2 = StartOfRound.Instance.allPlayerScripts;
								foreach (PlayerControllerB val3 in allPlayerScripts2)
								{
									if ((Object)(object)val3 != (Object)null && ((Behaviour)val3).isActiveAndEnabled && !val3.isPlayerDead && (int)val3.playerClientId == num9 && val3.isPlayerControlled)
									{
										StartOfRound.Instance.localPlayerController.TeleportPlayer(((Component)val3).transform.position, false, 0f, false, true);
									}
								}
							}
							else
							{
								int num10 = int.Parse(values[1]);
								playerRef = StartOfRound.Instance.localPlayerController;
								if ((int)StartOfRound.Instance.localPlayerController.playerClientId != num10)
								{
									return true;
								}
								playerRef.DespawnHeldObject();
							}
							break;
						case 'h':
							if (text3 == "heal")
							{
								int num3 = int.Parse(values[1]);
								playerRef = StartOfRound.Instance.localPlayerController;
								if ((int)StartOfRound.Instance.localPlayerController.playerClientId != num3)
								{
									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 'g':
						{
							if (!(text3 == "give"))
							{
								break;
							}
							int num4 = int.Parse(values[1]);
							int num5 = int.Parse(values[2]);
							ulong key = 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 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");
							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 's':
							if (text3 == "ship")
							{
								int num7 = int.Parse(values[1]);
								if ((int)StartOfRound.Instance.localPlayerController.playerClientId == num7)
								{
									StartOfRound.Instance.ForcePlayerIntoShip();
								}
							}
							break;
						case 'k':
						{
							if (!(text3 == "kill"))
							{
								break;
							}
							int num11 = int.Parse(values[1]);
							PlayerControllerB[] allPlayerScripts3 = StartOfRound.Instance.allPlayerScripts;
							foreach (PlayerControllerB val4 in allPlayerScripts3)
							{
								if ((Object)(object)val4 != (Object)null && ((Behaviour)val4).isActiveAndEnabled && !val4.isPlayerDead && (int)val4.playerClientId == num11 && val4.isPlayerControlled)
								{
									val4.KillPlayer(((Component)val4).transform.up * 100f, true, (CauseOfDeath)0, 0);
								}
							}
							break;
						}
						case 'b':
						{
							if (!(text3 == "body"))
							{
								break;
							}
							int num = int.Parse(values[1]);
							uint num2 = uint.Parse(values[2]);
							if (num2 == msgid)
							{
								return true;
							}
							msgid = num2;
							PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
							foreach (PlayerControllerB val in allPlayerScripts)
							{
								if ((Object)(object)val != (Object)null && ((Behaviour)val).isActiveAndEnabled && !val.isPlayerDead && (int)val.playerClientId == num && val.isPlayerControlled)
								{
									val.SpawnDeadBody((int)val.playerClientId, ((Component)val).transform.up * 2f + ((Component)val).transform.forward * 5f, 0, val, 0, (Transform)null);
								}
							}
							break;
						}
						}
						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;
				}
			}
			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;
					}
				}
			}
		}

		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>().stunNormalizedTimer = 6f;
		}

		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>().stunNormalizedTimer = 6f;
		}
	}
}
namespace LethalCompanyTestMod.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)
			TestMod.playerRef = __instance;
			TestMod.nightVision = ((Behaviour)TestMod.playerRef.nightVision).enabled;
			TestMod.nightVisionIntensity = TestMod.playerRef.nightVision.intensity;
			TestMod.nightVisionColor = TestMod.playerRef.nightVision.color;
			TestMod.nightVisionRange = TestMod.playerRef.nightVision.range;
			TestMod.playerRef.nightVision.color = Color.green;
			TestMod.playerRef.nightVision.intensity = 1000f;
			TestMod.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 (TestMod.nightVision)
			{
				TestMod.playerRef.nightVision.color = Color.green;
				TestMod.playerRef.nightVision.intensity = 1000f;
				TestMod.playerRef.nightVision.range = 10000f;
			}
			else
			{
				TestMod.playerRef.nightVision.color = TestMod.nightVisionColor;
				TestMod.playerRef.nightVision.intensity = TestMod.nightVisionIntensity;
				TestMod.playerRef.nightVision.range = TestMod.nightVisionRange;
			}
			((Behaviour)TestMod.playerRef.nightVision).enabled = true;
		}

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

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void InfiniteSprint(ref float ___sprintMeter)
		{
			if (TestMod.infSprint && TestMod.isHost)
			{
				Mathf.Clamp(___sprintMeter += 0.02f, 0f, 1f);
			}
		}
	}
}
namespace LethalCompanyTestMod.Component
{
	internal class GUILoader : MonoBehaviour
	{
		private KeyboardShortcut openCloseMenu;

		private bool isMenuOpen;

		public bool noClipButton;

		internal bool wasKeyDown;

		private int toolbarInt = 0;

		private string[] toolbarStrings = new string[4] { "AI Modification/Spawning", "Host Settings", "Time Settings", "Scrap Settings" };

		private int MENUWIDTH = 600;

		private int MENUHEIGHT = 800;

		private int MENUX;

		private int MENUY;

		private int ITEMWIDTH = 300;

		private int CENTERX;

		public bool guiHideCommandMessage;

		public bool guiHideEnemySpawnMessages;

		public bool guiShouldEnemiesSpawnNaturally;

		public bool guiEnableAIModifiers;

		public bool guiEnableInfiniteSprint;

		public bool guiEnableInfiniteCredits;

		public bool guiEnableGod;

		public bool guiEnableNightVision;

		public bool guiEnableSpeedHack;

		public bool guiEnableScrapModifiers;

		public bool guiEnableCustomBuyRate;

		public bool guiUseRandomBuyRate;

		public bool guiUseCustomTimeScale;

		public bool guiUseRandomTimeScale;

		public bool guiEnableInfiniteDeadline;

		public bool guiEnableCustomDeadline;

		public bool guiUseRandomDeadline;

		public bool guiSpawnButtonPressed;

		public string guiServerName;

		public string guiRoundPost;

		public string guiXPChange;

		public string guiSelectedEnemy;

		public string guiPrefix;

		public int guiMinScrap;

		public int guiMaxScrap;

		public int guiMinScrapValue;

		public int guiMaxScrapValue;

		public int guiMinimumDeadline;

		public int guiMaximumDeadline;

		public float guiSpringSpeed;

		public float guiPopupTimer;

		public float guiMaxJesterSpeed;

		public float guiCrankingTimer;

		public float guiJesterResetTimer;

		public float guiMinTimeScale;

		public float guiMaxTimeScale;

		public float guiMinBuyRate;

		public float guiMaxBuyRate;

		private GUIStyle menuStyle;

		private GUIStyle buttonStyle;

		private GUIStyle labelStyle;

		private GUIStyle toggleStyle;

		private GUIStyle hScrollStyle;

		public bool guiIsHost;

		private void Awake()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			TestMod.mls.LogInfo((object)"GUILoader loaded.");
			openCloseMenu = new KeyboardShortcut((KeyCode)277, Array.Empty<KeyCode>());
			isMenuOpen = false;
			MENUX = Screen.width / 2;
			MENUY = Screen.height / 2;
			CENTERX = MENUX + (MENUWIDTH / 2 - ITEMWIDTH / 2);
		}

		private Texture2D MakeTex(int width, int height, Color col)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			Color[] array = (Color[])(object)new Color[width * height];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = col;
			}
			Texture2D val = new Texture2D(width, height);
			val.SetPixels(array);
			val.Apply();
			return val;
		}

		private void intitializeMenu()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			if (menuStyle == null)
			{
				menuStyle = new GUIStyle(GUI.skin.box);
				buttonStyle = new GUIStyle(GUI.skin.button);
				labelStyle = new GUIStyle(GUI.skin.label);
				toggleStyle = new GUIStyle(GUI.skin.toggle);
				hScrollStyle = new GUIStyle(GUI.skin.horizontalSlider);
				menuStyle.normal.textColor = Color.white;
				menuStyle.normal.background = MakeTex(2, 2, new Color(0.01f, 0.01f, 0.1f, 0.9f));
				menuStyle.fontSize = 18;
				((Object)menuStyle.normal.background).hideFlags = (HideFlags)61;
				buttonStyle.normal.textColor = Color.white;
				buttonStyle.fontSize = 18;
				labelStyle.normal.textColor = Color.white;
				labelStyle.normal.background = MakeTex(2, 2, new Color(0.01f, 0.01f, 0.1f, 0.9f));
				labelStyle.fontSize = 18;
				labelStyle.alignment = (TextAnchor)4;
				((Object)labelStyle.normal.background).hideFlags = (HideFlags)61;
				toggleStyle.normal.textColor = Color.white;
				toggleStyle.fontSize = 18;
				hScrollStyle.normal.textColor = Color.white;
				hScrollStyle.normal.background = MakeTex(2, 2, new Color(0f, 0f, 0.2f, 0.9f));
				((Object)hScrollStyle.normal.background).hideFlags = (HideFlags)61;
			}
		}

		public void OnDestroy()
		{
			TestMod.mls.LogInfo((object)"The GUILoader was destroyed :(");
		}

		public void Update()
		{
			if (((KeyboardShortcut)(ref openCloseMenu)).IsDown() && !wasKeyDown)
			{
				wasKeyDown = true;
			}
			if (((KeyboardShortcut)(ref openCloseMenu)).IsUp() && wasKeyDown)
			{
				wasKeyDown = false;
				isMenuOpen = !isMenuOpen;
				if (isMenuOpen)
				{
					Cursor.visible = true;
					Cursor.lockState = (CursorLockMode)2;
				}
				else
				{
					Cursor.visible = false;
				}
			}
		}

		public void OnGUI()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0523: Unknown result type (might be due to invalid IL or missing references)
			//IL_0563: Unknown result type (might be due to invalid IL or missing references)
			//IL_059a: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0606: Unknown result type (might be due to invalid IL or missing references)
			//IL_063c: Unknown result type (might be due to invalid IL or missing references)
			//IL_067d: Unknown result type (might be due to invalid IL or missing references)
			//IL_06be: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0740: Unknown result type (might be due to invalid IL or missing references)
			//IL_0786: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0802: Unknown result type (might be due to invalid IL or missing references)
			//IL_0842: Unknown result type (might be due to invalid IL or missing references)
			//IL_0889: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0911: Unknown result type (might be due to invalid IL or missing references)
			//IL_0953: Unknown result type (might be due to invalid IL or missing references)
			//IL_0994: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a1b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a5a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ae3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b21: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b5e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ba5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0be4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c2b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c6b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cf2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d33: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d7a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dbb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e02: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e43: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e8a: Unknown result type (might be due to invalid IL or missing references)
			if (!guiIsHost)
			{
				return;
			}
			if (menuStyle == null)
			{
				intitializeMenu();
			}
			if (isMenuOpen)
			{
				GUI.Box(new Rect((float)MENUX, (float)MENUY, (float)MENUWIDTH, (float)MENUHEIGHT), "GameMaster", menuStyle);
				toolbarInt = GUI.Toolbar(new Rect((float)MENUX, (float)(MENUY - 30), (float)MENUWIDTH, 30f), toolbarInt, toolbarStrings, buttonStyle);
				switch (toolbarInt)
				{
				case 0:
					guiSelectedEnemy = GUI.TextField(new Rect((float)(MENUX + (MENUWIDTH / 2 - ITEMWIDTH)), (float)(MENUY + 30), (float)ITEMWIDTH, 30f), guiSelectedEnemy);
					guiSpawnButtonPressed = GUI.Button(new Rect((float)(MENUX + MENUWIDTH / 2), (float)(MENUY + 30), (float)ITEMWIDTH, 30f), "Spawn Enemy", buttonStyle);
					guiSpringSpeed = GUI.HorizontalSlider(new Rect((float)CENTERX, (float)(MENUY + 160), (float)ITEMWIDTH, 30f), guiSpringSpeed, 0.1f, 150f);
					GUI.Label(new Rect((float)CENTERX, (float)(MENUY + 130), (float)ITEMWIDTH, 30f), "Speed of the CoilHead " + guiSpringSpeed, labelStyle);
					GUI.Label(new Rect((float)CENTERX, (float)(MENUY + 200), (float)ITEMWIDTH, 30f), "Jester Popup speed " + guiPopupTimer, labelStyle);
					guiPopupTimer = GUI.HorizontalSlider(new Rect((float)CENTERX, (float)(MENUY + 230), (float)ITEMWIDTH, 30f), guiPopupTimer, 0.1f, 100f);
					GUI.Label(new Rect((float)CENTERX, (float)(MENUY + 270), (float)ITEMWIDTH, 30f), "Jester cranking speed " + guiCrankingTimer, labelStyle);
					guiCrankingTimer = GUI.HorizontalSlider(new Rect((float)CENTERX, (float)(MENUY + 300), (float)ITEMWIDTH, 30f), guiCrankingTimer, 0.1f, 10f);
					GUI.Label(new Rect((float)CENTERX, (float)(MENUY + 340), (float)ITEMWIDTH, 30f), "Jester reset speed " + guiJesterResetTimer, labelStyle);
					guiJesterResetTimer = GUI.HorizontalSlider(new Rect((float)CENTERX, (float)(MENUY + 370), (float)ITEMWIDTH, 30f), guiJesterResetTimer, 5f, 5000f);
					guiEnableAIModifiers = GUI.Toggle(new Rect((float)CENTERX, (float)(MENUY + 410), (float)ITEMWIDTH, 30f), guiEnableAIModifiers, "Enable AI Modifications", toggleStyle);
					guiShouldEnemiesSpawnNaturally = GUI.Toggle(new Rect((float)CENTERX, (float)(MENUY + 440), (float)ITEMWIDTH, 30f), guiShouldEnemiesSpawnNaturally, "Should Enemies Spawn Naturally", toggleStyle);
					break;
				case 1:
					GUI.Label(new Rect((float)CENTERX, (float)(MENUY + 30), (float)ITEMWIDTH, 30f), "Server Name", labelStyle);
					guiServerName = GUI.TextField(new Rect((float)CENTERX, (float)(MENUY + 60), (float)ITEMWIDTH, 30f), guiServerName);
					GUI.Label(new Rect((float)CENTERX, (float)(MENUY + 100), (float)ITEMWIDTH, 30f), "Server Message", labelStyle);
					guiRoundPost = GUI.TextField(new Rect((float)CENTERX, (float)(MENUY + 130), (float)ITEMWIDTH, 30f), guiRoundPost);
					guiHideCommandMessage = GUI.Toggle(new Rect((float)CENTERX, (float)(MENUY + 170), (float)ITEMWIDTH, 30f), guiHideCommandMessage, "Hide Command Messages", toggleStyle);
					guiHideEnemySpawnMessages = GUI.Toggle(new Rect((float)CENTERX, (float)(MENUY + 200), (float)ITEMWIDTH, 30f), guiHideEnemySpawnMessages, "Hide Enemy Spawn Messages", toggleStyle);
					GUI.Label(new Rect((float)CENTERX, (float)(MENUY + 230), (float)ITEMWIDTH, 30f), "Command Prefix", labelStyle);
					guiPrefix = GUI.TextField(new Rect((float)CENTERX, (float)(MENUY + 260), (float)ITEMWIDTH, 30f), guiPrefix);
					GUI.Label(new Rect((float)CENTERX, (float)(MENUY + 300), (float)ITEMWIDTH, 30f), "XP Change", labelStyle);
					guiXPChange = GUI.TextField(new Rect((float)CENTERX, (float)(MENUY + 330), (float)ITEMWIDTH, 30f), guiXPChange);
					guiEnableInfiniteSprint = GUI.Toggle(new Rect((float)CENTERX, (float)(MENUY + 360), (float)ITEMWIDTH, 30f), guiEnableInfiniteSprint, "Infinite Sprint", toggleStyle);
					guiEnableInfiniteCredits = GUI.Toggle(new Rect((float)CENTERX, (float)(MENUY + 390), (float)ITEMWIDTH, 30f), guiEnableInfiniteCredits, "Infinite Credits", toggleStyle);
					guiEnableGod = GUI.Toggle(new Rect((float)CENTERX, (float)(MENUY + 420), (float)ITEMWIDTH, 30f), guiEnableGod, "God Mode", toggleStyle);
					guiEnableNightVision = GUI.Toggle(new Rect((float)CENTERX, (float)(MENUY + 450), (float)ITEMWIDTH, 30f), guiEnableNightVision, "NightVision", toggleStyle);
					guiEnableSpeedHack = GUI.Toggle(new Rect((float)CENTERX, (float)(MENUY + 480), (float)ITEMWIDTH, 30f), guiEnableSpeedHack, "SpeedHack", toggleStyle);
					break;
				case 2:
					guiEnableInfiniteDeadline = GUI.Toggle(new Rect((float)CENTERX, (float)(MENUY + 30), (float)(ITEMWIDTH + 100), 30f), guiEnableInfiniteDeadline, "Infinite Deadline(overrides all deadline settings)", toggleStyle);
					guiEnableCustomDeadline = GUI.Toggle(new Rect((float)CENTERX, (float)(MENUY + 60), (float)ITEMWIDTH, 30f), guiEnableCustomDeadline, "Custom Deadline", toggleStyle);
					guiUseRandomDeadline = GUI.Toggle(new Rect((float)CENTERX, (float)(MENUY + 90), (float)ITEMWIDTH, 30f), guiUseRandomDeadline, "Random Deadline", toggleStyle);
					GUI.Label(new Rect((float)CENTERX, (float)(MENUY + 130), (float)ITEMWIDTH, 30f), "Minimum Deadline " + guiMinimumDeadline, labelStyle);
					guiMinimumDeadline = (int)GUI.HorizontalSlider(new Rect((float)CENTERX, (float)(MENUY + 160), (float)ITEMWIDTH, 30f), (float)guiMinimumDeadline, 1f, 20f);
					GUI.Label(new Rect((float)CENTERX, (float)(MENUY + 200), (float)ITEMWIDTH, 30f), "Maximum Deadline " + guiMaximumDeadline, labelStyle);
					guiMaximumDeadline = (int)GUI.HorizontalSlider(new Rect((float)CENTERX, (float)(MENUY + 230), (float)ITEMWIDTH, 30f), (float)guiMaximumDeadline, 1f, 20f);
					guiUseCustomTimeScale = GUI.Toggle(new Rect((float)CENTERX, (float)(MENUY + 270), (float)ITEMWIDTH, 30f), guiUseCustomTimeScale, "Custom Timescale", toggleStyle);
					guiUseRandomTimeScale = GUI.Toggle(new Rect((float)CENTERX, (float)(MENUY + 300), (float)ITEMWIDTH, 30f), guiUseRandomTimeScale, "Random Timescale", toggleStyle);
					GUI.Label(new Rect((float)CENTERX, (float)(MENUY + 330), (float)ITEMWIDTH, 30f), "Minimum Timescale " + guiMinTimeScale, labelStyle);
					guiMinTimeScale = GUI.HorizontalSlider(new Rect((float)CENTERX, (float)(MENUY + 360), (float)ITEMWIDTH, 30f), guiMinTimeScale, 0.1f, 10f);
					GUI.Label(new Rect((float)CENTERX, (float)(MENUY + 400), (float)ITEMWIDTH, 30f), "Maximum Timescale " + guiMaxTimeScale, labelStyle);
					guiMaxTimeScale = GUI.HorizontalSlider(new Rect((float)CENTERX, (float)(MENUY + 430), (float)ITEMWIDTH, 30f), guiMaxTimeScale, 0.1f, 10f);
					break;
				case 3:
					guiEnableCustomBuyRate = GUI.Toggle(new Rect((float)CENTERX, (float)(MENUY + 30), (float)ITEMWIDTH, 30f), guiEnableCustomBuyRate, "Custom Buyrate", toggleStyle);
					guiUseRandomBuyRate = GUI.Toggle(new Rect((float)CENTERX, (float)(MENUY + 60), (float)ITEMWIDTH, 30f), guiUseRandomBuyRate, "Random Buyrate", toggleStyle);
					GUI.Label(new Rect((float)CENTERX, (float)(MENUY + 110), (float)ITEMWIDTH, 30f), "Min Buy Rate " + guiMinBuyRate, labelStyle);
					guiMinBuyRate = GUI.HorizontalSlider(new Rect((float)CENTERX, (float)(MENUY + 140), (float)ITEMWIDTH, 30f), guiMinBuyRate, -1f, 10f);
					GUI.Label(new Rect((float)CENTERX, (float)(MENUY + 180), (float)ITEMWIDTH, 30f), "Max Buy Rate " + guiMaxBuyRate, labelStyle);
					guiMaxBuyRate = GUI.HorizontalSlider(new Rect((float)CENTERX, (float)(MENUY + 210), (float)ITEMWIDTH, 30f), guiMaxBuyRate, -1f, 10f);
					guiEnableScrapModifiers = GUI.Toggle(new Rect((float)CENTERX, (float)(MENUY + 260), (float)ITEMWIDTH, 30f), guiEnableScrapModifiers, "Enable Scrap Modifiers", toggleStyle);
					GUI.Label(new Rect((float)CENTERX, (float)(MENUY + 310), (float)ITEMWIDTH, 30f), "Minimum Amount of Scrap " + guiMinScrap, labelStyle);
					guiMinScrap = (int)GUI.HorizontalSlider(new Rect((float)CENTERX, (float)(MENUY + 340), (float)ITEMWIDTH, 30f), (float)guiMinScrap, 0f, 500f);
					GUI.Label(new Rect((float)CENTERX, (float)(MENUY + 380), (float)ITEMWIDTH, 30f), "Maximum Amount of Scrap " + guiMaxScrap, labelStyle);
					guiMaxScrap = (int)GUI.HorizontalSlider(new Rect((float)CENTERX, (float)(MENUY + 410), (float)ITEMWIDTH, 30f), (float)guiMaxScrap, 0f, 500f);
					GUI.Label(new Rect((float)CENTERX, (float)(MENUY + 450), (float)ITEMWIDTH, 30f), "Min Scrap Value " + guiMinScrapValue, labelStyle);
					guiMinScrapValue = (int)GUI.HorizontalSlider(new Rect((float)CENTERX, (float)(MENUY + 480), (float)ITEMWIDTH, 30f), (float)guiMinScrapValue, 0f, 100000f);
					GUI.Label(new Rect((float)CENTERX, (float)(MENUY + 520), (float)ITEMWIDTH, 30f), "Max Scrap Value " + guiMaxScrapValue, labelStyle);
					guiMaxScrapValue = (int)GUI.HorizontalSlider(new Rect((float)CENTERX, (float)(MENUY + 550), (float)ITEMWIDTH, 30f), (float)guiMaxScrapValue, 0f, 100000f);
					break;
				}
			}
		}
	}
}
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
	}
	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 localPlayerController9 = StartOfRound.Instance.localPlayerController;
				float drunkness = Math.Min((float)duration * 10f, 1200f);
				localPlayerController9.drunkness = drunkness;
				localPlayerController9.drunknessSpeed = 1f;
				localPlayerController9.drunknessInertia = 20f;
				break;
			}
			case BuffType.LOW_PITCH:
				TestMod.ActionQueue.Enqueue(delegate
				{
					HUDManager.Instance.AddTextToChatOnServer("<size=0>/cc_pitch_0.65</size>", -1);
				});
				break;
			case BuffType.HIGH_PITCH:
				TestMod.ActionQueue.Enqueue(delegate
				{
					HUDManager.Instance.AddTextToChatOnServer("<size=0>/cc_pitch_1.5</size>", -1);
				});
				break;
			case BuffType.NIGHT_VISION:
			{
				PlayerControllerB localPlayerController8 = StartOfRound.Instance.localPlayerController;
				TestMod.nightVision = true;
				break;
			}
			case BuffType.FREEZE:
			{
				PlayerControllerB localPlayerController7 = StartOfRound.Instance.localPlayerController;
				localPlayerController7.movementSpeed = 0f;
				break;
			}
			case BuffType.HYPER_MOVE:
			{
				PlayerControllerB localPlayerController6 = StartOfRound.Instance.localPlayerController;
				localPlayerController6.movementSpeed = 18f;
				break;
			}
			case BuffType.FAST_MOVE:
			{
				PlayerControllerB localPlayerController5 = StartOfRound.Instance.localPlayerController;
				localPlayerController5.movementSpeed = 9f;
				break;
			}
			case BuffType.SLOW_MOVE:
			{
				PlayerControllerB localPlayerController4 = StartOfRound.Instance.localPlayerController;
				localPlayerController4.movementSpeed = 1.25f;
				break;
			}
			case BuffType.ULTRA_JUMP:
			{
				PlayerControllerB localPlayerController3 = StartOfRound.Instance.localPlayerController;
				localPlayerController3.jumpForce = 50f;
				break;
			}
			case BuffType.HIGH_JUMP:
			{
				PlayerControllerB localPlayerController2 = StartOfRound.Instance.localPlayerController;
				localPlayerController2.jumpForce = 35f;
				break;
			}
			case BuffType.LOW_JUMP:
			{
				PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
				localPlayerController.jumpForce = 5f;
				break;
			}
			case BuffType.OHKO:
			case BuffType.INVUL:
			case BuffType.NOSTAM:
			case BuffType.INFSTAM:
				break;
			}
		}

		public void removeBuff()
		{
			switch (type)
			{
			case BuffType.DRUNK:
			{
				PlayerControllerB localPlayerController4 = StartOfRound.Instance.localPlayerController;
				localPlayerController4.drunkness = 0f;
				localPlayerController4.drunknessSpeed = 0f;
				localPlayerController4.drunknessInertia = 0f;
				break;
			}
			case BuffType.HIGH_PITCH:
			case BuffType.LOW_PITCH:
				TestMod.ActionQueue.Enqueue(delegate
				{
					HUDManager.Instance.AddTextToChatOnServer("<size=0>/cc_pitch_1.0</size>", -1);
				});
				break;
			case BuffType.NIGHT_VISION:
			{
				PlayerControllerB localPlayerController3 = StartOfRound.Instance.localPlayerController;
				TestMod.nightVision = false;
				break;
			}
			case BuffType.HYPER_MOVE:
			case BuffType.FAST_MOVE:
			case BuffType.SLOW_MOVE:
			case BuffType.FREEZE:
			{
				PlayerControllerB localPlayerController2 = StartOfRound.Instance.localPlayerController;
				localPlayerController2.movementSpeed = 4.6f;
				break;
			}
			case BuffType.ULTRA_JUMP:
			case BuffType.HIGH_JUMP:
			case BuffType.LOW_JUMP:
			{
				PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
				localPlayerController.jumpForce = 13f;
				break;
			}
			case BuffType.OHKO:
			case BuffType.INVUL:
				TestMod.ActionQueue.Enqueue(delegate
				{
					PlayerControllerB localPlayerController5 = StartOfRound.Instance.localPlayerController;
					localPlayerController5.health = (int)old;
					if (localPlayerController5.health >= 20)
					{
						localPlayerController5.MakeCriticallyInjured(false);
					}
					if (localPlayerController5.health < 10)
					{
						localPlayerController5.MakeCriticallyInjured(true);
					}
					HUDManager.Instance.UpdateHealthUI(localPlayerController5.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)
			{
				TestMod.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)
			{
				TestMod.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)
			{
				TestMod.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)
			{
				TestMod.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)
			{
				TestMod.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
				},
				{
					"launch",
					CrowdDelegates.Launch
				},
				{
					"fast",
					CrowdDelegates.FastMove
				},
				{
					"slow",
					CrowdDelegates.SlowMove
				},
				{
					"hyper",
					CrowdDelegates.HyperMove
				},
				{
					"freeze",
					CrowdDelegates.Freeze
				},
				{
					"drunk",
					CrowdDelegates.Drunk
				},
				{
					"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_coil",
					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
				},
				{
					"webs",
					CrowdDelegates.CreateWebs
				},
				{
					"killenemies",
					CrowdDelegates.KillEnemies
				},
				{
					"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_coil",
					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
				},
				{
					"give_0",
					CrowdDelegates.GiveItem
				},
				{
					"give_1",
					CrowdDelegates.GiveItem
				},
				{
					"give_2",
					CrowdDelegates.GiveItem
				},
				{
					"give_3",
					CrowdDelegates.GiveItem
				},
				{
					"give_4",
					CrowdDelegates.GiveItem
				},
				{
					"give_5",
					CrowdDelegates.GiveItem
				},
				{
					"give_6",
					CrowdDelegates.GiveItem
				},
				{
					"give_7",
					CrowdDelegates.GiveItem
				},
				{
					"give_8",
					CrowdDelegates.GiveItem
				},
				{
					"give_9",
					CrowdDelegates.GiveItem
				},
				{
					"give_10",
					CrowdDelegates.GiveItem
				},
				{
					"give_11",
					CrowdDelegates.GiveItem
				},
				{
					"givem_tragedymask",
					CrowdDelegates.GiveMask
				},
				{
					"givem_comedymask",
					CrowdDelegates.GiveMask
				},
				{
					"cgive_0",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_1",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_2",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_3",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_4",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_5",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_6",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_7",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_8",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_9",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_10",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgive_11",
					CrowdDelegates.GiveCrewItem
				},
				{
					"cgivem_tragedymask",
					CrowdDelegates.GiveCrewMask
				},
				{
					"cgivem_comedymask",
					CrowdDelegates.GiveCrewMask
				},
				{
					"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_0",
					CrowdDelegates.BuyItem
				},
				{
					"buy_1",
					CrowdDelegates.BuyItem
				},
				{
					"buy_2",
					CrowdDelegates.BuyItem
				},
				{
					"buy_3",
					CrowdDelegates.BuyItem
				},
				{
					"buy_4",
					CrowdDelegates.BuyItem
				},
				{
					"buy_5",
					CrowdDelegates.BuyItem
				},
				{
					"buy_6",
					CrowdDelegates.BuyItem
				},
				{
					"buy_7",
					CrowdDelegates.BuyItem
				},
				{
					"buy_8",
					CrowdDelegates.BuyItem
				},
				{
					"buy_9",
					CrowdDelegates.BuyItem
				},
				{
					"buy_10",
					CrowdDelegates.BuyItem
				},
				{
					"buy_11",
					CrowdDelegates.BuyItem
				},
				{
					"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
				}
			};
		}

		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()
		{
			TestMod.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)
			{
				TestMod.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)
			{
				TestMod.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
					{
						TestMod.mls.LogInfo((object)"Failed to connect to Crowd Control");
					}
					Socket.Close();
				}
				catch (Exception)
				{
					TestMod.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)
				{
					TestMod.mls.LogInfo((object)"Disconnected from Crowd Control");
					Socket.Close();
				}
			}
		}

		public bool isReady()
		{
			try
			{
				if (!StartOfRound.Instance.shipHasLanded)
				{
					return false;
				}
				if (RoundManager.Instance.currentLevel.PlanetName.ToLower().Contains("gordion"))
				{
					return false;
				}
				if (RoundManager.Instance.currentLevel.PlanetName.ToLower().Contains("company"))
				{
					return false;
				}
			}
			catch (Exception ex)
			{
				TestMod.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 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
				{
					TestMod.test = true;
				}
			}
			catch (Exception ex)
			{
				status = CrowdResponse.Status.STATUS_RETRY;
				TestMod.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
				{
					TestMod.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)
						if (TestMod.isHost)
						{
							playerRef.KillPlayer(((Component)playerRef).transform.up * 100f, true, (CauseOfDeath)0, 0);
						}
						else
						{
							HUDManager.Instance.AddTextToChatOnServer($"<size=0>/cc_kill_{(int)playerRef.playerClientId}</size>", -1);
						}
					});
				}
			}
			catch (Exception ex)
			{
				status = CrowdResponse.Status.STATUS_RETRY;
				TestMod.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
				{
					TestMod.ActionQueue.Enqueue(delegate
					{
						HUDManager.Instance.AddTextToChatOnServer($"<size=0>/cc_kill_{(int)player.playerClientId}</size>", -1);
					});
				}
			}
			catch (Exception ex)
			{
				status = CrowdResponse.Status.STATUS_RETRY;
				TestMod.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
				{
					TestMod.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;
				TestMod.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
				{
					TestMod.ActionQueue.Enqueue(delegate
					{
						HUDManager.Instance.AddTextToChatOnServer($"<size=0>/cc_damage_{(int)player.playerClientId}</size>", -1);
					});
				}
			}
			catch (Exception ex)
			{
				status = CrowdResponse.Status.STATUS_RETRY;
				TestMod.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
				{
					TestMod.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;
				TestMod.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
				{
					TestMod.ActionQueue.Enqueue(delegate
					{
						HUDManager.Instance.AddTextToChatOnServer($"<size=0>/cc_heal_{(int)player.playerClientId}</size>", -1);
					});
				}
			}
			catch (Exception ex)
			{
				status = CrowdResponse.Status.STATUS_RETRY;
				TestMod.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString()));
			}
			return new CrowdResponse(req.GetReqID(), status, message);
		}

		public static CrowdResponse Launch(ControlClient client, CrowdRequest req)
		{
			CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS;
			string message = "";
			try
			{
				PlayerControllerB playerRef = StartOfRound.Instance.localPlayerController;
				if (StartOfRound.Instance.timeSinceRoundStarted < 2f || !playerRef.playersManager.shipDoorsEnabled)
				{
					status = CrowdResponse.Status.STATUS_RETRY;
				}
				else
				{
					TestMod.ActionQueue.Enqueue(delegate
					{
						//IL_0036: Unknown result type (might be due to invalid IL or missing references)
						//IL_0046: Unknown result type (might be due to invalid IL or missing references)
						//IL_0050: Unknown result type (might be due to invalid IL or missing references)
						//IL_0055: Unknown result type (might be due to invalid IL or missing references)
						//IL_005a: Unknown result type (might be due to invalid IL or missing references)
						//IL_005b: Unknown result type (might be due to invalid IL or missing references)
						//IL_008d: Unknown result type (might be due to invalid IL or missing references)
						int num = ~LayerMask.GetMask(new string[1] { "Room" });
						num = ~LayerMask.GetMask(new string[1] { "Colliders" });
						Vector3 val = ((Component)playerRef).transform.position - ((Component)playerRef).transform.up * 5f;
						Collider[] array = Physics.OverlapSphere(val, 10f, num);
						for (int i = 0; i < array.Length; i++)
						{
							Rigidbody component = ((Component)array[i