Decompiled source of SusCompany v1.1.0

TestMod.dll

Decompiled 8 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LCShrinkRay.comp;
using LCShrinkRay.coroutines;
using LC_API.ClientAPI;
using LC_API.GameInterfaceAPI;
using LC_API.GameInterfaceAPI.Events.EventArgs.Player;
using LC_API.GameInterfaceAPI.Events.Handlers;
using LC_API.GameInterfaceAPI.Features;
using LC_API.Networking;
using SusMod;
using SusMod.Patches;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SusMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SusMod")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2fac2737-832e-47bc-a6e6-a6b97c35c5be")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
internal class Networking
{
	public List<int> ImpostorList { get; set; }

	public bool Vents { get; set; }
}
namespace LCShrinkRay.coroutines
{
	internal class RenderVents : MonoBehaviour
	{
		public GameObject go { get; private set; }

		public static void StartRoutine(GameObject gameObject)
		{
			RenderVents renderVents = gameObject.AddComponent<RenderVents>();
			renderVents.go = gameObject;
			((MonoBehaviour)renderVents).StartCoroutine(renderVents.run());
		}

		private IEnumerator run()
		{
			yield return (object)new WaitForSeconds(1f);
			EnemyVent[] vents = Object.FindObjectsOfType<EnemyVent>();
			EnemyVent[] array = vents;
			foreach (EnemyVent vent in array)
			{
				GameObject gameObject = ((Component)((Component)((Component)vent).gameObject.transform.Find("Hinge")).gameObject.transform.Find("VentCover")).gameObject;
				if ((Object)(object)gameObject == (Object)null)
				{
					SusModBase.mls.LogInfo((object)"A vent gameObject was null.");
					continue;
				}
				MeshRenderer meshRenderer = gameObject.GetComponent<MeshRenderer>();
				if ((Object)(object)meshRenderer == (Object)null)
				{
					SusModBase.mls.LogInfo((object)"A vent mesh renderer was null.");
				}
				else
				{
					((Renderer)meshRenderer).enabled = true;
				}
			}
		}
	}
}
namespace LCShrinkRay.comp
{
	internal class VentsPatch
	{
		internal class SussifiedVent : NetworkBehaviour
		{
			public EnemyVent siblingVent { get; set; }

			internal void Start()
			{
			}

			internal void TeleportPlayer(PlayerControllerB player)
			{
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				Transform transform = ((Component)player).gameObject.transform;
				if ((Object)(object)siblingVent != (Object)null)
				{
					siblingVent.ventAudio.Play();
					transform.position = ((Component)siblingVent.floorNode).transform.position;
				}
				else
				{
					transform.position = new Vector3(7.9186f, 0.286f, -14.1901f);
				}
			}
		}

		private static EnemyVent[] getAllVents()
		{
			if (RoundManager.Instance.allEnemyVents != null && RoundManager.Instance.allEnemyVents.Length != 0)
			{
				return RoundManager.Instance.allEnemyVents;
			}
			return Object.FindObjectsOfType<EnemyVent>();
		}

		public static void SussifyAll()
		{
			Random random = new Random(StartOfRound.Instance.randomMapSeed);
			if (!SusModBase.ConfigVents.Value)
			{
				SusModBase.mls.LogInfo((object)"Sussification of vents disabled.");
				return;
			}
			if (!SusModBase.impostorsIDs.Contains((int)Player.LocalPlayer.ClientId))
			{
				SusModBase.mls.LogInfo((object)"Sussification of vents only for sussy players.");
				return;
			}
			SusModBase.mls.LogInfo((object)"SUSSIFYING VENTS");
			EnemyVent[] allVents = getAllVents();
			if (allVents == null || allVents.Length == 0)
			{
				SusModBase.mls.LogInfo((object)"No vents to sussify.");
				return;
			}
			GameObject gameObject = GameObject.Find("EntranceTeleportA(Clone)");
			for (int i = 0; i < allVents.Length; i++)
			{
				SusModBase.mls.LogInfo((object)("SUSSIFYING VENT " + i));
				int num = allVents.Length - i - 1;
				if (num == i)
				{
					num = random.Next(0, allVents.Length);
				}
				SusModBase.mls.LogInfo((object)("\tPairing with vent " + num));
				sussify(allVents[i], allVents[num]);
			}
			RenderVents.StartRoutine(gameObject);
		}

