Decompiled source of Lethal Company Hide n Seek v1.2.1
LCHideAndSeekMod.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LCHideAndSeekMod.Core; using LCHideAndSeekMod.Core.Configuration; using LCHideAndSeekMod.Core.PlayerStats; using LethalConfig; using LethalConfig.ConfigItems; using TMPro; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("LCHideAndSeekMod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("LCHideAndSeekMod")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("2c31fa94-da26-4c78-be27-a22e4a8196e8")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] public class EndGameStatsUI : MonoBehaviour { public static EndGameStatsUI Instance; private List<TextMeshProUGUI> playerTexts = new List<TextMeshProUGUI>(); private List<TextMeshProUGUI> statTexts = new List<TextMeshProUGUI>(); private TextMeshProUGUI RoundNumber; private TextMeshProUGUI RoundTime; private TextMeshProUGUI WinnerText; private Image uiBase; public void Awake() { Instance = this; uiBase = ((Component)this).gameObject.GetComponentInChildren<Image>(); TextMeshProUGUI[] componentsInChildren = ((Component)this).GetComponentsInChildren<TextMeshProUGUI>(); for (int i = 0; i < 5; i++) { ((TMP_Text)componentsInChildren[i]).maxVisibleLines = 4; playerTexts.Add(componentsInChildren[i]); } for (int num = 9; num > 4; num--) { ((TMP_Text)componentsInChildren[num]).maxVisibleLines = 4; statTexts.Add(componentsInChildren[num]); } RoundNumber = componentsInChildren[10]; RoundTime = componentsInChildren[11]; WinnerText = componentsInChildren[12]; HideAll(); } private void HideAll() { ((Behaviour)uiBase).enabled = false; foreach (TextMeshProUGUI playerText in playerTexts) { ((Behaviour)playerText).enabled = false; } foreach (TextMeshProUGUI statText in statTexts) { ((Behaviour)statText).enabled = false; } ((Behaviour)RoundNumber).enabled = false; ((Behaviour)RoundTime).enabled = false; ((Behaviour)WinnerText).enabled = false; } public void Display() { FillWithStats(); ((MonoBehaviour)this).StartCoroutine(DisplayStats()); } private void FillWithStats() { for (int i = 0; i < PlayerStatManager.Instance.Stats.Count; i++) { StatBase statBase = PlayerStatManager.Instance.Stats.ElementAt(i); ((TMP_Text)playerTexts.ElementAt(i)).text = statBase.Player.playerUsername; ((TMP_Text)statTexts.ElementAt(i)).text = $"Tier {statBase.GetTier()}: {statBase.GetComment()}"; } ((TMP_Text)RoundNumber).text = Convert.ToString(GameManager.RoundCount - 1); ((TMP_Text)RoundTime).text = PlayerStatManager.Instance.MatchTime; int result = GameManager.Instance.Result; ((TMP_Text)WinnerText).text = result switch { 1 => "Seekers Win!", 0 => "Hiders Win!", _ => "Draw!", }; } private IEnumerator DisplayStats() { ((Behaviour)uiBase).enabled = true; ((Behaviour)WinnerText).enabled = true; yield return (object)new WaitForSeconds(0.5f); for (int i = 0; i < 5; i++) { ((Behaviour)playerTexts[i]).enabled = true; yield return (object)new WaitForSeconds(1f); ((Behaviour)statTexts[i]).enabled = true; } yield return (object)new WaitForSeconds(0.2f); ((Behaviour)RoundNumber).enabled = true; yield return (object)new WaitForSeconds(0.2f); ((Behaviour)RoundTime).enabled = true; yield return (object)new WaitForSeconds(3f); HideAll(); } public void OnDisable() { try { foreach (TextMeshProUGUI playerText in playerTexts) { ((TMP_Text)playerText).text = ""; } foreach (TextMeshProUGUI statText in statTexts) { ((TMP_Text)statText).text = ""; } ((TMP_Text)RoundNumber).text = ""; ((TMP_Text)RoundTime).text = ""; ((TMP_Text)WinnerText).text = ""; } catch (Exception) { } } } namespace LCHideAndSeekMod { [BepInPlugin("Tibnan.LCHideAndSeekMod", "LCHideAndSeekMod", "1.2.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class ModBase : BaseUnityPlugin { private const string guid = "Tibnan.LCHideAndSeekMod"; private const string modName = "LCHideAndSeekMod"; public const string Version = "1.2.1"; public static ManualLogSource mls; private readonly Harmony harmony = new Harmony("Tibnan.LCHideAndSeekMod"); public static ModBase Instance; public static Font ModFont; public static ConfigFile ModConfig = new ConfigFile("Tibnan.LCHideAndSeekMod", true); public static GameObject TPMineExplosion; public static GameObject TPMine; public static GameObject EndOfGameStatsBlue; public static GameObject EndOfGameStatsOrange; public void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = Logger.CreateLogSource("LCHideAndSeekMod"); harmony.PatchAll(Assembly.GetExecutingAssembly()); AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "lchns")); ModFont = val.LoadAsset<Font>("Assets\\Prefabs\\PerfectDOSVGA437.ttf"); TPMineExplosion = val.LoadAsset<GameObject>("Assets\\Prefabs\\TPMineExplosion.prefab"); TPMine = val.LoadAsset<GameObject>("Assets\\Custom\\TPMineComplete.prefab"); EndOfGameStatsBlue = val.LoadAsset<GameObject>("Assets\\Custom\\EndGameStats_blue.prefab"); EndOfGameStatsOrange = val.LoadAsset<GameObject>("Assets\\Custom\\EndGameStats_orange.prefab"); ConfigProcessor.AddConfigItems(); mls.LogInfo((object)"LC Hide and Seek mod loaded."); } } } namespace LCHideAndSeekMod.Patches { [HarmonyPatch(typeof(GameNetworkManager))] internal class GameNetworkManagerPatch { [HarmonyPatch("Start")] [HarmonyPostfix] public static void AddPrefabs(ref GameNetworkManager __instance) { ((Component)__instance).gameObject.GetComponent<NetworkManager>().AddNetworkPrefab(ModBase.TPMine); } [HarmonyPatch("Disconnect")] [HarmonyPrefix] public static void Reset() { HNSValues.TPMines.Clear(); GameManager.Instance = new GameManager(); GameManager.RoundCount = 1; PlayerStatManager.Instance = null; ConfigProcessor.Reset(); PlayerStatManager.Reset(); HNSValues.FirstWeaponReceived = false; } } [HarmonyPatch(typeof(HUDManager))] internal class HUDManagerPatch { [HarmonyPatch("ApplyPenalty")] [HarmonyPrefix] public static bool StopPenalty(HUDManager __instance) { ((Behaviour)__instance.endgameStatsAnimator).enabled = false; __instance.endgameStatsAnimator.Rebind(); ((Behaviour)__instance.endgameStatsAnimator).enabled = true; return false; } public static void AddRemoteChatMsg(ulong _, FastBufferReader reader) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0065: 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_0079: 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) string text = ""; int num = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives)); char c = default(char); for (int i = 0; i < num; i++) { ((FastBufferReader)(ref reader)).ReadValueSafe<char>(ref c, default(ForPrimitives)); text += c; } ulong sender = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref sender, default(ForPrimitives)); ulong num2 = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref num2, default(ForPrimitives)); PlayerControllerB val = ((IEnumerable<PlayerControllerB>)StartOfRound.Instance.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB x) => x.playerClientId == sender)); typeof(HUDManager).GetMethod("AddChatMessage", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(HUDManager.Instance, new object[2] { (num2 == ulong.MaxValue) ? text : ("/w" + text), val.playerUsername }); } [HarmonyPatch("AddChatMessage")] [HarmonyPrefix] public static bool StopTextChatSrv(ref string chatMessage, ref string nameOfUserWhoTyped, HUDManager __instance) { if (!StartOfRound.Instance.inShipPhase) { HNSPlayerComponent component = ((Component)GameNetworkManager.Instance.localPlayerController).GetComponent<HNSPlayerComponent>(); if (component != null && component.Role == PlayerRole.Seeker) { return false; } } if (__instance.lastChatMessage == chatMessage) { return false; } __instance.lastChatMessage = chatMessage; __instance.PingHUDElement(__instance.Chat, 4f, 1f, 0.2f); if (__instance.ChatMessageHistory.Count >= 4) { ((TMP_Text)__instance.chatText).text.Remove(0, __instance.ChatMessageHistory[0].Length); __instance.ChatMessageHistory.Remove(__instance.ChatMessageHistory[0]); } StringBuilder stringBuilder = new StringBuilder(chatMessage); stringBuilder.Replace("[playerNum0]", StartOfRound.Instance.allPlayerScripts[0].playerUsername); stringBuilder.Replace("[playerNum1]", StartOfRound.Instance.allPlayerScripts[1].playerUsername); stringBuilder.Replace("[playerNum2]", StartOfRound.Instance.allPlayerScripts[2].playerUsername); stringBuilder.Replace("[playerNum3]", StartOfRound.Instance.allPlayerScripts[3].playerUsername); chatMessage = stringBuilder.ToString(); string item = ((!string.IsNullOrEmpty(nameOfUserWhoTyped)) ? ("<color=#FF0000>" + nameOfUserWhoTyped + (chatMessage.StartsWith("/w") ? "</color>: <color=#00FF00>'" : "</color>: <color=#FFFF00>'") + chatMessage.Replace("/w", "") + "'</color>") : ("<color=#7069ff>" + chatMessage + "</color>")); __instance.ChatMessageHistory.Add(item); ((TMP_Text)__instance.chatText).text = ""; for (int i = 0; i < __instance.ChatMessageHistory.Count; i++) { TextMeshProUGUI chatText = __instance.chatText; ((TMP_Text)chatText).text = ((TMP_Text)chatText).text + "\n" + __instance.ChatMessageHistory[i]; } return false; } [HarmonyPatch("AddTextToChatOnServer")] [HarmonyPrefix] public static bool StopTextChatSrv2(ref string chatMessage, ref int playerId) { //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) if (playerId == -1) { return true; } PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerId]; if (!StartOfRound.Instance.inShipPhase) { HNSPlayerComponent component = ((Component)val).gameObject.GetComponent<HNSPlayerComponent>(); if (component != null && component.Role == PlayerRole.Seeker) { goto IL_0409; } } string text; PlayerControllerB val2; if (chatMessage.StartsWith("/w ")) { text = chatMessage.Substring(3).TakeWhile((char c) => c != ' ').ToArray() .Aggregate("", (string a, char b) => a + b); ModBase.mls.LogError((object)text); val2 = null; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val3 in allPlayerScripts) { if (val3.playerUsername.ToLower().Contains(text)) { val2 = val3; break; } } if (!StartOfRound.Instance.inShipPhase) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2 == (Object)(object)val)) { HNSPlayerComponent component2 = ((Component)val2).gameObject.GetComponent<HNSPlayerComponent>(); if (component2 != null && component2.Role == PlayerRole.Hider) { goto IL_016c; } } return false; } goto IL_016c; } FastBufferWriter val4 = default(FastBufferWriter); ((FastBufferWriter)(ref val4))..ctor(4 + chatMessage.Length * 2 + 16, (Allocator)2, -1); int length = chatMessage.Length; ((FastBufferWriter)(ref val4)).WriteValueSafe<int>(ref length, default(ForPrimitives)); string text2 = chatMessage; for (int j = 0; j < text2.Length; j++) { char c2 = text2[j]; ((FastBufferWriter)(ref val4)).WriteValueSafe<char>(ref c2, default(ForPrimitives)); } ((FastBufferWriter)(ref val4)).WriteValueSafe<ulong>(ref val.playerClientId, default(ForPrimitives)); ulong num = ulong.MaxValue; ((FastBufferWriter)(ref val4)).WriteValueSafe<ulong>(ref num, default(ForPrimitives)); if (NetworkManager.Singleton.IsServer) { NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("Tibnan.hnsmod_ClientAddRemoteTextMsg", val4, (NetworkDelivery)2); } else { NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("Tibnan.hnsmod_RequestRemoteMsgAddFromServer", 0uL, val4, (NetworkDelivery)2); } typeof(HUDManager).GetMethod("AddChatMessage", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(HUDManager.Instance, new object[2] { chatMessage, val.playerUsername }); goto IL_0409; IL_0409: return false; IL_016c: string text3 = chatMessage.Replace("/w ", "").Replace(text + " ", ""); if ((Object)(object)val2 == (Object)(object)GameNetworkManager.Instance.localPlayerController) { typeof(HUDManager).GetMethod("AddChatMessage", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(HUDManager.Instance, new object[2] { "/w" + text3, val.playerUsername }); return false; } FastBufferWriter val5 = default(FastBufferWriter); ((FastBufferWriter)(ref val5))..ctor(4 + text3.Length * 2 + 16, (Allocator)2, -1); length = text3.Length; ((FastBufferWriter)(ref val5)).WriteValueSafe<int>(ref length, default(ForPrimitives)); string text4 = text3; for (int k = 0; k < text4.Length; k++) { char c3 = text4[k]; ((FastBufferWriter)(ref val5)).WriteValueSafe<char>(ref c3, default(ForPrimitives)); } ((FastBufferWriter)(ref val5)).WriteValueSafe<ulong>(ref val.playerClientId, default(ForPrimitives)); ((FastBufferWriter)(ref val5)).WriteValueSafe<ulong>(ref val2.playerClientId, default(ForPrimitives)); if (NetworkManager.Singleton.IsServer) { NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("Tibnan.hnsmod_ClientAddRemoteTextMsg", val2.playerClientId, val5, (NetworkDelivery)2); } else { NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("Tibnan.hnsmod_RequestRemoteMsgAddFromServer", 0uL, val5, (NetworkDelivery)2); } goto IL_0409; } public static void ServerTransmitRemoteMsg(ulong _, FastBufferReader reader) { //IL_000d: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) string text = ""; int num = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives)); char c = default(char); for (int i = 0; i < num; i++) { ((FastBufferReader)(ref reader)).ReadValueSafe<char>(ref c, default(ForPrimitives)); text += c; } ulong num2 = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref num2, default(ForPrimitives)); ulong num3 = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref num3, default(ForPrimitives)); FastBufferWriter val = default(FastBufferWriter); if (num3 != ulong.MaxValue) { ((FastBufferWriter)(ref val))..ctor(4 + (text.Length + 2) * 2 + 16, (Allocator)2, -1); int num4 = text.Length + 2; ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num4, default(ForPrimitives)); char c2 = '/'; ((FastBufferWriter)(ref val)).WriteValueSafe<char>(ref c2, default(ForPrimitives)); c2 = 'w'; ((FastBufferWriter)(ref val)).WriteValueSafe<char>(ref c2, default(ForPrimitives)); } else { ((FastBufferWriter)(ref val))..ctor(4 + text.Length * 2 + 16, (Allocator)2, -1); int num4 = text.Length; ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num4, default(ForPrimitives)); } string text2 = text; for (int j = 0; j < text2.Length; j++) { char c3 = text2[j]; ((FastBufferWriter)(ref val)).WriteValueSafe<char>(ref c3, default(ForPrimitives)); } ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref num2, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref num3, default(ForPrimitives)); if (num2 == GameNetworkManager.Instance.localPlayerController.playerClientId || num3 == GameNetworkManager.Instance.localPlayerController.playerClientId) { typeof(HUDManager).GetMethod("AddChatMessage", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(HUDManager.Instance, new object[2] { "/w" + text, StartOfRound.Instance.allPlayerScripts[num2].playerUsername }); } else if (num3 != ulong.MaxValue) { NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("Tibnan.hnsmod_ClientAddRemoteTextMsg", num3, val, (NetworkDelivery)2); } else { typeof(HUDManager).GetMethod("AddChatMessage", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(HUDManager.Instance, new object[2] { text, StartOfRound.Instance.allPlayerScripts[num2].playerUsername }); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("Tibnan.hnsmod_ClientAddRemoteTextMsg", val, (NetworkDelivery)2); } } [HarmonyPatch("Update")] [HarmonyPrefix] public static bool Update(ref HUDElement ___Clock) { if (ConfigProcessor.Config.AlwaysShowClock) { ___Clock.targetAlpha = 1f; } if (ConfigProcessor.Config.QuickRefreshClock) { TimeOfDay.Instance.RefreshClockUI(); } return true; } [HarmonyPatch("DisplayDaysLeft")] [HarmonyPrefix] public static bool StopDisplayDaysLeft(HUDManager __instance) { return false; } } [HarmonyPatch(typeof(KeyItem))] internal class KeyItemPatch { [HarmonyPatch("ItemActivate")] [HarmonyPrefix] public static bool LockDoorAndStopActivate(KeyItem __instance) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)__instance).IsOwner || !ConfigProcessor.Config.DoorLockEnabled) { return true; } RaycastHit val = default(RaycastHit); if (Physics.Raycast(new Ray(((Component)((GrabbableObject)__instance).playerHeldBy.gameplayCamera).transform.position, ((Component)((GrabbableObject)__instance).playerHeldBy.gameplayCamera).transform.forward), ref val, 3f, 2816)) { DoorLock component = ((Component)((RaycastHit)(ref val)).transform).GetComponent<DoorLock>(); if ((Object)(object)component != (Object)null && !component.isLocked && !component.isPickingLock) { component.LockDoor(30f); ((GrabbableObject)__instance).playerHeldBy.DespawnHeldObject(); if (NetworkManager.Singleton.IsServer) { SendDoorLock(((NetworkBehaviour)component).NetworkObjectId); } else { RequestDoorLock(((NetworkBehaviour)component).NetworkObjectId); } return false; } } return true; } public static void SendDoorLock(ulong id) { //IL_004a: 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_0066: Unknown result type (might be due to invalid IL or missing references) DoorLock componentInChildren = ((Component)NetworkManager.Singleton.SpawnManager.SpawnedObjects[id]).gameObject.GetComponentInChildren<DoorLock>(); if (!componentInChildren.isLocked) { componentInChildren.LockDoor(30f); } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(8, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref id, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("Tibnan.hnsmod_DoorLocked", val, (NetworkDelivery)2); } public static void RequestDoorLock(ulong id) { //IL_0011: 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_002f: Unknown result type (might be due to invalid IL or missing references) FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(8, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValue<ulong>(ref id, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("Tibnan.hnsmod_ServerLockDoor", 0uL, val, (NetworkDelivery)2); } public static void ServerTransmitDoorLock(ulong _, FastBufferReader reader) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) ulong id = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref id, default(ForPrimitives)); SendDoorLock(id); } public static void ClientLockDoor(ulong _, FastBufferReader reader) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) ulong key = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref key, default(ForPrimitives)); DoorLock componentInChildren = ((Component)NetworkManager.Singleton.SpawnManager.SpawnedObjects[key]).gameObject.GetComponentInChildren<DoorLock>(); if (!componentInChildren.isLocked) { componentInChildren.LockDoor(30f); } } } [HarmonyPatch(typeof(Landmine))] internal class LandminePatch { [HarmonyPatch("Start")] [HarmonyPostfix] public static void RollTPMineChance(Landmine __instance) { //IL_004c: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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) if (ConfigProcessor.Config.SpawnTPMines && NetworkManager.Singleton.IsServer && !HNSValues.TPMines.Contains(((NetworkBehaviour)__instance).NetworkObjectId)) { GameObject val = Object.Instantiate<GameObject>(ModBase.TPMine, ((Component)__instance).transform.position, Quaternion.identity); val.GetComponentInChildren<NetworkObject>().Spawn(true); HNSValues.TPMines.Add(((NetworkBehaviour)val.GetComponentInChildren<Landmine>()).NetworkObjectId); if (((NetworkBehaviour)__instance).NetworkObject.IsSpawned) { ((NetworkBehaviour)__instance).NetworkObject.Despawn(true); } Landmine componentInChildren = val.GetComponentInChildren<Landmine>(); Animator mineAnimator = componentInChildren.mineAnimator; mineAnimator.speed *= 10f; FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(8, (Allocator)2, -1); ulong networkObjectId = ((NetworkBehaviour)componentInChildren).NetworkObjectId; ((FastBufferWriter)(ref val2)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("Tibnan.hnsmod_TPMineSpawned", val2, (NetworkDelivery)2); } } [HarmonyPatch("PressMineServerRpc")] [HarmonyPostfix] public static void StopExplosionSpawnIfSpecial(Landmine __instance) { if (HNSValues.TPMines.Contains(((NetworkBehaviour)__instance).NetworkObjectId)) { ((MonoBehaviour)GameNetworkManager.Instance).StartCoroutine(TPPlayerToRandomPos(__instance, StartOfRound.Instance.allPlayerScripts.OrderBy((PlayerControllerB x) => Vector3.Distance(((Component)__instance).transform.position, ((Component)x).transform.position)).First())); } } [HarmonyPatch("SetOffMineAnimation")] [HarmonyPrefix] public static bool StopExplosion(Landmine __instance) { return !HNSValues.TPMines.Contains(((NetworkBehaviour)__instance).NetworkObjectId); } public static IEnumerator TPPlayerToRandomPos(Landmine mine, PlayerControllerB player) { for (int i = 0; i < 3; i++) { GameObject explosion = Object.Instantiate<GameObject>(ModBase.TPMineExplosion, ((Component)mine).transform.position, Quaternion.identity, RoundManager.Instance.mapPropsContainer.transform); explosion.SetActive(true); yield return (object)new WaitForSeconds(0.5f); } Random rnd = new Random(); Vector3 vec = RoundManager.Instance.insideAINodes[rnd.Next(0, RoundManager.Instance.insideAINodes.Length)].transform.position; Vector3 tpPos = RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(vec, 10f, default(NavMeshHit), rnd, -1); player.TeleportPlayer(tpPos, false, 0f, false, true); if (NetworkManager.Singleton.IsServer && ((NetworkBehaviour)mine).NetworkObject.IsSpawned) { ((NetworkBehaviour)mine).NetworkObject.Despawn(true); } } public static void AddMineToList(ulong _, FastBufferReader reader) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) ulong key = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref key, default(ForPrimitives)); Landmine componentInChildren = ((Component)NetworkManager.Singleton.SpawnManager.SpawnedObjects[key]).gameObject.GetComponentInChildren<Landmine>(); Animator mineAnimator = componentInChildren.mineAnimator; mineAnimator.speed *= 10f; HNSValues.TPMines.Add(((NetworkBehaviour)componentInChildren).NetworkObjectId); } } [HarmonyPatch(typeof(ManualCameraRenderer))] internal class ManualCameraRendererPatch { [HarmonyPatch("SwitchRadarTargetForward")] [HarmonyPrefix] public static bool StopSwitchForward() { return ((Component)GameNetworkManager.Instance.localPlayerController).gameObject.GetComponent<HNSPlayerComponent>().Role != PlayerRole.Seeker || ConfigProcessor.Config.LetSeekerSwitchCam; } [HarmonyPatch("SwitchRadarTargetAndSync")] [HarmonyPrefix] public static bool StopSwitch() { return ((Component)GameNetworkManager.Instance.localPlayerController).gameObject.GetComponent<HNSPlayerComponent>().Role != PlayerRole.Seeker || ConfigProcessor.Config.LetSeekerSwitchCam; } [HarmonyPatch("SwitchRadarTargetServerRpc")] [HarmonyPrefix] public static bool StopSwitchRPC() { return ((Component)GameNetworkManager.Instance.localPlayerController).gameObject.GetComponent<HNSPlayerComponent>().Role != PlayerRole.Seeker || ConfigProcessor.Config.LetSeekerSwitchCam; } } [HarmonyPatch(typeof(PlayerControllerB))] internal class PlayerControllerBPatch { [HarmonyPatch("ConnectClientToPlayerObject")] [HarmonyPostfix] public static void Setup(PlayerControllerB __instance) { //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Expected O, but got Unknown //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Expected O, but got Unknown //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Expected O, but got Unknown //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Expected O, but got Unknown //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Expected O, but got Unknown //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Expected O, but got Unknown //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Expected O, but got Unknown //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Expected O, but got Unknown //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Expected O, but got Unknown //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Expected O, but got Unknown //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Expected O, but got Unknown //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown ((Component)__instance).gameObject.AddComponent<CustomUI>(); GameObject val = Object.Instantiate<GameObject>((ConfigProcessor.Config.EndGameUIStyle == EndGameUIStyle.Blue) ? ModBase.EndOfGameStatsBlue : ModBase.EndOfGameStatsOrange); val.AddComponent<EndGameStatsUI>(); if (NetworkManager.Singleton.IsServer) { for (int i = 1; i < 8; i++) { MethodInfo method = typeof(StartOfRound).GetMethod("SpawnUnlockable", BindingFlags.Instance | BindingFlags.NonPublic); if (i < 4) { method.Invoke(StartOfRound.Instance, new object[1] { i }); } else { method.Invoke(StartOfRound.Instance, new object[1] { i + 20 }); } } NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("Tibnan.hnsmod_ServerLockDoor", new HandleNamedMessageDelegate(KeyItemPatch.ServerTransmitDoorLock)); NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("Tibnan.hnsmod_RequestRemoteMsgAddFromServer", new HandleNamedMessageDelegate(HUDManagerPatch.ServerTransmitRemoteMsg)); } else { NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("Tibnan.hnsmod_ClientReceivesRoleMSG", new HandleNamedMessageDelegate(GameManager.SetRole)); NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("Tibnan.hnsmod_ClientRefreshPlayerComps", new HandleNamedMessageDelegate(GameManager.RefreshPlayerComps)); NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("Tibnan.hnsmod_ShowRoles", new HandleNamedMessageDelegate(GameManager.ShowRoles)); NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("Tibnan.hnsmod_EndGame", new HandleNamedMessageDelegate(GameManager.EndGameClient)); NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("Tibnan.hnsmod_ShotgunSpawned", new HandleNamedMessageDelegate(GameManager.GrabWeaponIfSeeker)); NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("Tibnan.hnsmod_ClientReceivesBroadcastMsg", new HandleNamedMessageDelegate(CustomUI.ProcessBroadcastMessage)); NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("Tibnan.hnsmod_RecalcTime", new HandleNamedMessageDelegate(GameManager.RecalcTime)); NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("Tibnan.hnsmod_ClientSwitchSuits", new HandleNamedMessageDelegate(GameManager.ClientSwitchSuits)); NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("Tibnan.hnsmod_TPMineSpawned", new HandleNamedMessageDelegate(LandminePatch.AddMineToList)); NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("Tibnan.hnsmod_DoorLocked", new HandleNamedMessageDelegate(KeyItemPatch.ClientLockDoor)); NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("Tibnan.hnsmod_ClientReceivePlayerStats", new HandleNamedMessageDelegate(PlayerStatManager.ClientSetPlayerStats)); NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("Tibnan.hnsmod_ClientReceiveServerConfig", new HandleNamedMessageDelegate(ConfigProcessor.ClientSetServerConfig)); NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("Tibnan.hnsmod_ClientAddRemoteTextMsg", new HandleNamedMessageDelegate(HUDManagerPatch.AddRemoteChatMsg)); } if (ConfigProcessor.Config.DisplayWarning) { HUDManager.Instance.DisplayTip("Caution", string.Format("Playing Hide n Seek. Several core gameplay features disabled.\nVersion: {0}", "1.2.1"), false, false, "LC_Tip1"); } } [HarmonyPatch("KillPlayer")] [HarmonyPrefix] public static bool StopKillPlayer() { HNSPlayerComponent component = ((Component)GameNetworkManager.Instance.localPlayerController).gameObject.GetComponent<HNSPlayerComponent>(); return component.Role == PlayerRole.Hider || (component.Role == PlayerRole.Seeker && ConfigProcessor.Config.CanSeekerDie); } } [HarmonyPatch(typeof(RoundManager))] internal class RoundManagerPatch { [HarmonyPatch("SpawnEnemyFromVent")] [HarmonyPrefix] public static bool StopSpawnEnemyFromVent(RoundManager __instance) { return false; } [HarmonyPatch("SpawnEnemyOnServer")] [HarmonyPrefix] public static bool StopSpawnEnemyOnServer(RoundManager __instance) { return false; } [HarmonyPatch("SpawnDaytimeEnemiesOutside")] [HarmonyPrefix] public static bool StopSpawnDaytimeEnemiesOutside(RoundManager __instance) { return false; } [HarmonyPatch("BeginEnemySpawning")] [HarmonyPrefix] public static bool StopBeginEnemySpawning(RoundManager __instance) { return false; } [HarmonyPatch("SpawnEnemiesOutside")] [HarmonyPrefix] public static bool StopSpawnEnemiesOutside(RoundManager __instance) { return false; } } [HarmonyPatch(typeof(ShotgunItem))] internal class ShotgunItemPatch { [HarmonyPatch("ShootGun")] [HarmonyPostfix] public static void ResetShells(ShotgunItem __instance) { __instance.shellsLoaded = 2; } [HarmonyPatch("ShootGun")] [HarmonyPostfix] public static void TryHitDoor(ShotgunItem __instance, ref Vector3 shotgunPosition, ref Vector3 shotgunForward) { //IL_0002: 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_000d: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = default(RaycastHit); if (Physics.Raycast(new Ray(shotgunPosition, shotgunForward), ref val, 10f, 2816, (QueryTriggerInteraction)2)) { DoorLockShotgunInteract componentInChildren = ((Component)((RaycastHit)(ref val)).transform).GetComponentInChildren<DoorLockShotgunInteract>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.Hit(((GrabbableObject)__instance).playerHeldBy); } } } } [HarmonyPatch(typeof(StartMatchLever))] internal class StartMatchLeverPatch { [HarmonyPatch("LeverAnimation")] [HarmonyPrefix] public static bool CheckPlayerCount(StartMatchLever __instance) { ModBase.mls.LogWarning((object)("Checking player count... " + (StartOfRound.Instance.connectedPlayersAmount + 1))); bool flag = StartOfRound.Instance.connectedPlayersAmount > 0; if (!flag) { ((Component)GameNetworkManager.Instance.localPlayerController).gameObject.GetComponent<CustomUI>().ShowLocalMessage("<color=red>At least 2 players are required to start.</color>", 2); } return flag; } } [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { [HarmonyPatch("StartGame")] [HarmonyPostfix] public static void StartHNS(StartOfRound __instance) { StartOfRound.Instance.currentLevel.Enemies.ForEach(delegate(SpawnableEnemyWithRarity x) { x.enemyType.spawningDisabled = true; }); if (NetworkManager.Singleton.IsServer) { GameManager.StartGame(StartOfRound.Instance.connectedPlayersAmount); } } [HarmonyPatch("EndOfGameClientRpc")] [HarmonyPostfix] public static void ResetPlayers(StartOfRound __instance) { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { HNSPlayerComponent component = ((Component)val).gameObject.GetComponent<HNSPlayerComponent>(); if ((Object)(object)component != (Object)null) { component.Role = PlayerRole.None; } } TimeOfDay.Instance.timeUntilDeadline = 3240f; HNSValues.TPMines.Clear(); HNSValues.FirstWeaponReceived = false; } [HarmonyPatch("ShipLeaveAutomatically")] [HarmonyPostfix] public static void GrabShipLeaveTime(ref bool leavingOnMidnight) { GameManager.Instance.ShipLeavingTime = Utils.CalcTime(TimeOfDay.Instance.normalizedTimeOfDay + (leavingOnMidnight ? 0f : 0.2f), TimeOfDay.Instance.numberOfHours); GameManager.Instance.ShipLeavingEarly = true; } [HarmonyPatch("OnShipLandedMiscEvents")] [HarmonyPostfix] public static void AddDoorComponents() { ModBase.mls.LogInfo((object)"Adding door interact components."); DoorLock[] array = Object.FindObjectsOfType<DoorLock>(); DoorLock[] array2 = array; foreach (DoorLock val in array2) { ((Component)val).gameObject.AddComponent<DoorLockShotgunInteract>(); } } [HarmonyPatch("ReviveDeadPlayers")] [HarmonyPostfix] public static void SwitchSuits() { UnlockableSuit.SwitchSuitForAllPlayers(0, false); if (ConfigProcessor.Config.StatsEnabled) { try { EndGameStatsUI.Instance.Display(); } catch (Exception) { } } } [HarmonyPatch("OnClientConnect")] [HarmonyPostfix] public static void SendServerConfiguration(ref ulong clientId) { if (NetworkManager.Singleton.IsServer) { ((MonoBehaviour)GameNetworkManager.Instance).StartCoroutine(ConfigProcessor.Config.TransferConfigTo(clientId)); } } } [HarmonyPatch(typeof(Terminal))] internal class TerminalPatch { private protected static readonly Regex randomRegex = new Regex("(?i)r(a)?n(d)?o(m)?|rand|rnd"); [HarmonyPatch("OnSubmit")] [HarmonyPrefix] public static bool CheckForModKeyword(Terminal __instance) { if (StartOfRound.Instance.inShipPhase) { string text = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded).ToLower(); ModBase.mls.LogInfo((object)"PARSED SENTENCE:"); ModBase.mls.LogInfo((object)text); if (randomRegex.IsMatch(text)) { int num = new Random().Next(1, 13); while (num == 11 || num == 3) { num = new Random().Next(1, 13); } StartOfRound.Instance.ChangeLevelServerRpc(num, __instance.groupCredits); __instance.screenText.text = ""; __instance.QuitTerminal(true); return false; } return true; } return true; } } [HarmonyPatch(typeof(TimeOfDay))] internal class TimeOfDayPatch { [HarmonyPatch("UpdateProfitQuotaCurrentTime")] [HarmonyPrefix] public static bool StopUpdateProfitQuotaCurrentTime(TimeOfDay __instance) { return false; } } } namespace LCHideAndSeekMod.Core { internal class CustomUI : NetworkBehaviour { private GameObject canvasObject; private GameObject canvasTextObject; private Text canvasText; private Coroutine fadeCoroutine; private PlayerControllerB ownerPlayer; private bool updateOverridden = false; private HNSPlayerComponent localHNSComponent; private void Awake() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_00c1: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) canvasObject = new GameObject(); canvasObject.transform.parent = ((Component)this).transform; ((Object)canvasObject).name = "CustomUICanvas"; Canvas val = canvasObject.AddComponent<Canvas>(); canvasObject.SetActive(false); val.renderMode = (RenderMode)0; canvasObject.AddComponent<CanvasScaler>(); CanvasGroup val2 = canvasObject.AddComponent<CanvasGroup>(); val2.blocksRaycasts = false; canvasObject.AddComponent<GraphicRaycaster>(); canvasTextObject = new GameObject(); ((Object)canvasTextObject).name = "CustomUICanvasText"; Text val3 = (canvasText = canvasTextObject.AddComponent<Text>()); Transform transform = canvasTextObject.transform; Rect rect = ((Component)val).GetComponent<RectTransform>().rect; float num = ((Rect)(ref rect)).width / 2f - 20f; rect = ((Component)val).GetComponent<RectTransform>().rect; transform.localPosition = new Vector3(num, ((Rect)(ref rect)).height / 2f - 75f, 0f); val3.text = ""; val3.font = ModBase.ModFont; val3.alignment = (TextAnchor)7; ((Graphic)val3).rectTransform.sizeDelta = new Vector2(500f, 400f); val3.fontSize = 26; ((Component)val3).transform.parent = canvasObject.transform; val3.supportRichText = true; ownerPlayer = GameNetworkManager.Instance.localPlayerController; ((MonoBehaviour)this).StartCoroutine(WaitForHNSComponent()); } private IEnumerator WaitForHNSComponent() { yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)((Component)ownerPlayer).gameObject.GetComponent<HNSPlayerComponent>() != (Object)null)); ModBase.mls.LogInfo((object)"Assigning hns comp to ui"); localHNSComponent = ((Component)ownerPlayer).gameObject.GetComponent<HNSPlayerComponent>(); } public static void BroadcastMessage(string msg, int fadeDuration = 0, bool includeServer = true) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_007e: 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_009b: Unknown result type (might be due to invalid IL or missing references) if (NetworkManager.Singleton.IsServer) { char[] array = msg.ToCharArray(); FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(4 + 2 * array.Length + 4, (Allocator)2, -1); int num = array.Length; ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives)); for (int i = 0; i < array.Length; i++) { ((FastBufferWriter)(ref val)).WriteValueSafe<char>(ref array[i], default(ForPrimitives)); } ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref fadeDuration, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("Tibnan.hnsmod_ClientReceivesBroadcastMsg", val, (NetworkDelivery)2); if (includeServer) { CustomUI component = ((Component)GameNetworkManager.Instance.localPlayerController).gameObject.GetComponent<CustomUI>(); component.ShowLocalMessage(msg, fadeDuration); } } } public static void BroadcastMessage(string msg, int fadeDuration = 0, bool includeServer = true, params ulong[] clients) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_007e: 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_00ae: Unknown result type (might be due to invalid IL or missing references) if (NetworkManager.Singleton.IsServer) { char[] array = msg.ToCharArray(); FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(4 + 2 * array.Length + 4, (Allocator)2, -1); int num = array.Length; ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives)); for (int i = 0; i < array.Length; i++) { ((FastBufferWriter)(ref val)).WriteValueSafe<char>(ref array[i], default(ForPrimitives)); } ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref fadeDuration, default(ForPrimitives)); foreach (ulong num2 in clients) { NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("Tibnan.hnsmod_ClientReceivesBroadcastMsg", num2, val, (NetworkDelivery)2); } if (includeServer) { CustomUI component = ((Component)GameNetworkManager.Instance.localPlayerController).gameObject.GetComponent<CustomUI>(); component.ShowLocalMessage(msg, fadeDuration); } } } public static void ProcessBroadcastMessage(ulong _, FastBufferReader reader) { //IL_000d: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0061: Unknown result type (might be due to invalid IL or missing references) string text = ""; int num = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives)); char c = default(char); for (int i = 0; i < num; i++) { ((FastBufferReader)(ref reader)).ReadValueSafe<char>(ref c, default(ForPrimitives)); text += c; } int duration = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref duration, default(ForPrimitives)); CustomUI component = ((Component)GameNetworkManager.Instance.localPlayerController).gameObject.GetComponent<CustomUI>(); component.ShowLocalMessage(text, duration); } private void Update() { if (!updateOverridden && (ConfigProcessor.Config?.UIShow ?? false) && GameManager.Instance.GameRunning) { if (localHNSComponent.Role == PlayerRole.Hider) { SetText($"<color=white>Round {GameManager.RoundCount}: Hiders left: {GameManager.Instance.HidersCount}</color>", overrideUpdate: false); Show(show: true); } else if (localHNSComponent.Role == PlayerRole.Seeker && TimeOfDay.Instance.shipLeavingAlertCalled) { SetText($"<color=red>Round {GameManager.RoundCount}: Hiders left: {GameManager.Instance.HidersCount}\nShip leaving at: {GameManager.Instance.ShipLeavingTime}</color>", overrideUpdate: false); Show(show: true); } } } public void WaitUntilFadeThenDo(Action action, int duration = -1) { ((MonoBehaviour)this).StartCoroutine(WaitForFade(action, duration)); } private IEnumerator WaitForFade(Action action, int duration) { FadeOut(duration); yield return (object)new WaitUntil((Func<bool>)(() => !canvasObject.activeInHierarchy)); action(); } public void SetText(string text, bool overrideUpdate = true) { canvasText.text = text; updateOverridden = overrideUpdate; } public void Show(bool show) { canvasObject.SetActive(show); } public void FadeOut(int duration = -1) { if (duration != -1) { if (fadeCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(fadeCoroutine); } fadeCoroutine = ((MonoBehaviour)this).StartCoroutine(FadeTextOutCoroutine(duration)); } } public void ShowLocalMessage(string msg, int duration = 0) { SetText(msg); Show(show: true); FadeOut(duration); } private IEnumerator FadeTextOutCoroutine(int duration) { float alpha = 1f; ((Graphic)canvasText).canvasRenderer.SetAlpha(alpha); yield return (object)new WaitForSeconds((float)duration); while (alpha > 0f) { alpha -= 0.01f; ((Graphic)canvasText).canvasRenderer.SetAlpha(alpha); yield return null; } Show(show: false); ((Graphic)canvasText).canvasRenderer.SetAlpha(1f); updateOverridden = false; } } internal class DoorLockShotgunInteract : MonoBehaviour { private int health; private DoorLock mainScript; private void Awake() { mainScript = ((Component)this).gameObject.GetComponentInChildren<DoorLock>(); health = ConfigProcessor.Config.DoorHits; } public void Hit(PlayerControllerB playerWhoHit) { if ((Object)(object)playerWhoHit == (Object)(object)GameNetworkManager.Instance.localPlayerController && mainScript.isLocked && health >= 1) { health--; if (health < 1) { mainScript.UnlockDoorSyncWithServer(); mainScript.OpenOrCloseDoor(playerWhoHit); health = ConfigProcessor.Config.DoorHits; } } } } internal class GameManager : MonoBehaviour { private enum GameState { WaitingForPlayers, InGame, GameOver } private enum GameResult { HiderWin, SeekerWin, None, Draw } public delegate void GameEndedHandler(); private GameObject obj; private PlayerControllerB seeker; private List<PlayerControllerB> hiders = new List<PlayerControllerB>(); private GameState gameState = GameState.WaitingForPlayers; private GameResult gameResult = GameResult.None; private bool shipLeavingEarly = false; private bool twoPlayerMode; private string shipLeavingTime = ""; private List<PlayerControllerB> activePlayers = new List<PlayerControllerB>(); public static GameManager Instance = new GameManager(); public static int RoundCount = 1; public bool GameRunning => gameState == GameState.InGame; public int HidersCount { get { if (NetworkManager.Singleton.IsServer) { return hiders.Count; } return hiders.Count((PlayerControllerB x) => !x.isPlayerDead && !x.disconnectedMidGame); } } public string ShipLeavingTime { get { return shipLeavingTime; } set { shipLeavingTime = value; } } public bool ShipLeavingEarly { get { return shipLeavingEarly; } set { shipLeavingEarly = value; } } public bool SeekerInTerminal => seeker.inTerminalMenu; public ReadOnlyCollection<PlayerControllerB> Hiders => hiders.AsReadOnly(); public PlayerControllerB Seeker => seeker; public int Result => (int)gameResult; public ReadOnlyCollection<PlayerControllerB> Players => activePlayers.AsReadOnly(); public event GameEndedHandler GameEnded; public void Update() { switch (gameState) { case GameState.WaitingForPlayers: break; case GameState.InGame: hiders.RemoveAll(delegate(PlayerControllerB x) { if (x.disconnectedMidGame) { activePlayers.Remove(x); } return x.isPlayerDead || x.disconnectedMidGame; }); if (seeker.isPlayerDead || seeker.disconnectedMidGame) { gameResult = GameResult.HiderWin; if (hiders.Count < 1) { gameResult = GameResult.Draw; } gameState = GameState.GameOver; } else if (hiders.Count < 1) { gameResult = GameResult.SeekerWin; gameState = GameState.GameOver; } if (StartOfRound.Instance.shipIsLeaving || StartOfRound.Instance.shipLeftAutomatically) { gameResult = GameResult.HiderWin; gameState = GameState.GameOver; } if (ConfigProcessor.Config.StartShipEarly && hiders.Count == 1 && !shipLeavingEarly && !twoPlayerMode) { MakeShipLeaveEarly(); } break; case GameState.GameOver: Instance.StopGame(); break; } } private void MakeShipLeaveEarly() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) TimeOfDay.Instance.SetShipLeaveEarlyClientRpc(TimeOfDay.Instance.normalizedTimeOfDay + 0.2f, 0); shipLeavingTime = Utils.CalcTime(TimeOfDay.Instance.normalizedTimeOfDay + 0.2f, TimeOfDay.Instance.numberOfHours); FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(4, (Allocator)2, -1); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("Tibnan.hnsmod_RecalcTime", seeker.playerClientId, val, (NetworkDelivery)2); shipLeavingEarly = true; } private void StopGame() { //IL_0079: 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_0095: Unknown result type (might be due to invalid IL or missing references) if ((gameState == GameState.GameOver && Object.FindObjectOfType<StartMatchLever>().triggerScript.interactable) || StartOfRound.Instance.shipIsLeaving || StartOfRound.Instance.shipLeftAutomatically) { ModBase.mls.LogInfo((object)("SENDING END MESSAGE WITH RESULT " + gameResult)); FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(4, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValueSafe<GameResult>(ref gameResult, default(ForEnums)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("Tibnan.hnsmod_EndGame", val, (NetworkDelivery)2); StartOfRound.Instance.EndGameClientRpc((int)GameNetworkManager.Instance.localPlayerController.playerClientId); gameState = GameState.WaitingForPlayers; EndGame(gameResult); } } private IEnumerator GrantSeekerWeapons(SeekerWeapon weapon, GamemodeOption gamemode) { GameObject shovel = null; GameObject shotgun = null; NetworkObject shovelNO = null; NetworkObject shotgunNO = null; switch (weapon) { case SeekerWeapon.Both: shovel = Object.Instantiate<GameObject>(StartOfRound.Instance.allItemsList.itemsList.Find((Item x) => x.itemName == "Shovel").spawnPrefab, ((Component)GameNetworkManager.Instance.localPlayerController).transform.position, Quaternion.identity); shotgun = Object.Instantiate<GameObject>(StartOfRound.Instance.allItemsList.itemsList.Find((Item x) => x.itemName == "Shotgun").spawnPrefab, ((Component)GameNetworkManager.Instance.localPlayerController).transform.position, Quaternion.identity); break; case SeekerWeapon.Shovel: shovel = Object.Instantiate<GameObject>(StartOfRound.Instance.allItemsList.itemsList.Find((Item x) => x.itemName == "Shovel").spawnPrefab, ((Component)GameNetworkManager.Instance.localPlayerController).transform.position, Quaternion.identity); break; default: shotgun = Object.Instantiate<GameObject>(StartOfRound.Instance.allItemsList.itemsList.Find((Item x) => x.itemName == "Shotgun").spawnPrefab, ((Component)GameNetworkManager.Instance.localPlayerController).transform.position, Quaternion.identity); break; } if ((Object)(object)shovel != (Object)null) { shovelNO = shovel.GetComponent<NetworkObject>(); shovelNO.Spawn(false); FastBufferWriter writer2 = new FastBufferWriter(8, (Allocator)2, -1); ulong networkObjectId = shovelNO.NetworkObjectId; ((FastBufferWriter)(ref writer2)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("Tibnan.hnsmod_ShotgunSpawned", writer2, (NetworkDelivery)2); writer2 = default(FastBufferWriter); } if ((Object)(object)shotgun != (Object)null) { shotgunNO = shotgun.GetComponent<NetworkObject>(); shotgunNO.Spawn(false); FastBufferWriter writer = new FastBufferWriter(8, (Allocator)2, -1); ulong networkObjectId = shotgunNO.NetworkObjectId; ((FastBufferWriter)(ref writer)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("Tibnan.hnsmod_ShotgunSpawned", writer, (NetworkDelivery)2); writer = default(FastBufferWriter); } PlayerControllerB player = GameNetworkManager.Instance.localPlayerController; if (((Component)player).gameObject.GetComponent<HNSPlayerComponent>().Role != PlayerRole.Seeker) { yield break; } ModBase.mls.LogInfo((object)"Grabbing weapon(s) on server"); if ((Object)(object)shovel != (Object)null) { Traverse trav = Traverse.Create((object)player); trav.Field("currentlyGrabbingObject").SetValue((object)shovel.GetComponent<GrabbableObject>()); object? value = typeof(PlayerControllerB).GetField("currentlyGrabbingObject", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(player); ((GrabbableObject)((value is GrabbableObject) ? value : null)).InteractItem(); typeof(PlayerControllerB).GetMethod("GrabObjectServerRpc", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(player, new object[1] { (object)new NetworkObjectReference(shovelNO) }); MethodInfo mInfo2 = typeof(PlayerControllerB).GetMethod("GrabObject", BindingFlags.Instance | BindingFlags.NonPublic); IEnumerator coroutine2 = (IEnumerator)mInfo2.Invoke(player, null); ((MonoBehaviour)this).StartCoroutine(coroutine2); } yield return (object)new WaitForSeconds(0.5f); if (!((Object)(object)shotgun != (Object)null)) { yield break; } if (gamemode == GamemodeOption.DelayedWeapon) { yield return (object)new WaitUntil((Func<bool>)(() => Utils.CalcHour(TimeOfDay.Instance.normalizedTimeOfDay, TimeOfDay.Instance.numberOfHours) >= 12)); } Traverse trav2 = Traverse.Create((object)player); trav2.Field("currentlyGrabbingObject").SetValue((object)shotgun.GetComponent<GrabbableObject>()); object? value2 = typeof(PlayerControllerB).GetField("currentlyGrabbingObject", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(player); ((GrabbableObject)((value2 is GrabbableObject) ? value2 : null)).InteractItem(); typeof(PlayerControllerB).GetMethod("GrabObjectServerRpc", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(player, new object[1] { (object)new NetworkObjectReference(shotgunNO) }); MethodInfo mInfo = typeof(PlayerControllerB).GetMethod("GrabObject", BindingFlags.Instance | BindingFlags.NonPublic); IEnumerator coroutine = (IEnumerator)mInfo.Invoke(player, null); ((MonoBehaviour)this).StartCoroutine(coroutine); } public static void StartGame(int playerCount) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) Instance.obj = new GameObject("HNSManager"); Instance = Instance.obj.AddComponent<GameManager>(); Instance.twoPlayerMode = playerCount == 1; if (ConfigProcessor.Config.StatsEnabled) { MiscStat.Reset(); } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(4, (Allocator)2, -1); PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val2 in allPlayerScripts) { if ((val2.isPlayerControlled || val2.isPlayerDead) && (Object)(object)((Component)val2).gameObject.GetComponent<HNSPlayerComponent>() == (Object)null) { ((Component)val2).gameObject.AddComponent<HNSPlayerComponent>(); } } NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("Tibnan.hnsmod_ClientRefreshPlayerComps", val, (NetworkDelivery)2); Instance.activePlayers = StartOfRound.Instance.allPlayerScripts.ToList().FindAll((PlayerControllerB x) => (Object)(object)((Component)x).gameObject.GetComponent<HNSPlayerComponent>() != (Object)null); foreach (PlayerControllerB activePlayer in Instance.activePlayers) { ModBase.mls.LogError((object)(activePlayer.playerUsername + " " + ((Component)activePlayer).gameObject.GetComponent<HNSPlayerComponent>().Role.ToString() + " CHANCE BEFORE SEEKER CHOOSE: " + ((Component)activePlayer).gameObject.GetComponent<HNSPlayerComponent>().SeekerChance)); } Instance.ChooseSeeker(); ((Component)Instance.seeker).GetComponent<HNSPlayerComponent>().Role = PlayerRole.Seeker; ModBase.mls.LogWarning((object)("Choosing seeker: " + Instance.seeker.playerUsername + " " + ((Component)Instance.seeker).gameObject.GetComponent<HNSPlayerComponent>().Role.ToString() + " " + ((Component)Instance.seeker).gameObject.GetComponent<HNSPlayerComponent>().SeekerChance)); SendRoleMessage(Instance.seeker.playerClientId, PlayerRole.Seeker); Instance.activePlayers.ForEach(delegate(PlayerControllerB x) { HNSPlayerComponent component3 = ((Component)x).gameObject.GetComponent<HNSPlayerComponent>(); if (component3.Role != PlayerRole.Seeker) { component3.Role = PlayerRole.Hider; Instance.hiders.Add(x); SendRoleMessage(x.playerClientId, PlayerRole.Hider); } }); Instance.AdjustChances(); ((MonoBehaviour)Instance).StartCoroutine(Instance.GrantSeekerWeapons(ConfigProcessor.Config.SeekerWeapon, ConfigProcessor.Config.GamemodeOption)); Instance.SwitchSuits(ConfigProcessor.Config.SeekerSuit, ConfigProcessor.Config.HiderSuit); Instance.gameState = GameState.InGame; StartOfRound.Instance.mapScreen.SwitchRadarTargetClientRpc((int)Instance.seeker.playerClientId); if (ConfigProcessor.Config.StatsEnabled) { ((Component)Instance).gameObject.AddComponent<PlayerStatManager>(); } if (ConfigProcessor.Config.UIShow) { CustomUI component = ((Component)GameNetworkManager.Instance.localPlayerController).gameObject.GetComponent<CustomUI>(); HNSPlayerComponent component2 = ((Component)GameNetworkManager.Instance.localPlayerController).gameObject.GetComponent<HNSPlayerComponent>(); component.ShowLocalMessage((component2.Role == PlayerRole.Seeker) ? "<color=red>You are a seeker.</color>" : "<color=white>You are a hider.</color>", 10); } NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("Tibnan.hnsmod_ShowRoles", val, (NetworkDelivery)2); } private static void SendRoleMessage(ulong id, PlayerRole role) { //IL_0012: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(12, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref id, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<PlayerRole>(ref role, default(ForEnums)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("Tibnan.hnsmod_ClientReceivesRoleMSG", val, (NetworkDelivery)2); } public static void SetRole(ulong _, FastBufferReader reader) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) ulong num = default(ulong); ((FastBufferReader)(ref reader)).ReadValue<ulong>(ref num, default(ForPrimitives)); PlayerRole playerRole = default(PlayerRole); ((FastBufferReader)(ref reader)).ReadValue<PlayerRole>(ref playerRole, default(ForEnums)); PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[num]; ((Component)val).GetComponent<HNSPlayerComponent>().Role = playerRole; ModBase.mls.LogError((object)(val.playerUsername + " " + ((Component)val).gameObject.GetComponent<HNSPlayerComponent>().Role)); if (playerRole == PlayerRole.Seeker) { Instance.seeker = val; } else { Instance.hiders.Add(val); } } public static void ClientSwitchSuits(ulong _, FastBufferReader reader) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) Suit seekerSuit = default(Suit); ((FastBufferReader)(ref reader)).ReadValue<Suit>(ref seekerSuit, default(ForEnums)); Suit hiderSuit = default(Suit); ((FastBufferReader)(ref reader)).ReadValue<Suit>(ref hiderSuit, default(ForEnums)); Instance.SwitchSuits(seekerSuit, hiderSuit, issuedByServer: true); } private void SwitchSuits(Suit seekerSuit, Suit hiderSuit, bool issuedByServer = false) { //IL_0098: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) if (!(ConfigProcessor.Config.UseCustomSuits || issuedByServer)) { return; } int num = (int)seekerSuit; UnlockableSuit.SwitchSuitForPlayer(seeker, (num > 3) ? (num + 20) : num, true); num = (int)hiderSuit; foreach (PlayerControllerB hider in hiders) { UnlockableSuit.SwitchSuitForPlayer(hider, (num > 3) ? (num + 20) : num, true); } if (NetworkManager.Singleton.IsServer) { FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(8, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValueSafe<Suit>(ref seekerSuit, default(ForEnums)); ((FastBufferWriter)(ref val)).WriteValueSafe<Suit>(ref hiderSuit, default(ForEnums)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("Tibnan.hnsmod_ClientSwitchSuits", val, (NetworkDelivery)2); } } private void ChooseSeeker() { activePlayers.RemoveAll((PlayerControllerB x) => x.disconnectedMidGame); if (ConfigProcessor.Config.ChanceBasedSeeker) { float num = activePlayers.Sum((PlayerControllerB x) => ((Component)x).gameObject.GetComponent<HNSPlayerComponent>().SeekerChance); float num2 = Random.Range(0.065f, num); float num3 = 0f; { foreach (PlayerControllerB activePlayer in activePlayers) { num3 += ((Component)activePlayer).GetComponent<HNSPlayerComponent>().SeekerChance; if (num3 >= num2) { seeker = activePlayer; break; } } return; } } seeker = activePlayers.ElementAt(new Random().Next(0, activePlayers.Count)); } private void AdjustChances() { if (!ConfigProcessor.Config.ChanceBasedSeeker) { return; } foreach (PlayerControllerB activePlayer in activePlayers) { HNSPlayerComponent component = ((Component)activePlayer).gameObject.GetComponent<HNSPlayerComponent>(); if (component.Role == PlayerRole.Seeker) { component.SeekerChance -= 0.3f; if (component.SeekerChance < 0f) { component.SeekerChance = 0f; } } else { component.SeekerChance += 0.065f; } ModBase.mls.LogWarning((object)("CHANCE AFTER ADJUSTMENT: " + activePlayer.playerUsername + " " + component.Role.ToString() + " " + component.SeekerChance)); } } private void ShowEndGameMessage(GameResult result) { CustomUI component = ((Component)GameNetworkManager.Instance.localPlayerController).gameObject.GetComponent<CustomUI>(); HNSPlayerComponent component2 = ((Component)GameNetworkManager.Instance.localPlayerController).gameObject.GetComponent<HNSPlayerComponent>(); Object.FindObjectsOfType<HNSPlayerComponent>().ToList().ForEach(delegate(HNSPlayerComponent x) { ModBase.mls.LogWarning((object)(x.player.playerUsername + " " + x.Role)); }); switch (result) { case GameResult.Draw: component.ShowLocalMessage("<color=yellow>The game result was a draw!</color>", 5); break; case GameResult.SeekerWin: if (component2.Role == PlayerRole.Seeker) { component.ShowLocalMessage("<color=green>You won as the seeker!</color>", 5); } else { component.ShowLocalMessage("<color=red>The seeker won this round!</color>", 5); } break; case GameResult.HiderWin: if (component2.Role == PlayerRole.Hider) { component.ShowLocalMessage("<color=green>You won as one of the hiders!</color>", 5); } else { component.ShowLocalMessage("<color=red>The hiders won this round!</color>", 5); } break; case GameResult.None: break; } } public static void EndGameClient(ulong _, FastBufferReader reader) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) GameResult result = default(GameResult); ((FastBufferReader)(ref reader)).ReadValueSafe<GameResult>(ref result, default(ForEnums)); Instance.gameState = GameState.WaitingForPlayers; Instance.gameResult = result; Instance.EndGame(result); } private void EndGame(GameResult result) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) foreach (PlayerControllerB activePlayer in Instance.activePlayers) { if ((Object)(object)activePlayer != (Object)null && !activePlayer.isPlayerDead) { activePlayer.DropAllHeldItems(true, false); activePlayer.TeleportPlayer(StartOfRound.Instance.playerSpawnPositions[(uint)activePlayer.playerClientId].position, false, 0f, false, true); } } if (NetworkManager.Singleton.IsServer) { ShotgunItem[] array = Object.FindObjectsOfType<ShotgunItem>(); ShotgunItem[] array2 = array; foreach (ShotgunItem val in array2) { ((NetworkBehaviour)val).NetworkObject.Despawn(true); } Shovel[] array3 = Object.FindObjectsOfType<Shovel>(); Shovel[] array4 = array3; foreach (Shovel val2 in array4) { ((NetworkBehaviour)val2).NetworkObject.Despawn(true); } this.GameEnded?.Invoke(); } if (ConfigProcessor.Config.UIShow) { Instance.ShowEndGameMessage(result); ((Component)GameNetworkManager.Instance.localPlayerController).gameObject.GetComponent<CustomUI>().WaitUntilFadeThenDo(delegate { RoundCount++; }, 5); } else { RoundCount++; } hiders.Clear(); shipLeavingTime = ""; } public static void RefreshPlayerComps(ulong _, FastBufferReader __) { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((val.isPlayerControlled || val.isPlayerDead) && (Object)(object)((Component)val).gameObject.GetComponent<HNSPlayerComponent>() == (Object)null) { ((Component)val).gameObject.AddComponent<HNSPlayerComponent>(); Instance.activePlayers.Add(val); } } } public static void ShowRoles(ulong _, FastBufferReader __) { if (ConfigProcessor.Config.UIShow) { CustomUI component = ((Component)GameNetworkManager.Instance.localPlayerController).gameObject.GetComponent<CustomUI>(); HNSPlayerComponent component2 = ((Component)GameNetworkManager.Instance.localPlayerController).gameObject.GetComponent<HNSPlayerComponent>(); component.ShowLocalMessage((component2.Role == PlayerRole.Seeker) ? "<color=red>You are a seeker.</color>" : "<color=white>You are a hider.</color>", 10); } Instance.gameState = GameState.InGame; } public static void GrabWeaponIfSeeker(ulong _, FastBufferReader reader) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) ulong key = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref key, default(ForPrimitives)); NetworkObject val = NetworkManager.Singleton.SpawnManager.SpawnedObjects[key]; GameObject gameObject = ((Component)val).gameObject; ModBase.mls.LogError((object)((Object)gameObject).name); PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if (((Component)localPlayerController).gameObject.GetComponent<HNSPlayerComponent>().Role == PlayerRole.Seeker) { if (!HNSValues.FirstWeaponReceived) { ((MonoBehaviour)GameNetworkManager.Instance).StartCoroutine(GrabWeapon(localPlayerController, val, gameObject, delay: false)); HNSValues.FirstWeaponReceived = true; } else { ((MonoBehaviour)GameNetworkManager.Instance).StartCoroutine(GrabWeapon(localPlayerController, val, gameObject, delay: true)); } } } private static IEnumerator GrabWeapon(PlayerControllerB player, NetworkObject nObject, GameObject weapon, bool delay) { if (delay) { if (ConfigProcessor.Config.GamemodeOption == GamemodeOption.DelayedWeapon) { yield return (object)new WaitUntil((Func<bool>)(() => Utils.CalcHour(TimeOfDay.Instance.normalizedTimeOfDay, TimeOfDay.Instance.numberOfHours) >= 12)); } else { yield return (object)new WaitForSeconds(0.5f); } } ModBase.mls.LogInfo((object)"Trying to grab spawned weapon on client"); Traverse trav = Traverse.Create((object)player); trav.Field("currentlyGrabbingObject").SetValue((object)weapon.GetComponent<GrabbableObject>()); object? value = typeof(PlayerControllerB).GetField("currentlyGrabbingObject", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(player); ((GrabbableObject)((value is GrabbableObject) ? value : null)).InteractItem(); typeof(PlayerControllerB).GetMethod("GrabObjectServerRpc", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(player, new object[1] { (object)new NetworkObjectReference(nObject) }); MethodInfo mInfo = typeof(PlayerControllerB).GetMethod("GrabObject", BindingFlags.Instance | BindingFlags.NonPublic); IEnumerator coroutine = (IEnumerator)mInfo.Invoke(player, null); ((MonoBehaviour)GameNetworkManager.Instance).StartCoroutine(coroutine); } public static void RecalcTime(ulong _, FastBufferReader __) { Instance.shipLeavingTime = Utils.CalcTime(TimeOfDay.Instance.normalizedTimeOfDay + 0.2f, TimeOfDay.Instance.numberOfHours); } } public enum PlayerRole { Hider, Seeker, None } internal class HNSPlayerComponent : MonoBehaviour { public PlayerRole Role = PlayerRole.None; private float seekerChance = 0.5f; public PlayerControllerB player; public float SeekerChance { get { return seekerChance; } set { seekerChance = value; } } public void Awake() { player = ((Component)this).GetComponent<PlayerControllerB>(); } } internal static class HNSValues { public static List<ulong> TPMines = new List<ulong>(); public static bool FirstWeaponReceived = false; } internal static class Utils { public static string CalcTime(float timeNormalized, float numberOfHours) { int num = (int)(timeNormalized * (60f * numberOfHours)) + 360; int num2 = (int)Mathf.Floor((float)(num / 60)); if (num2 >= 24) { return "12:00 AM"; } string text = ((num2 >= 12) ? "PM" : "AM"); if (num2 > 12) { num2 %= 12; } int num3 = num % 60; return $"{num2:00}:{num3:00}".TrimStart(new char[1] { '0' }) + text; } public static int CalcHour(float timeNormalized, float numberOfHours) { int num = (int)(timeNormalized * (60f * numberOfHours)) + 360; return (int)Mathf.Floor((float)(num / 60)); } public static T Retrieve<T>(this List<StatBase> list) where T : StatBase { return (T)list.FirstOrDefault((StatBase x) => x is T); } public static T RetrieveFor<T>(this List<StatBase> list, PlayerControllerB player) where T : StatBase { return (T)list.FirstOrDefault((StatBase x) => x is T && (Object)(object)x.Player == (Object)(object)player); } public static List<StatBase> RetrieveAll<T>(this List<StatBase> list) where T : StatBase { return list.FindAll((StatBase x) => x is T); } public static bool WasWinnerThisRound(this PlayerControllerB player) { return ((Component)player).gameObject.GetComponent<HNSPlayerComponent>().Role == (PlayerRole)GameManager.Instance.Result; } } } namespace LCHideAndSeekMod.Core.PlayerStats { internal sealed class ClosestToSeekerStat : StatBase, INetworkSerializable { public string comment = "Got closest to the seeker."; public int tier = 1; public bool deleteOnDeath = false; private float distance; private int typeID = 1; public float Distance => distance; public ClosestToSeekerStat(PlayerControllerB player, float distance) : base(player) { this.distance = distance; } public override string GetComment() { return comment; } public override int GetTier() { return tier; } public override bool GetDeleteOnDeath() { return deleteOnDeath; } public override int NetworkSize() { return 4 + base.NetworkSize() + 4; } public override bool IsBetterThan(StatBase other) { return !(other is ClosestToSeekerStat) || distance <= ((ClosestToSeekerStat)other).distance; } public unsafe override void NetworkSerialize<T>(BufferSerializer<T> serializer) { //IL_000b: 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) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) ((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref typeID, default(ForPrimitives)); base.NetworkSerialize<T>(serializer); ((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref distance, default(ForPrimitives)); } } internal class LongestHiderStat : StatBase, INetworkSerializable { public string comment = "Hid for the longest time."; public int tier = 2; public bool deleteOnDeath = false; private int seconds; private int typeID = 2; public int Seconds => seconds; public LongestHiderStat(PlayerControllerB player, int seconds) : base(player) { this.seconds = seconds; } public override string GetComment() { return comment; } public override int GetTier() { return tier; } public override bool GetDeleteOnDeath() { return deleteOnDeath; } public override int NetworkSize() { return base.NetworkSize() + 8; } public override bool IsBetterThan(StatBase other) { return !(other is LongestHiderStat) || seconds >= ((LongestHiderStat)other).seconds; } public unsafe override void NetworkSerialize<T>(BufferSerializer<T> serializer) { //IL_000b: 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) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) ((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref typeID, default(ForPrimitives)); base.NetworkSerialize<T>(serializer); ((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref seconds, default(ForPrimitives)); } } internal class MiscStat : StatBase, INetworkSerializable { public string comment; public int tier = 0; public bool deleteOnDeath = false; private int typeID = 5; private static string[] DeadComments = new string[5] { "Ventured too far and got caught in the wild.", "Gave it their all, but the seeker was relentless.", "Played with heart, but luck wasn't on their side.", "Gave it their best shot, but the seeker prevailed.", "Embraced the challenge, even if it ended in capture." }; private static string[] AliveComments = new string[5] { "Your hiding spots were pure genius.", "You watched the game unfold from the perfect vantage point.", "Your presence was felt, but never seen.", "You blended in so well, even the walls were jealous.", "You moved like a shadow in the night." }; private static List<int> availableDeadComments = new List<int>(); private static List<int> availableAliveComments = new List<int>(); public MiscStat(PlayerControllerB player) : base(player) { if (player.isPlayerDead) { int index = Random.Range(0, availableDeadComments.Count); comment = DeadComments[availableDeadComments[index]]; availableDeadComments.Remove(availableDeadComments[index]); } else { int num = Random.Range(0, availableAliveComments.Count); comment = AliveComments[availableAliveComments[num]]; availableAliveComments.Remove(num); } } public static void Reset() { availableAliveComments.Clear(); availableDeadComments.Clear(); for (int i = 0; i < AliveComments.Length; i++) { availableAliveComments.Add(i); } for (int j = 0; j < DeadComments.Length; j++) { availableDeadComments.Add(j); } } public MiscStat(PlayerControllerB player, string comment) : base(player) { this.comment = comment; } public override int GetTier() { return tier; } public override string GetComment() { return comment; } public override bool GetDeleteOnDeath() { return deleteOnDeath; } public override int NetworkSize() { return base.NetworkSize() + 8 + comment.Length * 2; } public override bool IsBetterThan(StatBase other) { throw new NotImplementedException(); } public unsafe override void NetworkSerialize<T>(BufferSerializer<T> serializer) { //IL_000b: 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) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) ((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref typeID, default(ForPrimitives)); base.NetworkSerialize<T>(serializer); int length = comment.Length; ((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref length, default(ForPrimitives)); string text = comment; foreach (char c in text) { char c2 = c; ((BufferSerializer<char>*)(&serializer))->SerializeValue<char>(ref c2, default(ForPrimitives)); } } } internal class MostVCTimeStat : StatBase, INetworkSerializable { public string comment = "Talked the most in voice chat."; public int tier = 2; public bool deleteOnDeath = false; public int seconds; private int typeID = 3; public MostVCTimeStat(PlayerControllerB player, int seconds) : base(player) { this.seconds = seconds; } public override string GetComment() { return comment; } public override int GetTier() { return tier; } public override bool GetDeleteOnDeath() { return deleteOnDeath; } public override int NetworkSize() { return base.NetworkSize() + 8; } public override bool IsBetterThan(StatBase other) { return !(other is MostVCTimeStat) || seconds >= ((MostVCTimeStat)other).seconds; } public unsafe override void NetworkSerialize<T>(BufferSerializer<T> serializer) { //IL_000b: 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) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) ((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref typeID, default(ForPrimitives)); base.NetworkSerialize<T>(serializer); ((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref seconds, default(ForPrimitives)); } } internal class PlayerStatManager : MonoBehaviour { public delegate void StatsUpdatedDelegate(); public static PlayerStatManager Instance; private GameManager manager; private List<StatBase> playerStats = new List<StatBase>(); private Coroutine lastHiderCoroutine; private Coroutine roundWonCoroutine; private Coroutine vcCoroutine; private Coroutine seekerKillCoroutine; private static List<RoundsWonStat> roundsWonStats = new List<RoundsWonStat>(); private int matchSeconds = 0; public ReadOnlyCollection<StatBase> Stats { get { return playerStats.AsReadOnly(); } set { if (!NetworkManager.Singleton.IsServer) { playerStats = value.ToList(); } } } public bool IsBusy => lastHiderCoroutine != null || roundWonCoroutine != null || vcCoroutine != null || seekerKillCoroutine != null; public string MatchTime { get { int num = matchSeconds / 60; int num2 = matchSeconds % 60; return ((num < 10) ? ("0" + num) : num.ToString()) + ((num2 < 10) ? (":0" + num2) : (":" + num2)); } } public event StatsUpdatedDelegate StatProcessingDone; public void Awake() { Instance = this; manager = GameManager.Instance; } public void Start() { playerStats = playerStats.Union(roundsWonStats).ToList(); ((MonoBehaviour)this).StartCoroutine(TryDeterminePlayerStats()); ((MonoBehaviour)this).StartCoroutine(CountMatchTime()); manager.GameEnded += delegate { ((MonoBehaviour)this).StartCoroutine(WaitUntilThisIsWorking()); }; } private void LogInfo(string msg) { ModBase.mls.LogInfo((object)$"[PLAYER STAT MANAGER]: {msg}"); } private IEnumerator CountMatchTime() { while (manager.GameRunning) { yield return (object)new WaitForSeconds(1f); matchSeconds++; } } private IEnumerator TryDeterminePlayerStats() { yield return (object)new WaitUntil((Func<bool>)(() => Utils.CalcHour(TimeOfDay.Instance.normalizedTimeOfDay, TimeOfDay.Instance.numberOfHours) >= 10)); while (manager.GameRunning) { DetermineClosestToSeeker(); DetermineLongestHider(); DetermineWhoWonRound(); DetermineSeekerKills(); yield return (object)new WaitForSeconds(0.5f); } } private IEnumerator WaitUntilThisIsWorking() { yield return (object)new WaitWhile((Func<bool>)(() => IsBusy)); ProcessStats(); } private void ProcessStats() { LogInfo($"-----BEGIN PROCESSING STAT LIST ({playerStats.Count})-----"); RemoveOnDeathStats(); RemoveDuplicates(); KeepBestForAll(); AddMiscStatsAtEndOfGame(); SelectTopFive(); this.StatProcessingDone?.Invoke(); ((MonoBehaviour)this).StartCoroutine(NetworkTransferStats()); LogInfo($"-----END ({playerStats.Count})-----"); } private void SelectTopFive() { playerStats = playerStats.OrderByDescending((StatBase x) => x.GetTier()).Take(5).ToList(); } private void KeepBestForAll() { foreach (PlayerControllerB player in manager.Players) { StatBase best = (from x in playerStats.FindAll((StatBase x) => (Object)(object)x.Player == (Object)(object)player) orderby x.GetTier() descending select x).FirstOrDefault(); LogInfo(string.Format("BEST FOR: {0}, {1}", player.playerUsername, (best == null) ? "NULL" : best.GetComment())); playerStats.RemoveAll((StatBase x) => (Object)(object)x.Player == (Object)(object)player && x != best); } } private void KeepBest<T>() where T : StatBase { List<StatBase> list = playerStats.RetrieveAll<T>(); StatBase statBase = list.FirstOrDefault(); if (list.Count == 1) { return; } foreach (T item in list) { if (item != statBase) { if (item.IsBetterThan(statBase)) { playerStats.Remove(statBase); statBase = item; } else { playerStats.Remove(item); } } } } private void RemoveDuplicates() { KeepBest<ClosestToSeekerStat>(); KeepBest<LongestHiderStat>(); KeepBest<MostVCTimeStat>(); KeepBest<RoundsWonStat>(); } private void RemoveOnDeathStats() { playerStats.RemoveAll((StatBase x) => x.GetDeleteOnDeath()); playerStats.RemoveAll((StatBase x) => x.Player.disconnectedMidGame); } private void AddMiscStatsAtEndOfGame() { foreach (PlayerControllerB player in manager.Players) { if (!playerStats.Any((StatBase x) => (Object)(object)x.Player == (Object)(object)player)) { playerStats.Add(new MiscStat(player)); } } } private IEnumerator NetworkTransferStats() { yield return (object)new WaitUntil((Func<bool>)(() => !IsBusy)); FastBufferWriter writer = new FastBufferWriter(4 + playerStats.Sum((StatBase x) => x.NetworkSize()), (Allocator)2, -1); int count = playerStats.Count; ((FastBufferWriter)(ref writer)).WriteValueSafe<int>(ref count, default(ForPrimitives)); foreach (StatBase playerStat in playerStats) { StatBase stat = playerStat; ModBase.mls.LogInfo((object)$"SERIALIZING STAT! {stat.Player.playerUsername} {stat.GetType().Name} {stat.GetComment()}"); ((FastBufferWriter)(ref writer)).WriteValueSafe<StatBase>(ref stat, default(ForNetworkSerializable)); } NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("Tibnan.hnsmod_ClientReceivePlayerStats", writer, (NetworkDelivery)2); } public static void ClientSetPlayerStats(ulong _, FastBufferReader reader) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0041: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) int num = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives)); List<StatBase> list = new List<StatBase>(); int num2 = default(int); ulong num3 = default(ulong); float distance = default(float); int seconds = default(int); int seconds2 = default(int); int count = default(int); int num4 = default(int); char c = default(char); int kills = default(int); for (int i = 0; i < num; i++) { ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num2, default(ForPrimitives)); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref num3, default(ForPrimitives)); switch (num2) { case 1: ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref distance, default(ForPrimitives)); list.Add(new ClosestToSeekerStat(StartOfRound.Instance.allPlayerScripts[(uint)num3], distance)); break; case 2: ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref seconds, default(ForPrimitives)); list.Add(new LongestHiderStat(StartOfRound.Instance.allPlayerScripts[(uint)num3], seconds)); break; case 3: ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref seconds2, default(ForPrimitives)); list.Add(new MostVCTimeStat(StartOfRound.Instance.allPlayerScripts[(uint)num3], seconds2)); break; case 4: ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref count, default(ForPrimitives)); list.Add(new RoundsWonStat(StartOfRound.Instance.allPlayerScripts[(uint)num3], count)); break; case 5: { string text = ""; ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num4, default(ForPrimitives)); for (int j = 0; j < num4; j++) { ((FastBufferReader)(ref reader)).ReadValueSafe<char>(ref c, default(ForPrimitives)); text += c; } list.Add(new MiscStat(StartOfRound.Instance.allPlayerScripts[(uint)num3], text)); break; } case 6: ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref kills, default(ForPrimitives)); list.Add(new SeekerKillInIntervalStat(StartOfRound.Instance.allPlayerScripts[(uint)num3], kills)); break; } if ((Object)(object)Instance == (Object)null) { Instance = new PlayerStatManager(); } Instance.Stats = list.AsReadOnly(); } } private void DetermineWhoVoiceChattedMost() { if (vcCoroutine == null) { vcCoroutine = ((MonoBehaviour)this).StartCoroutine(CountPlayerVCHeld()); } } private void DetermineWhoWonRound() { if (roundWonCoroutine == null) { roundWonCoroutine = ((MonoBehaviour)this).StartCoroutine(AddToCounterAfterRoundEnd()); } } private IEnumerator CountPlayerVCHeld() { Dictionary<PlayerControllerB, int> timeHeld = new Dictionary<PlayerControllerB, int>(); while (manager.GameRunning) { foreach (PlayerControllerB player in manager.Players) { if ((Object)(object)player == (Object)(object)GameNetworkManager.Instance.localPlayerController && player.currentVoiceChatAudioSource.isPlaying) { if (timeHeld.ContainsKey(player)) { timeHeld[player]++; } else { timeHeld.Add(player, 1); } } else if (player.voicePlayerState.IsSpeaking) { if (timeHeld.ContainsKey(player)) { timeHeld[player]++; } else { timeHeld.Add(player, 1); } } } yield return (object)new WaitForSeconds(1f); } vcCoroutine = null; } private IEnumerator AddToCounterAfterRoundEnd() { yield return (object)new WaitUntil((Func<bool>)(() => !manager.GameRunning)); foreach (PlayerControllerB player in manager.Players) { if (player.WasWinnerThisRound()) { RoundsWonStat stat = roundsWonStats.Find((RoundsWonStat x) => (Object)(object)x.Player == (Object)(object)player); if (stat == null) { roundsWonStats.Add(new RoundsWonStat(player, 1)); continue; } roundsWonStats.Remove(stat); roundsWonStats.Add(new RoundsWonStat(player, stat.Count + 1)); } } playerStats = playerStats.Union(roundsWonStats).ToList(); roundWonCoroutine = null; } private Tuple<PlayerControllerB, float> FindClosestHider(PlayerControllerB seeker, ReadOnlyCollection<PlayerControllerB> hiders) { //IL_0021: 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) PlayerControllerB item = null; float num = float.MaxValue; foreach (PlayerControllerB hider in hiders) { float num2 = Vector3.Distance(((Component)seeker).transform.position, ((Component)hider).transform.position); if (num2 < num) { num = num2; item = hider; } } return new Tuple<PlayerControllerB, float>(item, num); } private void DetermineClosestToSeeker() { Tuple<PlayerControllerB, float> tuple = FindClosestHider(manager.Seeker, manager.Hiders); PlayerControllerB item = tuple.Item1; float item2 = tuple.Item2; if (item2 < 20f) { ClosestToSeekerStat closestToSeekerStat = playerStats.RetrieveFor<ClosestToSeekerStat>(item); if (closestToSeekerStat == null) { playerStats.Add(new ClosestToSeekerStat(item, item2)); } else if ((Object)(object)closestToSeekerStat.Player == (Object)(object)item && item2 < closestToSeekerStat.Distance)