Decompiled source of EvilPlayer Imposter v1.1.0

infiltratorMod.dll

Decompiled 10 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 Unity.Netcode;
using UnityEngine;
using infiltratorMod.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("infiltratorMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("infiltratorMod")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("08de51c8-694e-4a4e-9cbf-d565d3fb11d3")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace infiltratorMod
{
	[BepInPlugin("EvilPlayer_Imposter.Tormad", "EvilPlayer_Imposter", "1.1.0")]
	public class ModBase : BaseUnityPlugin
	{
		public const string modGUID = "EvilPlayer_Imposter.Tormad";

		public const string modName = "EvilPlayer_Imposter";

		public const string modVersion = "1.1.0";

		private readonly Harmony harmony = new Harmony("EvilPlayer_Imposter.Tormad");

		private static ModBase Instance;

		internal ManualLogSource mls;

		private ConfigEntry<float> movSpeed;

		private ConfigEntry<float> carryWeight;

		private ConfigEntry<int> health;

		private ConfigEntry<float> transparency;

		private ConfigEntry<float> sprintSpeed;

		private ConfigEntry<float> hitDistance;

		private ConfigEntry<int> attackForce;

		private ConfigEntry<int> maxEnemies;

		private ConfigEntry<bool> canFly;

		private ConfigEntry<bool> canDrop;

		private ConfigEntry<bool> canRegen;

		private ConfigEntry<bool> canOpenDoors;

		private ConfigEntry<bool> canUnlockDoors;

		private ConfigEntry<bool> canInteractInShip;

		private ConfigEntry<int> doorLockMax;

		private ConfigEntry<bool> nightVision;

		private ConfigEntry<float> hitCooldown;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("EvilPlayer_Imposter.Tormad");
			mls.LogInfo((object)"!!The EVIL player mod started!!");
			movSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("EvilPlayer", "MovementSpeed", 2f, "Movement speed of the evil player. (normal player can move at 4.6 with 0 weight)");
			carryWeight = ((BaseUnityPlugin)this).Config.Bind<float>("EvilPlayer", "CarryWeight", 2.5f, "Carry weight of the evil player. (will reduce sprint time)");
			health = ((BaseUnityPlugin)this).Config.Bind<int>("EvilPlayer", "Health", 10, "Health of the evil player.");
			transparency = ((BaseUnityPlugin)this).Config.Bind<float>("EvilPlayer", "Transparency", 0.1f, "Transparency of the evil player.");
			sprintSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("EvilPlayer", "SprintSpeed", 10f, "Sprint speed of the evil player.");
			hitDistance = ((BaseUnityPlugin)this).Config.Bind<float>("EvilPlayer", "HitDistance", 1.2f, "Hit distance of the evil player.");
			attackForce = ((BaseUnityPlugin)this).Config.Bind<int>("EvilPlayer", "AttackForce", 1, "Damage dealt by the evil player.");
			maxEnemies = ((BaseUnityPlugin)this).Config.Bind<int>("EvilPlayer", "MaxEnemies", 0, "Max enemies put 0 if none (does not increase past vanilla amount).");
			canFly = ((BaseUnityPlugin)this).Config.Bind<bool>("EvilPlayer", "CanFly", true, "Can the evil player fly (jump on air).");
			canDrop = ((BaseUnityPlugin)this).Config.Bind<bool>("EvilPlayer", "CanDrop", true, "Can the evil player drop the clipboard. (allows switching of evil player only in ship)");
			canRegen = ((BaseUnityPlugin)this).Config.Bind<bool>("EvilPlayer", "CanRegen", false, "Can regen of the evil player. (after being killed)");
			canOpenDoors = ((BaseUnityPlugin)this).Config.Bind<bool>("EvilPlayer", "CanOpenDoors", true, "Can the evil player open doors. (will not open doors that require a key)");
			canUnlockDoors = ((BaseUnityPlugin)this).Config.Bind<bool>("EvilPlayer", "CanUnlockDoors", true, "Can the evil player unlock doors. (will not require a key)");
			doorLockMax = ((BaseUnityPlugin)this).Config.Bind<int>("EvilPlayer", "DoorLockMax", 1, "Max doors the evil player can lock.");
			canInteractInShip = ((BaseUnityPlugin)this).Config.Bind<bool>("EvilPlayer", "CanInteractInShip", false, "Can the evil player interact with things in the ship.");
			nightVision = ((BaseUnityPlugin)this).Config.Bind<bool>("EvilPlayer", "NightVision", false, "Can the evil player see in the dark. (broken currently do nto enable)");
			hitCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("EvilPlayer", "HitCooldown", 0.2f, "Can the evil player hit multiple times in a row. (broken currently do nto enable)");
			movSpeed.SettingChanged += OnConfigChanged;
			carryWeight.SettingChanged += OnConfigChanged;
			health.SettingChanged += OnConfigChanged;
			transparency.SettingChanged += OnConfigChanged;
			sprintSpeed.SettingChanged += OnConfigChanged;
			hitDistance.SettingChanged += OnConfigChanged;
			attackForce.SettingChanged += OnConfigChanged;
			maxEnemies.SettingChanged += OnConfigChanged;
			canFly.SettingChanged += OnConfigChanged;
			canDrop.SettingChanged += OnConfigChanged;
			canRegen.SettingChanged += OnConfigChanged;
			canOpenDoors.SettingChanged += OnConfigChanged;
			canUnlockDoors.SettingChanged += OnConfigChanged;
			doorLockMax.SettingChanged += OnConfigChanged;
			canInteractInShip.SettingChanged += OnConfigChanged;
			nightVision.SettingChanged += OnConfigChanged;
			hitCooldown.SettingChanged += OnConfigChanged;
			PlayerSelectorPatch.modBaseInstance = this;
			ApplyConfig();
			harmony.PatchAll();
		}

		public void ApplyConfig()
		{
			EvilPlayer.movSpeed = movSpeed.Value;
			EvilPlayer.carryWeight = carryWeight.Value;
			EvilPlayer.health = health.Value;
			EvilPlayer.transparency = transparency.Value;
			EvilPlayer.sprintSpeed = sprintSpeed.Value;
			EvilPlayer.hitDistance = hitDistance.Value;
			EvilPlayer.attackHitForce = attackForce.Value;
			EvilPlayer.canFly = canFly.Value;
			EvilPlayer.canDrop = canDrop.Value;
			EvilPlayer.RegenHealth = canRegen.Value;
			EvilPlayer.maxEnemy = maxEnemies.Value;
			EvilPlayer.canOpenDoors = canOpenDoors.Value;
			EvilPlayer.canUnlockDoors = canUnlockDoors.Value;
			EvilPlayer.doorLockMax = doorLockMax.Value;
			EvilPlayer.canInteractInShip = canInteractInShip.Value;
			EvilPlayer.nightVision = nightVision.Value;
			EvilPlayer.hitCooldown = hitCooldown.Value;
		}

		private void OnConfigChanged(object sender, EventArgs e)
		{
			ApplyConfig();
		}
	}
}
namespace infiltratorMod.Patches
{
	public static class EvilPlayer
	{
		public static float startTime = Time.realtimeSinceStartup;