		public static void sussify(EnemyVent enemyVent, EnemyVent siblingVent)
		{
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Expected O, but got Unknown
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Expected O, but got Unknown
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Expected O, but got Unknown
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Expected O, but got Unknown
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			GameObject gameObject = ((Component)((Component)((Component)enemyVent).gameObject.transform.Find("Hinge")).gameObject.transform.Find("VentCover")).gameObject;
			if (!Object.op_Implicit((Object)(object)gameObject))
			{
				SusModBase.mls.LogInfo((object)"Vent has no cover to sussify");
				return;
			}
			gameObject.GetComponent<MeshRenderer>();
			gameObject.tag = "InteractTrigger";
			gameObject.layer = LayerMask.NameToLayer("InteractableObject");
			SussifiedVent sussifiedVent = ((Component)enemyVent).gameObject.AddComponent<SussifiedVent>();
			sussifiedVent.siblingVent = siblingVent;
			InteractTrigger val = gameObject.AddComponent<InteractTrigger>();
			gameObject.AddComponent<BoxCollider>();
			GameObject obj = GameObject.Find("StartGameLever");
			val.hoverIcon = ((obj == null) ? null : obj.GetComponent<InteractTrigger>()?.hoverIcon);
			val.hoverTip = "Enter : [LMB]";
			val.interactable = true;
			val.oneHandedItemAllowed = true;
			val.twoHandedItemAllowed = true;
			val.holdInteraction = true;
			val.timeToHold = 1.5f;
			val.timeToHoldSpeedMultiplier = 1f;
			val.holdingInteractEvent = new InteractEventFloat();
			val.onInteract = new InteractEvent();
			val.onInteractEarly = new InteractEvent();
			val.onStopInteract = new InteractEvent();
			val.onCancelAnimation = new InteractEvent();
			((UnityEvent<PlayerControllerB>)(object)val.onInteract).AddListener((UnityAction<PlayerControllerB>)delegate(PlayerControllerB player)
			{
				sussifiedVent.TeleportPlayer(player);
			});
			((Behaviour)val).enabled = true;
			gameObject.GetComponent<Renderer>().enabled = true;
			SusModBase.mls.LogInfo((object)("VentCover Object: " + ((Object)gameObject).name));
			SusModBase.mls.LogInfo((object)("VentCover Renderer Enabled: " + gameObject.GetComponent<Renderer>().enabled));
			SusModBase.mls.LogInfo((object)("Hover Icon: " + (((Object)(object)val.hoverIcon != (Object)null) ? ((Object)val.hoverIcon).name : "null")));
		}

		public static void rerenderAllSussified()
		{
			MeshRenderer val = ((Component)((Component)GameObject.Find("VentEntrance").gameObject.transform.Find("Hinge")).gameObject.transform.Find("VentCover")).gameObject.GetComponentsInChildren<MeshRenderer>()[0];
			((Renderer)val).enabled = true;
		}

		public static void unsussifyAll()
		{
			EnemyVent[] allVents = getAllVents();
			foreach (EnemyVent enemyVent in allVents)
			{
				unsussify(enemyVent);
			}
		}

