Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of MoreCompanyBeta v1.12.1
BepInEx/plugins/MoreCompany.dll
Decompiled 3 hours 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.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.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("MoreCompany")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright © NotNotSwipez 2023")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+1377c22a695c7675ee219e4d6bd29839586ade1b")] [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.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<string> splitMessage) { //IL_00d6: 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) CosmeticApplication cosmeticApplication = ((Component)((Component)StartOfRound.Instance.allPlayerScripts[playerClientId]).transform.Find("ScavengerModel").Find("metarig")).gameObject.GetComponent<CosmeticApplication>(); if (!Object.op_Implicit((Object)(object)cosmeticApplication)) { cosmeticApplication = ((Component)((Component)StartOfRound.Instance.allPlayerScripts[playerClientId]).transform.Find("ScavengerModel").Find("metarig")).gameObject.AddComponent<CosmeticApplication>(); } cosmeticApplication.parentType = ParentType.Player; cosmeticApplication.ClearCosmetics(); List<string> list = new List<string>(); 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_0085: 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_00a7: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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<ulong>(ref num, default(ForPrimitives)); string text = default(string); ((FastBufferReader)(ref messagePayload)).ReadValueSafe(ref text, false); bool flag = default(bool); ((FastBufferReader)(ref messagePayload)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); List<string> 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<ulong>(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<ulong>(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<int, List<string>> dictionary = JsonConvert.DeserializeObject<Dictionary<int, List<string>>>(text); foreach (KeyValuePair<int, List<string>> item in dictionary) { UpdateCosmeticsForPlayer(item.Key, item.Value); } MainClass.StaticLogger.LogInfo((object)$"Client received {dictionary.Sum((KeyValuePair<int, List<string>> x) => x.Value.Count)} cosmetics from {dictionary.Keys.Count} players"); } public static void CL_ReceiveCosmetics(ulong senderId, FastBufferReader messagePayload) { //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) if (!NetworkManager.Singleton.IsServer) { ulong num = default(ulong); ((FastBufferReader)(ref messagePayload)).ReadValueSafe<ulong>(ref num, default(ForPrimitives)); string text = default(string); ((FastBufferReader)(ref messagePayload)).ReadValueSafe(ref text, false); List<string> 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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<string> cosmeticsToSync = CosmeticRegistry.GetCosmeticsToSync(); string text = (disabled ? "" : string.Join(',', cosmeticsToSync)); int num = FastBufferWriter.GetWriteSize<ulong>(ref val.playerClientId, default(ForStructs)) + FastBufferWriter.GetWriteSize(text, false) + FastBufferWriter.GetWriteSize<bool>(ref requestAll, default(ForStructs)); FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(num, (Allocator)2, -1); FastBufferWriter val3 = val2; try { ((FastBufferWriter)(ref val2)).WriteValueSafe<ulong>(ref val.playerClientId, default(ForPrimitives)); ((FastBufferWriter)(ref val2)).WriteValueSafe(text, false); ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(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_0066: 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_0071: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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.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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) if (MainClass.playerIdsAndCosmetics.ContainsKey(playerClientId)) { List<string> list = MainClass.playerIdsAndCosmetics[playerClientId]; CosmeticApplication cosmeticApplication = ((Component)cosmeticRoot).GetComponent<CosmeticApplication>(); if (!Object.op_Implicit((Object)(object)cosmeticApplication)) { cosmeticApplication = ((Component)cosmeticRoot).gameObject.AddComponent<CosmeticApplication>(); } 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<SkinnedMeshRenderer>(); ((EnemyAI)__instance).meshRenderers = ((Component)__instance).gameObject.GetComponentsInChildren<MeshRenderer>(); } } } [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_00a8: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0115: 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) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0210: 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<Terminal>().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<Item>(); foreach (Item val7 in array4) { if (val7.itemName.ToLower() == text2.ToLower()) { val6 = val7; break; } } GameObject val8 = Object.Instantiate<GameObject>(val6.spawnPrefab, val5, Quaternion.identity, (Transform)null); GrabbableObject component = val8.GetComponent<GrabbableObject>(); ((Component)component).transform.rotation = Quaternion.Euler(component.itemProperties.restingRotation); component.fallTime = 0f; NetworkObject component2 = val8.GetComponent<NetworkObject>(); 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<EnemyType>(); 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<Item>(); 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<EnemyType>(); foreach (EnemyType val2 in array2) { MainClass.StaticLogger.LogInfo((object)val2.enemyName); } break; } } } } [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<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(); 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<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(); 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(EnemyAI), "GetAllPlayersInLineOfSight")] public static class GetAllPlayersInLineOfSightPatch { public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(); 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<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(); 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<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(); 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<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(); 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown inputField.text = MainClass.newPlayerCount.ToString(); if (!Object.op_Implicit((Object)(object)((Component)inputField).transform.Find("Registered"))) { ((UnityEvent<string>)(object)inputField.onSubmit).AddListener((UnityAction<string>)delegate(string s) { UpdateTextBox(inputField, s); }); ((UnityEvent<string>)(object)inputField.onDeselect).AddListener((UnityAction<string>)delegate(string s) { UpdateTextBox(inputField, s); }); GameObject val = new GameObject("Registered"); val.transform.parent = ((Component)inputField).transform; } } public static void CreateCrewCountInput(MenuManager __instance) { //IL_00a0: 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<TMP_InputField>(); 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<GameObject>(MainClass.crewCountUI, val2); ((Object)val3).name = "MC_CrewCount"; RectTransform component = val3.GetComponent<RectTransform>(); ((Transform)component).localPosition = new Vector3(96.9f, -70f, -6.7f); TMP_InputField componentInChildren2 = ((Component)val3.transform).GetComponentInChildren<TMP_InputField>(); 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_002f: 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_00af: 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<Image>().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<Image>().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_005b: 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) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Expected O, but got Unknown //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Expected O, but got Unknown CosmeticRegistry.SpawnCosmeticGUI(mainMenu: false); GameObject gameObject = ((Component)__instance.playerListPanel.transform.Find("Image")).gameObject; GameObject val = Object.Instantiate<GameObject>(MainClass.quickMenuScrollParent, gameObject.transform); RectTransform component = val.GetComponent<RectTransform>(); ((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<GameObject>(MainClass.playerEntry, val2); val3.SetActive(false); ((Object)val3).name = "PlayerListSlot" + finalIndex; __instance.playerListSlots[finalIndex].slotContainer = val3; RectTransform component2 = val3.GetComponent<RectTransform>(); ((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<TextMeshProUGUI>(); __instance.playerListSlots[finalIndex].volumeSlider = ((Component)val3.transform.Find("PlayerVolumeSlider")).GetComponent<Slider>(); __instance.playerListSlots[finalIndex].volumeSliderContainer = ((Component)__instance.playerListSlots[finalIndex].volumeSlider).gameObject; ((UnityEvent<float>)(object)__instance.playerListSlots[finalIndex].volumeSlider.onValueChanged).AddListener((UnityAction<float>)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<Button>(); ((UnityEvent)component3.onClick).AddListener((UnityAction)delegate { __instance.OpenUserSteamProfile(finalIndex); }); Button component4 = ((Component)val3.transform.Find("KickButton")).GetComponent<Button>(); ((UnityEvent)component4.onClick).AddListener((UnityAction)delegate { __instance.KickUserFromServer(finalIndex); }); __instance.playerListSlots[finalIndex].KickUserButton = ((Component)component4).gameObject; } } } [HarmonyPatch(typeof(QuickMenuManager), "Update")] public static class QuickMenuUpdatePatch { public static bool Prefix() { return false; } } [HarmonyPatch(typeof(QuickMenuManager), "AddUserToPlayerList")] public static class AddUserPlayerListPatch { private static void Prefix(QuickMenuManager __instance, ulong steamId, string playerName, int playerObjectId) { if (playerObjectId > 4) { __instance.playerListSlots[playerObjectId].KickUserButton.SetActive(((NetworkBehaviour)StartOfRound.Instance).IsServer); __instance.playerListSlots[playerObjectId].slotContainer.SetActive(true); __instance.playerListSlots[playerObjectId].isConnected = true; __instance.playerListSlots[playerObjectId].playerSteamId = steamId; ((TMP_Text)__instance.playerListSlots[playerObjectId].usernameHeader).text = playerName; if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null) { __instance.playerListSlots[playerObjectId].volumeSliderContainer.SetActive(playerObjectId != (int)GameNetworkManager.Instance.localPlayerController.playerClientId); } } } private static void Postfix(QuickMenuManager __instance, ulong steamId, string playerName, int playerObjectId) { if (playerObjectId >= 0) { Slider volumeSlider = __instance.playerListSlots[playerObjectId].volumeSlider; volumeSlider.value = Mathf.Clamp(SoundManager.Instance.playerVoiceVolumes[playerObjectId] * (volumeSlider.maxValue - volumeSlider.minValue) + volumeSlider.minValue, volumeSlider.minValue, volumeSlider.maxValue); Transform obj = __instance.playerListSlots[playerObjectId].slotContainer.transform.Find("Text (1)"); if (obj != null) { ((Component)obj).gameObject.SetActive(__instance.playerListSlots[playerObjectId].volumeSliderContainer.activeSelf); } } } } [HarmonyPatch(typeof(QuickMenuManager), "ConfirmKickUserFromServer")] public static class KickPatch { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(); bool flag = false; bool flag2 = false; foreach (CodeInstruction instruction in instructions) { if (!flag2) { if (!flag && ((object)instruction).ToString() == "ldfld int QuickMenuManager::playerObjToKick") { flag = true; } else if (flag && ((object)instruction).ToString() == "ldc.i4.3 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)"KickPatch failed to replace newPlayerCount"); } return list.AsEnumerable(); } } [HarmonyPatch(typeof(HUDManager), "UpdateBoxesSpectateUI")] public static class SpectatorBoxUpdatePatch { public static void Postfix(HUDManager __instance) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) Dictionary<Animator, PlayerControllerB> fieldValue = ReflectionUtils.GetFieldValue<Dictionary<Animator, PlayerControllerB>>(__instance, "spectatingPlayerBoxes"); int num = -64; int num2 = 0; int num3 = 0; int num4 = -70; int num5 = 230; int num6 = 4; foreach (KeyValuePair<Animator, PlayerControllerB> item in fieldValue) { if (((Component)item.Key).gameObject.activeInHierarchy) { GameObject gameObject = ((Component)item.Key).gameObject; RectTransform component = gameObject.GetComponent<RectTransform>(); int num7 = (int)Math.Floor((double)num3 / (double)num6); int num8 = num3 % num6; int num9 = num8 * num4; int num10 = num7 * num5; component.anchoredPosition = Vector2.op_Implicit(new Vector3((float)(num + num10), (float)(num2 + num9), 0f)); num3++; } } } } [HarmonyPatch(typeof(HUDManager), "Start")] public static class HudStartPatch { public static void Postfix(HUDManager __instance) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) EndOfGameStatUIElements statsUIElements = __instance.statsUIElements; GameObject gameObject = ((Component)((Component)statsUIElements.playerNamesText[0]).gameObject.transform.parent).gameObject; GameObject gameObject2 = ((Component)gameObject.transform.parent.parent).gameObject; GameObject gameObject3 = ((Component)gameObject2.transform.Find("BGBoxes")).gameObject; gameObject2.transform.parent.Find("DeathScreen").SetSiblingIndex(3); gameObject3.transform.localScale = new Vector3(2.5f, 1f, 1f); MakePlayerHolder(4, gameObject, statsUIElements, new Vector3(426.9556f, -0.7932f, 0f)); MakePlayerHolder(5, gameObject, statsUIElements, new Vector3(426.9556f, -115.4483f, 0f)); MakePlayerHolder(6, gameObject, statsUIElements, new Vector3(-253.6783f, -115.4483f, 0f)); MakePlayerHolder(7, gameObject, statsUIElements, new Vector3(-253.6783f, -0.7932f, 0f)); for (int i = 8; i < MainClass.newPlayerCount; i++) { MakePlayerHolder(i, gameObject, statsUIElements, new Vector3(10000f, 10000f, 0f)); } } public static void MakePlayerHolder(int index, GameObject original, EndOfGameStatUIElements uiElements, Vector3 localPosition) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) if (index + 1 <= MainClass.newPlayerCount) { GameObject val = Object.Instantiate<GameObject>(original); RectTransform component = val.GetComponent<RectTransform>(); RectTransform component2 = original.GetComponent<RectTransform>(); ((Transform)component).SetParent(((Transform)component2).parent); ((Transform)component).localScale = new Vector3(1f, 1f, 1f); ((Transform)component).localPosition = localPosition; GameObject gameObject = ((Component)val.transform.Find("PlayerName1")).gameObject; GameObject gameObject2 = ((Component)val.transform.Find("Notes")).gameObject; ((Transform)gameObject2.GetComponent<RectTransform>()).localPosition = new Vector3(-95.7222f, 43.3303f, 0f); GameObject gameObject3 = ((Component)val.transform.Find("Symbol")).gameObject; if (index >= uiElements.playerNamesText.Length) { Array.Resize(ref uiElements.playerNamesText, index + 1); Array.Resize(ref uiElements.playerStates, index + 1); Array.Resize(ref uiElements.playerNotesText, index + 1); } uiElements.playerNamesText[index] = gameObject.GetComponent<TextMeshProUGUI>(); uiElements.playerNotesText[index] = gameObject2.GetComponent<TextMeshProUGUI>(); uiElements.playerStates[index] = gameObject3.GetComponent<Image>(); } } } public class LANMenu : MonoBehaviour { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__0_0; internal void <InitializeMenu>b__0_0() { GameObject.Find("Canvas/MenuContainer/LobbyJoinSettings").gameObject.SetActive(true); } } public static void InitializeMenu() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown CreateUI(); GameObject val = GameObject.Find("Canvas/MenuContainer/MainButtons/StartLAN"); if (!((Object)(object)val != (Object)null)) { return; } MainClass.StaticLogger.LogInfo((object)"LANMenu startLAN Patched"); val.GetComponent<Button>().onClick = new ButtonClickedEvent(); ButtonClickedEvent onClick = val.GetComponent<Button>().onClick; object obj = <>c.<>9__0_0; if (obj == null) { UnityAction val2 = delegate { GameObject.Find("Canvas/MenuContainer/LobbyJoinSettings").gameObject.SetActive(true); }; <>c.<>9__0_0 = val2; obj = (object)val2; } ((UnityEvent)onClick).AddListener((UnityAction)obj); } private static GameObject CreateUI() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Expected O, but got Unknown //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Expected O, but got Unknown if ((Object)(object)GameObject.Find("Canvas/MenuContainer/LobbyJoinSettings") != (Object)null) { return null; } GameObject val = GameObject.Find("Canvas/MenuContainer"); if ((Object)(object)val == (Object)null) { return null; } GameObject val2 = GameObject.Find("Canvas/MenuContainer/LobbyHostSettings"); if ((Object)(object)val2 == (Object)null) { return null; } GameObject val3 = Object.Instantiate<GameObject>(val2, val2.transform.position, val2.transform.rotation, val.transform); ((Object)val3).name = "LobbyJoinSettings"; Transform val4 = val3.transform.Find("HostSettingsContainer"); if ((Object)(object)val4 != (Object)null) { ((Object)val4).name = "JoinSettingsContainer"; ((Object)((Component)val4).transform.Find("LobbyHostOptions")).name = "LobbyJoinOptions"; Object.Destroy((Object)(object)((Component)val3.transform.Find("ChallengeLeaderboard")).gameObject); Object.Destroy((Object)(object)((Component)val3.transform.Find("FilesPanel")).gameObject); Object.Destroy((Object)(object)((Component)((Component)val4).transform.Find("LobbyJoinOptions/OptionsNormal")).gameObject); Object.Destroy((Object)(object)((Component)((Component)val4).transform.Find("LobbyJoinOptions/LANOptions/AllowRemote")).gameObject); Object.Destroy((Object)(object)((Component)((Component)val4).transform.Find("LobbyJoinOptions/LANOptions/Local")).gameObject); Transform val5 = ((Component)val4).transform.Find("LobbyJoinOptions/LANOptions/Header"); if ((Object)(object)val5 != (Object)null) { ((TMP_Text)((Component)val5).GetComponent<TextMeshProUGUI>()).text = "Join LAN Server:"; } Transform val6 = ((Component)val4).transform.Find("LobbyJoinOptions/LANOptions/ServerNameField"); if ((Object)(object)val6 != (Object)null) { ((Component)val6).transform.localPosition = new Vector3(0f, 15f, -6.5f); ((Component)val6).gameObject.SetActive(true); } TMP_InputField ip_field = ((Component)val6).GetComponent<TMP_InputField>(); if ((Object)(object)ip_field != (Object)null) { TextMeshProUGUI ip_placeholder = ((Component)ip_field.placeholder).GetComponent<TextMeshProUGUI>(); ((TMP_Text)ip_placeholder).text = ES3.Load<string>("LANIPAddress", "LCGeneralSaveData", "127.0.0.1"); Transform obj = ((Component)val4).transform.Find("Confirm"); Button val7 = ((obj != null) ? ((Component)obj).GetComponent<Button>() : null); if ((Object)(object)val7 != (Object)null) { val7.onClick = new ButtonClickedEvent(); ((UnityEvent)val7.onClick).AddListener((UnityAction)delegate { string text = "127.0.0.1"; text = ((!(ip_field.text != "")) ? ((TMP_Text)ip_placeholder).text : ip_field.text); ES3.Save<string>("LANIPAddress", text, "LCGeneralSaveData"); GameObject.Find("Canvas/MenuContainer/LobbyJoinSettings").gameObject.SetActive(false); ((Component)NetworkManager.Singleton).GetComponent<UnityTransport>().ConnectionData.Address = text; MainClass.StaticLogger.LogInfo((object)("Listening to LAN server: " + text)); GameObject.Find("MenuManager").GetComponent<MenuManager>().StartAClient(); }); } } ((Component)((Component)val4).transform.Find("LobbyJoinOptions/LANOptions")).gameObject.SetActive(true); } return val3; } } [HarmonyPatch(typeof(GameNetworkManager), "OnLocalClientConnectionDisapproved")] public static class ConnectionDisapprovedPatch { [CompilerGenerated] private sealed class <delayedReconnect>d__1 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <delayedReconnect>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 1; return true; case 1: <>1__state = -1; GameObject.Find("MenuManager").GetComponent<MenuManager>().StartAClient(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static int crewSizeMismatch; [IteratorStateMachine(typeof(<delayedReconnect>d__1))] private static IEnumerator delayedReconnect() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <delayedReconnect>d__1(0); } private static void Prefix(GameNetworkManager __instance, ulong clientId) { crewSizeMismatch = 0; if (!__instance.disableSteam) { return; } try { if (!string.IsNullOrEmpty(NetworkManager.Singleton.DisconnectReason) && NetworkManager.Singleton.DisconnectReason.StartsWith("Crew size mismatch!")) { crewSizeMismatch = int.Parse(NetworkManager.Singleton.DisconnectReason.Split("Their size: ")[1].Split(". ")[0]); } } catch { } } private static void Postfix(GameNetworkManager __instance, ulong clientId) { if (__instance.disableSteam && crewSizeMismatch != 0) { MainClass.newPlayerCount = Mathf.Clamp(crewSizeMismatch, MainClass.minPlayerCount, MainClass.maxPlayerCount); if (MainClass.newPlayerCount == crewSizeMismatch) { GameObject.Find("MenuManager").GetComponent<MenuManager>().menuNotification.SetActive(false); Object.FindObjectOfType<MenuManager>().SetLoadingScreen(true, (RoomEnter)5, ""); ((MonoBehaviour)__instance).StartCoroutine(delayedReconnect()); } crewSizeMismatch = 0; } } } public static class PluginInformation { public const string PLUGIN_NAME = "MoreCompany"; public const string PLUGIN_VERSION = "1.12.0"; public const string PLUGIN_GUID = "me.swipez.melonloader.morecompany"; } [BepInPlugin("me.swipez.melonloader.morecompany", "MoreCompany", "1.12.0")] public class MainClass : BaseUnityPlugin { public static readonly int defaultPlayerCount = 32; public static readonly int minPlayerCount = 4; public static readonly int maxPlayerCount = 50; public static int newPlayerCount = 32; public static ConfigFile StaticConfig; public static ConfigEntry<int> playerCount; public static ConfigEntry<bool> cosmeticsDeadBodies; public static ConfigEntry<bool> cosmeticsMaskedEnemy; public static ConfigEntry<bool> cosmeticsSyncOther; public static ConfigEntry<bool> defaultCosmetics; public static ConfigEntry<bool> cosmeticsPerProfile; public static ConfigEntry<string> disabledCosmetics; public static Texture2D mainLogo; public static GameObject quickMenuScrollParent; public static GameObject playerEntry; public static GameObject crewCountUI; public static GameObject cosmeticGUIInstance; public static GameObject cosmeticButton; public static ManualLogSource StaticLogger; public static Dictionary<int, List<string>> playerIdsAndCosmetics = new Dictionary<int, List<string>>(); public static string dynamicCosmeticsPath; public static string cosmeticSavePath; private void Awake() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Expected O, but got Unknown StaticLogger = ((BaseUnityPlugin)this).Logger; StaticConfig = ((BaseUnityPlugin)this).Config; playerCount = StaticConfig.Bind<int>("General", "Player Count", defaultPlayerCount, new ConfigDescription("How many players can be in your lobby?", (AcceptableValueBase)(object)new AcceptableValueRange<int>(minPlayerCount, maxPlayerCount), Array.Empty<object>())); newPlayerCount = Mathf.Max(minPlayerCount, playerCount.Value); cosmeticsSyncOther = StaticConfig.Bind<bool>("Cosmetics", "Show Cosmetics", true, "Should you be able to see cosmetics of other players?"); cosmeticsDeadBodies = StaticConfig.Bind<bool>("Cosmetics", "Show On Dead Bodies", true, "Should you be able to see cosmetics on dead bodies?"); cosmeticsMaskedEnemy = StaticConfig.Bind<bool>("Cosmetics", "Show On Masked Enemy", true, "Should you be able to see cosmetics on the masked enemy?"); defaultCosmetics = StaticConfig.Bind<bool>("Cosmetics", "Default Cosmetics", true, "Should the default cosmetics be enabled?"); cosmeticsPerProfile = StaticConfig.Bind<bool>("Cosmetics", "Per Profile Cosmetics", false, "Should the cosmetics be saved per-profile?"); disabledCosmetics = StaticConfig.Bind<string>("Cosmetics", "Disabled Cosmetics", "", "Comma separated list of cosmetics to disable"); cosmeticsSyncOther.SettingChanged += delegate { PlayerControllerB[] array3 = Object.FindObjectsByType<PlayerControllerB>((FindObjectsSortMode)0); foreach (PlayerControllerB val6 in array3) { Transform val7 = ((Component)val6).transform.Find("ScavengerModel").Find("metarig"); if (!((Object)(object)val7 == (Object)null)) { CosmeticApplication component3 = ((Component)val7).gameObject.GetComponent<CosmeticApplication>(); if (!((Object)(object)component3 == (Object)null)) { component3.UpdateAllCosmeticVisibilities((int)val6.playerClientId == StartOfRound.Instance.thisClientPlayerId); } } } }; cosmeticsDeadBodies.SettingChanged += delegate { PlayerControllerB[] array2 = Object.FindObjectsByType<PlayerControllerB>((FindObjectsSortMode)0); foreach (PlayerControllerB val5 in array2) { Transform transform = ((Component)val5.deadBody).transform; if (!((Object)(object)transform == (Object)null)) { CosmeticApplication component2 = ((Component)transform).GetComponent<CosmeticApplication>(); if (!((Object)(object)component2 == (Object)null)) { component2.UpdateAllCosmeticVisibilities(); } } } }; cosmeticsMaskedEnemy.SettingChanged += delegate { MaskedPlayerEnemy[] array = Object.FindObjectsByType<MaskedPlayerEnemy>((FindObjectsSortMode)0); foreach (MaskedPlayerEnemy val3 in array) { Transform val4 = ((Component)val3).transform.Find("ScavengerModel").Find("metarig"); if (!((Object)(object)val4 == (Object)null)) { CosmeticApplication component = ((Component)val4).GetComponent<CosmeticApplication>(); if (!((Object)(object)component == (Object)null)) { component.UpdateAllCosmeticVisibilities(); ((EnemyAI)val3).skinnedMeshRenderers = ((Component)val3).gameObject.GetComponentsInChildren<SkinnedMeshRenderer>(); ((EnemyAI)val3).meshRenderers = ((Component)val3).gameObject.GetComponentsInChildren<MeshRenderer>(); } } } }; Harmony val = new Harmony("me.swipez.melonloader.morecompany"); try { val.PatchAll(); } catch (Exception ex) { StaticLogger.LogError((object)("Failed to patch: " + ex)); } StaticLogger.LogInfo((object)"Loading MoreCompany..."); SteamFriends.OnGameLobbyJoinRequested += delegate(Lobby lobby, SteamId steamId) { newPlayerCount = ((Lobby)(ref lobby)).MaxMembers; }; SteamMatchmaking.OnLobbyEntered += delegate(Lobby lobby) { newPlayerCount = ((Lobby)(ref lobby)).MaxMembers; }; StaticLogger.LogInfo((object)"Loading SETTINGS..."); dynamicCosmeticsPath = Paths.PluginPath + "/MoreCompanyCosmetics"; if (cosmeticsPerProfile.Value) { cosmeticSavePath = Application.persistentDataPath + "/morecompanycosmetics-" + Directory.GetParent(Paths.BepInExRootPath).Name + ".txt"; } else { cosmeticSavePath = Application.persistentDataPath + "/morecompanycosmetics.txt"; } cosmeticsPerProfile.SettingChanged += delegate { if (cosmeticsPerProfile.Value) { cosmeticSavePath = Application.persistentDataPath + "/MCCosmeticsSave-" + Directory.GetParent(Paths.BepInExRootPath).Name + ".mcs"; } else { cosmeticSavePath = Application.persistentDataPath + "/MCCosmeticsSave.mcs"; } }; StaticLogger.LogInfo((object)("Checking: " + dynamicCosmeticsPath)); if (!Directory.Exists(dynamicCosmeticsPath)) { StaticLogger.LogInfo((object)"Creating cosmetics directory"); Directory.CreateDirectory(dynamicCosmeticsPath); } StaticLogger.LogInfo((object)"Loading COSMETICS..."); ReadCosmeticsFromFile(); if (defaultCosmetics.Value) { StaticLogger.LogInfo((object)"Loading DEFAULT COSMETICS..."); AssetBundle val2 = BundleUtilities.LoadBundleFromInternalAssembly("morecompany.cosmetics", Assembly.GetExecutingAssembly()); CosmeticRegistry.LoadCosmeticsFromBundle(val2, "morecompany.cosmetics"); val2.Unload(false); } StaticLogger.LogInfo((object)"Loading USER COSMETICS..."); RecursiveCosmeticLoad(Paths.PluginPath); AssetBundle bundle = BundleUtilities.LoadBundleFromInternalAssembly("morecompany.assets", Assembly.GetExecutingAssembly()); LoadAssets(bundle); StaticLogger.LogInfo((object)"Loaded MoreCompany FULLY"); } private void RecursiveCosmeticLoad(string directory) { string[] directories = Directory.GetDirectories(directory); foreach (string directory2 in directories) { RecursiveCosmeticLoad(directory2); } string[] files = Directory.GetFiles(directory); foreach (string text in files) { if (text.EndsWith(".cosmetics")) { AssetBundle val = AssetBundle.LoadFromFile(text); CosmeticRegistry.LoadCosmeticsFromBundle(val, text); val.Unload(false); } } } private void ReadCosmeticsFromFile() { if (File.Exists(cosmeticSavePath)) { string[] array = File.ReadAllLines(cosmeticSavePath); string[] array2 = array; foreach (string item in array2) { CosmeticRegistry.locallySelectedCosmetics.Add(item); } } } public static void WriteCosmeticsToFile() { string text = ""; foreach (string locallySelectedCosmetic in CosmeticRegistry.locallySelectedCosmetics) { text = text + locallySelectedCosmetic + "\n"; } File.WriteAllText(cosmeticSavePath, text); } private static void LoadAssets(AssetBundle bundle) { if (Object.op_Implicit((Object)(object)bundle)) { mainLogo = bundle.LoadPersistentAsset<Texture2D>("assets/morecompanyassets/morecompanytransparentred.png"); quickMenuScrollParent = bundle.LoadPersistentAsset<GameObject>("assets/morecompanyassets/quickmenuoverride.prefab"); playerEntry = bundle.LoadPersistentAsset<GameObject>("assets/morecompanyassets/playerlistslot.prefab"); cosmeticGUIInstance = bundle.LoadPersistentAsset<GameObject>("assets/morecompanyassets/testoverlay.prefab"); cosmeticButton = bundle.LoadPersistentAsset<GameObject>("assets/morecompanyassets/cosmeticinstance.prefab"); crewCountUI = bundle.LoadPersistentAsset<GameObject>("assets/morecompanyassets/crewcountfield.prefab"); bundle.Unload(false); } } public static void ResizePlayerCache(Dictionary<uint, Dictionary<int, NetworkObject>> ScenePlacedObjects) { //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Expected O, but got Unknown //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Expected O, but got Unknown StartOfRound instance = StartOfRound.Instance; if (instance.allPlayerObjects.Length != newPlayerCount) { int num = instance.allPlayerObjects.Length; int num2 = newPlayerCount - num; StaticLogger.LogInfo((object)$"Resizing arrays from {num} to {newPlayerCount} with difference of {num2}"); Array.Resize(ref instance.allPlayerObjects, newPlayerCount); Array.Resize(ref instance.allPlayerScripts, newPlayerCount); Array.Resize(ref instance.gameStats.allPlayerStats, newPlayerCount); Array.Resize(ref instance.playerSpawnPositions, newPlayerCount); if (num2 > 0) { GameObject val = instance.allPlayerObjects[num - 1]; uint num3 = 10001u; for (int i = 0; i < num2; i++) { GameObject val2 = Object.Instantiate<GameObject>(val, val.transform.parent); ((Object)val2).name = $"Player ({num + i})"; NetworkObject[] componentsInChildren = val2.GetComponentsInChildren<NetworkObject>(); foreach (NetworkObject val3 in componentsInChildren) { ReflectionUtils.SetFieldValue(val3, "GlobalObjectIdHash", num3); Scene scene = ((Component)val3).gameObject.scene; int handle = ((Scene)(ref scene)).handle; if (!ScenePlacedObjects.ContainsKey(num3)) { ScenePlacedObjects.Add(num3, new Dictionary<int, NetworkObject>()); } if (ScenePlacedObjects[num3].ContainsKey(handle)) { string arg = (((Object)(object)ScenePlacedObjects[num3][handle] != (Object)null) ? ((Object)ScenePlacedObjects[num3][handle]).name : "Null Entry"); throw new Exception($"{((Object)val3).name} tried to registered with ScenePlacedObjects which already contains the same GlobalObjectIdHash value {num3} for {arg}!"); } ScenePlacedObjects[num3].Add(handle, val3); num3++; } PlayerControllerB componentInChildren = val2.GetComponentInChildren<PlayerControllerB>(); componentInChildren.playerClientId = (ulong)(num + i); componentInChildren.playerUsername = $"Player #{componentInChildren.playerClientId}"; componentInChildren.isPlayerControlled = false; componentInChildren.isPlayerDead = false; componentInChildren.DropAllHeldItems(false, false, false, false, default(Vector3), default(Vector3), default(Vector3), default(Vector3), default(Vector3)); componentInChildren.TeleportPlayer(instance.notSpawnedPosition.position, false, 0f, false, true); instance.allPlayerObjects[num + i] = val2; instance.gameStats.allPlayerStats[num + i] = new PlayerStats(); instance.allPlayerScripts[num + i] = componentInChildren; instance.playerSpawnPositions[num + i] = instance.playerSpawnPositions[3]; StartOfRound.Instance.mapScreen.radarTargets.Add(new TransformAndName(((Component)componentInChildren).transform, componentInChildren.playerUsername, false)); } } } PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val4 in allPlayerScripts) { ((TMP_Text)val4.usernameBillboardText).text = val4.playerUsername; } } } [HarmonyPatch(typeof(PlayerControllerB), "Start")] public static class PlayerControllerBStartPatch { public static void Postfix(ref PlayerControllerB __instance) { Collider[] value = (Collider[])(object)new Collider[MainClass.newPlayerCount]; ReflectionUtils.SetFieldValue(__instance, "nearByPlayers", value); } } [HarmonyPatch(typeof(PlayerControllerB), "SendNewPlayerValuesServerRpc")] public static class SendNewPlayerValuesServerRpcPatch { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(); bool flag = false; bool flag2 = false; foreach (CodeInstruction instruction in instructions) { if (!flag2) { if (!flag && ((object)instruction).ToString() == "callvirt virtual void System.Collections.Generic.List<ulong>::Add(ulong item)") { 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)"SendNewPlayerValuesServerRpcPatch failed to replace newPlayerCount"); } return list.AsEnumerable(); } } [HarmonyPatch(typeof(HUDManager), "SyncAllPlayerLevelsServerRpc", new Type[] { })] public static class SyncAllPlayerLevelsPatch { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(); 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 != 2) { MainClass.StaticLogger.LogWarning((object)$"SyncAllPlayerLevelsPatch failed to replace newPlayerCount: {num}/2"); } return list.AsEnumerable(); } } [HarmonyPatch] public static class SyncShipUnlockablesPatch { [HarmonyPatch(typeof(StartOfRound), "SyncShipUnlockablesServerRpc")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> ServerTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(); bool flag = false; int num = 0; foreach (CodeInstruction instruction in instructions) { if (num != 2) { if (!flag && ((object)instruction).ToString() == "callvirt bool Unity.Netcode.NetworkManager::get_IsHost()") { flag = true; } else if (((object)instruction).ToString().StartsWith("ldc.i4.4 NULL")) { num++; CodeInstruction val = new CodeInstruction(instruction); val.opcode = OpCodes.Ldsfld; val.operand = AccessTools.Field(typeof(MainClass), "newPlayerCount"); list.Add(val); continue; } } list.Add(instruction); } if (num != 2) { MainClass.StaticLogger.LogWarning((object)$"SyncShipUnlockablesServerRpc failed to replace newPlayerCount: {num}/2"); } return list.AsEnumerable(); } [HarmonyPatch(typeof(StartOfRound), "SyncShipUnlockablesClientRpc")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> ClientTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(); bool flag = false; bool flag2 = false; foreach (CodeInstruction instruction in instructions) { if (!flag2) { if (!flag && ((object)instruction).ToString() == "callvirt void UnityEngine.Renderer::set_sharedMaterial(UnityEngine.Material value)") { 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)"SyncShipUnlockablesClientRpc failed to replace newPlayerCount"); } return list.AsEnumerable(); } } [HarmonyPatch(typeof(NetworkSceneManager), "PopulateScenePlacedObjects")] public static class ScenePlacedObjectsInitPatch { public static void Postfix(ref Dictionary<uint, Dictionary<int, NetworkObject>> ___ScenePlacedObjects) { MainClass.ResizePlayerCache(___ScenePlacedObjects); } } [HarmonyPatch(typeof(GameNetworkManager), "LobbyDataIsJoinable")] public static class LobbyDataJoinablePatch { public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(); bool flag = false; bool flag2 = false; foreach (CodeInstruction instruction in instructions) { if (!flag2) { if (!flag && ((object)instruction).ToString() == "call int Steamworks.Data.Lobby::get_MemberCount()") { 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), "maxPlayerCount")); list.Add(item); continue; } } list.Add(instruction); } if (!flag2) { MainClass.StaticLogger.LogWarning((object)"LobbyDataIsJoinable failed to replace maxPlayerCount"); } return list.AsEnumerable(); } } [HarmonyPatch(typeof(SteamMatchmaking), "CreateLobbyAsync")] public static class LobbyThingPatch { public static void Prefix(ref int maxMembers) { maxMembers = MainClass.newPlayerCount; } } [HarmonyPatch(typeof(GameNetworkManager), "SetConnectionDataBeforeConnecting")] public static class ConnectionDataPatch { public static void Postfix(ref GameNetworkManager __instance) { string @string = Encoding.ASCII.GetString(NetworkManager.Singleton.NetworkConfig.ConnectionData); List<string> list = new List<string> { @string }; if (__instance.disableSteam) { list.Add($"maxslots:{MainClass.newPlayerCount}"); } else { list.Add("maxslots:-1"); } string s = string.Join(',', list); NetworkManager.Singleton.NetworkConfig.ConnectionData = Encoding.ASCII.GetBytes(s); } } [HarmonyPatch(typeof(GameNetworkManager), "ConnectionApproval")] public static class ConnectionApproval { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(); bool flag = false; bool flag2 = false; foreach (CodeInstruction instruction in instructions) { if (!flag2) { if (!flag && ((object)instruction).ToString() == "ldfld int GameNetworkManager::connectedPlayers") { 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)"ConnectionApproval failed to replace newPlayerCount"); } return list.AsEnumerable(); } private static void Postfix(ref GameNetworkManager __instance, ref ConnectionApprovalRequest request, ref ConnectionApprovalResponse response) { if (!response.Approved) { return; } string @string = Encoding.ASCII.GetString(request.Payload); string[] source = @string.Split(","); int num = 4; if (!string.IsNullOrEmpty(@string)) { if (__instance.disableSteam) { if (source.Any((string x) => Regex.IsMatch(x, "^maxslots:\\d+$"))) { string text = source.First((string x) => Regex.IsMatch(x, "^maxslots:\\d+$")); int num2 = int.Parse(text.Substring(9)); num = num2; } } else if (source.Contains("maxslots:-1")) { num = MainClass.newPlayerCount; } } if (response.Approved && MainClass.newPlayerCount > 4 && MainClass.newPlayerCount != num) { response.Reason = $"Crew size mismatch! Their size: {MainClass.newPlayerCount}. Your size: {num}"; response.Approved = false; } } } [HarmonyPatch] public static class TogglePlayerObjectsPatch { [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] [HarmonyPrefix] private static void ConnectClientToPlayerObject() { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (val.isPlayerControlled || val.isPlayerDead) { ((Component)val).gameObject.SetActive(true); } else { ((Component)val).gameObject.SetActive(false); } } } [HarmonyPatch(typeof(StartOfRound), "OnPlayerConnectedClientRpc")] [HarmonyPrefix] private static void OnPlayerConnectedClientRpc(StartOfRound __instance, ulong clientId, int connectedPlayers, ulong[] connectedPlayerIdsOrdered, int assignedPlayerObjectId, int serverMoneyAmount, int levelID, int profitQuota, int timeUntilDeadline, int quotaFulfilled, int randomSeed, bool isChallenge) { ((Component)__instance.allPlayerScripts[assignedPlayerObjectId]).gameObject.SetActive(true); SoundManager.Instance.playerVoiceVolumes[assignedPlayerObjectId] = 0.5f; } [HarmonyPatch(typeof(StartOfRound), "OnPlayerDC")] [HarmonyPostfix] private static void OnPlayerDC(StartOfRound __instance, int playerObjectNumber, ulong clientId) { ((Component)__instance.allPlayerScripts[playerObjectNumber]).gameObject.SetActive(false); } [HarmonyPatch(typeof(HUDManager), "UpdateWeightCounter")] [HarmonyPrefix] private static bool UpdateWeightCounter() { return (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null; } [HarmonyPatch(typeof(StartOfRound), "KickPlayer")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> KickPlayer_Reason(IEnumerable<CodeInstruction> instructions) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(); bool flag = false; bool flag2 = false; foreach (CodeInstruction instruction in instructions) { if (!flag2) { if (!flag && instruction.opcode == OpCodes.Ldfld && instruction.operand?.ToString() == "System.UInt64 actualClientId") { flag = true; list.Add(instruction); CodeInstruction item = new CodeInstruction(OpCodes.Ldstr, (object)"You have been kicked."); list.Add(item); continue; } if (flag && instruction.opcode == OpCodes.Callvirt && instruction.operand?.ToString() == "Void DisconnectClient(UInt64)") { flag2 = true; instruction.operand = AccessTools.Method(typeof(NetworkManager), "DisconnectClient", new Type[2] { typeof(ulong), typeof(string) }, (Type[])null); } } list.Add(instruction); } if (!flag2) { MainClass.StaticLogger.LogWarning((object)"KickPlayer failed to append reason"); return instructions.AsEnumerable(); } return list.AsEnumerable(); } } public class ReflectionUtils { public static void InvokeMethod(object obj, string methodName, object[] parameters) { Type type = obj.GetType(); MethodInfo method = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); method.Invoke(obj, parameters); } public static void InvokeMethod(object obj, Type forceType, string methodName, object[] parameters) { MethodInfo method = forceType.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); method.Invoke(obj, parameters); } public static void SetPropertyValue(object obj, string propertyName, object value) { Type type = obj.GetType(); PropertyInfo property = type.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); property.SetValue(obj, value); } public static T InvokeMethod<T>(object obj, string methodName, object[] parameters) { Type type = obj.GetType(); MethodInfo method = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); return (T)method.Invoke(obj, parameters); } public static T GetFieldValue<T>(object obj, string fieldName) { Type type = obj.GetType(); FieldInfo field = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); return (T)field.GetValue(obj); } public static void SetFieldValue(object obj, string fieldName, object value) { Type type = obj.GetType(); FieldInfo field = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); field.SetValue(obj, value); } } [HarmonyPatch(typeof(ShipTeleporter), "Awake")] public static class ShipTeleporterAwakePatch { public static void Postfix(ref ShipTeleporter __instance) { int[] array = new int[MainClass.newPlayerCount]; for (int i = 0; i < MainClass.newPlayerCount; i++) { array[i] = -1; } ReflectionUtils.SetFieldValue(__instance, "playersBeingTeleported", array); } } [HarmonyPatch] public static class SoundManagerPatch { internal const float defaultPlayerVolume = 0.5f; internal static bool initialVolumeSet; [HarmonyPatch(typeof(SoundManager), "Start")] [HarmonyPostfix] public static void SM_Start(ref SoundManager __instance) { initialVolumeSet = false; float num = 16f; __instance.diageticMixer.SetFloat("PlayerVolume0", num); __instance.diageticMixer.SetFloat("PlayerVolume1", num); __instance.diageticMixer.SetFloat("PlayerVolume2", num); __instance.diageticMixer.SetFloat("PlayerVolume3", num); initialVolumeSet = true; Array.Resize(ref __instance.playerVoicePitchLerpSpeed, MainClass.newPlayerCount); Array.Resize(ref __instance.playerVoicePitchTargets, MainClass.newPlayerCount); Array.Resize(ref __instance.playerVoicePitches, MainClass.newPlayerCount); Array.Resize(ref __instance.playerVoiceVolumes, MainClass.newPlayerCount); Array.Resize(ref __instance.playerVoiceMixers, MainClass.newPlayerCount); AudioMixerGroup val = ((IEnumerable<AudioMixerGroup>)Resources.FindObjectsOfTypeAll<AudioMixerGroup>()).FirstOrDefault((Func<AudioMixerGroup, bool>)((AudioMixerGroup x) => ((Object)x).name.StartsWith("VoicePlayer"))); for (int i = 0; i < MainClass.newPlayerCount; i++) { __instance.playerVoicePitchLerpSpeed[i] = 3f; __instance.playerVoicePitchTargets[i] = 1f; __instance.playerVoicePitches[i] = 1f; __instance.playerVoiceVolumes[i] = 0.5f; if (!Object.op_Implicit((Object)(object)__instance.playerVoiceMixers[i])) { __instance.playerVoiceMixers[i] = val; } } } } [HarmonyPatch(typeof(StartOfRound), "GetPlayerSpawnPosition")] public static class SpawnPositionClampPatch { public static void Prefix(ref StartOfRound __instance, ref int playerNum, bool simpleTeleport = false) { if (!Object.op_Implicit((Object)(object)__instance.playerSpawnPositions[playerNum])) { playerNum = __instance.playerSpawnPositions.Length - 1; } } } [HarmonyPatch(typeof(StartOfRound), "OnClientConnect")] public static class OnClientConnectedPatch { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(); bool flag = false; bool flag2 = false; foreach (CodeInstruction instruction in instructions) { if (!flag2) { if (!flag && ((object)instruction).ToString() == "callvirt virtual bool System.Collections.Generic.List<int>::Contains(int item)") { 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)"OnClientConnect failed to replace newPlayerCount"); } return list.AsEnumerable(); } } [HarmonyPatch(typeof(StartOfRound), "OnPlayerDC")] public static class OnPlayerDCPatch { public static void Postfix(int playerObjectNumber, ulong clientId) { if (MainClass.playerIdsAndCosmetics.ContainsKey(playerObjectNumber)) { MainClass.playerIdsAndCosmetics.Remove(playerObjectNumber); } } } [HarmonyPatch(typeof(GameNetworkManager), "Awake")] public static class GameNetworkAwakePatch { public static int originalVersion; public static void Postfix(GameNetworkManager __instance) { originalVersion = __instance.gameVersionNum; if (!Chainloader.PluginInfos.ContainsKey("LC_API")) { __instance.gameVersionNum = 9950 + originalVersion; } } } [HarmonyPatch(typeof(MenuManager), "Awake")] public static class MenuManagerVersionDisplayPatch { public static void Postfix(MenuManager __instance) { if (!__instance.isInitScene && (Object)(object)__instance.versionNumberText != (Object)null) { ((TMP_Text)__instance.versionNumberText).text = $"{((TMP_Text)__instance.versionNumberText).text.Replace($"v{9950 + GameNetworkAwakePatch.originalVersion}", $"v{GameNetworkAwakePatch.originalVersion}")} (MC)"; } } } [HarmonyPatch(typeof(SteamLobbyManager), "loadLobbyListAndFilter")] public static class LoadLobbyListAndFilterPatch { [CompilerGenerated] private sealed class <Postfix>d__0 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator result; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Postfix>d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; break; } if (result.MoveNext()) { <>2__current = result.Current; <>1__state = 1; return true; } LobbySlot[] array = Object.FindObjectsOfType<LobbySlot>(); LobbySlot[] array2 = array; foreach (LobbySlot val in array2) { ((TMP_Text)val.playerCount).text = $"{((Lobby)(ref val.thisLobby)).MemberCount} / {((Lobby)(ref val.thisLobby)).MaxMembers}"; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [IteratorStateMachine(typeof(<Postfix>d__0))] public static IEnumerator Postfix(IEnumerator result) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Postfix>d__0(0) { result = result }; } } } namespace MoreCompany.Utils { public class BundleUtilities { public static byte[] GetResourceBytes(string filename, Assembly assembly) { string[] manifestResourceNames = assembly.GetManifestResourceNames(); foreach (string text in manifestResourceNames) { if (!text.Contains(filename)) { continue; } using Stream stream = assembly.GetManifestResourceStream(text); if (stream == null) { return null; } byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); return array; } return null; } public static AssetBundle LoadBundleFromInternalAssembly(string filename, Assembly assembly) { return AssetBundle.LoadFromMemory(GetResourceBytes(filename, assembly)); } } public static class AssetBundleExtension { public static T LoadPersistentAsset<T>(this AssetBundle bundle, string name) where T : Object { Object val = bundle.LoadAsset(name); if (val != (Object)null) { val.hideFlags = (HideFlags)32; return (T)(object)val; } return default(T); } } } namespace MoreCompany.Cosmetics { public enum ParentType { Player, DeadBody, MaskedEnemy, DisplayGuy } public class CosmeticApplication : MonoBehaviour { public bool detachedHead; public ParentType parentType; public Transform head; public Transform hip; public Transform lowerArmRight; public Transform shinLeft; public Transform shinRight; public Transform chest; public List<CosmeticInstance> spawnedCosmetics = new List<CosmeticInstance>(); public List<string> spawnedCosmeticsIds = new List<string>(); public void Awake() { Transform val = ((Component)this).transform.Find("spine") ?? ((Component)this).transform; chest = val.Find("spine.001").Find("spine.002").Find("spine.003"); head = chest.Find("spine.004"); lowerArmRight = chest.Find("shoulder.R").Find("arm.R_upper").Find("arm.R_lower"); hip = val; shinLeft = val.Find("thigh.L").Find("shin.L"); shinRight = val.Find("thigh.R").Find("shin.R"); if (parentType == ParentType.DisplayGuy) { CosmeticRegistry.UpdateCosmeticsOnDisplayGuy(startEnabled: false); } RefreshAllCosmeticPositions(); } private void OnDisable() { foreach (CosmeticInstance spawnedCosmetic in spawnedCosmetics) { if (Object.op_Implicit((Object)(object)spawnedCosmetic)) { ((Component)spawnedCosmetic).gameObject.SetActive(false); } } } private void OnEnable() { if (spawnedCosmetics.Count <= 0) { return; } if (parentType == ParentType.Player) { PlayerControllerB componentInParent = ((Component)((Component)this).transform).GetComponentInParent<PlayerControllerB>(); UpdateAllCosmeticVisibilities((Object)(object)componentInParent != (Object)null && (int)componentInParent.playerClientId == StartOfRound.Instance.thisClientPlayerId); } else if (parentType == ParentType.MaskedEnemy) { UpdateAllCosmeticVisibilities(); MaskedPlayerEnemy componentInParent2 = ((Component)((Component)this).transform).GetComponentInParent<MaskedPlayerEnemy>(); if ((Object)(object)componentInParent2 != (Object)null) { ((EnemyAI)componentInParent2).skinnedMeshRenderers = ((Component)componentInParent2).gameObject.GetComponentsInChildren<SkinnedMeshRenderer>(); ((EnemyAI)componentInParent2).meshRenderers = ((Component)componentInParent2).gameObject.GetComponentsInChildren<MeshRenderer>(); } } else { UpdateAllCosmeticVisibilities(); } } public void ClearCosmetics() { foreach (CosmeticInstance spawnedCosmetic in spawnedCosmetics) { if (Object.op_Implicit((Object)(object)spawnedCosmetic)) { Object.Destroy((Object)(object)((Component)spawnedCosmetic).gameObject); } } spawnedCosmetics.Clear(); spawnedCosmeticsIds.Clear(); } public bool ApplyCosmetic(string cosmeticId, bool startEnabled) { if (CosmeticRegistry.cosmeticInstances.ContainsKey(cosmeticId) && !spawnedCosmeticsIds.Contains(cosmeticId)) { CosmeticInstance cosmeticInstance = CosmeticRegistry.cosmeticInstances[cosmeticId]; if (startEnabled && cosmeticInstance.cosmeticType == CosmeticType.HAT && detachedHead) { return false; } GameObject val = Object.Instantiate<GameObject>(((Component)cosmeticInstance).gameObject); val.SetActive(startEnabled); CosmeticInstance component = val.GetComponent<CosmeticInstance>(); spawnedCosmetics.Add(component); ParentCosmetic(component); spawnedCosmeticsIds.Add(cosmeticId); return true; } return false; } public void UpdateAllCosmeticVisibilities(bool isLocalPlayer = false) { bool active = false; if (parentType == ParentType.Player) { active = MainClass.cosmeticsSyncOther.Value && !isLocalPlayer; } else if (parentType == ParentType.DeadBody) { active = MainClass.cosmeticsDeadBodies.Value; } else if (parentType == ParentType.MaskedEnemy) { active = MainClass.cosmeticsMaskedEnemy.Value; } else if (parentType == ParentType.DisplayGuy) { active = true; } foreach (CosmeticInstance spawnedCosmetic in spawnedCosmetics) { if (Object.op_Implicit((Object)(object)spawnedCosmetic) && (spawnedCosmetic.cosmeticType != 0 || !detachedHead)) { ((Component)spawnedCosmetic).gameObject.SetActive(active); } } } public void RefreshAllCosmeticPositions() { foreach (CosmeticInstance spawnedCosmetic in spawnedCosmetics) { if (Object.op_Implicit((Object)(object)spawnedCosmetic)) { ParentCosmetic(spawnedCosmetic); } } } private bool ParentCosmetic(CosmeticInstance cosmeticInstance) { //IL_0098: 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) Transform val = null; switch (cosmeticInstance.cosmeticType) { case CosmeticType.HAT: val = head; break; case CosmeticType.R_LOWER_ARM: val = lowerArmRight; break; case CosmeticType.HIP: val = hip; break; case CosmeticType.L_SHIN: val = shinLeft; break; case CosmeticType.R_SHIN: val = shinRight; break; case CosmeticType.CHEST: val = chest; break; } if ((Object)(object)val == (Object)null) { MainClass.StaticLogger.LogError((object)("Failed to find transform of type: " + cosmeticInstance.cosmeticType)); return false; } ((Component)cosmeticInstance).transform.position = val.position; ((Component)cosmeticInstance).transform.rotation = val.rotation; ((Component)cosmeticInstance).transform.parent = val; return true; } } public class CosmeticInstance : MonoBehaviour { public CosmeticType cosmeticType; public string cosmeticId; public Texture2D icon; } public class CosmeticGeneric { public virtual string gameObjectPath { get; } public virtual string cosmeticId { get; } public virtual string textureIconPath { get; } public CosmeticType cosmeticType { get; } public void LoadFromBundle(AssetBundle bundle) { GameObject val = bundle.LoadPersistentAsset<GameObject>(gameObjectPath); Texture2D icon = bundle.LoadPersistentAsset<Texture2D>(textureIconPath); CosmeticInstance cosmeticInstance = val.AddComponent<CosmeticInstance>(); cosmeticInstance.cosmeticId = cosmeticId; cosmeticInstance.icon = icon; cosmeticInstance.cosmeticType = cosmeticType; MainClass.StaticLogger.LogInfo((object)("Loaded cosmetic: " + cosmeticId + " from bundle: " + ((Object)bundle).name)); CosmeticRegistry.cosmeticInstances.Add(cosmeticId, cosmeticInstance); } } public enum CosmeticType { HAT, WRIST, CHEST, R_LOWER_ARM, HIP, L_SHIN, R_SHIN } public class CosmeticRegistry { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__10_0; public static UnityAction <>9__10_1; public static Func<string, bool> <>9__16_0; internal void <SpawnCosmeticGUI>b__10_0() { MainClass.cosmeticsSyncOther.Value = true; MainClass.StaticConfig.Save(); } internal void <SpawnCosmeticGUI>b__10_1() { MainClass.cosmeticsSyncOther.Value = false; MainClass.StaticConfig.Save(); } internal bool <GetCosmeticsToSync>b__16_0(string x) { return cosmeticInstances.ContainsKey(x); } } public static Dictionary<string, CosmeticInstance> cosmeticInstances = new Dictionary<string, CosmeticInstance>(); public static Transform cosmeticGUIGlobalScale; private static GameObject displayGuy; internal static CosmeticApplication displayGuyCosmeticApplication; public static List<string> locallySelectedCosmetics = new List<string>(); public static bool menuIsInGame = false; public const float COSMETIC_PLAYER_SCALE_MULT = 0.38f; public static void LoadCosmeticsFromBundle(AssetBundle bundle, string bundleName = null) { string[] allAssetNames = bundle.GetAllAssetNames(); foreach (string text in allAssetNames) { if (!text.EndsWith(".prefab")) { continue; } GameObject val = bundle.LoadPersistentAsset<GameObject>(text); CosmeticInstance component = val.GetComponent<CosmeticInstance>(); if (!((Object)(object)component == (Object)null)) { if (MainClass.disabledCosmetics.Value.Split(',').Contains(component.cosmeticId)) { MainClass.StaticLogger.LogInfo((object)("Skipped cosmetic: " + component.cosmeticId + ", bundle: " + bundleName + ", reason: disabled")); } else if (cosmeticInstances.ContainsKey(component.cosmeticId)) { MainClass.StaticLogger.LogWarning((object)("Skipped cosmetic: " + component.cosmeticId + ", bundle: " + bundleName + ", reason: duplicate id")); } else { MainClass.StaticLogger.LogInfo((object)("Loaded cosmetic: " + component.cosmeticId + " from bundle: " + bundleName)); cosmeticInstances.Add(component.cosmeticId, component); } } } } public static void LoadCosmeticsFromAssembly(Assembly assembly, AssetBundle bundle) { Type[] types = assembly.GetTypes(); foreach (Type type in types) { if (type.IsSubclassOf(typeof(CosmeticGeneric))) { CosmeticGeneric cosmeticGeneric = (CosmeticGeneric)type.GetConstructor(new Type[0]).Invoke(new object[0]); cosmeticGeneric.LoadFromBundle(bundle); } } } public static void UpdateVisibilityCheckbox(GameObject enableCosmeticsButton, GameObject disableCosmeticsButton) { if (MainClass.cosmeticsSyncOther.Value) { enableCosmeticsButton.SetActive(false); disableCosmeticsButton.SetActive(true); } else { enableCosmeticsButton.SetActive(true); disableCosmeticsButton.SetActive(false); } } public static void SpawnCosmeticGUI(bool mainMenu) { //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Expected O, but got Unknown //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Expected O, but got Unknown if (cosmeticInstances.Count == 0) { return; } menuIsInGame = !mainMenu; GameObject val = Object.Instantiate<GameObject>(MainClass.cosmeticGUIInstance); cosmeticGUIGlobalScale = val.transform.Find("Canvas").Find("GlobalScale"); if (menuIsInGame) { ((Component)cosmeticGUIGlobalScale).transform.parent = GameObject.Find("Systems/UI/Canvas/").transform; ((Component)cosmeticGUIGlobalScale).transform.localPosition = new Vector3(0f, 0f, 0f); ((Component)cosmeticGUIGlobalScale).transform.localScale = new Vector3(0.9f, 0.9f,