		public static float startTime1 = Time.realtimeSinceStartup;

		public static ulong evilPlayerId = 696969uL;

		public static List<float> yRot = new List<float>();

		public static bool shouldTP = false;

		public static bool hasLanded = false;

		public static float movSpeed;

		public static float carryWeight = 2.5f;

		public static float jumpForce = 2f;

		public static float sprintSpeed;

		public static float hitDistance = 1.5f;

		public static int health = 100;

		public static float transparency = 0.7f;

		public static List<Vector3> positions = new List<Vector3>();

		public static int ventIndex = 0;

		public static bool shipPhase = true;

		public static string currentMoon = "";

		public static bool changedSkin = false;

		public static int attackHitForce = 1;

		public static bool RegenHealth = true;

		public static bool canFly = true;

		public static bool canDrop = false;

		public static int maxEnemy = 0;

		public static int EnemyCount = 0;

		public static bool canOpenDoors = true;

		public static bool canUnlockDoors = false;

		public static int DoorsLocked = 0;

		public static int doorLockMax = 1;

		public static bool canInteractInShip = true;

		public static Transform Playerpos;

		public static bool nightVision = true;

		public static float lastPlayerAngle = 0f;

		public static float lastHitTime = 0f;

		public static float hitCooldown;

		public static bool ShipLeaving = false;
	}
	[HarmonyPatch(typeof(ClipboardItem))]
	internal class PlayerSelectorPatch
	{
		private static ManualLogSource logger;

		private static int attackMask;

		public static ModBase modBaseInstance;

		static PlayerSelectorPatch()
		{
			attackMask = 11012424;
			logger = Logger.CreateLogSource("EvilPlayer_Imposter.Tormad");
		}