		public static void unsussify(EnemyVent enemyVent)
		{
			GameObject gameObject = ((Component)((Component)((Component)enemyVent).gameObject.transform.Find("Hinge")).gameObject.transform.Find("VentCover")).gameObject;
			if (Object.op_Implicit((Object)(object)gameObject))
			{
				SusModBase.mls.LogInfo((object)"0");
				if ((Object)(object)((Component)enemyVent).gameObject.AddComponent<SussifiedVent>() != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)enemyVent).gameObject.AddComponent<SussifiedVent>());
				}
				if ((Object)(object)gameObject.GetComponent<BoxCollider>() != (Object)null)
				{
					Object.Destroy((Object)(object)gameObject.GetComponent<BoxCollider>());
				}
				if ((Object)(object)gameObject.GetComponent<InteractTrigger>() != (Object)null)
				{
					Object.Destroy((Object)(object)gameObject.GetComponent<InteractTrigger>());
				}
			}
		}
	}
}
namespace TestMod.Patches
{
	[HarmonyPatch(typeof(StartMatchLever))]
	internal class LeverPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void ImpLever()
		{
			try
			{
				if (SusModBase.impostorsIDs.Contains((int)Player.LocalPlayer.ClientId))
				{
					InteractTrigger triggerScript = Object.FindObjectOfType<StartMatchLever>().triggerScript;
					triggerScript.interactable = false;
					triggerScript.disabledHoverTip = "Impostor can't start the ship";
				}
			}
			catch
			{
			}
		}
	}
}
namespace SusMod
{
	[BepInPlugin("Sussy", "SusCompany", "1.1.0")]
	public class SusModBase : BaseUnityPlugin
	{
		private const string modGUID = "Sussy";

		private const string modName = "SusCompany";

		private const string modVersion = "1.1.0";

		private readonly Harmony harmony = new Harmony("Sussy");

		private static SusModBase Instance;

		public static ManualLogSource mls;

		public static List<int> impostorsIDs = new List<int>();

		public static bool DebugMode = false;

		public static ConfigEntry<float> ConfigimpostorSpawnRate;

		public static ConfigEntry<bool> ConfigisImposterCountRandom;

		public static ConfigEntry<bool> ConfigVents;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			ConfigimpostorSpawnRate = ((BaseUnityPlugin)this).Config.Bind<float>("General", "SpawnRate", 0.25f, "Spawn rate of impostors");
			ConfigisImposterCountRandom = ((BaseUnityPlugin)this).Config.Bind<bool>("General.Toggles", "IsRandomSpawnRate", true, "If true, impostor spawn rate will be randomized between 0 and SpawnRate");
			ConfigVents = ((BaseUnityPlugin)this).Config.Bind<bool>("General.Toggles", "AreVentsOn", true, "If true, impostor is albe to teleports beetwen vents");
			mls = Logger.CreateLogSource("Sussy");
			mls.LogInfo((object)"The SusCompany mod has awaken");
			harmony.PatchAll();
			Player.Dying += OtherFunctions.OnDiedCheckForImpostorVictory;
			Player.Left += OtherFunctions.OnLeftCheckForImpostorVictory;
			Network.RegisterAll();
			ConsoleCommands.RegisterConsoleCommands();
		}
	}
}
namespace SusMod.Patches
{
	[HarmonyPatch(typeof(EnemyAI))]
	internal class EnemyAiPatch
	{
		[HarmonyPatch("PlayerIsTargetable")]
		[HarmonyPostfix]
		public static void MonstersDontTarget(PlayerControllerB playerScript, ref bool __result)
		{
			if (SusModBase.impostorsIDs.Contains((int)playerScript.actualClientId))
			{
				__result = false;
				SusModBase.mls.LogInfo((object)("Player " + playerScript.actualClientId + " is impostor and is not targetable"));
			}
		}

		[HarmonyPatch(typeof(EnemyAI), "MeetsStandardPlayerCollisionConditions")]
		[HarmonyPostfix]
		public static void MeetsStandardPlayerCollisionConditions(ref PlayerControllerB __result)
		{
			try
			{
				if (SusModBase.impostorsIDs.Contains((int)__result.actualClientId))
				{
					SusModBase.mls.LogInfo((object)("Player " + __result.actualClientId + " is impostor and shouldnt colide with mobs"));
					__result = null;
				}
			}
			catch
			{
			}
		}

