using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using MoreCompany.Cosmetics; using MoreCompany.Utils; using Newtonsoft.Json; using Steamworks; using Steamworks.Data; using TMPro; using Unity.Collections; using Unity.Netcode; using Unity.Netcode.Transports.UTP; using UnityEngine; using UnityEngine.Audio; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.SceneManagement; 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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("MoreCompany")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyCopyright("Copyright © NotNotSwipez 2023")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MoreCompany")] [assembly: AssemblyTitle("MoreCompany")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MoreCompany { [HarmonyPatch(typeof(AudioMixer), "SetFloat")] public static class AudioMixerSetFloatPatch { public static bool Prefix(string name, ref float value) { if (name.StartsWith("PlayerVolume")) { string s = name.Replace("PlayerVolume", ""); int num = int.Parse(s); if (!SoundManagerPatch.initialVolumeSet) { MainClass.StaticLogger.LogInfo((object)$"Setting initial volume for {num} to {value}"); return true; } PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[num]; if ((Object)(object)val != (Object)null) { AudioSource currentVoiceChatAudioSource = val.currentVoiceChatAudioSource; if (Object.op_Implicit((Object)(object)currentVoiceChatAudioSource)) { currentVoiceChatAudioSource.volume = value / 16f; } } return false; } if (name.StartsWith("PlayerPitch")) { return MainClass.newPlayerCount <= 4; } return true; } } [HarmonyPatch(typeof(HUDManager), "AddTextToChatOnServer")] public static class SendChatToServerPatch { public static bool Prefix(string chatMessage, int playerId = -1) { if (DebugCommandRegistry.commandEnabled && ((NetworkBehaviour)StartOfRound.Instance).IsHost && chatMessage != null && chatMessage.StartsWith("/mc")) { string text = chatMessage.Replace("/mc ", ""); DebugCommandRegistry.HandleCommand(text.Split(' ')); return false; } return true; } } [HarmonyPatch] public static class CosmeticSyncPatch { [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__SV_ReceiveCosmetics; public static HandleNamedMessageDelegate <1>__CL_ReceiveCosmetics; public static HandleNamedMessageDelegate <2>__CL_ReceiveAllCosmetics; } public static void UpdateCosmeticsForPlayer(int playerClientId, List splitMessage) { //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) CosmeticApplication cosmeticApplication = ((Component)((Component)StartOfRound.Instance.allPlayerScripts[playerClientId]).transform.Find("ScavengerModel").Find("metarig")).gameObject.GetComponent(); if (!Object.op_Implicit((Object)(object)cosmeticApplication)) { cosmeticApplication = ((Component)((Component)StartOfRound.Instance.allPlayerScripts[playerClientId]).transform.Find("ScavengerModel").Find("metarig")).gameObject.AddComponent(); } cosmeticApplication.parentType = ParentType.Player; cosmeticApplication.ClearCosmetics(); List list = new List(); foreach (string item in splitMessage) { if (cosmeticApplication.ApplyCosmetic(item, startEnabled: false)) { list.Add(item); } } foreach (CosmeticInstance spawnedCosmetic in cosmeticApplication.spawnedCosmetics) { Transform transform = ((Component)spawnedCosmetic).transform; transform.localScale *= 0.38f; } cosmeticApplication.UpdateAllCosmeticVisibilities(playerClientId == StartOfRound.Instance.thisClientPlayerId); if (MainClass.playerIdsAndCosmetics.ContainsKey(playerClientId)) { MainClass.playerIdsAndCosmetics[playerClientId] = list; } else { MainClass.playerIdsAndCosmetics.Add(playerClientId, list); } } public static void SV_ReceiveCosmetics(ulong senderId, FastBufferReader messagePayload) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) if (!NetworkManager.Singleton.IsServer) { return; } ulong num = default(ulong); ((FastBufferReader)(ref messagePayload)).ReadValueSafe(ref num, default(ForPrimitives)); string text = default(string); ((FastBufferReader)(ref messagePayload)).ReadValueSafe(ref text, false); bool flag = default(bool); ((FastBufferReader)(ref messagePayload)).ReadValueSafe(ref flag, default(ForPrimitives)); List list = text.Split(',').ToList(); UpdateCosmeticsForPlayer((int)num, list); MainClass.StaticLogger.LogInfo((object)$"Server received {list.Count} cosmetics from {num} | Request All: {flag}"); int num2 = FastBufferWriter.GetWriteSize(ref num, default(ForStructs)) + FastBufferWriter.GetWriteSize(text, false); FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(num2, (Allocator)2, -1); FastBufferWriter val2 = val; try { ((FastBufferWriter)(ref val)).WriteValueSafe(ref num, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(text, false); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("MC_CL_ReceiveCosmetics", val, (NetworkDelivery)((((FastBufferWriter)(ref val)).Capacity > 1300) ? 4 : 2)); } finally { ((IDisposable)(FastBufferWriter)(ref val2)).Dispose(); } if (senderId != 0 && flag) { string text2 = JsonConvert.SerializeObject((object)MainClass.playerIdsAndCosmetics); int writeSize = FastBufferWriter.GetWriteSize(text2, false); FastBufferWriter val3 = default(FastBufferWriter); ((FastBufferWriter)(ref val3))..ctor(writeSize, (Allocator)2, -1); FastBufferWriter val4 = val3; try { ((FastBufferWriter)(ref val3)).WriteValueSafe(text2, false); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("MC_CL_ReceiveAllCosmetics", senderId, val3, (NetworkDelivery)((((FastBufferWriter)(ref val3)).Capacity > 1300) ? 4 : 2)); } finally { ((IDisposable)(FastBufferWriter)(ref val4)).Dispose(); } } } public static void CL_ReceiveAllCosmetics(ulong senderId, FastBufferReader messagePayload) { string text = default(string); ((FastBufferReader)(ref messagePayload)).ReadValueSafe(ref text, false); Dictionary> dictionary = JsonConvert.DeserializeObject>>(text); foreach (KeyValuePair> item in dictionary) { UpdateCosmeticsForPlayer(item.Key, item.Value); } MainClass.StaticLogger.LogInfo((object)$"Client received {dictionary.Sum((KeyValuePair> x) => x.Value.Count)} cosmetics from {dictionary.Keys.Count} players"); } public static void CL_ReceiveCosmetics(ulong senderId, FastBufferReader messagePayload) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (!NetworkManager.Singleton.IsServer) { ulong num = default(ulong); ((FastBufferReader)(ref messagePayload)).ReadValueSafe(ref num, default(ForPrimitives)); string text = default(string); ((FastBufferReader)(ref messagePayload)).ReadValueSafe(ref text, false); List list = text.Split(',').ToList(); UpdateCosmeticsForPlayer((int)num, list); MainClass.StaticLogger.LogInfo((object)$"Client received {list.Count} cosmetics from {num}"); } } public static void SyncCosmeticsToOtherClients(PlayerControllerB playerControllerTmp = null, bool disabled = false, bool requestAll = false) { //IL_0048: 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) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = playerControllerTmp ?? StartOfRound.Instance?.localPlayerController; if ((Object)(object)val != (Object)null) { List cosmeticsToSync = CosmeticRegistry.GetCosmeticsToSync(); string text = (disabled ? "" : string.Join(',', cosmeticsToSync)); int num = FastBufferWriter.GetWriteSize(ref val.playerClientId, default(ForStructs)) + FastBufferWriter.GetWriteSize(text, false) + FastBufferWriter.GetWriteSize(ref requestAll, default(ForStructs)); FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(num, (Allocator)2, -1); FastBufferWriter val3 = val2; try { ((FastBufferWriter)(ref val2)).WriteValueSafe(ref val.playerClientId, default(ForPrimitives)); ((FastBufferWriter)(ref val2)).WriteValueSafe(text, false); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref requestAll, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("MC_SV_SyncCosmetics", 0uL, val2, (NetworkDelivery)((((FastBufferWriter)(ref val2)).Capacity > 1300) ? 4 : 2)); } finally { ((IDisposable)(FastBufferWriter)(ref val3)).Dispose(); } MainClass.StaticLogger.LogInfo((object)$"Sending {cosmeticsToSync.Count} cosmetics to the server | Request All: {requestAll}"); } } [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] [HarmonyPostfix] public static void ConnectClientToPlayerObject(PlayerControllerB __instance) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown MainClass.playerIdsAndCosmetics.Clear(); if (NetworkManager.Singleton.IsServer) { CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; object obj = <>O.<0>__SV_ReceiveCosmetics; if (obj == null) { HandleNamedMessageDelegate val = SV_ReceiveCosmetics; <>O.<0>__SV_ReceiveCosmetics = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("MC_SV_SyncCosmetics", (HandleNamedMessageDelegate)obj); } else { CustomMessagingManager customMessagingManager2 = NetworkManager.Singleton.CustomMessagingManager; object obj2 = <>O.<1>__CL_ReceiveCosmetics; if (obj2 == null) { HandleNamedMessageDelegate val2 = CL_ReceiveCosmetics; <>O.<1>__CL_ReceiveCosmetics = val2; obj2 = (object)val2; } customMessagingManager2.RegisterNamedMessageHandler("MC_CL_ReceiveCosmetics", (HandleNamedMessageDelegate)obj2); CustomMessagingManager customMessagingManager3 = NetworkManager.Singleton.CustomMessagingManager; object obj3 = <>O.<2>__CL_ReceiveAllCosmetics; if (obj3 == null) { HandleNamedMessageDelegate val3 = CL_ReceiveAllCosmetics; <>O.<2>__CL_ReceiveAllCosmetics = val3; obj3 = (object)val3; } customMessagingManager3.RegisterNamedMessageHandler("MC_CL_ReceiveAllCosmetics", (HandleNamedMessageDelegate)obj3); } SyncCosmeticsToOtherClients(__instance, disabled: false, requestAll: true); } [HarmonyPatch(typeof(GameNetworkManager), "SetInstanceValuesBackToDefault")] [HarmonyPostfix] public static void SetInstanceValuesBackToDefault() { if ((Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.CustomMessagingManager != null) { NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler("MC_CL_ReceiveCosmetics"); NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler("MC_CL_ReceiveAllCosmetics"); NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler("MC_SV_SyncCosmetics"); MainClass.StaticLogger.LogInfo((object)"Unregistered Named Message Handlers"); } } } [HarmonyPatch] public static class PreventOldVersionChatSpamPatch { [HarmonyPatch(typeof(HUDManager), "AddChatMessage")] [HarmonyPrefix] public static bool AddChatMessage_Prefix(string chatMessage, string nameOfUserWhoTyped = "") { if (chatMessage != null && (chatMessage.StartsWith("[replacewithdata]") || chatMessage.StartsWith("[morecompanycosmetics]"))) { return false; } return true; } } [HarmonyPatch] public class CosmeticPatches { public static bool CloneCosmeticsToNonPlayer(ParentType parentType, Transform cosmeticRoot, int playerClientId, bool detachedHead = false) { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) if (MainClass.playerIdsAndCosmetics.ContainsKey(playerClientId)) { List list = MainClass.playerIdsAndCosmetics[playerClientId]; CosmeticApplication cosmeticApplication = ((Component)cosmeticRoot).GetComponent(); if (!Object.op_Implicit((Object)(object)cosmeticApplication)) { cosmeticApplication = ((Component)cosmeticRoot).gameObject.AddComponent(); } cosmeticApplication.parentType = parentType; cosmeticApplication.detachedHead = detachedHead; cosmeticApplication.ClearCosmetics(); foreach (string item in list) { cosmeticApplication.ApplyCosmetic(item, startEnabled: false); } foreach (CosmeticInstance spawnedCosmetic in cosmeticApplication.spawnedCosmetics) { Transform transform = ((Component)spawnedCosmetic).transform; transform.localScale *= 0.38f; } cosmeticApplication.UpdateAllCosmeticVisibilities(); return true; } return false; } [HarmonyPatch(typeof(PlayerControllerB), "SpawnDeadBody")] [HarmonyPostfix] public static void SpawnDeadBody(ref PlayerControllerB __instance, int deathAnimation = 0) { if ((Object)(object)__instance.deadBody == (Object)null) { return; } Transform transform = ((Component)__instance.deadBody).transform; if (!((Object)(object)transform == (Object)null)) { bool detachedHead = __instance.deadBody.detachedHead; if (deathAnimation == 4 || deathAnimation == 5) { detachedHead = true; } CloneCosmeticsToNonPlayer(ParentType.DeadBody, transform, (int)__instance.playerClientId, detachedHead); } } [HarmonyPatch(typeof(MaskedPlayerEnemy), "SetEnemyOutside")] [HarmonyPostfix] public static void SetEnemyOutside(MaskedPlayerEnemy __instance) { if (!((Object)(object)__instance.mimickingPlayer == (Object)null)) { Transform val = ((Component)__instance).transform.Find("ScavengerModel").Find("metarig"); if (!((Object)(object)val == (Object)null)) { CloneCosmeticsToNonPlayer(ParentType.MaskedEnemy, val, (int)__instance.mimickingPlayer.playerClientId); ((EnemyAI)__instance).skinnedMeshRenderers = ((Component)__instance).gameObject.GetComponentsInChildren(); ((EnemyAI)__instance).meshRenderers = ((Component)__instance).gameObject.GetComponentsInChildren(); } } } [HarmonyPatch(typeof(QuickMenuManager), "OpenQuickMenu")] [HarmonyPatch(typeof(QuickMenuManager), "CloseQuickMenu")] [HarmonyPostfix] public static void ToggleQuickMenu(QuickMenuManager __instance) { if (CosmeticRegistry.menuIsInGame && (Object)(object)CosmeticRegistry.cosmeticGUIGlobalScale != (Object)null) { ((Component)CosmeticRegistry.cosmeticGUIGlobalScale.Find("ActivateButton")).gameObject.SetActive(__instance.isMenuOpen); if (!__instance.isMenuOpen) { ((Component)CosmeticRegistry.cosmeticGUIGlobalScale.Find("CosmeticsScreen")).gameObject.SetActive(false); } } } } public class DebugCommandRegistry { public static bool commandEnabled; public static void HandleCommand(string[] args) { //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) if (!commandEnabled) { return; } PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController; switch (args[0]) { case "money": { int groupCredits = int.Parse(args[1]); Terminal val9 = Resources.FindObjectsOfTypeAll().First(); val9.groupCredits = groupCredits; break; } case "spawnscrap": { string text2 = ""; for (int m = 1; m < args.Length; m++) { text2 = text2 + args[m] + " "; } text2 = text2.Trim(); Vector3 val5 = ((Component)localPlayerController).transform.position + ((Component)localPlayerController).transform.forward * 2f; Item val6 = null; Item[] array4 = Resources.FindObjectsOfTypeAll(); foreach (Item val7 in array4) { if (val7.itemName.ToLower() == text2.ToLower()) { val6 = val7; break; } } GameObject val8 = Object.Instantiate(val6.spawnPrefab, val5, Quaternion.identity, (Transform)null); GrabbableObject component = val8.GetComponent(); ((Component)component).transform.rotation = Quaternion.Euler(component.itemProperties.restingRotation); component.fallTime = 0f; NetworkObject component2 = val8.GetComponent(); component2.Spawn(false); break; } case "spawnenemy": { string text = ""; for (int k = 1; k < args.Length; k++) { text = text + args[k] + " "; } text = text.Trim(); EnemyType val3 = null; EnemyType[] array3 = Resources.FindObjectsOfTypeAll(); foreach (EnemyType val4 in array3) { if (val4.enemyName.ToLower() == text.ToLower()) { val3 = val4; break; } } RoundManager.Instance.SpawnEnemyGameObject(((Component)localPlayerController).transform.position + ((Component)localPlayerController).transform.forward * 2f, 0f, -1, val3); break; } case "listall": { MainClass.StaticLogger.LogInfo((object)"-----------------"); MainClass.StaticLogger.LogInfo((object)"Spawnable scrap:"); Item[] array = Resources.FindObjectsOfTypeAll(); foreach (Item val in array) { MainClass.StaticLogger.LogInfo((object)val.itemName); } MainClass.StaticLogger.LogInfo((object)"-----------------"); MainClass.StaticLogger.LogInfo((object)"Spawnable enemies:"); EnemyType[] array2 = Resources.FindObjectsOfTypeAll(); foreach (EnemyType val2 in array2) { MainClass.StaticLogger.LogInfo((object)val2.enemyName); } break; } } } } public static class InstructionUtils { public static bool DoesSafeMatchInstruction(List instructions, int index, OpCode opCode) { if (index >= instructions.Count) { return false; } CodeInstruction val = instructions[index]; if (val.opcode != opCode) { return false; } return true; } } [HarmonyPatch(typeof(ForestGiantAI), "LookForPlayers")] public static class LookForPlayersForestGiantPatch { public static void Prefix(ref ForestGiantAI __instance) { if (__instance.playerStealthMeters.Length != MainClass.newPlayerCount) { Array.Resize(ref __instance.playerStealthMeters, MainClass.newPlayerCount); for (int i = 0; i < MainClass.newPlayerCount; i++) { __instance.playerStealthMeters[i] = 0f; } } } } [HarmonyPatch(typeof(BlobAI), "Start")] public static class BlobAIStartPatch { public static void Postfix(ref BlobAI __instance) { Collider[] value = (Collider[])(object)new Collider[MainClass.newPlayerCount]; ReflectionUtils.SetFieldValue(__instance, "ragdollColliders", value); } } [HarmonyPatch(typeof(CrawlerAI), "Start")] public static class CrawlerAIStartPatch { public static void Postfix(ref CrawlerAI __instance) { Collider[] value = (Collider[])(object)new Collider[MainClass.newPlayerCount]; ReflectionUtils.SetFieldValue(__instance, "nearPlayerColliders", value); } } [HarmonyPatch(typeof(SpringManAI), "Update")] public static class SpringManAIUpdatePatch { private static IEnumerable Transpiler(IEnumerable instructions) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown List list = new List(); bool flag = false; bool flag2 = false; foreach (CodeInstruction instruction in instructions) { if (!flag2) { if (!flag && ((object)instruction).ToString() == "call static float UnityEngine.Vector3::Distance(UnityEngine.Vector3 a, UnityEngine.Vector3 b)") { flag = true; } else if (flag && ((object)instruction).ToString() == "ldc.i4.4 NULL") { flag2 = true; CodeInstruction item = new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MainClass), "newPlayerCount")); list.Add(item); continue; } } list.Add(instruction); } if (!flag2) { MainClass.StaticLogger.LogWarning((object)"SpringManAIUpdatePatch failed to replace newPlayerCount"); } return list.AsEnumerable(); } } [HarmonyPatch(typeof(EnemyAI), "GetClosestPlayer")] public static class GetClosestPlayerPatch { private static IEnumerable Transpiler(IEnumerable instructions) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown List list = new List(); bool flag = false; foreach (CodeInstruction instruction in instructions) { if (!flag && ((object)instruction).ToString() == "ldc.i4.4 NULL") { flag = true; CodeInstruction item = new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MainClass), "newPlayerCount")); list.Add(item); } else { list.Add(instruction); } } if (!flag) { MainClass.StaticLogger.LogWarning((object)"GetClosestPlayerPatch failed to replace newPlayerCount"); } return list.AsEnumerable(); } } [HarmonyPatch(typeof(BushWolfEnemy), "Update")] public static class BushWolfEnemyPlayerObservePatch { private static IEnumerable Transpiler(IEnumerable instructions) { //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown List list = instructions.ToList(); FieldInfo field = typeof(StartOfRound).GetField("livingPlayers", BindingFlags.Instance | BindingFlags.Public); MethodInfo operand = AccessTools.Method(typeof(Mathf), "Clamp", new Type[3] { typeof(int), typeof(int), typeof(int) }, (Type[])null); bool flag = false; for (int i = 0; i < list.Count; i++) { CodeInstruction val = list[i]; if (val.opcode == OpCodes.Ldfld && (FieldInfo)val.operand == field && InstructionUtils.DoesSafeMatchInstruction(list, i + 1, OpCodes.Ldc_I4_2) && InstructionUtils.DoesSafeMatchInstruction(list, i + 2, OpCodes.Sub)) { list.RemoveAt(i + 1); list.RemoveAt(i + 1); list.Insert(i + 2, new CodeInstruction(OpCodes.Ldc_I4_3, (object)null)); list[i + 3].operand = operand; flag = true; break; } } if (!flag) { MainClass.StaticLogger.LogWarning((object)"BushWolfEnemy.Update failed to patch observation rule (Max 3 observers)"); } return list; } } [HarmonyPatch(typeof(BushWolfEnemy), "GetClosestPlayerToNest")] public static class BushWolfEnemyClosestPlayerNestPatch { private static IEnumerable Transpiler(IEnumerable instructions) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown List list = new List(); bool flag = false; foreach (CodeInstruction instruction in instructions) { if (!flag && ((object)instruction).ToString() == "ldc.i4.4 NULL") { flag = true; CodeInstruction item = new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MainClass), "newPlayerCount")); list.Add(item); } else { list.Add(instruction); } } if (!flag) { MainClass.StaticLogger.LogWarning((object)"GetClosestPlayerToNest failed to replace newPlayerCount"); } return list.AsEnumerable(); } } [HarmonyPatch(typeof(BushWolfEnemy), "DoAIInterval")] public static class BushWolfTargetDelayPatch { public static void Prefix(BushWolfEnemy __instance, ref int ___checkPlayer) { PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[___checkPlayer]; int num = 0; while ((!val.isPlayerControlled || val.isPlayerDead) && num < StartOfRound.Instance.allPlayerScripts.Length) { ___checkPlayer = (___checkPlayer + 1) % StartOfRound.Instance.allPlayerScripts.Length; val = StartOfRound.Instance.allPlayerScripts[___checkPlayer]; num++; } } } [HarmonyPatch(typeof(EnemyAI), "GetAllPlayersInLineOfSight")] public static class GetAllPlayersInLineOfSightPatch { public static IEnumerable Transpiler(IEnumerable instructions) { List list = new List(); int num = 0; foreach (CodeInstruction instruction in instructions) { if (instruction.opcode == OpCodes.Ldc_I4_4) { num++; instruction.opcode = OpCodes.Ldsfld; instruction.operand = AccessTools.Field(typeof(MainClass), "newPlayerCount"); } list.Add(instruction); } if (num != 2) { MainClass.StaticLogger.LogWarning((object)$"GetAllPlayersInLineOfSightPatch failed to replace newPlayerCount: {num}/2"); } return list.AsEnumerable(); } } [HarmonyPatch(typeof(DressGirlAI), "ChoosePlayerToHaunt")] public static class DressGirlHauntPatch { public static IEnumerable Transpiler(IEnumerable instructions) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown List list = new List(); int num = 0; foreach (CodeInstruction instruction in instructions) { if (((object)instruction).ToString() == "ldc.i4.4 NULL") { num++; CodeInstruction item = new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MainClass), "newPlayerCount")); list.Add(item); } else { list.Add(instruction); } } if (num != 3) { MainClass.StaticLogger.LogWarning((object)$"DressGirlHauntPatch failed to replace newPlayerCount: {num}/3"); } return list.AsEnumerable(); } } [HarmonyPatch(typeof(ButlerEnemyAI), "Start")] public static class ButlerEnemyAIPatch { public static IEnumerable Transpiler(IEnumerable instructions) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown List list = new List(); int num = 0; foreach (CodeInstruction instruction in instructions) { if (((object)instruction).ToString() == "ldc.i4.4 NULL") { num++; CodeInstruction item = new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MainClass), "newPlayerCount")); list.Add(item); } else { list.Add(instruction); } } if (num != 3) { MainClass.StaticLogger.LogWarning((object)$"ButlerEnemyAIPatch failed to replace newPlayerCount: {num}/3"); } return list.AsEnumerable(); } } [HarmonyPatch(typeof(CaveDwellerAI), "GetAllPlayerBodiesInLineOfSight")] public static class GetAllPlayerBodiesInLineOfSightPatch { public static IEnumerable Transpiler(IEnumerable instructions) { List list = new List(); int num = 0; foreach (CodeInstruction instruction in instructions) { if (instruction.opcode == OpCodes.Ldc_I4_4) { num++; instruction.opcode = OpCodes.Ldsfld; instruction.operand = AccessTools.Field(typeof(MainClass), "newPlayerCount"); } list.Add(instruction); } if (num != 2) { MainClass.StaticLogger.LogWarning((object)$"GetAllPlayerBodiesInLineOfSightPatch failed to replace newPlayerCount: {num}/2"); } return list.AsEnumerable(); } } [HarmonyPatch(typeof(HUDManager), "AddChatMessage")] public static class HudChatPatch { public static void Prefix(HUDManager __instance, ref string chatMessage, string nameOfUserWhoTyped = "") { if (!(__instance.lastChatMessage == chatMessage)) { StringBuilder stringBuilder = new StringBuilder(chatMessage); for (int i = 0; i < MainClass.newPlayerCount; i++) { string oldValue = $"[playerNum{i}]"; string playerUsername = StartOfRound.Instance.allPlayerScripts[i].playerUsername; stringBuilder.Replace(oldValue, playerUsername); } chatMessage = stringBuilder.ToString(); } } } [HarmonyPatch(typeof(MenuManager), "ClickHostButton")] [HarmonyPriority(0)] public static class MenuManagerHost { public static void UpdateTextBox(TMP_InputField inputField, string s) { if (inputField.text == MainClass.newPlayerCount.ToString()) { return; } if (int.TryParse(s, out var result)) { int newPlayerCount = MainClass.newPlayerCount; MainClass.newPlayerCount = Mathf.Clamp(result, MainClass.minPlayerCount, MainClass.maxPlayerCount); inputField.text = MainClass.newPlayerCount.ToString(); if (MainClass.newPlayerCount != newPlayerCount) { MainClass.StaticLogger.LogInfo((object)$"Changed Crew Count: {MainClass.newPlayerCount}"); } MainClass.playerCount.Value = MainClass.newPlayerCount; MainClass.StaticConfig.Save(); } else if (s.Length != 0) { inputField.text = MainClass.newPlayerCount.ToString(); inputField.caretPosition = 1; } } public static void SetupCrewCountInput(TMP_InputField inputField) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown inputField.text = MainClass.newPlayerCount.ToString(); if (!Object.op_Implicit((Object)(object)((Component)inputField).transform.Find("Registered"))) { ((UnityEvent)(object)inputField.onSubmit).AddListener((UnityAction)delegate(string s) { UpdateTextBox(inputField, s); }); ((UnityEvent)(object)inputField.onDeselect).AddListener((UnityAction)delegate(string s) { UpdateTextBox(inputField, s); }); GameObject val = new GameObject("Registered"); val.transform.parent = ((Component)inputField).transform; } } public static void CreateCrewCountInput(MenuManager __instance) { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)GameObject.Find("MC_CrewCount"))) { TMP_InputField componentInChildren = GameObject.Find("MC_CrewCount").GetComponentInChildren(); SetupCrewCountInput(componentInChildren); return; } Transform val = __instance.HostSettingsScreen.transform.Find("HostSettingsContainer/LobbyHostOptions"); if ((Object)(object)val != (Object)null) { Transform val2 = val.Find(__instance.HostSettingsOptionsLAN.activeSelf ? "LANOptions" : "OptionsNormal"); if ((Object)(object)val2 != (Object)null) { GameObject val3 = Object.Instantiate(MainClass.crewCountUI, val2); ((Object)val3).name = "MC_CrewCount"; RectTransform component = val3.GetComponent(); ((Transform)component).localPosition = new Vector3(96.9f, -70f, -6.7f); TMP_InputField componentInChildren2 = ((Component)val3.transform).GetComponentInChildren(); componentInChildren2.characterLimit = 3; SetupCrewCountInput(componentInChildren2); } } } public static void Postfix(MenuManager __instance) { MainClass.newPlayerCount = Mathf.Max(MainClass.minPlayerCount, MainClass.playerCount.Value); CreateCrewCountInput(__instance); } } [HarmonyPatch] public static class MenuManagerLogoOverridePatch { public static bool lanWarningShown; [HarmonyPatch(typeof(MenuManager), "Awake")] [HarmonyPostfix] [HarmonyPriority(0)] public static void Awake_Postfix(MenuManager __instance) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) if (__instance.isInitScene) { return; } try { Sprite sprite = Sprite.Create(MainClass.mainLogo, new Rect(0f, 0f, (float)((Texture)MainClass.mainLogo).width, (float)((Texture)MainClass.mainLogo).height), new Vector2(0.5f, 0.5f)); GameObject gameObject = ((Component)((Component)__instance).transform.parent).gameObject; Transform val = gameObject.transform.Find("MenuContainer/MainButtons/HeaderImage"); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.GetComponent().sprite = sprite; } Transform val2 = gameObject.transform.Find("MenuContainer/LoadingScreen"); if ((Object)(object)val2 != (Object)null) { val2.localScale = new Vector3(1.02f, 1.06f, 1.02f); Transform val3 = val2.Find("Image"); if ((Object)(object)val3 != (Object)null) { ((Component)val3).GetComponent().sprite = sprite; } } } catch (Exception ex) { MainClass.StaticLogger.LogError((object)ex); } try { LANMenu.InitializeMenu(); } catch (Exception ex2) { MainClass.StaticLogger.LogError((object)ex2); } CosmeticRegistry.SpawnCosmeticGUI(mainMenu: true); } [HarmonyPatch(typeof(MenuManager), "Start")] [HarmonyPostfix] public static void Start_Postfix(MenuManager __instance) { if (!__instance.isInitScene && GameNetworkManager.Instance.disableSteam) { if (lanWarningShown) { __instance.lanWarningContainer.SetActive(false); } else { lanWarningShown = true; } } } } [HarmonyPatch(typeof(QuickMenuManager), "Start")] public static class QuickmenuVisualInjectPatch { public static void Postfix(QuickMenuManager __instance) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Expected O, but got Unknown //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Expected O, but got Unknown CosmeticRegistry.SpawnCosmeticGUI(mainMenu: false); GameObject gameObject = ((Component)__instance.playerListPanel.transform.Find("Image")).gameObject; GameObject val = Object.Instantiate(MainClass.quickMenuScrollParent, gameObject.transform); RectTransform component = val.GetComponent(); ((Transform)component).localPosition = new Vector3(0f, -31.2f, 0f); ((Transform)component).localScale = Vector3.one; Transform val2 = val.transform.Find("Holder"); if (!((Object)(object)val2 != (Object)null)) { return; } Array.Resize(ref __instance.playerListSlots, MainClass.newPlayerCount); for (int i = 0; i < MainClass.newPlayerCount; i++) { int finalIndex = i; if (__instance.playerListSlots[finalIndex] == null) { __instance.playerListSlots[finalIndex] = new PlayerListSlot(); } if ((Object)(object)__instance.playerListSlots[finalIndex].slotContainer != (Object)null) { Object.Destroy((Object)(object)__instance.playerListSlots[finalIndex].slotContainer); } GameObject val3 = Object.Instantiate(MainClass.playerEntry, val2); val3.SetActive(false); ((Object)val3).name = "PlayerListSlot" + finalIndex; __instance.playerListSlots[finalIndex].slotContainer = val3; RectTransform component2 = val3.GetComponent(); ((Transform)component2).localScale = Vector3.one; ((Transform)component2).localPosition = new Vector3(0f, 0f - ((Transform)component2).localPosition.y, 0f); __instance.playerListSlots[finalIndex].usernameHeader = ((Component)val3.transform.Find("PlayerNameButton").Find("PName")).GetComponent(); __instance.playerListSlots[finalIndex].volumeSlider = ((Component)val3.transform.Find("PlayerVolumeSlider")).GetComponent(); __instance.playerListSlots[finalIndex].volumeSliderContainer = ((Component)__instance.playerListSlots[finalIndex].volumeSlider).gameObject; ((UnityEvent)(object)__instance.playerListSlots[finalIndex].volumeSlider.onValueChanged).AddListener((UnityAction)delegate(float f) { float num = (f - __instance.playerListSlots[finalIndex].volumeSlider.minValue) / (__instance.playerListSlots[finalIndex].volumeSlider.maxValue - __instance.playerListSlots[finalIndex].volumeSlider.minValue); if (num <= 0f) { num = -70f; } SoundManager.Instance.playerVoiceVolumes[finalIndex] = num; }); Button component3 = ((Component)val3.transform.Find("ProfileIcon")).GetComponent