Decompiled source of TinyTaurenMurder v2.2.3

LethalMurder.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LC_API.GameInterfaceAPI;
using LC_API.GameInterfaceAPI.Events.EventArgs.Player;
using LC_API.GameInterfaceAPI.Events.Handlers;
using LC_API.GameInterfaceAPI.Features;
using LethalNetworkAPI;
using LethalNetworkAPI.Utils;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using Unity.Netcode.Components;
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: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: AssemblyCompany("LethalMurder")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+77943971768c43d5ca3c7721079a417c481afd7f")]
[assembly: AssemblyProduct("My first plugin")]
[assembly: AssemblyTitle("LethalMurder")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LethalMurder
{
	[HarmonyPatch(typeof(BlobAI))]
	internal class BlobPatch
	{
		[HarmonyPatch("OnCollideWithPlayer")]
		[HarmonyPostfix]
		private static void OnCollideWithPlayerPatch(Collider other, BlobAI __instance)
		{
			PlayerControllerB val = ((EnemyAI)__instance).MeetsStandardPlayerCollisionConditions(other, false, false);
			if (!((Object)(object)val == (Object)null) && !val.isPlayerDead)
			{
				Plugin.Instance.modManager.TeleportPlayerAtRandomLocation(val);
			}
		}
	}
	[HarmonyPatch(typeof(HoarderBugAI))]
	internal class BugPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static void UpdatePatch(ref PlayerControllerB ___angryAtPlayer)
		{
			if (!((Object)(object)Plugin.Instance.modManager == (Object)null) && !((Object)(object)___angryAtPlayer == (Object)null) && Plugin.Instance.modManager.playerList.Count >= (int)LethalNetworkExtensions.GetClientId(___angryAtPlayer) && Plugin.Instance.modManager.playerList[(int)LethalNetworkExtensions.GetClientId(___angryAtPlayer)].role == ModManager.ERoles.Impostor)
			{
				___angryAtPlayer = null;
			}
		}
	}
	internal class ButtonBehavior : MonoBehaviour
	{
		private float m_Timer = 0f;

		[SerializeField]
		private float m_timerTickTime = 5f;

		private void Start()
		{
		}

		private void Update()
		{
		}

		private void Action()
		{
			Debug.Log((object)"Button Verification");
			NetworkObject val = default(NetworkObject);
			if (((Component)this).TryGetComponent<NetworkObject>(ref val))
			{
				Debug.Log((object)"Network Object Found");
			}
			NetworkTransform val2 = default(NetworkTransform);
			if (((Component)this).TryGetComponent<NetworkTransform>(ref val2))
			{
				Debug.Log((object)"Network Transform Found");
			}
		}
	}
	[HarmonyPatch(typeof(HauntedMaskItem))]
	internal class HauntedMaskPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePatch(HauntedMaskItem __instance, ref bool ___attaching, ref PlayerControllerB ___previousPlayerHeldBy, ref bool ___maskOn, ref bool ___holdingLastFrame, ref bool ___finishedAttaching, ref float ___lastIntervalCheck)
		{
			if (!((!__instance.maskIsHaunted || !((NetworkBehaviour)__instance).IsOwner || (Object)(object)___previousPlayerHeldBy == (Object)null || !___maskOn || !___holdingLastFrame) | ___finishedAttaching) && !___attaching && !StartOfRound.Instance.shipIsLeaving && (!StartOfRound.Instance.inShipPhase || !((Object)(object)StartOfRound.Instance.testRoom == (Object)null)) && !((double)Time.realtimeSinceStartup <= (double)___lastIntervalCheck))
			{
				__instance.BeginAttachment();
			}
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal class HUDManagerPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePatch(HUDManager __instance)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Invalid comparison between Unknown and I4
			if (!((Object)(object)GameNetworkManager.Instance == (Object)null) && !((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null) && !((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null) && !GameNetworkManager.Instance.localPlayerController.isPlayerDead && !((Object)(object)Plugin.Instance.modManager == (Object)null))
			{
				if ((int)GameState.ShipState == 0)
				{
					((TMP_Text)__instance.weightCounter).text = "Otarie <3";
				}
				else
				{
					((TMP_Text)__instance.weightCounter).text = Plugin.Instance.modManager.m_Role.ToString();
				}
			}
		}
	}
	[HarmonyPatch(typeof(StartMatchLever))]
	internal class MatchLeverPatch
	{
		[HarmonyPatch("LeverAnimation")]
		[HarmonyPrefix]
		private static bool blockingLevelShipPatch()
		{
			//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 == 1)
			{
				if (!Plugin.Instance.modManager.canShipLever)
				{
					Player.LocalPlayer.QueueTip("YOU CANT RUN THE SHIP", "The IMPOSTOR is still alive", 5f, 0, true, false, "LC_Tip1");
				}
				return Plugin.Instance.modManager.canShipLever;
			}
			return true;
		}
	}
	internal class ModConfig
	{
		public readonly ConfigEntry<float> killCooldown;

		public readonly ConfigEntry<float> voteCallCooldown;

		public readonly ConfigEntry<float> voteTime;

		public readonly ConfigEntry<float> timeAfterVote;

		public ModConfig(ConfigFile configFile)
		{
			killCooldown = configFile.Bind<float>("Gameplay", "KillCooldown", 100f, "The cooldown between each kill in seconds");
			voteCallCooldown = configFile.Bind<float>("Gameplay", "VoteCallCooldown", 160f, "The cooldown between each vote call in seconds");
			voteTime = configFile.Bind<float>("Gameplay", "VoteTime", 60f, "The time for voting in seconds");
			timeAfterVote = configFile.Bind<float>("Gameplay", "TimeAfterVote", 7f, "The time after voting in seconds");
		}
	}
	internal class ModManager : MonoBehaviour
	{
		public enum ERoles
		{
			Crewmate,
			Impostor
		}

		public struct FPlayer
		{
			public ulong playerID;

			public ERoles role;

			public PlayerControllerB playerScript;

			public Player API_Player;

			public FPlayer()
			{
				playerID = 0uL;
				role = ERoles.Crewmate;
				playerScript = null;
				API_Player = null;
			}

			public FPlayer(ulong playerID, ERoles role, PlayerControllerB playerScript, Player apiPlayer)
			{
				this.playerID = playerID;
				this.role = role;
				this.playerScript = playerScript;
				API_Player = apiPlayer;
			}
		}

		internal ERoles m_Role = ERoles.Crewmate;

		internal bool isRoleReceived = false;

		internal bool canShipLever = false;

		internal bool canInstantKill = false;

		internal float killCooldown = 30f;

		internal float killCoolDownTime = 0f;

		internal Coroutine KillRoutine;

		internal LethalClientMessage<ulong> CloseKillMessage;

		internal LNetworkMessage<ulong> TryKillMessage;

		internal LNetworkMessage<float> KillCoolDownMessage;

		internal LNetworkMessage<int> RoleMessage;

		internal LNetworkMessage<string> ServerInfoMessage;

		internal LNetworkMessage<bool> PlayerDiedMessage;

		internal LNetworkMessage<bool> CanShipLeverMessage;

		internal LNetworkMessage<Vector3> SpawnEnemyOnPlayerPositionMessage;

		internal VoteManager voteManager;

		internal List<FPlayer> playerList = new List<FPlayer>();

		internal int impostorCount = 0;

		internal int crewMateCount = 0;

		internal LNetworkMessage<Color> syncParametersMessage_1;

		internal Color syncParameters_1;

		private void Awake()
		{
			//IL_00ef: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			CloseKillMessage = new LethalClientMessage<ulong>("closeKillMessage", (Action<ulong>)null, (Action<ulong, ulong>)null);
			TryKillMessage = LNetworkMessage<ulong>.Create("TryKillMessage", (Action<ulong, ulong>)null, (Action<ulong>)null, (Action<ulong, ulong>)null);
			KillCoolDownMessage = LNetworkMessage<float>.Create("KillCoolDownMessage", (Action<float, ulong>)null, (Action<float>)null, (Action<float, ulong>)null);
			RoleMessage = LNetworkMessage<int>.Create("RoleMessageServer", (Action<int, ulong>)null, (Action<int>)null, (Action<int, ulong>)null);
			ServerInfoMessage = LNetworkMessage<string>.Create("ServerInfoMessage", (Action<string, ulong>)null, (Action<string>)null, (Action<string, ulong>)null);
			PlayerDiedMessage = LNetworkMessage<bool>.Create("ImpostorDeathMessage", (Action<bool, ulong>)null, (Action<bool>)null, (Action<bool, ulong>)null);
			CanShipLeverMessage = LNetworkMessage<bool>.Create("CanShipLeverMessage", (Action<bool, ulong>)null, (Action<bool>)null, (Action<bool, ulong>)null);
			SpawnEnemyOnPlayerPositionMessage = LNetworkMessage<Vector3>.Create("SpawnEnemyOnPlayerPositionMessage", (Action<Vector3, ulong>)null, (Action<Vector3>)null, (Action<Vector3, ulong>)null);
			CreatingVoteManager();
			syncParametersMessage_1 = LNetworkMessage<Color>.Create("SyncParametersMessage", (Action<Color, ulong>)null, (Action<Color>)null, (Action<Color, ulong>)null);
			syncParameters_1 = new Color(Plugin.Config.killCooldown.Value, Plugin.Config.voteCallCooldown.Value, Plugin.Config.voteTime.Value, Plugin.Config.timeAfterVote.Value);
			OnClientReceivedSync_1(syncParameters_1);
		}

		private void OnEnable()
		{
			Debug.Log((object)"ModManager OnEnable");
			CloseKillMessage.OnReceivedFromClient += OnCloseKillClientReceived;
			RoleMessage.OnClientReceived += OnRoleReceivedForClient;
			ServerInfoMessage.OnServerReceived += InfoMessageServerReception;
			ServerInfoMessage.OnClientReceived += InfoMessageClientReception;
			TryKillMessage.OnServerReceived += OntryKillServerCalculations;
			TryKillMessage.OnClientReceived += OnClientKill;
			KillCoolDownMessage.OnClientReceived += RunKillCoolDownOnClient;
			PlayerDiedMessage.OnServerReceived += OnPlayerDeathServer;
			CanShipLeverMessage.OnClientReceived += ShipLeverModif;
			SpawnEnemyOnPlayerPositionMessage.OnServerReceived += SpawnEnemyServerSide;
			GameState.LandOnMoon += LandOnMoonEvent;
			GameState.ShipStartedLeaving += ShipLeavingEvent;
			Player.Died += OnPlayerDied;
			syncParametersMessage_1.OnClientReceived += OnClientReceivedSync_1;
			syncParametersMessage_1.OnServerReceived += OnServerReceivedSync_1;
		}

		private void OnDisable()
		{
			CloseKillMessage.OnReceivedFromClient -= OnCloseKillClientReceived;
			RoleMessage.OnClientReceived -= OnRoleReceivedForClient;
			ServerInfoMessage.OnServerReceived -= InfoMessageServerReception;
			ServerInfoMessage.OnClientReceived -= InfoMessageClientReception;
			TryKillMessage.OnServerReceived -= OntryKillServerCalculations;
			TryKillMessage.OnClientReceived -= OnClientKill;
			CanShipLeverMessage.OnClientReceived -= ShipLeverModif;
			SpawnEnemyOnPlayerPositionMessage.OnServerReceived -= SpawnEnemyServerSide;
			GameState.LandOnMoon -= LandOnMoonEvent;
			GameState.ShipStartedLeaving -= ShipLeavingEvent;
			Player.Died -= OnPlayerDied;
			PlayerDiedMessage.OnServerReceived -= OnPlayerDeathServer;
			syncParametersMessage_1.OnClientReceived -= OnClientReceivedSync_1;
			syncParametersMessage_1.OnServerReceived -= OnServerReceivedSync_1;
		}

		private void LandOnMoonEvent()
		{
			isRoleReceived = false;
			Debug.Log((object)"LandOnMoonEvent");
			canShipLever = false;
			if (Player.LocalPlayer.IsHost)
			{
				CreatingRoles();
				SpawnButton();
			}
		}

		private void ShipLeavingEvent()
		{
			((MonoBehaviour)this).StopAllCoroutines();
			((MonoBehaviour)voteManager).StopAllCoroutines();
			canInstantKill = false;
			voteManager.canCallVote = false;
			voteManager.DestroyAllVoteObjects();
		}

		private void UpdatingPlayerScripts()
		{
			playerList.Clear();
			foreach (Player active in Player.ActiveList)
			{
				playerList.Add(new FPlayer(active.ClientId, ERoles.Crewmate, active.PlayerController, active));
				Debug.Log((object)("PlayerList count : " + playerList.Count));
				Debug.Log((object)("Player ID : " + active.ClientId));
				Debug.Log((object)("Player Username : " + active.Username));
			}
		}

		internal bool GetPlayerByID(ulong id, out FPlayer player)
		{
			foreach (FPlayer player2 in playerList)
			{
				if (player2.playerID == id)
				{
					player = player2;
					return true;
				}
			}
			player = new FPlayer();
			return false;
		}

		private void CreatingRoles()
		{
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			UpdatingPlayerScripts();
			int num = Random.Range(0, playerList.Count);
			for (int i = 0; i < playerList.Count; i++)
			{
				if (i == num)
				{
					playerList[i] = new FPlayer(playerList[i].playerID, ERoles.Impostor, playerList[i].playerScript, playerList[i].API_Player);
					impostorCount++;
				}
				else
				{
					if (Random.Range(0f, 1f) > 0.8f)
					{
					}
					crewMateCount++;
				}
				Debug.Log((object)("PlayerList count after role: " + playerList.Count));
				Debug.Log((object)("Player ID after role: " + playerList[i].playerID));
				Debug.Log((object)("Player Username after role: " + playerList[i].playerScript.playerUsername));
			}
			Debug.Log((object)"LISTING EVERY PLAYERS ROLES AND ID  ");
			foreach (FPlayer player in playerList)
			{
				ulong playerID = player.playerID;
				string text = playerID.ToString();
				ERoles role = player.role;
				Debug.Log((object)("Player ID: " + text + " Role: " + role));
			}
			Debug.Log((object)"SENDING ROLES ");
			foreach (FPlayer player2 in playerList)
			{
				RoleMessage.SendClient((int)player2.role, player2.playerID);
			}
			foreach (FPlayer player3 in playerList)
			{
				Item.CreateAndSpawnItem("Shovel", true, ((Component)player3.playerScript).transform.position, Quaternion.identity);
			}
		}

		private void ShipLeverModif(bool CanShipLever)
		{
			Debug.Log((object)("Ship Lever Modif to : " + CanShipLever));
			canShipLever = CanShipLever;
		}

		private void CreatingVoteManager()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			Debug.Log((object)"Creating VoteManager");
			GameObject val = new GameObject("ModManager");
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).hideFlags = (HideFlags)61;
			voteManager = val.AddComponent<VoteManager>();
		}

		private void GiveItemToPlayer(string itemString, ulong PlayerID)
		{
			if (PlayerID == Player.HostPlayer.ClientId)
			{
				try
				{
					Item.CreateAndGiveItem(itemString, Player.HostPlayer, true, true);
					return;
				}
				catch (NullReferenceException ex)
				{
					Debug.Log((object)("tema l'erreur " + ex.Message));
					return;
				}
			}
			Item.CreateAndGiveItem(itemString, Player.Get(PlayerID), true, true);
		}

		private void InfoMessageServerReception(string param, ulong ClientID)
		{
			Debug.Log((object)("Server Received Info Message " + param + " and client id :  " + ClientID));
		}

		private void InfoMessageClientReception(string message)
		{
			Player.LocalPlayer.QueueTip("INFO MESSAGE", message, 10f, 0, false, false, "LC_Tip1");
		}

		private void OnPlayerDied(DiedEventArgs ev)
		{
			if (ev.Player.IsLocalPlayer)
			{
				Debug.Log((object)"Player Died");
				if (m_Role == ERoles.Impostor)
				{
					PlayerDiedMessage.SendServer(true);
				}
				else
				{
					PlayerDiedMessage.SendServer(false);
				}
			}
		}

		private void OnPlayerDeathServer(bool isImpostor, ulong ClientID)
		{
			if (isImpostor)
			{
				Debug.Log((object)"Impostor Died");
				impostorCount--;
				if (impostorCount <= 0)
				{
					ServerInfoMessage.SendClients("the impostors are dead, the crewmates win!");
					CanShipLeverMessage.SendClients(true);
				}
			}
			else
			{
				crewMateCount--;
				if (crewMateCount <= 0)
				{
					ServerInfoMessage.SendClients("the crewmates are all dead, the impostors win!");
					CanShipLeverMessage.SendClients(true);
				}
			}
		}

		private void OnRoleReceivedForClient(int Role)
		{
			if (!isRoleReceived)
			{
				isRoleReceived = true;
				m_Role = (ERoles)Role;
				Debug.Log((object)("I AM  :  " + m_Role));
				if (m_Role == ERoles.Impostor)
				{
					RunKillCooldown(killCooldown);
				}
				else
				{
					((MonoBehaviour)this).StopAllCoroutines();
					canInstantKill = false;
				}
				Player.LocalPlayer.QueueTip("YOUR ROLE IS ", m_Role.ToString(), 15f, 1, true, false, "LC_Tip1");
			}
		}

		private void RunKillCoolDownOnClient(float cooldown)
		{
			if (m_Role == ERoles.Impostor)
			{
				RunKillCooldown(killCooldown);
			}
		}

		private void OntryKillServerCalculations(ulong param, ulong ClientID)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)("Server Received Try Kill Message " + param + " and client id :  " + ClientID));
			PlayerControllerB playerController = LethalNetworkExtensions.GetPlayerController(ClientID);
			if (!playerController.isPlayerControlled)
			{
				return;
			}
			RaycastHit[] array = Physics.RaycastAll(((Component)playerController.gameplayCamera).transform.position, ((Component)playerController.gameplayCamera).transform.forward, playerController.grabDistance, 8);
			RaycastHit[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				RaycastHit val = array2[i];
				if (((Component)((RaycastHit)(ref val)).collider).gameObject.CompareTag("Player") && (Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponent<PlayerControllerB>() != (Object)null && ((Component)((RaycastHit)(ref val)).collider).GetComponent<PlayerControllerB>().isPlayerControlled && LethalNetworkExtensions.GetClientId(((Component)((RaycastHit)(ref val)).collider).GetComponent<PlayerControllerB>()) != ClientID)
				{
					ulong clientId = LethalNetworkExtensions.GetClientId(((Component)((RaycastHit)(ref val)).collider).GetComponent<PlayerControllerB>());
					Debug.Log((object)("Player" + clientId + "  Hit"));
					TryKillMessage.SendClient(clientId, clientId);
					KillCoolDownMessage.SendClient(killCooldown, ClientID);
					break;
				}
			}
		}

		private void OnClientKill(ulong param)
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_009a: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)("Client Received Try Kill Message " + param));
			if ((Object)(object)Plugin.Instance.modManager.voteManager != (Object)null)
			{
				float num = (Plugin.Instance.modManager.voteManager.inVoteMode ? 1f : 5f);
				Player.LocalPlayer.Kill(Vector3.one * num, true, (CauseOfDeath)0, 0, default(Vector3));
			}
			else
			{
				Player.LocalPlayer.Kill(Vector3.one * 5f, true, (CauseOfDeath)0, 0, default(Vector3));
			}
		}

		internal void RunKillCooldown(float time)
		{
			if (KillRoutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(KillRoutine);
			}
			canInstantKill = false;
			KillRoutine = ((MonoBehaviour)this).StartCoroutine(KillCooldownWithTimer(time));
		}

		[Obsolete("Use KillCooldownWithTimer instead", true)]
		private IEnumerator KillCooldown(float time)
		{
			_ = time / 4f;
			yield return (object)new WaitForSeconds(time * 0.75f);
			Player.LocalPlayer.QueueTip("KILL COOLDOWN", "ENDS IN " + time * 0.25f + " SECONDS", 5f, 0, false, false, "LC_Tip1");
			yield return (object)new WaitForSeconds(time * 0.25f);
			Player.LocalPlayer.QueueTip("YOU CAN INSTANT KILL", "Just Press E on a Player", 10f, 0, false, false, "LC_Tip1");
			canInstantKill = true;
		}

		private IEnumerator KillCooldownWithTimer(float time)
		{
			float i = 0f;
			float rate = 1f / time;
			while (i < 1f)
			{
				killCoolDownTime = i * time;
				i += Time.deltaTime * rate;
				yield return 0;
			}
			Player.LocalPlayer.QueueTip("YOU CAN INSTANT KILL", "Just Press E on a Player", 10f, 0, false, false, "LC_Tip1");
			canInstantKill = true;
			killCoolDownTime = 0f;
		}

		internal void TeleportPlayerAtRandomLocation()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_003b: 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)
			//IL_0046: 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)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			if ((int)GameState.ShipState == 1)
			{
				Random random = new Random();
				Vector3 position = RoundManager.Instance.insideAINodes[random.Next(0, RoundManager.Instance.insideAINodes.Length)].transform.position;
				RoundManager instance = RoundManager.Instance;
				Random random2 = random;
				Vector3 randomNavMeshPositionInBoxPredictable = instance.GetRandomNavMeshPositionInBoxPredictable(position, 10f, default(NavMeshHit), random2, -1);
				Player.LocalPlayer.PlayerController.TeleportPlayer(randomNavMeshPositionInBoxPredictable, false, 0f, false, true);
			}
		}

		internal void TeleportPlayerAtRandomLocation(PlayerControllerB playerController)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_003b: 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)
			//IL_0046: 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)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			if ((int)GameState.ShipState == 1)
			{
				Random random = new Random();
				Vector3 position = RoundManager.Instance.insideAINodes[random.Next(0, RoundManager.Instance.insideAINodes.Length)].transform.position;
				RoundManager instance = RoundManager.Instance;
				Random random2 = random;
				Vector3 randomNavMeshPositionInBoxPredictable = instance.GetRandomNavMeshPositionInBoxPredictable(position, 10f, default(NavMeshHit), random2, -1);
				playerController.TeleportPlayer(randomNavMeshPositionInBoxPredictable, false, 0f, false, true);
			}
		}

		internal void CustomSpawnEnemy()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (Player.LocalPlayer.IsHost)
			{
				SpawnEnemyServerSide(Player.LocalPlayer.Position, 0uL);
			}
			else
			{
				SpawnEnemyClientSide();
			}
		}

		internal void SpawnEnemyServerSide(Vector3 position, ulong senderID)
		{
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			if (Player.LocalPlayer.IsInFactory)
			{
				if (RoundManager.Instance.currentLevel.Enemies.Count != 0)
				{
					int num = Random.Range(0, RoundManager.Instance.currentLevel.Enemies.Count);
					GameObject enemyPrefab = RoundManager.Instance.currentLevel.Enemies[0].enemyType.enemyPrefab;
					GameObject val = Object.Instantiate<GameObject>(enemyPrefab, position, Quaternion.Euler(Vector3.zero));
					val.gameObject.GetComponentInChildren<NetworkObject>().Spawn(true);
					RoundManager.Instance.SpawnedEnemies.Add(val.GetComponent<EnemyAI>());
					EnemyType enemyType = val.GetComponent<EnemyAI>().enemyType;
					enemyType.numberSpawned++;
				}
			}
			else if (RoundManager.Instance.currentLevel.OutsideEnemies.Count != 0)
			{
				int num2 = Random.Range(0, RoundManager.Instance.currentLevel.OutsideEnemies.Count);
				GameObject enemyPrefab2 = RoundManager.Instance.currentLevel.OutsideEnemies[0].enemyType.enemyPrefab;
				GameObject val2 = Object.Instantiate<GameObject>(enemyPrefab2, position, Quaternion.Euler(Vector3.zero));
				val2.gameObject.GetComponentInChildren<NetworkObject>().Spawn(true);
				RoundManager.Instance.SpawnedEnemies.Add(val2.GetComponent<EnemyAI>());
				EnemyType enemyType2 = val2.GetComponent<EnemyAI>().enemyType;
				enemyType2.numberSpawned++;
			}
		}

		internal void SpawnEnemyClientSide()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			SpawnEnemyOnPlayerPositionMessage.SendServer(Player.LocalPlayer.Position);
		}

		public void SpawnButton()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"creating testButton");
			Vector3 position = ((Component)Player.LocalPlayer.PlayerController).transform.position;
			Debug.Log((object)("player pos is " + ((object)(Vector3)(ref position)).ToString()));
			voteManager.VoteButtonCreation();
		}

		private void OnClientReceivedSync_1(Color parameters)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"Client Received Sync Parameters");
			if ((Object)(object)voteManager == (Object)null)
			{
				Debug.Log((object)"vote manager is null");
			}
			killCooldown = parameters.r;
			voteManager.voteCoolDown = parameters.g;
			voteManager.VoteTime = parameters.b;
			voteManager.ShortVoteTime = parameters.a;
			Debug.Log((object)("Kill Cooldown : " + killCooldown));
			Debug.Log((object)("Vote Cooldown : " + voteManager.voteCoolDown));
			Debug.Log((object)("Vote Time : " + voteManager.VoteTime));
			Debug.Log((object)("Time After Vote : " + voteManager.ShortVoteTime));
		}

		private void OnServerReceivedSync_1(Color parameters, ulong clientID)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			syncParametersMessage_1.SendClient(syncParameters_1, clientID);
		}

		internal static void ShuffleList<T>(List<T> list)
		{
			Random random = new Random();
			int num = list.Count;
			while (num > 1)
			{
				num--;
				int index = random.Next(num + 1);
				T value = list[index];
				list[index] = list[num];
				list[num] = value;
			}
		}

		private void OnCloseKillClientReceived(ulong parameter, ulong clientID)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)("Client Received Close Kill Message " + parameter + " and client id :  " + clientID));
			ulong clientId = Player.LocalPlayer.ClientId;
			Debug.Log((object)("Distance between players is " + Vector3.Distance(((Component)LethalNetworkExtensions.GetPlayerController(clientId)).transform.position, ((Component)LethalNetworkExtensions.GetPlayerController(clientID)).transform.position)));
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal class ModSync : MonoBehaviour
	{
		[HarmonyPatch("Singleton_OnClientConnectedCallback")]
		[HarmonyPostfix]
		private static void JoinLobbyPatch(ulong clientId)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)StartOfRound.Instance).IsHost)
			{
				Debug.Log((object)("AYAYA a player connected : " + LethalNetworkExtensions.GetPlayerController(clientId).playerUsername));
				Plugin.Instance.modManager.syncParametersMessage_1.SendClient(Plugin.Instance.modManager.syncParameters_1, clientId);
			}
		}

		[HarmonyPatch("Disconnect")]
		[HarmonyPostfix]
		private static void DisconnectPatch()
		{
			Debug.Log((object)"Disconnecting, stoping routines and etc");
			if (Plugin.Instance.modManager.KillRoutine != null)
			{
				((MonoBehaviour)Plugin.Instance.modManager).StopCoroutine(Plugin.Instance.modManager.KillRoutine);
			}
			if (Plugin.Instance.modManager.voteManager.VoteTimeRoutine != null)
			{
				((MonoBehaviour)Plugin.Instance.modManager).StopCoroutine(Plugin.Instance.modManager.voteManager.VoteTimeRoutine);
			}
			Plugin.Instance.modManager.voteManager.DestroyAllVoteObjects();
			Plugin.Instance.modManager.voteManager.inVoteMode = false;
			Plugin.Instance.modManager.canInstantKill = false;
			Plugin.Instance.modManager.canShipLever = true;
			Plugin.Instance.modManager.voteManager.canCallVote = false;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		private ManualLogSource Logger;

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void infiniteSprint(ref float ___sprintMeter)
		{
			if (___sprintMeter < 1f)
			{
				___sprintMeter += 0.03f * Time.deltaTime;
			}
		}

		[HarmonyPatch("KillPlayer")]
		[HarmonyPrefix]
		private static bool KillPlayerPatch(CauseOfDeath causeOfDeath)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Invalid comparison between Unknown and I4
			Debug.Log((object)("cause of death : " + ((object)(CauseOfDeath)(ref causeOfDeath)).ToString()));
			if (Plugin.Instance.modManager.m_Role == ModManager.ERoles.Impostor)
			{
				if ((int)causeOfDeath == 2 && Player.LocalPlayer.IsInFactory)
				{
					Plugin.Instance.modManager.TeleportPlayerAtRandomLocation();
					return false;
				}
				if (!Plugin.Instance.modManager.voteManager.inVoteMode && Random.Range(0f, 1f) > 0.5f)
				{
					Plugin.Instance.modManager.CustomSpawnEnemy();
				}
			}
			return true;
		}

		[HarmonyPatch("Interact_performed")]
		[HarmonyPostfix]
		private static void InteractPerformedPatch(ref ulong ___actualClientId, PlayerControllerB __instance)
		{
			if (Plugin.Instance.modManager.voteManager.inVoteMode)
			{
				InteractPerformedVoteMode(___actualClientId, __instance);
			}
			else
			{
				InteractPerformedPlayMode(___actualClientId, __instance);
			}
		}

		private static void InteractPerformedVoteMode(ulong ___actualClientId, PlayerControllerB __instance)
		{
			if (Plugin.Instance.modManager.voteManager.canVote)
			{
				Plugin.Instance.modManager.voteManager.VotePlayer();
			}
			else
			{
				Debug.Log((object)"you can't vote now");
			}
		}

		private static void InteractPerformedPlayMode(ulong ___actualClientId, PlayerControllerB __instance)
		{
			if (Plugin.Instance.modManager.canInstantKill && !Plugin.Instance.modManager.voteManager.inVoteMode)
			{
				Plugin.Instance.modManager.TryKillMessage.SendServer(___actualClientId);
			}
			if (Plugin.Instance.modManager.voteManager.buttonFound && Plugin.Instance.modManager.voteManager.canCallVote)
			{
				Plugin.Instance.modManager.voteManager.VoteCall();
			}
		}

		[HarmonyPatch("SetHoverTipAndCurrentInteractTrigger")]
		[HarmonyPostfix]
		private static void InteractTriggerPatch(PlayerControllerB __instance)
		{
			if (!((Object)(object)Plugin.Instance.modManager == (Object)null) && !((Object)(object)Plugin.Instance.modManager.voteManager == (Object)null))
			{
				if (Plugin.Instance.modManager.voteManager.inVoteMode)
				{
					TipHoverVoteMode(__instance);
				}
				else
				{
					TipHoverPlayMode(__instance);
				}
			}
		}

		private static void TipHoverVoteMode(PlayerControllerB __instance)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.isGrabbingObjectAnimation || __instance.inSpecialMenu || __instance.quickMenuManager.isMenuOpen)
			{
				return;
			}
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(((Component)__instance.gameplayCamera).transform.position, ((Component)__instance.gameplayCamera).transform.forward);
			RaycastHit[] array = Physics.RaycastAll(val, __instance.grabDistance * 10f, 8);
			RaycastHit[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				RaycastHit val2 = array2[i];
				if (((Component)((RaycastHit)(ref val2)).collider).gameObject.CompareTag("Player") && (Object)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponent<PlayerControllerB>() != (Object)null && ((Component)((RaycastHit)(ref val2)).collider).GetComponent<PlayerControllerB>().isPlayerControlled && LethalNetworkExtensions.GetClientId(((Component)((RaycastHit)(ref val2)).collider).GetComponent<PlayerControllerB>()) != LethalNetworkExtensions.GetClientId(__instance))
				{
					((Behaviour)__instance.cursorIcon).enabled = true;
					__instance.cursorIcon.sprite = __instance.grabItemIcon;
					((TMP_Text)__instance.cursorTip).text = "Vote for " + ((Component)((RaycastHit)(ref val2)).collider).GetComponent<PlayerControllerB>().playerUsername;
					break;
				}
			}
		}

		private static void TipHoverPlayMode(PlayerControllerB __instance)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.isGrabbingObjectAnimation || __instance.inSpecialMenu || __instance.quickMenuManager.isMenuOpen)
			{
				return;
			}
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(((Component)__instance.gameplayCamera).transform.position, ((Component)__instance.gameplayCamera).transform.forward);
			RaycastHit[] array = Physics.RaycastAll(val, __instance.grabDistance);
			bool flag = false;
			RaycastHit[] array2 = array;
			ButtonBehavior buttonBehavior = default(ButtonBehavior);
			for (int i = 0; i < array2.Length; i++)
			{
				RaycastHit val2 = array2[i];
				if (((Component)((RaycastHit)(ref val2)).collider).gameObject.CompareTag("Player") && (Object)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponent<PlayerControllerB>() != (Object)null && ((Component)((RaycastHit)(ref val2)).collider).GetComponent<PlayerControllerB>().isPlayerControlled && LethalNetworkExtensions.GetClientId(((Component)((RaycastHit)(ref val2)).collider).GetComponent<PlayerControllerB>()) != LethalNetworkExtensions.GetClientId(__instance) && Plugin.Instance.modManager.m_Role == ModManager.ERoles.Impostor)
				{
					if (Plugin.Instance.modManager.canInstantKill)
					{
						((Behaviour)__instance.cursorIcon).enabled = true;
						__instance.cursorIcon.sprite = __instance.grabItemIcon;
						((TMP_Text)__instance.cursorTip).text = "Murder : [E]";
					}
					else
					{
						int num = (int)(Plugin.Instance.modManager.killCooldown - Plugin.Instance.modManager.killCoolDownTime);
						((TMP_Text)__instance.cursorTip).text = "You can kill in : " + num;
					}
					break;
				}
				if ((Object)(object)((RaycastHit)(ref val2)).collider != (Object)null && ((Component)((RaycastHit)(ref val2)).collider).TryGetComponent<ButtonBehavior>(ref buttonBehavior))
				{
					if (Plugin.Instance.modManager.voteManager.canCallVote)
					{
						((Behaviour)__instance.cursorIcon).enabled = true;
						__instance.cursorIcon.sprite = __instance.grabItemIcon;
						((TMP_Text)__instance.cursorTip).text = "Call for a reunion";
						flag = true;
					}
					else
					{
						int num2 = (int)(Plugin.Instance.modManager.voteManager.voteCoolDown - Plugin.Instance.modManager.voteManager.voteCoolDownTime);
						((TMP_Text)__instance.cursorTip).text = "Reunion can be called in : " + num2;
						flag = true;
					}
					break;
				}
			}
			if (Plugin.Instance.modManager.voteManager.buttonFound != flag)
			{
				Plugin.Instance.modManager.voteManager.buttonFound = flag;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("ConnectClientToPlayerObject")]
		public static void InitializeLocalPlayer()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsHost)
			{
				Plugin.Instance.modManager.syncParametersMessage_1.SendServer(Plugin.Instance.modManager.syncParameters_1);
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("TinyTaurenMurder", "TinyTaurenMurder", "2.2.3")]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "TinyTaurenMurder";

		private const string NAME = "TinyTaurenMurder";

		private const string VERSION = "2.2.3";

		private Harmony m_Harmony = new Harmony("TinyTaurenMurder");

		internal static ManualLogSource Logger;

		public static Plugin Instance;

		internal ModManager modManager;

		internal static ModConfig Config { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			else
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			Config = new ModConfig(((BaseUnityPlugin)this).Config);
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin TinyTaurenMurder  is loaded!");
			m_Harmony.PatchAll(typeof(Plugin));
			m_Harmony.PatchAll(typeof(PlayerControllerBPatch));
			m_Harmony.PatchAll(typeof(MatchLeverPatch));
			m_Harmony.PatchAll(typeof(TurretPatch));
			m_Harmony.PatchAll(typeof(BlobPatch));
			m_Harmony.PatchAll(typeof(BugPatch));
			m_Harmony.PatchAll(typeof(HauntedMaskPatch));
			m_Harmony.PatchAll(typeof(HUDManagerPatch));
			m_Harmony.PatchAll(typeof(ModSync));
			m_Harmony.PatchAll(typeof(StartOfRoundPatch));
			m_Harmony.PatchAll(typeof(ModConfig));
			Task.Delay(10).ContinueWith(delegate
			{
				CreateModManager();
			});
		}

		public void LogMessage(string message)
		{
			Logger.LogInfo((object)message);
		}

		internal static void CreateModManager()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			Debug.Log((object)"Creating ModManager");
			Logger.LogInfo((object)"Creating ModManager");
			Logger.LogInfo((object)"Swaaaaaaaaaaag");
			GameObject val = new GameObject("ModManager");
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).hideFlags = (HideFlags)61;
			ModManager modManager = val.AddComponent<ModManager>();
			Instance.modManager = modManager;
		}

		internal static ulong GetMyPlayerID()
		{
			ulong[] otherConnectedClients = LNetworkUtils.OtherConnectedClients;
			return 6uL;
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("ReviveDeadPlayers")]
		[HarmonyPostfix]
		private static void ReviveDeadPlayersPatch()
		{
		}
	}
	[HarmonyPatch(typeof(Turret))]
	internal class TurretPatch
	{
		[HarmonyPatch("CheckForPlayersInLineOfSight")]
		[HarmonyPostfix]
		private static PlayerControllerB CheckLineSightPatch(PlayerControllerB playerOutput)
		{
			if ((Object)(object)playerOutput == (Object)null)
			{
				return null;
			}
			if ((Object)(object)Plugin.Instance.modManager == (Object)null)
			{
				return playerOutput;
			}
			if (Plugin.Instance.modManager.playerList[(int)LethalNetworkExtensions.GetClientId(playerOutput)].role == ModManager.ERoles.Impostor)
			{
				return null;
			}
			return playerOutput;
		}
	}
	internal class VoteManager : MonoBehaviour
	{
		internal struct FplayerVote
		{
			internal ModManager.FPlayer Player;

			internal int voteNumber;

			public FplayerVote()
			{
				Player = new ModManager.FPlayer();
				voteNumber = 0;
			}

			public FplayerVote(ModManager.FPlayer player, int voteNumber)
			{
				Player = player;
				this.voteNumber = voteNumber;
			}
		}

		internal LNetworkMessage<Vector3> voteCallMessage;

		internal LNetworkMessage<Vector3> ButtonCreationMessage;

		internal LNetworkMessage<bool> EndVoteMessage;

		internal LNetworkMessage<int> VotePlayerMessage;

		public static AssetBundle voteButtonBundle;

		internal VotePositions VotePositions;

		internal bool buttonFound = false;

		internal bool canCallVote = false;

		internal float voteCoolDown = 30f;

		internal float voteCoolDownTime = 0f;

		internal bool inVoteMode = false;

		internal bool canVote = false;

		internal TMP_Text VoteTimer;

		internal Coroutine VoteTimeRoutine;

		internal float VoteTime = 30f;

		internal float ShortVoteTime = 7f;

		private GameObject VoteButtonGO;

		private GameObject VoteTimerGO;

		private GameObject VotePositionsGO;

		private GameObject VoteRoomGO;

		private Vector3 VoteTarget;

		private List<FplayerVote> playerVotes = new List<FplayerVote>();

		private void Awake()
		{
			voteCallMessage = LNetworkMessage<Vector3>.Create("VoteCall", (Action<Vector3, ulong>)null, (Action<Vector3>)null, (Action<Vector3, ulong>)null);
			ButtonCreationMessage = LNetworkMessage<Vector3>.Create("ButtonCreation", (Action<Vector3, ulong>)null, (Action<Vector3>)null, (Action<Vector3, ulong>)null);
			EndVoteMessage = LNetworkMessage<bool>.Create("EndVote", (Action<bool, ulong>)null, (Action<bool>)null, (Action<bool, ulong>)null);
			VotePlayerMessage = LNetworkMessage<int>.Create("VotePlayer", (Action<int, ulong>)null, (Action<int>)null, (Action<int, ulong>)null);
		}

		private void OnEnable()
		{
			voteCallMessage.OnServerReceived += VoteCallServerReceived;
			voteCallMessage.OnClientReceived += VoteCallClientReceived;
			ButtonCreationMessage.OnServerReceived += VoteButtonCreationServerReceived;
			ButtonCreationMessage.OnClientReceived += VoteButtonCreationClientReceived;
			EndVoteMessage.OnServerReceived += EndVoteServerReceived;
			EndVoteMessage.OnClientReceived += EndVoteClientReceived;
			VotePlayerMessage.OnServerReceived += VotePlayerServerReceived;
			VotePlayerMessage.OnClientReceived += VotePlayerClientReceived;
		}

		private void OnDisable()
		{
			voteCallMessage.OnServerReceived -= VoteCallServerReceived;
			voteCallMessage.OnClientReceived -= VoteCallClientReceived;
			ButtonCreationMessage.OnServerReceived -= VoteButtonCreationServerReceived;
			ButtonCreationMessage.OnClientReceived -= VoteButtonCreationClientReceived;
			EndVoteMessage.OnServerReceived -= EndVoteServerReceived;
			EndVoteMessage.OnClientReceived -= EndVoteClientReceived;
			VotePlayerMessage.OnServerReceived -= VotePlayerServerReceived;
			VotePlayerMessage.OnClientReceived -= VotePlayerClientReceived;
		}

		private IEnumerator VoteCoolDown(float time)
		{
			float i = 0f;
			float rate = 1f / time;
			while (i < 1f)
			{
				voteCoolDownTime = i * time;
				i += Time.deltaTime * rate;
				yield return 0;
			}
			canCallVote = true;
		}

		internal void VoteButtonCreation()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Component)Player.LocalPlayer.PlayerController).transform.position + ((Component)Player.LocalPlayer.PlayerController).transform.forward * 15f;
			val = ((Component)StartOfRound.Instance.shipBounds).transform.position + -((Component)StartOfRound.Instance.shipBounds).transform.right * 20f + Vector3.down * 10f;
			if (Player.LocalPlayer.IsHost)
			{
				VoteButtonCreationServerReceived(val, Player.HostPlayer.ClientId);
			}
			else
			{
				ButtonCreationMessage.SendServer(val);
			}
		}

		private void VoteButtonCreationServerReceived(Vector3 message, ulong clientID)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			ButtonCreationMessage.SendClients(message);
		}

		private void VoteButtonCreationClientReceived(Vector3 message)
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)voteButtonBundle == (Object)null)
			{
				string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
				Debug.Log((object)Path.Combine(directoryName, "modassets"));
				voteButtonBundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "modassets"));
			}
			VoteButtonGO = voteButtonBundle.LoadAsset<GameObject>("Button");
			VoteRoomGO = voteButtonBundle.LoadAsset<GameObject>("VoteRoom");
			VotePositionsGO = voteButtonBundle.LoadAsset<GameObject>("VotePositions");
			VoteTimerGO = voteButtonBundle.LoadAsset<GameObject>("Vote_Timer");
			VoteButtonGO = Object.Instantiate<GameObject>(VoteButtonGO, message, Quaternion.identity);
			VoteButtonGO.AddComponent<ButtonBehavior>();
			VoteRoomGO = Object.Instantiate<GameObject>(VoteRoomGO, message + Vector3.up * 100f, Quaternion.identity);
			VoteTimerGO = Object.Instantiate<GameObject>(VoteTimerGO, message + Vector3.up * 100f, Quaternion.identity);
			VoteTimer = VoteTimerGO.GetComponentInChildren<TMP_Text>();
			VoteTimer.text = "its working";
			((MonoBehaviour)this).StartCoroutine(VoteCoolDown(voteCoolDown));
			VotePositionsGO = Object.Instantiate<GameObject>(VotePositionsGO, message + Vector3.up * 100f, Quaternion.identity);
			VotePositions = VotePositionsGO.AddComponent<VotePositions>();
		}

		internal void DestroyAllVoteObjects()
		{
			if ((Object)(object)VoteButtonGO != (Object)null)
			{
				Object.Destroy((Object)(object)VoteButtonGO);
			}
			if ((Object)(object)VoteRoomGO != (Object)null)
			{
				Object.Destroy((Object)(object)VoteRoomGO);
			}
			if ((Object)(object)VotePositionsGO != (Object)null)
			{
				Object.Destroy((Object)(object)VotePositionsGO);
			}
			if ((Object)(object)VoteTimerGO != (Object)null)
			{
				Object.Destroy((Object)(object)VoteTimerGO);
			}
		}

		internal void VoteCall()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (Player.LocalPlayer.IsHost)
			{
				VoteCallServerReceived(Vector3.zero, Player.HostPlayer.ClientId);
			}
			else
			{
				voteCallMessage.SendServer(Vector3.zero);
			}
		}

		private void VoteCallServerReceived(Vector3 message, ulong clientID)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = message;
			Debug.Log((object)("message received : " + ((object)(Vector3)(ref val)).ToString()));
			if ((Object)(object)VotePositions == (Object)null)
			{
				return;
			}
			VotePositions.ClearChairs();
			foreach (ModManager.FPlayer player in Plugin.Instance.modManager.playerList)
			{
				VotePositions.FindEmptyChair(out var position);
				Vector3 position2 = position.transform.position;
				voteCallMessage.SendClient(position2, player.playerID);
			}
			playerVotes.Clear();
			foreach (ModManager.FPlayer player2 in Plugin.Instance.modManager.playerList)
			{
				if (!player2.API_Player.IsDead)
				{
					playerVotes.Add(new FplayerVote(player2, 0));
				}
			}
		}

		private void VoteCallClientReceived(Vector3 pos)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"client received vote call");
			((Behaviour)VoteTimer).enabled = true;
			TeleportPlayerToVote(pos);
			canVote = true;
			canCallVote = false;
			if (VoteTimeRoutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(VoteTimeRoutine);
			}
			VoteTimeRoutine = ((MonoBehaviour)this).StartCoroutine(TimerRoutine(VoteTime));
			if (Plugin.Instance.modManager.m_Role == ModManager.ERoles.Impostor && Plugin.Instance.modManager.KillRoutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(Plugin.Instance.modManager.KillRoutine);
			}
		}

		private void EndVote()
		{
			if (Player.LocalPlayer.IsHost)
			{
				EndVoteServerReceived(isKilled: false, Player.HostPlayer.ClientId);
			}
		}

		private void EndVoteServerReceived(bool isKilled, ulong ClientID)
		{
			Debug.Log((object)"Server End vote received");
			List<FplayerVote> EqualVotePlayerList = new List<FplayerVote>();
			if (IsThereEqualVotes(out EqualVotePlayerList))
			{
				Debug.Log((object)"equal votes, no one will be killed");
				{
					foreach (FplayerVote playerVote in playerVotes)
					{
						EndVoteMessage.SendClient(false, playerVote.Player.playerID);
					}
					return;
				}
			}
			foreach (FplayerVote playerVote2 in playerVotes)
			{
				if (playerVote2.Player.playerID == EqualVotePlayerList[0].Player.playerID)
				{
					EndVoteMessage.SendClient(true, playerVote2.Player.playerID);
				}
				else
				{
					EndVoteMessage.SendClient(false, playerVote2.Player.playerID);
				}
			}
		}

		private void EndVoteClientReceived(bool isKilled)
		{
			//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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			((Behaviour)VoteTimer).enabled = false;
			if (VoteTimeRoutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(VoteTimeRoutine);
			}
			((MonoBehaviour)this).StartCoroutine(VoteCoolDown(voteCoolDown));
			if (isKilled)
			{
				Player.LocalPlayer.Kill(Vector3.one * 5f, true, (CauseOfDeath)0, 0, default(Vector3));
				return;
			}
			Player.LocalPlayer.PlayerController.disableLookInput = false;
			Player.LocalPlayer.PlayerController.timeSinceStartingEmote = 0f;
			Player.LocalPlayer.PlayerController.performingEmote = true;
			Player.LocalPlayer.PlayerController.playerBodyAnimator.SetInteger("emoteNumber", 1);
			Player.LocalPlayer.PlayerController.StartPerformingEmoteServerRpc();
			Task.Delay((int)ShortVoteTime * 1000).ContinueWith(delegate
			{
				ReleasePlayer();
			});
		}

		internal void VotePlayer()
		{
			canVote = false;
			if (Player.LocalPlayer.IsHost)
			{
				VotePlayerServerReceived(1, Player.HostPlayer.ClientId);
			}
			else
			{
				VotePlayerMessage.SendServer(1);
			}
		}

		private void VotePlayerClientReceived(int voteNumber)
		{
			if (voteNumber == 0)
			{
				Debug.Log((object)"you voted on the wall");
				canVote = true;
				return;
			}
			Debug.Log((object)"you voted on a player");
			canVote = false;
			Player.LocalPlayer.PlayerController.disableLookInput = true;
			Player.LocalPlayer.PlayerController.timeSinceStartingEmote = 0f;
			Player.LocalPlayer.PlayerController.performingEmote = true;
			Player.LocalPlayer.PlayerController.playerBodyAnimator.SetInteger("emoteNumber", 2);
			Player.LocalPlayer.PlayerController.StartPerformingEmoteServerRpc();
		}

		private void VotePlayerServerReceived(int voteNumber, ulong ClientID)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)("Server received vote Message " + voteNumber + " and client id :  " + ClientID));
			PlayerControllerB playerController = LethalNetworkExtensions.GetPlayerController(ClientID);
			if (!playerController.isPlayerControlled)
			{
				return;
			}
			RaycastHit[] array = Physics.RaycastAll(((Component)playerController.gameplayCamera).transform.position, ((Component)playerController.gameplayCamera).transform.forward, playerController.grabDistance * 10f, 8);
			RaycastHit[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				RaycastHit val = array2[i];
				if (!((Component)((RaycastHit)(ref val)).collider).gameObject.CompareTag("Player") || !((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponent<PlayerControllerB>() != (Object)null) || !((Component)((RaycastHit)(ref val)).collider).GetComponent<PlayerControllerB>().isPlayerControlled || LethalNetworkExtensions.GetClientId(((Component)((RaycastHit)(ref val)).collider).GetComponent<PlayerControllerB>()) == ClientID)
				{
					continue;
				}
				ulong clientId = LethalNetworkExtensions.GetClientId(((Component)((RaycastHit)(ref val)).collider).GetComponent<PlayerControllerB>());
				Debug.Log((object)("Player" + clientId + "  voted"));
				if (Plugin.Instance.modManager.GetPlayerByID(clientId, out var player))
				{
					if (GetPlayerVoteIndex(player, out var playerVoteIndex))
					{
						playerVotes[playerVoteIndex] = new FplayerVote(playerVotes[playerVoteIndex].Player, playerVotes[playerVoteIndex].voteNumber + 1);
						VotePlayerMessage.SendClient(1, ClientID);
						foreach (FplayerVote playerVote in playerVotes)
						{
							ulong playerID = playerVote.Player.playerID;
							string text = playerID.ToString();
							int voteNumber2 = playerVote.voteNumber;
							Debug.Log((object)("Player : " + text + "  votes : " + voteNumber2));
						}
						if (AllVotesDone())
						{
							Debug.Log((object)("vote number is : " + voteNumber + "  playerVotes.Count : " + playerVotes.Count + "ending vote"));
							EndVote();
						}
						return;
					}
					Debug.Log((object)"can't get player index");
					break;
				}
				Debug.Log((object)"can't get player by ID");
				break;
			}
			VotePlayerMessage.SendClient(0, ClientID);
		}

		private void ReleasePlayer()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			Player.LocalPlayer.PlayerController.disableMoveInput = false;
			Player.LocalPlayer.PlayerController.TeleportPlayer(VotePositions.PositionBeforeVote, false, 0f, false, true);
			((MonoBehaviour)this).StopCoroutine(VoteTimeRoutine);
			inVoteMode = false;
			canVote = false;
			if (Plugin.Instance.modManager.m_Role == ModManager.ERoles.Impostor)
			{
				Plugin.Instance.modManager.RunKillCooldown(Plugin.Instance.modManager.killCooldown);
			}
		}

		private void TeleportPlayerToVote(Vector3 pos)
		{
			//IL_004b: 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_0056: 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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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)
			if ((Object)(object)VotePositions != (Object)null)
			{
				VotePositions.PositionBeforeVote = pos + Vector3.down * 98f;
			}
			Player.LocalPlayer.PlayerController.disableMoveInput = true;
			Player.LocalPlayer.PlayerController.TeleportPlayer(pos + Vector3.up * 5f, false, 0f, false, true);
			inVoteMode = true;
		}

		internal bool GetPlayerVoteIndex(ModManager.FPlayer player, out int playerVoteIndex)
		{
			playerVoteIndex = -1;
			for (int i = 0; i < playerVotes.Count; i++)
			{
				if (playerVotes[i].Player.playerID == player.playerID)
				{
					playerVoteIndex = i;
					return true;
				}
			}
			return false;
		}

		private bool AllVotesDone()
		{
			int num = 0;
			foreach (FplayerVote playerVote in playerVotes)
			{
				num += playerVote.voteNumber;
			}
			if (num >= playerVotes.Count)
			{
				return true;
			}
			return false;
		}

		internal ulong FindPlayerIDWithMostVotes(out int maxVotes)
		{
			maxVotes = 0;
			ulong result = 0uL;
			foreach (FplayerVote playerVote in playerVotes)
			{
				if (playerVote.voteNumber > maxVotes)
				{
					maxVotes = playerVote.voteNumber;
					result = playerVote.Player.playerID;
				}
			}
			return result;
		}

		internal FplayerVote FindPlayerWithMostVotes(out int maxVotes)
		{
			maxVotes = 0;
			FplayerVote result = new FplayerVote();
			foreach (FplayerVote playerVote in playerVotes)
			{
				if (playerVote.voteNumber > maxVotes)
				{
					maxVotes = playerVote.voteNumber;
					result = playerVote;
				}
			}
			return result;
		}

		internal bool IsThereEqualVotes(out List<FplayerVote> EqualVotePlayerList)
		{
			EqualVotePlayerList = new List<FplayerVote>();
			int maxVotes = 0;
			int num = 0;
			EqualVotePlayerList.Add(FindPlayerWithMostVotes(out maxVotes));
			foreach (FplayerVote playerVote in playerVotes)
			{
				num += playerVote.voteNumber;
				if (playerVote.voteNumber == maxVotes && !EqualVotePlayerList.Contains(playerVote))
				{
					EqualVotePlayerList.Add(playerVote);
				}
			}
			if (playerVotes.Count / 2 >= num)
			{
				return true;
			}
			if (EqualVotePlayerList.Count > 1)
			{
				Debug.Log((object)("there is equal votings of " + EqualVotePlayerList.Count + " players"));
				return true;
			}
			Debug.Log((object)("one player must die : " + EqualVotePlayerList[0].Player.API_Player.Username));
			return false;
		}

		private IEnumerator TimerRoutine(float time)
		{
			float timer = time;
			VoteTimer.text = "Time left : " + timer + " seconds";
			while (timer > 0f)
			{
				yield return (object)new WaitForSeconds(1f);
				timer -= 1f;
				VoteTimer.text = "Time left : " + timer + " seconds";
			}
			VoteTimer.text = "no Time Left";
			EndVote();
			yield return 0;
		}
	}
	internal class VotePositions : MonoBehaviour
	{
		internal struct FVotePosition
		{
			internal Transform transform;

			internal bool isOccupied;

			internal int voteCount;

			internal FVotePosition(Transform transform)
			{
				this.transform = transform;
				isOccupied = false;
				voteCount = 0;
			}

			internal FVotePosition(Transform transform, bool isOccupied, int voteCount)
			{
				this.transform = transform;
				this.isOccupied = isOccupied;
				this.voteCount = voteCount;
			}
		}

		private List<FVotePosition> positionsList = new List<FVotePosition>();

		internal Vector3 PositionBeforeVote;

		private void Awake()
		{
			for (int i = 0; i < ((Component)this).transform.childCount; i++)
			{
				positionsList.Add(new FVotePosition(((Component)this).transform.GetChild(i)));
				Debug.Log((object)("Added transform : " + ((Object)((Component)this).transform.GetChild(i)).name));
			}
		}

		internal bool FindEmptyChair(out FVotePosition position)
		{
			List<FVotePosition> list = positionsList;
			ModManager.ShuffleList(list);
			position = list[0];
			for (int i = 0; i < list.Count; i++)
			{
				if (!list[i].isOccupied)
				{
					position = list[i];
					list[i] = new FVotePosition(list[i].transform, isOccupied: true, list[i].voteCount);
					positionsList = list;
					return true;
				}
			}
			return false;
		}

		internal void ClearChairs()
		{
			for (int i = 0; i < ((Component)this).transform.childCount; i++)
			{
				positionsList[i] = new FVotePosition(((Component)this).transform.GetChild(i));
			}
		}

		private void OnEnable()
		{
		}

		private void OnDisable()
		{
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LethalMurder";

		public const string PLUGIN_NAME = "My first plugin";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}