		[HarmonyPatch("CheckLineOfSightForPlayer")]
		[HarmonyPostfix]
		public static void CheckLineOfSightForPlayerOverwrite(ref PlayerControllerB __result)
		{
			try
			{
				if (SusModBase.impostorsIDs.Contains((int)__result.actualClientId))
				{
					SusModBase.mls.LogInfo((object)("Player " + __result.actualClientId + " is impostor and should not be in line of sight check"));
					__result = null;
				}
			}
			catch
			{
			}
		}
	}
	internal class NetworkingPatch
	{
		public static void SynchronizeImpList()
		{
			SusModBase.mls.LogInfo((object)"Sending imp list to clients");
			Network.Broadcast<Networking>("SyncImpList", new Networking
			{
				ImpostorList = SusModBase.impostorsIDs,
				Vents = SusModBase.ConfigVents.Value
			});
			if (SusModBase.ConfigVents.Value)
			{
				VentsPatch.SussifyAll();
			}
		}
	}
	internal class ConsoleCommands
	{
		public static void RegisterConsoleCommands()
		{
			SusModBase.mls.LogInfo((object)"Registering console commands");
			CommandHandler.RegisterCommand("susmax", (Action<string[]>)delegate(string[] args)
			{
				if (CheckConsoleCommand())
				{
					if (int.TryParse(args[0], out var result) && result <= 100 && result >= 0)
					{
						SusModBase.mls.LogInfo((object)("Impostors chance changed to " + args[0].ToString() + "%"));
						SusModBase.ConfigimpostorSpawnRate.Value = float.Parse(args[0]) / 100f;
						Player.LocalPlayer.QueueTip("Succes", "Impostors chance changed succesfuly to " + args[0].ToString() + "%", 1f, 0, false, false, "LC_Tip1");
					}
					else
					{
						SusModBase.mls.LogInfo((object)"Invalid argument");
						Player.LocalPlayer.QueueTip("Error", "Invalid argument - accepted arguments: [0-100%]", 3f, 0, true, false, "LC_Tip1");
					}
				}
			});
			CommandHandler.RegisterCommand("susrandom", (Action<string[]>)delegate(string[] args)
			{
				if (CheckConsoleCommand())
				{
					if (args[0] == "yes" || args[0] == "true" || args[0] == "1")
					{
						SusModBase.mls.LogInfo((object)"Impostors Random changed to true");
						SusModBase.ConfigisImposterCountRandom.Value = true;
						Player.LocalPlayer.QueueTip("Succes", "Impostors Randomization changed succesfuly to true ", 1f, 0, false, false, "LC_Tip1");
					}
					else if (args[0] == "no" || args[0] == "false" || args[0] == "0")
					{
						SusModBase.mls.LogInfo((object)"Impostors Random changed to false");
						SusModBase.ConfigisImposterCountRandom.Value = false;
						Player.LocalPlayer.QueueTip("Succes", "Impostors Randomization changed succesfuly to false ", 1f, 0, false, false, "LC_Tip1");
					}
					else
					{
						SusModBase.mls.LogInfo((object)"Invalid argument");
						Player.LocalPlayer.QueueTip("Error", "Invalid argument - accepted arguments: yes , no", 3f, 0, true, false, "LC_Tip1");
					}
				}
			});
			CommandHandler.RegisterCommand("susdebug", (Action<string[]>)delegate
			{
				SusModBase.DebugMode = true;
				SusModBase.mls.LogInfo((object)"Debug mode enabled");
				Player.LocalPlayer.QueueTip("Succes", "Debug mode enabled", 1f, 0, false, false, "LC_Tip1");
			});
			CommandHandler.RegisterCommand("susvent", (Action<string[]>)delegate(string[] args)
			{
				if (CheckConsoleCommand())
				{
					if (args[0] == "yes" || args[0] == "true" || args[0] == "1")
					{
						SusModBase.mls.LogInfo((object)"Impostors Vents changed to true");
						SusModBase.ConfigVents.Value = true;
						Player.LocalPlayer.QueueTip("Succes", "Impostors Vents changed succesfuly to true ", 1f, 0, false, false, "LC_Tip1");
					}
					else if (args[0] == "no" || args[0] == "false" || args[0] == "0")
					{
						SusModBase.mls.LogInfo((object)"Impostors Vents changed to false");
						SusModBase.ConfigVents.Value = false;
						Player.LocalPlayer.QueueTip("Succes", "Impostors Vents changed succesfuly to false ", 1f, 0, false, false, "LC_Tip1");
					}
					else
					{
						SusModBase.mls.LogInfo((object)"Invalid argument");
						Player.LocalPlayer.QueueTip("Error", "Invalid argument - accepted arguments: yes , no", 3f, 0, true, false, "LC_Tip1");
					}
				}
			});
			CommandHandler.RegisterCommand("sushelp", (Action<string[]>)delegate
			{
				Player.LocalPlayer.QueueTip("HELPING", "/susmax [% of all players] | /susrandom [yes,no] | /susvent [yes,no] ", 5f, 0, false, false, "LC_Tip1");
			});
		}