		[HarmonyPostfix]
		[HarmonyPatch("EquipItem")]
		private static void PostfixEquipItem(ClipboardItem __instance)
		{
			if ((Object)(object)__instance == (Object)null || (Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)null)
			{
				logger.LogError((object)"PostfixEquipItem: __instance or playerHeldBy is null.");
				return;
			}
			modBaseInstance.ApplyConfig();
			EvilPlayer.evilPlayerId = ((GrabbableObject)__instance).playerHeldBy.playerClientId;
			((GrabbableObject)__instance).playerHeldBy.health = EvilPlayer.health;
			((GrabbableObject)__instance).playerHeldBy.carryWeight = EvilPlayer.carryWeight;
			((GrabbableObject)__instance).playerHeldBy.grabDistance = 2f;
			((GrabbableObject)__instance).playerHeldBy.movementSpeed = EvilPlayer.movSpeed;
			logger.LogInfo((object)"!___Player ID___!");
			logger.LogInfo((object)EvilPlayer.evilPlayerId.ToString());
			logger.LogInfo((object)"!___Player ID___!");
			EvilPlayer.changedSkin = false;
			if (((NetworkBehaviour)__instance).IsOwner)
			{
				HUDManager.Instance.DisplayTip("To use the EVil players abilities:", "Press Q to teleport between vents, hit left click to attack players and spam space to float.", true, true, "LCTip_UseManual");
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(ClipboardItem), "ItemInteractLeftRight")]
		private static bool preItemInteractLeftRight(ClipboardItem __instance, bool right)
		{
			int ventIndex = EvilPlayer.ventIndex;
			((GrabbableObject)__instance).RequireCooldown();
			if (!right)
			{
				EvilPlayer.ventIndex = Mathf.Clamp(EvilPlayer.ventIndex - 1, -1, EvilPlayer.positions.Count - 1);
			}
			if (EvilPlayer.ventIndex != ventIndex)
			{
				Logger.CreateLogSource("EvilPlayer_Imposter.Tormad").LogInfo((object)("Vent num is num! " + ventIndex + " And VentIndex is " + EvilPlayer.ventIndex));
				RoundManager.PlayRandomClip(__instance.thisAudio, __instance.turnPageSFX, true, 1f, 0);
				if (EvilPlayer.ventIndex == -1)
				{
					EvilPlayer.ventIndex = EvilPlayer.positions.Count - 1;
				}
				logger.LogInfo((object)("!___Vent___! " + ventIndex));
				EvilPlayer.shouldTP = true;
			}
			logger.LogInfo((object)"tried to work");
			UpdateRadarTexture((GrabbableObject)(object)__instance);
			return false;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GrabbableObject), "InspectItem")]
		private static void PostfixInspectItem(GrabbableObject __instance)
		{
			ManualLogSource val = Logger.CreateLogSource("EvilPlayer_Imposter.Tormad");
			val.LogInfo((object)"InspectItem method called.");
			ClipboardItem val2 = (ClipboardItem)(object)((__instance is ClipboardItem) ? __instance : null);
			if (val2 == null || (Object)(object)((GrabbableObject)val2).playerHeldBy == (Object)null)
			{
				val.LogInfo((object)"Not a ClipboardItem or playerHeldBy is null.");
				return;
			}
			val.LogInfo((object)"Calling UpdateRadarTexture...");
			UpdateRadarTexture(__instance);
		}

		private static void UpdateRadarTexture(GrabbableObject clipboardItem)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource val = Logger.CreateLogSource("EvilPlayer_Imposter.Tormad");
			val.LogInfo((object)"UpdateRadarTexture method called.");
			int num = 630;
			int num2 = 630;
			Texture2D val2 = new Texture2D(num, num2);
			for (int i = 0; i < 900; i++)
			{
				for (int j = 0; j < 1260; j++)
				{
					val2.SetPixel(i, j, Color.black);
				}
			}
			LayerMask val3 = LayerMask.op_Implicit(LayerMask.GetMask(new string[1] { "Player" }));
			Transform playerpos = EvilPlayer.Playerpos;
			float num3 = 30f;
			Collider[] array = Physics.OverlapSphere(playerpos.position, num3, LayerMask.op_Implicit(val3));
			val.LogInfo((object)$"Detected {array.Length} players.");
			Collider[] array2 = array;
			foreach (Collider val4 in array2)
			{
				Vector2 radarPosition = GetRadarPosition(((Component)val4).transform.position, playerpos, num, num2, num3);
				val.LogInfo((object)$"Player detected at position: {((Component)val4).transform.position}, Radar position: {radarPosition}");
				DrawDot(val2, radarPosition, Color.red, 10);
			}
			Vector2 radarPosition2 = GetRadarPosition(playerpos.position, playerpos, num, num2, num3);
			DrawDot(val2, radarPosition2, Color.yellow, 10);
			DrawDot(val2, new Vector2((float)(num / 2), (float)(num2 / 2)), Color.green, 10);
			val2.Apply();
			UpdateMaterial(val2, clipboardItem);
		}

		private static void DrawDot(Texture2D texture, Vector2 center, Color color, int dotSize)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			int num = -100;
			for (int i = -dotSize; i <= dotSize; i++)
			{
				for (int j = -dotSize; j <= dotSize; j++)
				{
					int num2 = (int)center.x + i + num;
					int num3 = (int)center.y + j;
					if (num2 >= 0 && num2 < ((Texture)texture).width && num3 >= 0 && num3 < ((Texture)texture).height)
					{
						texture.SetPixel(num2, num3, color);
					}
				}
			}
		}

		private static void UpdateMaterial(Texture2D newTexture, GrabbableObject grabbableObject)
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource val = Logger.CreateLogSource("EvilPlayer_Imposter.Tormad");
			val.LogInfo((object)"UpdateMaterial method called.");
			Transform val2 = ((Component)grabbableObject).transform.Find("Plane");
			if ((Object)(object)val2 == (Object)null)
			{
				val.LogWarning((object)"Child 'Plane' not found in GrabbableObject.");
				return;
			}
			SkinnedMeshRenderer component = ((Component)val2).GetComponent<SkinnedMeshRenderer>();
			if ((Object)(object)component == (Object)null)
			{
				val.LogWarning((object)"SkinnedMeshRenderer not found on 'Plane' child.");
				return;
			}
			Material val3 = new Material(Shader.Find("HDRP/Lit"));
			val3.mainTexture = (Texture)(object)newTexture;
			Color val4 = default(Color);
			((Color)(ref val4))..ctor(2f, 2f, 2f);
			val3.EnableKeyword("_EMISSION");
			val3.SetColor("_EmissionColor", val4);
			if (val3.HasProperty("_EmissionIntensity"))
			{
				val3.SetFloat("_EmissionIntensity", 2f);
			}
			((Renderer)component).material = val3;
			val.LogInfo((object)"Material with emission updated successfully.");
		}

		private static Vector2 GetRadarPosition(Vector3 worldPos, Transform radarTransform, int radarWidth, int radarHeight, float detectionRadius)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = radarTransform.InverseTransformPoint(worldPos);
			float num = (float)radarWidth / (2f * detectionRadius);
			float num2 = (float)radarHeight / (2f * detectionRadius);
			float num3 = val.x * num + (float)(radarWidth / 2);
			float num4 = val.z * num2 + (float)(radarHeight / 2);
			num3 = Mathf.Clamp(num3, 0f, (float)radarWidth);
			num4 = Mathf.Clamp(num4, 0f, (float)radarHeight);
			Debug.Log((object)$"Radar Pos: {num3}, {num4} for World Pos: {worldPos}");
			return new Vector2(num3, num4);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GrabbableObject), "ItemActivate")]
		private static void PostfixItemActivate(GrabbableObject __instance, bool used, bool buttonDown)
		{
			ClipboardItem val = (ClipboardItem)(object)((__instance is ClipboardItem) ? __instance : null);
			if (val != null && !((Object)(object)((GrabbableObject)val).playerHeldBy == (Object)null) && buttonDown)
			{
				PerformInstantHit(((GrabbableObject)val).playerHeldBy);
				TryUnlockDoor(((GrabbableObject)val).playerHeldBy);
				if (EvilPlayer.DoorsLocked >= EvilPlayer.doorLockMax)
				{
					TryLockDoor(((GrabbableObject)val).playerHeldBy);
				}
			}
		}

		private static void PerformInstantHit(PlayerControllerB playerHeldBy)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			if (Time.realtimeSinceStartup - EvilPlayer.lastHitTime < EvilPlayer.hitCooldown)
			{
				return;
			}
			logger.LogInfo((object)"!_hit ");
			RaycastHit[] source = Physics.SphereCastAll(((Component)playerHeldBy.gameplayCamera).transform.position, 0.75f, ((Component)playerHeldBy.gameplayCamera).transform.forward, EvilPlayer.hitDistance, attackMask, (QueryTriggerInteraction)2);
			IHittable val = default(IHittable);
			foreach (RaycastHit item in source.OrderBy((RaycastHit h) => ((RaycastHit)(ref h)).distance))
			{
				RaycastHit current = item;
				if (!((Component)((RaycastHit)(ref current)).transform).TryGetComponent<IHittable>(ref val) || (Object)(object)((RaycastHit)(ref current)).transform == (Object)(object)((Component)playerHeldBy).transform)
				{
					continue;
				}
				try
				{
					bool flag = val.Hit(EvilPlayer.attackHitForce, ((RaycastHit)(ref current)).point, playerHeldBy, true);
					logger.LogInfo((object)(flag ? "Hit successful" : "Hit failed"));
					if (flag)
					{
						EvilPlayer.lastHitTime = Time.realtimeSinceStartup;
					}
				}
				catch (Exception arg)
				{
					logger.LogError((object)$"Exception caught when hitting object with ClipboardItem: {arg}");
				}
			}
		}

		private static void TryUnlockDoor(PlayerControllerB playerHeldBy)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(((Component)playerHeldBy.gameplayCamera).transform.position, ((Component)playerHeldBy.gameplayCamera).transform.forward);
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val, ref val2, 3f, 2816))
			{
				DoorLock component = ((Component)((RaycastHit)(ref val2)).transform).GetComponent<DoorLock>();
				if ((Object)(object)component != (Object)null && component.isLocked && !component.isPickingLock)
				{
					component.UnlockDoorSyncWithServer();
				}
			}
		}

		private static void TryLockDoor(PlayerControllerB playerHeldBy)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(((Component)playerHeldBy.gameplayCamera).transform.position, ((Component)playerHeldBy.gameplayCamera).transform.forward);
			RaycastHit val2 = default(RaycastHit);
			if (!Physics.Raycast(val, ref val2, 3f, 2816))
			{
				return;
			}
			DoorLock component = ((Component)((RaycastHit)(ref val2)).transform).GetComponent<DoorLock>();
			if ((Object)(object)component != (Object)null && !component.isLocked)
			{
				component.doorLockSFX.Stop();
				component.doorLockSFX.PlayOneShot(component.unlockSFX);
				if (!component.isLocked)
				{
					component.isLocked = true;
					EvilPlayer.DoorsLocked++;
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")]
	internal class PlayerKillPatch
	{
		[HarmonyPrefix]
		private static bool preKillPlayer(PlayerControllerB __instance)
		{
			if (__instance.playerClientId != EvilPlayer.evilPlayerId)
			{
				return true;
			}
			((Renderer)__instance.thisPlayerModelArms).enabled = false;
			EvilPlayer.shouldTP = true;
			if (EvilPlayer.RegenHealth)
			{
				__instance.health = EvilPlayer.health;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "OnDestroy")]
	internal class OnDestroyPatch
	{
		[HarmonyPrefix]
		private static void preOnDestroy(PlayerControllerB __instance)
		{
			EvilPlayer.evilPlayerId = 696969uL;
		}
	}
	[HarmonyPatch(typeof(DoorLock), "Update")]
	internal class DoorLockPatch
	{
		[HarmonyPrefix]
		private static bool preUpdate(DoorLock __instance)
		{
			InteractTrigger val = AccessTools.FieldRefAccess<DoorLock, InteractTrigger>(__instance, "doorTrigger");
			int num = AccessTools.FieldRefAccess<DoorLock, int>(__instance, "playersPickingDoor");
			float num2 = AccessTools.FieldRefAccess<DoorLock, float>(__instance, "playerPickingLockProgress");
			if (GameNetworkManager.Instance.localPlayerController.playerClientId != EvilPlayer.evilPlayerId)
			{
				return true;
			}
			if (EvilPlayer.canUnlockDoors && __instance.isLocked)
			{
				if (StartOfRound.Instance.localPlayerUsingController)
				{
					val.disabledHoverTip = "Use key: [R-trigger]";
				}
				else
				{
					val.disabledHoverTip = "Unlock: [ LMB ]";
				}
			}
			if (EvilPlayer.DoorsLocked >= EvilPlayer.doorLockMax && !__instance.isLocked)
			{
				if (StartOfRound.Instance.localPlayerUsingController)
				{
					val.disabledHoverTip = "Use key: [R-trigger]";
				}
				else
				{
					val.disabledHoverTip = "Lock Door: [ LMB ] only done once per moon";
				}
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "Jump_performed")]
	internal class PlayerJumpPatch
	{
		[HarmonyPrefix]
		private static bool preJump_performed(PlayerControllerB __instance)
		{
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			string name = ((Object)((Component)__instance).gameObject).name;
			Logger.CreateLogSource("EvilPlayer_Imposter.Tormad").LogInfo((object)("GameObject Name: " + name));
			if (__instance.playerClientId != EvilPlayer.evilPlayerId || !EvilPlayer.canFly)
			{
				return true;
			}
			if (!__instance.quickMenuManager.isMenuOpen && __instance.isPlayerControlled && !__instance.isTypingChat)
			{
				FieldInfo fieldInfo = AccessTools.Field(typeof(PlayerControllerB), "isJumping");
				fieldInfo.SetValue(__instance, true);
				FieldInfo fieldInfo2 = AccessTools.Field(typeof(PlayerControllerB), "jumpCoroutine");
				Coroutine val = (Coroutine)fieldInfo2.GetValue(__instance);
				if (val != null)
				{
					((MonoBehaviour)__instance).StopCoroutine(val);
				}
				MethodInfo methodInfo = AccessTools.Method(typeof(PlayerControllerB), "PlayerJump", (Type[])null, (Type[])null);
				val = ((MonoBehaviour)__instance).StartCoroutine((IEnumerator)methodInfo.Invoke(__instance, null));
				fieldInfo2.SetValue(__instance, val);
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "DiscardHeldObject")]
	internal class DiscardHeldObjectpPatch
	{
		[HarmonyPrefix]
		private static bool preDiscardHeldObject(PlayerControllerB __instance)
		{
			if (__instance.playerClientId != EvilPlayer.evilPlayerId)
			{
				return true;
			}
			if (EvilPlayer.shipPhase && EvilPlayer.canDrop)
			{
				EvilPlayer.evilPlayerId = 696969uL;
				return true;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "ScrollMouse_performed")]
	internal class ScrollMouse_performedPatch
	{
		[HarmonyPrefix]
		private static bool preScrollMouse_performed(PlayerControllerB __instance)
		{
			if (__instance.playerClientId != EvilPlayer.evilPlayerId)
			{
				return true;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "BeginGrabObject")]
	internal class BeginGrabObjectPatch
	{
		[HarmonyPrefix]
		private static bool preBeginGrabObject(PlayerControllerB __instance)
		{
			if (__instance.playerClientId != EvilPlayer.evilPlayerId)
			{
				return true;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "SwitchToItemSlot")]
	internal class SwitchToItemSlotPatch
	{
		[HarmonyPrefix]
		private static bool preSwitchToItemSlot(PlayerControllerB __instance)
		{
			if (__instance.playerClientId != EvilPlayer.evilPlayerId)
			{
				return true;
			}
			__instance.twoHanded = true;
			return false;
		}
	}
	[HarmonyPatch(typeof(EnemyVent), "Update")]
	internal class EnemyVentPatch
	{
		[HarmonyPostfix]
		private static void postUpdate(EnemyVent __instance)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			Vector3 newPos = __instance.floorNode.position;
			newPos.y += 1f;
			if (!EvilPlayer.positions.Any((Vector3 pos) => pos == newPos))
			{
				EvilPlayer.positions.Add(newPos);
				EvilPlayer.ventIndex = EvilPlayer.positions.Count / 2;
				EvilPlayer.yRot.Add(__instance.floorNode.eulerAngles.y);
				Logger.CreateLogSource("EvilPlayer_Imposter.Tormad").LogInfo((object)"!_Added vent!");
				Logger.CreateLogSource("EvilPlayer_Imposter.Tormad").LogInfo((object)newPos);
				EvilPlayer.shouldTP = true;
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager), "Update")]
	internal class LandingCheckerPatch
	{
		[HarmonyPrefix]
		private static void preUpdate(RoundManager __instance)
		{
			EvilPlayer.hasLanded = __instance.dungeonCompletedGenerating;
			if (__instance.currentLevel.PlanetName != EvilPlayer.currentMoon)
			{
				EvilPlayer.changedSkin = false;
				Logger.CreateLogSource("EvilPlayer_Imposter.Tormad").LogInfo((object)("!_____" + __instance.currentLevel.PlanetName));
				EvilPlayer.currentMoon = __instance.currentLevel.PlanetName;
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager), "SpawnEnemyFromVent")]
	internal class EnemySpawnPatch
	{
		[HarmonyPrefix]
		private static bool preSpawnEnemyFromVent()
		{
			if (EvilPlayer.maxEnemy <= EvilPlayer.EnemyCount)
			{
				return false;
			}
			EvilPlayer.EnemyCount++;
			return true;
		}
	}
	[HarmonyPatch(typeof(TimeOfDay), "OnDayChanged")]
	public class DayCaller
	{
		[HarmonyPostfix]
		private static void PostfixLoadShipGrabbableItems()
		{
			EvilPlayer.shipPhase = true;
			EvilPlayer.hasLanded = false;
			Logger.CreateLogSource("Market.Tormad").LogInfo((object)"! NEW DAY BABY");
			EvilPlayer.EnemyCount = 0;
			EvilPlayer.changedSkin = false;
			Logger.CreateLogSource("EvilPlayer_Imposter.Tormad").LogInfo((object)"tried to clear list");
			EvilPlayer.positions.Clear();
			EvilPlayer.yRot.Clear();
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "Update")]
	internal class PlayerControllerPatch
	{
		[HarmonyPrefix]
		private static void PrefixUpdate(PlayerControllerB __instance)
		{
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Expected O, but got Unknown
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Unknown result type (might be due to invalid IL or missing references)
			//IL_054e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dd: 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_04f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0503: Unknown result type (might be due to invalid IL or missing references)
			//IL_0508: Unknown result type (might be due to invalid IL or missing references)
			//IL_050b: Unknown result type (might be due to invalid IL or missing references)
			//IL_057d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_060b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0632: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.playerClientId != EvilPlayer.evilPlayerId)
			{
				if (__instance.carryWeight == EvilPlayer.carryWeight)
				{
					Logger.CreateLogSource("EvilPlayer_Imposter.Tormad").LogInfo((object)"!___Dropped___!");
					UnlockableSuit.SwitchSuitForPlayer(__instance, 0, true);
					__instance.movementSpeed = 4.6f;
					__instance.sprintTime = 5f;
					__instance.jumpForce = 13f;
					__instance.hinderedMultiplier = 1f;
					__instance.velocityMovingAverageLength = 20;
					__instance.insanitySpeedMultiplier = 1f;
					__instance.carryWeight = 1f;
					__instance.grabDistance = 3f;
					((Behaviour)__instance.nightVision).enabled = false;
					__instance.twoHanded = false;
					__instance.isMovementHindered = 0;
					__instance.sprintMeter = 1f;
				}
				return;
			}
			if (__instance.playersManager.livingPlayers == 1 && __instance.playerClientId == EvilPlayer.evilPlayerId && __instance.isInsideFactory && !EvilPlayer.ShipLeaving)
			{
				Logger.CreateLogSource("EvilPlayer_Imposter.Tormad").LogInfo((object)"ship leaving due to 1 living player");
				__instance.playersManager.allPlayersDead = true;
				__instance.playersManager.ShipLeaveAutomatically(false);
				EvilPlayer.ShipLeaving = true;
			}
			if (!EvilPlayer.changedSkin)
			{
				Material val = new Material(Shader.Find("HDRP/Lit"));
				val.SetFloat("_Smoothness", 1f);
				val.SetFloat("_Metallic", 1f);
				val.SetFloat("_RefractionModel", 1f);
				val.SetFloat("_IOR", 1.5f);
				val.SetFloat("_MaterialType", 1f);
				val.SetColor("_SubsurfaceColor", Color.red);
				val.SetFloat("_SurfaceType", 1f);
				val.SetColor("_BaseColor", new Color(0f, 0f, 0f, EvilPlayer.transparency));
				val.EnableKeyword("_RIMLIGHT");
				val.SetFloat("_RimLightIntensity", 0.2f);
				((Renderer)__instance.thisPlayerModel).material = val;
				((Renderer)__instance.thisPlayerModelLOD1).material = val;
				((Renderer)__instance.thisPlayerModelLOD2).material = val;
				((Renderer)__instance.thisPlayerModelArms).material = val;
				Logger.CreateLogSource("EvilPlayer_Imposter.Tormad").LogInfo((object)"!___Updated Material___!");
				EvilPlayer.changedSkin = true;
			}
			if (__instance.movementSpeed != EvilPlayer.movSpeed && !__instance.isSprinting)
			{
				__instance.movementSpeed = EvilPlayer.movSpeed;
			}
			if (__instance.movementSpeed != EvilPlayer.sprintSpeed && __instance.isSprinting)
			{
				__instance.movementSpeed = EvilPlayer.sprintSpeed;
			}
			if (!__instance.isInsideFactory && !EvilPlayer.shipPhase)
			{
				EvilPlayer.changedSkin = false;
				EvilPlayer.shipPhase = true;
			}
			if (__instance.isInsideFactory && EvilPlayer.shipPhase)
			{
				EvilPlayer.shipPhase = false;
			}
			if (EvilPlayer.shipPhase == __instance.isInsideFactory)
			{
				EvilPlayer.evilPlayerId = 696969uL;
			}
			if (__instance.grabDistance != 0f && EvilPlayer.shipPhase && !EvilPlayer.canInteractInShip)
			{
				__instance.grabDistance = 0f;
			}
			if (EvilPlayer.shipPhase)
			{
				EvilPlayer.ShipLeaving = false;
			}
			else if (__instance.grabDistance != 2f && !EvilPlayer.shipPhase && EvilPlayer.canOpenDoors)
			{
				__instance.grabDistance = 2f;
			}
			if (__instance.isInHangarShipRoom && !EvilPlayer.shouldTP && EvilPlayer.hasLanded)
			{
				EvilPlayer.shouldTP = true;
			}
			if (!((Behaviour)__instance.nightVision).enabled && EvilPlayer.nightVision)
			{
				((Behaviour)__instance.nightVision).enabled = true;
				Logger.CreateLogSource("EvilPlayer_Imposter.Tormad").LogInfo((object)"!___night vision___!");
			}
			if (Time.realtimeSinceStartup > EvilPlayer.startTime1 + 20f)
			{
				Transform val2 = (EvilPlayer.Playerpos = __instance.cameraContainerTransform);
				Logger.CreateLogSource("EvilPlayer_Imposter.Tormad").LogInfo((object)val2.eulerAngles.y);
				EvilPlayer.startTime1 = Time.realtimeSinceStartup;
			}
			if (EvilPlayer.shouldTP && Time.realtimeSinceStartup > EvilPlayer.startTime + 0.2f)
			{
				EvilPlayer.startTime = Time.realtimeSinceStartup;
				Transform thisPlayerBody = __instance.thisPlayerBody;
				Logger.CreateLogSource("EvilPlayer_Imposter.Tormad").LogInfo((object)"!___TRIED TO TELEPORT___!");
				thisPlayerBody.eulerAngles = new Vector3(thisPlayerBody.eulerAngles.x, EvilPlayer.yRot[EvilPlayer.ventIndex], thisPlayerBody.eulerAngles.z);
				Vector3 forward = ((Component)thisPlayerBody).transform.forward;
				float num = 1f;
				Vector3 val3 = EvilPlayer.positions[EvilPlayer.ventIndex] + forward * num;
				__instance.TeleportPlayer(val3, false, 0f, false, true);
				__instance.isInHangarShipRoom = false;
				__instance.isInsideFactory = true;
				if (!__instance.isInHangarShipRoom && EvilPlayer.shouldTP)
				{
					EvilPlayer.shouldTP = false;
				}
			}
			if (__instance.thisPlayerBody.position.y <= -300f)
			{
				Transform thisPlayerBody2 = __instance.thisPlayerBody;
				Logger.CreateLogSource("EvilPlayer_Imposter.Tormad").LogInfo((object)thisPlayerBody2.position);
				Random random = new Random();
				__instance.TeleportPlayer(EvilPlayer.positions[random.Next(0, EvilPlayer.positions.Count)], false, 0f, false, true);
			}
			if (EvilPlayer.currentMoon == "71 Gordion" && Time.realtimeSinceStartup > EvilPlayer.startTime + 0.2f)
			{
				EvilPlayer.startTime = Time.realtimeSinceStartup;
				Transform thisPlayerBody3 = __instance.thisPlayerBody;
				Logger.CreateLogSource("EvilPlayer_Imposter.Tormad").LogInfo((object)thisPlayerBody3.position);
				Random random2 = new Random();
				__instance.TeleportPlayer(new Vector3(0f, 6f, 0f), false, 0f, false, true);
			}
		}
	}
}