		public static bool CheckConsoleCommand()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			if ((int)GameState.ShipState == 0)
			{
				if (Player.LocalPlayer.IsHost)
				{
					return true;
				}
				SusModBase.mls.LogInfo((object)"You are not the host");
				Player.LocalPlayer.QueueTip("Error", "You are not the host", 3f, 0, true, false, "LC_Tip1");
			}
			else
			{
				SusModBase.mls.LogInfo((object)"Can't change impostors config while not in orbit");
				Player.LocalPlayer.QueueTip("Error", "Can't change impostors config while not in orbit", 3f, 0, true, false, "LC_Tip1");
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(Turret))]
	internal class TurretPach
	{
		[HarmonyPatch("CheckForPlayersInLineOfSight")]
		[HarmonyPostfix]
		public static void ExcludeImposterFromLineOfSight(ref PlayerControllerB __result)
		{
			try
			{
				if (SusModBase.impostorsIDs.Contains((int)__result.actualClientId))
				{
					SusModBase.mls.LogInfo((object)("Player " + __result.actualClientId + " is impostor and is not targetable by turret"));
					__result = null;
				}
			}
			catch
			{
			}
		}
	}
	internal class OtherFunctions
	{
		public static void CheckForImpostorVictory()
		{
			SusModBase.mls.LogInfo((object)"Checking for Impostor Victory");
			int num = 0;
			IEnumerator<Player> enumerator = Player.ActiveList.GetEnumerator();
			while (enumerator.MoveNext())
			{
				if (!enumerator.Current.IsDead && !SusModBase.impostorsIDs.Contains((int)enumerator.Current.ClientId))
				{
					num++;
				}
			}
			SusModBase.mls.LogInfo((object)("aliveCrewMates is : " + num));
			if (num == 0)
			{
				SusModBase.mls.LogInfo((object)"Impostors Won");
				StartOfRound.Instance.ShipLeaveAutomatically(false);
			}
		}

		public static void OnDiedCheckForImpostorVictory(DyingEventArgs dyingEventArgs)
		{
			CheckForImpostorVictory();
		}

		public static void OnLeftCheckForImpostorVictory(LeftEventArgs leftEventArgs)
		{
			if (leftEventArgs.Player.IsLocalPlayer)
			{
				SusModBase.mls.LogInfo((object)"Local player has left, Clearing Player.Dictionary");
				Player.Dictionary.Clear();
			}
			CheckForImpostorVictory();
		}

		public static void RemoveImposter()
		{
			SusModBase.impostorsIDs.Clear();
			Player.LocalPlayer.PlayerController.nightVision.intensity = 1000f;
			Player.LocalPlayer.PlayerController.nightVision.range = 2000f;
			((Behaviour)Player.LocalPlayer.PlayerController.nightVision).enabled = false;
			SusModBase.mls.LogInfo((object)"Removing Impostors");
		}

		public static void GetImpostorStartingItem(int ItemNumber, Player player)
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			string text = ItemNumber switch
			{
				1 => "Shovel", 
				2 => "Tragedy", 
				3 => "Extension ladder", 
				4 => "Zap gun", 
				5 => "Stun grenade", 
				6 => "Shotgun", 
				7 => "Key", 
				_ => "", 
			};
			SusModBase.mls.LogInfo((object)("itemNameIm is:" + text));
			SusModBase.mls.LogInfo((object)("ItemNumber is:" + ItemNumber));
			Item val = Item.CreateAndSpawnItem(text, false, player.Position, default(Quaternion));
			SusModBase.mls.LogInfo((object)("item is:" + (object)val));
			val.ItemProperties.itemName = "Impostor's " + text;
			val.ItemProperties.twoHanded = false;
			val.ItemProperties.isConductiveMetal = false;
			val.ItemProperties.isScrap = false;
			if (text == "Tragedy")
			{
				val.ScanNodeProperties.maxRange = 1;
			}
			SusModBase.mls.LogInfo((object)("Testing item name" + ((Object)val).name));
			SusModBase.mls.LogInfo((object)("Testing player name" + ((Object)player).name));
			SusModBase.mls.LogInfo((object)"Trying to add item to slot");
			if (player.IsLocalPlayer)
			{
				try
				{
					Player.LocalPlayer.Inventory.TryAddItemToSlot(val, 3, false);
					return;
				}
				catch
				{
					SusModBase.mls.LogInfo((object)"Failed to add item to LOCAL slot 3 ");
					return;
				}
			}
			try
			{
				player.Inventory.TryAddItemToSlot(val, 3, false);
			}
			catch
			{
				SusModBase.mls.LogInfo((object)"Failed to add item to slot 3");
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void PlayerControllerUpdate()
		{
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			IEnumerator<Player> enumerator = Player.ActiveList.GetEnumerator();
			while (enumerator.MoveNext())
			{
				if (SusModBase.impostorsIDs.Contains((int)enumerator.Current.ClientId) && enumerator.Current.IsControlled && SusModBase.impostorsIDs.Contains((int)Player.LocalPlayer.ClientId))
				{
					enumerator.Current.PlayerController.usernameBillboardText.canvasRenderer.SetColor(Color.red);
					enumerator.Current.PlayerController.usernameAlpha.alpha = 1f;
				}
				else
				{
					enumerator.Current.PlayerController.usernameBillboardText.canvasRenderer.SetColor(Color.white);
				}
			}
			try
			{
				if (SusModBase.impostorsIDs.Contains((int)Player.LocalPlayer.ClientId))
				{
					Player.LocalPlayer.PlayerController.sprintMeter = 1f;
					((Behaviour)Player.LocalPlayer.PlayerController.nightVision).enabled = true;
				}
			}
			catch
			{
				SusModBase.mls.LogInfo((object)"Failed to get Player.LocalPlayer.ClientId");
			}
			if (UnityInput.Current.GetKeyDown("F5"))
			{
				SusModBase.mls.LogInfo((object)"F5 pressed");
				if (SusModBase.DebugMode)
				{
					int ___randomMapSeed = 111111111;
					int ___currentLevelID = 4;
					if (!SusModBase.impostorsIDs.Contains((int)Player.LocalPlayer.ClientId))
					{
						StartOfRoundPatch.ImpostorStartGame(ref ___randomMapSeed, ref ___currentLevelID);
					}
				}
			}
			if (UnityInput.Current.GetKeyDown("F6"))
			{
				SusModBase.mls.LogInfo((object)"F6 pressed");
				if (SusModBase.DebugMode)
				{
					OtherFunctions.RemoveImposter();
				}
			}
			if (UnityInput.Current.GetKeyDown("F7"))
			{
				SusModBase.mls.LogInfo((object)"F7 pressed");
				if (SusModBase.DebugMode)
				{
					OtherFunctions.GetImpostorStartingItem(7, Player.LocalPlayer);
				}
			}
			if (UnityInput.Current.GetKeyDown("F8"))
			{
				SusModBase.mls.LogInfo((object)"F8 pressed");
				if (SusModBase.DebugMode)
				{
					Player.LocalPlayer.PlayerController.movementSpeed = 30f;
					Player.LocalPlayer.PlayerController.climbSpeed = 100f;
				}
			}
			if (UnityInput.Current.GetKeyDown("F9"))
			{
				SusModBase.mls.LogInfo((object)"F9 pressed");
				if (!SusModBase.DebugMode)
				{
				}
			}
		}

		[HarmonyPatch("KillPlayerClientRpc")]
		[HarmonyPostfix]
		public static void KillPlayerClientRpcPatch()
		{
			OtherFunctions.CheckForImpostorVictory();
		}

		[HarmonyPatch("KillPlayerServerRpc")]
		[HarmonyPostfix]
		public static void KillPlayerServerRpcPatch()
		{
			OtherFunctions.CheckForImpostorVictory();
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("OnShipLandedMiscEvents")]
		[HarmonyPostfix]
		public static void ImpostorStartGame(ref int ___randomMapSeed, ref int ___currentLevelID)
		{
			if (___currentLevelID == 3 || !Player.LocalPlayer.IsHost)
			{
				return;
			}
			SusModBase.mls.LogInfo((object)("Seed is : " + ___randomMapSeed));
			SusModBase.impostorsIDs.Clear();
			Random random = new Random(___randomMapSeed);
			float value = SusModBase.ConfigimpostorSpawnRate.Value;
			bool value2 = SusModBase.ConfigisImposterCountRandom.Value;
			int num = (int)((float)Player.ActiveList.Count * value);
			SusModBase.mls.LogInfo((object)("Player.ActiveList.Count is : " + Player.ActiveList.Count));
			SusModBase.mls.LogInfo((object)("impostorsToSpawn is : " + num));
			if (value2)
			{
				num = random.Next(0, num + 1);
				SusModBase.mls.LogInfo((object)"Spawn rate is randomized");
			}
			int choosenImpostorID;
			while (SusModBase.impostorsIDs.Count < num)
			{
				List<Player> list = Player.ActiveList.ToList();
				list.Sort((Player x, Player y) => x.ClientId.CompareTo(y.ClientId));
				choosenImpostorID = (int)list.ElementAt(random.Next(0, list.Count)).ClientId;
				if (!SusModBase.impostorsIDs.Contains(choosenImpostorID))
				{
					SusModBase.impostorsIDs.Add(choosenImpostorID);
					OtherFunctions.GetImpostorStartingItem(random.Next(1, 6), ((IEnumerable<Player>)Player.ActiveList).FirstOrDefault((Func<Player, bool>)((Player p) => (int)p.ClientId == choosenImpostorID)));
					SusModBase.mls.LogInfo((object)("Client ID " + choosenImpostorID + " is impostor"));
				}
			}
			NetworkingPatch.SynchronizeImpList();
			ImpostorLever();
		}

		[HarmonyPatch("ShipHasLeft")]
		[HarmonyPrefix]
		public static void ShipHasLeftPatch()
		{
			OtherFunctions.RemoveImposter();
			VentsPatch.unsussifyAll();
		}

		[NetworkMessage("SyncImpList", false)]
		public static void SyncHandler(ulong sender, Networking message)
		{
			SusModBase.mls.LogInfo((object)"Recived imp list from host");
			SusModBase.impostorsIDs = message.ImpostorList;
			if (SusModBase.impostorsIDs.Contains((int)Player.LocalPlayer.ClientId))
			{
				HUDManager.Instance.DisplayTip("Alert", "You Are The Impostor!", true, false, "");
				Player.LocalPlayer.PlayerController.nightVision.intensity = 3000f;
				Player.LocalPlayer.PlayerController.nightVision.range = 5000f;
			}
			if (message.Vents)
			{
				VentsPatch.SussifyAll();
			}
			ImpostorLever();
		}

		public static void ImpostorLever()
		{
			if (SusModBase.impostorsIDs.Contains((int)Player.LocalPlayer.ClientId))
			{
				InteractTrigger triggerScript = Object.FindObjectOfType<StartMatchLever>().triggerScript;
				triggerScript.interactable = false;
				triggerScript.disabledHoverTip = "Impostor can't start the ship";
			}
		}
	}
}