Please disclose if any significant portion of your mod was created 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 LethalPlayers v0.5.75
LethalPlayers.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using GameNetcodeStuff; using HarmonyLib; using LC_API.BundleAPI; using LC_API.ServerAPI; using LethalPlayers.Patches; using Steamworks; using Steamworks.Data; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.Audio; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")] [assembly: AssemblyCompany("LethalPlayers")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Increase the max players in Lethal Company")] [assembly: AssemblyFileVersion("1.0.5.0")] [assembly: AssemblyInformationalVersion("1.0.5")] [assembly: AssemblyProduct("LethalPlayers")] [assembly: AssemblyTitle("LethalPlayers")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.5.0")] [module: UnverifiableCode] namespace LethalPlayers { public static class Helper { public static T[] ResizeArray<T>(T[] oldArray, int newSize) { T[] array = new T[newSize]; oldArray.CopyTo(array, 0); return array; } public static void ResizeList<T>(this List<T> list, int size, T element = default(T)) { int count = list.Count; if (size < count) { list.RemoveRange(size, count - size); } else if (size > count) { if (size > list.Capacity) { list.Capacity = size; } list.AddRange(Enumerable.Repeat(element, size - count)); } } } [BepInPlugin("LethalPlayers", "LethalPlayers", "1.0.5")] public class Plugin : BaseUnityPlugin { public static bool oldhastime; public static int MaxPlayers = 32; public static bool instantiating; public static NetworkObject[] PlayerObjects = (NetworkObject[])(object)new NetworkObject[0]; public static Harmony _harmony; public static Harmony _harmony2; private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown _harmony = new Harmony("LethalPlayers"); _harmony2 = new Harmony("LethalPlayersA"); _harmony.PatchAll(typeof(NonGamePatches)); _harmony.PatchAll(typeof(NonGamePatches.InternalPatch2)); _harmony.PatchAll(typeof(NonGamePatches.InternalPatches)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"LethalPlayers loaded"); BundleLoader.OnLoadedAssets = (OnLoadedAssetsDelegate)Delegate.Combine((Delegate?)(object)BundleLoader.OnLoadedAssets, (Delegate?)new OnLoadedAssetsDelegate(OnLoaded)); } private void OnLoaded() { AudioMixer loadedAsset = BundleLoader.GetLoadedAsset<AudioMixer>("assets/diagetic.mixer"); if (Object.op_Implicit((Object)(object)loadedAsset)) { } } private void OnDestroy() { ModdedServer.SetServerModdedOnly(); } } public static class PluginInfo { public const string PLUGIN_GUID = "LethalPlayers"; public const string PLUGIN_NAME = "LethalPlayers"; public const string PLUGIN_VERSION = "1.0.5"; } } namespace LethalPlayers.Patches { [HarmonyPatch(typeof(HUDManager))] internal class InternalPatch3 { private static MethodInfo TargetMethod() { return typeof(HUDManager).GetMethod("AddChatMessage", BindingFlags.Instance | BindingFlags.NonPublic); } [HarmonyPrefix] private static void Prefix(HUDManager __instance, string chatMessage, string nameOfUserWhoTyped = "") { if (!(__instance.lastChatMessage == chatMessage)) { __instance.lastChatMessage = chatMessage; __instance.PingHUDElement(__instance.Chat, 4f, 1f, 0.2f); if (__instance.ChatMessageHistory.Count >= 4) { ((TMP_Text)__instance.chatText).text.Remove(0, __instance.ChatMessageHistory[0].Length); __instance.ChatMessageHistory.Remove(__instance.ChatMessageHistory[0]); } StringBuilder stringBuilder = new StringBuilder(chatMessage); for (int i = 1; i < StartOfRound.Instance.allPlayerScripts.Length; i++) { stringBuilder.Replace("[playerNum" + i + "]", StartOfRound.Instance.allPlayerScripts[i].playerUsername); } stringBuilder.Replace("bizzlemip", "<color=#008282>bizzlemip</color>"); chatMessage = stringBuilder.ToString(); nameOfUserWhoTyped = nameOfUserWhoTyped.Replace("bizzlemip", "<color=#008282>bizzlemip</color>"); string item = ((!string.IsNullOrEmpty(nameOfUserWhoTyped)) ? ("<color=#FF0000>" + nameOfUserWhoTyped + "</color>: <color=#FFFF00>'" + chatMessage + "'</color>") : ("<color=#7069ff>" + chatMessage + "</color>")); __instance.ChatMessageHistory.Add(item); ((TMP_Text)__instance.chatText).text = ""; for (int j = 0; j < __instance.ChatMessageHistory.Count; j++) { TextMeshProUGUI chatText = __instance.chatText; ((TMP_Text)chatText).text = ((TMP_Text)chatText).text + "\n" + __instance.ChatMessageHistory[j]; } } } } [HarmonyPatch] public class ListSizeTranspilers { [HarmonyPatch(typeof(HUDManager), "SyncAllPlayerLevelsServerRpc")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> SyncLevelsRpc(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Newarr && list[i - 1].opcode == OpCodes.Ldc_I4_4) { list[i - 1].opcode = OpCodes.Ldc_I4_S; list[i - 1].operand = Plugin.MaxPlayers; } } return list.AsEnumerable(); } [HarmonyPatch(typeof(CrawlerAI), "Start")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> CrawlerAIPatch(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Newarr && list[i - 1].opcode == OpCodes.Ldc_I4_4) { list[i - 1].opcode = OpCodes.Ldc_I4_S; list[i - 1].operand = Plugin.MaxPlayers; } } return list.AsEnumerable(); } [HarmonyPatch(typeof(DressGirlAI), "ChoosePlayerToHaunt")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> DressPatch(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Newarr && list[i - 1].opcode == OpCodes.Ldc_I4_4) { list[i - 1].opcode = OpCodes.Ldc_I4_S; list[i - 1].operand = Plugin.MaxPlayers; } } return list.AsEnumerable(); } [HarmonyPatch(typeof(PlayerControllerB), "SendNewPlayerValuesServerRpc")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> SendNewPlayerValuesServerRpc(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Blt && list[i - 1].opcode == OpCodes.Ldc_I4_4) { list[i - 1].opcode = OpCodes.Ldc_I4_S; list[i - 1].operand = Plugin.MaxPlayers; break; } } return list.AsEnumerable(); } [HarmonyPatch(typeof(StartOfRound), "SyncShipUnlockablesClientRpc")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> SyncShipUnlockablesClientRpc(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Blt && list[i - 1].opcode == OpCodes.Ldc_I4_4) { list[i - 1].opcode = OpCodes.Ldc_I4_S; list[i - 1].operand = Plugin.MaxPlayers; break; } } return list.AsEnumerable(); } [HarmonyPatch(typeof(DressGirlAI), "ChoosePlayerToHaunt")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> ChoosePlayerToHaunt(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Blt && list[i - 1].opcode == OpCodes.Ldc_I4_4) { list[i - 1].opcode = OpCodes.Ldc_I4_S; list[i - 1].operand = Plugin.MaxPlayers; Debug.Log((object)"Dress AI Fix Applied"); } } return list.AsEnumerable(); } [HarmonyPatch(typeof(EnemyAI), "GetClosestPlayer")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> GetClosestPlayer(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Blt && list[i - 1].opcode == OpCodes.Ldc_I4_4) { list[i - 1].opcode = OpCodes.Ldc_I4_S; list[i - 1].operand = Plugin.MaxPlayers; Debug.Log((object)"Gen AI Fix Applied"); break; } } return list.AsEnumerable(); } [HarmonyPatch(typeof(SpringManAI), "Update")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> SUpdate(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Blt && list[i - 1].opcode == OpCodes.Ldc_I4_4 && list[i - 2].opcode == OpCodes.Ldloc_2) { list[i - 1].opcode = OpCodes.Ldc_I4_S; list[i - 1].operand = Plugin.MaxPlayers; Debug.Log((object)"Spring AI Fix 2 Applied"); break; } } return list.AsEnumerable(); } [HarmonyPatch(typeof(SpringManAI), "DoAIInterval")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> AIInterval(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Blt && list[i - 1].opcode == OpCodes.Ldc_I4_4) { list[i - 1].opcode = OpCodes.Ldc_I4_S; list[i - 1].operand = Plugin.MaxPlayers; Debug.Log((object)"Spring AI Fix Applied"); break; } } return list.AsEnumerable(); } [HarmonyPatch(typeof(StartOfRound), "SyncShipUnlockablesServerRpc")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> SyncShipUnlockablesServerRpc(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Ldc_I4_4) { list[i].opcode = OpCodes.Ldc_I4_S; list[i].operand = Plugin.MaxPlayers; } } return list.AsEnumerable(); } [HarmonyPatch(typeof(StartOfRound), "OnClientConnect")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> OnClientConnect(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Ldc_I4_4) { list[i].opcode = OpCodes.Ldc_I4_S; list[i].operand = Plugin.MaxPlayers; } } return list.AsEnumerable(); } [HarmonyPatch(typeof(HUDManager), "FillEndGameStats")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> FillEndGameStats(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Blt) { list[i].opcode = OpCodes.Bgt; } } return list.AsEnumerable(); } [HarmonyPatch(typeof(PlayerControllerB), "SpectateNextPlayer")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> SpectateNextPlayer(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Ldc_I4_4) { list[i].opcode = OpCodes.Ldc_I4_S; list[i].operand = Plugin.MaxPlayers; } } return list.AsEnumerable(); } } [HarmonyPatch] public class NonGamePatches { [HarmonyPatch(typeof(GameNetworkManager))] internal class InternalPatches { private static MethodInfo TargetMethod() { return typeof(GameNetworkManager).GetMethod("ConnectionApproval", BindingFlags.Instance | BindingFlags.NonPublic); } [HarmonyPrefix] private static bool PostFix(GameNetworkManager __instance, ConnectionApprovalRequest request, ConnectionApprovalResponse response) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) Debug.Log((object)("Connection approval callback! Game version of client request: " + Encoding.ASCII.GetString(request.Payload).ToString())); Debug.Log((object)$"Joining client id: {request.ClientNetworkId}; Local/host client id: {NetworkManager.Singleton.LocalClientId}"); if (request.ClientNetworkId == NetworkManager.Singleton.LocalClientId) { Debug.Log((object)"Stopped connection approval callback, as the client in question was the host!"); return false; } bool flag = !__instance.disallowConnection; if (flag) { string @string = Encoding.ASCII.GetString(request.Payload); string[] array = @string.Split(","); if (string.IsNullOrEmpty(@string)) { response.Reason = "Unknown; please verify your game files."; flag = false; } else if (__instance.gameHasStarted) { response.Reason = "Game has already started!"; flag = false; } else if (__instance.gameVersionNum.ToString() != array[0]) { response.Reason = $"Game version mismatch! Their version: {__instance.gameVersionNum}. Your version: {array[0]}"; flag = false; } else if (!__instance.disableSteam && ((Object)(object)StartOfRound.Instance == (Object)null || array.Length < 2 || StartOfRound.Instance.KickedClientIds.Contains((ulong)Convert.ToInt64(array[1])))) { response.Reason = "You cannot rejoin after being kicked."; flag = false; } } else { response.Reason = "The host was not accepting connections."; } Debug.Log((object)$"Approved connection?: {flag}. Connected players #: {__instance.connectedPlayers}"); Debug.Log((object)("Disapproval reason: " + response.Reason)); response.CreatePlayerObject = false; response.Approved = flag; response.Pending = false; return false; } } [HarmonyPatch(typeof(QuickMenuManager))] internal class InternalPatch2 { private static MethodInfo TargetMethod() { return typeof(QuickMenuManager).GetMethod("NonHostPlayerSlotsEnabled", BindingFlags.Instance | BindingFlags.NonPublic); } [HarmonyPrefix] private static bool PostFix(ref bool __result) { __result = false; return false; } } [HarmonyPatch(typeof(SoundManager), "SetPlayerVoiceFilters")] [HarmonyPrefix] public static bool SetPlayerVoiceFilters(ref SoundManager __instance) { for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++) { if (!StartOfRound.Instance.allPlayerScripts[i].isPlayerControlled && !StartOfRound.Instance.allPlayerScripts[i].isPlayerDead) { __instance.playerVoicePitches[i] = 1f; __instance.playerVoiceVolumes[i] = 1f; } else if (Mathf.Abs(__instance.playerVoicePitches[i] - __instance.playerVoicePitchTargets[i]) > 0.025f) { __instance.playerVoicePitches[i] = Mathf.Lerp(__instance.playerVoicePitches[i], __instance.playerVoicePitchTargets[i], 3f * Time.deltaTime); } else if (__instance.playerVoicePitches[i] != __instance.playerVoicePitchTargets[i]) { __instance.playerVoicePitches[i] = __instance.playerVoicePitchTargets[i]; } } return false; } [HarmonyPatch(typeof(MenuManager), "OnEnable")] [HarmonyPostfix] public static void CustomMenu(ref MenuManager __instance) { //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_020d: 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_022b: 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_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) if (!__instance.isInitScene) { GameObject gameObject = ((Component)__instance.HostSettingsOptionsNormal.transform.parent.parent).gameObject; Component component = gameObject.GetComponent(typeof(RectTransform)); RectTransform val = (RectTransform)(object)((component is RectTransform) ? component : null); GameObject gameObject2 = ((Component)gameObject.transform.Find("PrivatePublicDescription")).gameObject; Component component2 = gameObject2.GetComponent(typeof(RectTransform)); RectTransform val2 = (RectTransform)(object)((component2 is RectTransform) ? component2 : null); GameObject gameObject3 = ((Component)__instance.HostSettingsOptionsNormal.transform.Find("EnterAName")).gameObject; Component component3 = gameObject3.GetComponent(typeof(RectTransform)); RectTransform val3 = (RectTransform)(object)((component3 is RectTransform) ? component3 : null); GameObject gameObject4 = ((Component)__instance.HostSettingsOptionsNormal.transform.Find("ServerNameField")).gameObject; Component component4 = gameObject4.GetComponent(typeof(RectTransform)); RectTransform val4 = (RectTransform)(object)((component4 is RectTransform) ? component4 : null); GameObject gameObject5 = ((Component)gameObject.transform.Find("Confirm")).gameObject; Component component5 = gameObject5.GetComponent(typeof(RectTransform)); RectTransform val5 = (RectTransform)(object)((component5 is RectTransform) ? component5 : null); GameObject gameObject6 = ((Component)gameObject.transform.Find("Back")).gameObject; Component component6 = gameObject6.GetComponent(typeof(RectTransform)); RectTransform val6 = (RectTransform)(object)((component6 is RectTransform) ? component6 : null); GameObject gameObject7 = ((Component)__instance.HostSettingsOptionsNormal.transform.Find("Public")).gameObject; Component component7 = gameObject7.GetComponent(typeof(RectTransform)); RectTransform val7 = (RectTransform)(object)((component7 is RectTransform) ? component7 : null); GameObject gameObject8 = ((Component)__instance.HostSettingsOptionsNormal.transform.Find("Private")).gameObject; Component component8 = gameObject8.GetComponent(typeof(RectTransform)); RectTransform val8 = (RectTransform)(object)((component8 is RectTransform) ? component8 : null); GameObject val9 = Object.Instantiate<GameObject>(gameObject4, gameObject4.transform.parent); Component component9 = val9.GetComponent(typeof(RectTransform)); RectTransform val10 = (RectTransform)(object)((component9 is RectTransform) ? component9 : null); val.sizeDelta = new Vector2(val.sizeDelta.x, 200f); val2.anchoredPosition = new Vector2(val2.anchoredPosition.x, -50f); val3.anchoredPosition = new Vector2(val3.anchoredPosition.x, 40f); val4.anchoredPosition = new Vector2(val4.anchoredPosition.x, 55f); val5.anchoredPosition = new Vector2(val5.anchoredPosition.x, -60f); val6.anchoredPosition = new Vector2(val6.anchoredPosition.x, -85f); val7.anchoredPosition = new Vector2(val7.anchoredPosition.x, -23f); val8.anchoredPosition = new Vector2(val8.anchoredPosition.x, -23f); val10.anchoredPosition = new Vector2(val10.anchoredPosition.x, 21f); ((Object)val10).name = "ServerPlayersField"; ((Component)val10).GetComponent<TMP_InputField>().contentType = (ContentType)2; ((TMP_Text)((Component)((Component)val10).transform.Find("Text Area").Find("Placeholder")).gameObject.GetComponent<TextMeshProUGUI>()).text = "Max players..."; ((Component)val10).transform.parent = __instance.HostSettingsOptionsNormal.transform; } } [HarmonyPatch(typeof(MenuManager), "StartHosting")] [HarmonyPrefix] public static bool StartHost(MenuManager __instance) { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) if (!GameNetworkManager.Instance.currentLobby.HasValue) { return true; } GameObject gameObject = ((Component)__instance.HostSettingsOptionsNormal.transform.Find("ServerPlayersField")).gameObject; Debug.Log((object)gameObject); GameObject gameObject2 = ((Component)gameObject.transform.Find("Text Area").Find("Text")).gameObject; Debug.Log((object)gameObject2); TextMeshProUGUI component = gameObject2.GetComponent<TextMeshProUGUI>(); Debug.Log((object)component); string text = Regex.Replace(((TMP_Text)component).text, "[^0-9]", ""); Debug.Log((object)text); if (!int.TryParse(text, out var result)) { result = 20; } result = Math.Min(Math.Max(result, 4), 100); Debug.Log((object)result); Lobby valueOrDefault = GameNetworkManager.Instance.currentLobby.GetValueOrDefault(); ((Lobby)(ref valueOrDefault)).SetData("MaxPlayers", result.ToString()); Plugin.MaxPlayers = result; Debug.Log((object)"SetMax"); Debug.Log((object)result); return true; } [HarmonyPatch(typeof(GameNetworkManager), "StartHost")] [HarmonyPrefix] public static bool DoTheThe() { Plugin._harmony2.PatchAll(typeof(InternalPatch3)); Plugin._harmony2.PatchAll(typeof(ListSizeTranspilers)); Plugin._harmony2.PatchAll(typeof(PlayerObjects)); Debug.Log((object)"she worble on my sneebler till i sneefenschnorf?"); return true; } [HarmonyPatch(typeof(GameNetworkManager), "StartClient")] [HarmonyPrefix] public static bool StartClient() { Plugin._harmony2.PatchAll(typeof(InternalPatch3)); Plugin._harmony2.PatchAll(typeof(ListSizeTranspilers)); Plugin._harmony2.PatchAll(typeof(PlayerObjects)); Debug.Log((object)"glimbo on a wheezer till i ghripehndorf?"); return true; } [HarmonyPatch(typeof(MenuManager), "StartAClient")] [HarmonyPrefix] public static bool StartAClient() { Plugin._harmony2.PatchAll(typeof(InternalPatch3)); Plugin._harmony2.PatchAll(typeof(ListSizeTranspilers)); Plugin._harmony2.PatchAll(typeof(PlayerObjects)); Debug.Log((object)"glimbo on a wheezer till i ghripehndorf?"); return true; } [HarmonyPatch(typeof(SteamLobbyManager), "LoadServerList")] [HarmonyPrefix] public static async void LoadServerList(SteamLobbyManager __instance) { if (GameNetworkManager.Instance.waitingForLobbyDataRefresh) { return; } Debug.Log((object)typeof(SteamLobbyManager).GetField("refreshServerListTimer", BindingFlags.Instance | BindingFlags.NonPublic)); typeof(SteamLobbyManager).GetField("refreshServerListTimer", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, 0f); ((TMP_Text)__instance.serverListBlankText).text = "Loading server list..."; FieldInfo LL = typeof(SteamLobbyManager).GetField("currentLobbyList", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo LP = typeof(SteamLobbyManager).GetField("lobbySlotPositionOffset", BindingFlags.Instance | BindingFlags.NonPublic); LL.SetValue(__instance, null); LobbySlot[] array = Object.FindObjectsOfType<LobbySlot>(); for (int i = 0; i < array.Length; i++) { Object.Destroy((Object)(object)((Component)array[i]).gameObject); } LobbyQuery val; switch (__instance.sortByDistanceSetting) { case 0: val = SteamMatchmaking.LobbyList; ((LobbyQuery)(ref val)).FilterDistanceClose(); break; case 1: val = SteamMatchmaking.LobbyList; ((LobbyQuery)(ref val)).FilterDistanceFar(); break; case 2: val = SteamMatchmaking.LobbyList; ((LobbyQuery)(ref val)).FilterDistanceWorldwide(); break; } GameNetworkManager.Instance.waitingForLobbyDataRefresh = true; val = SteamMatchmaking.LobbyList; val = ((LobbyQuery)(ref val)).WithSlotsAvailable(1); val = ((LobbyQuery)(ref val)).WithKeyValue("vers", GameNetworkManager.Instance.gameVersionNum.ToString()); Lobby[] results = await ((LobbyQuery)(ref val)).RequestAsync(); Debug.Log((object)results); LL.SetValue(__instance, results); GameNetworkManager.Instance.waitingForLobbyDataRefresh = false; if (LL.GetValue(__instance) != null) { if ((LL.GetValue(__instance) as Array).Length == 0) { ((TMP_Text)__instance.serverListBlankText).text = "No available servers to join.\n\n\nBizzlemip wuz here :3"; } else { ((TMP_Text)__instance.serverListBlankText).text = ""; } LP.SetValue(__instance, 0f); for (int j = 0; j < (LL.GetValue(__instance) as Lobby[]).Length; j++) { GameObject obj = Object.Instantiate<GameObject>(__instance.LobbySlotPrefab, __instance.levelListContainer); obj.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, (float)LP.GetValue(__instance)); LP.SetValue(__instance, (float)LP.GetValue(__instance) - 42f); LobbySlot componentInChildren = obj.GetComponentInChildren<LobbySlot>(); ((TMP_Text)componentInChildren.LobbyName).text = ((Lobby)(ref (LL.GetValue(__instance) as Lobby[])[j])).GetData("name"); string text = ((Lobby)(ref (LL.GetValue(__instance) as Lobby[])[j])).GetData("MaxPlayers"); Debug.Log((object)text); if (!int.TryParse(text, out var number)) { number = 4; } number = Math.Min(Math.Max(number, 4), 100); ((TMP_Text)componentInChildren.playerCount).text = $"{((Lobby)(ref (LL.GetValue(__instance) as Lobby[])[j])).MemberCount} / " + number; componentInChildren.lobbyId = ((Lobby)(ref (LL.GetValue(__instance) as Lobby[])[j])).Id; componentInChildren.thisLobby = (LL.GetValue(__instance) as Lobby[])[j]; } } else { ((TMP_Text)__instance.serverListBlankText).text = "No available servers to join.\n\n\nBizzlemip wuz here :3"; } } [HarmonyPatch(typeof(SteamMatchmaking), "CreateLobbyAsync")] [HarmonyPrefix] public static void SetMaxMembers(ref int maxMembers) { maxMembers = Plugin.MaxPlayers; } [HarmonyPatch(typeof(Lobby), "Leave")] [HarmonyPostfix] public static void LeaveLobby() { Plugin._harmony2.UnpatchSelf(); } [HarmonyPatch(typeof(GameNetworkManager), "LobbyDataIsJoinable")] [HarmonyPrefix] public static bool SkipLobbySizeCheck(ref GameNetworkManager __instance, ref bool __result, Lobby lobby) { //IL_006e: 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) string data = ((Lobby)(ref lobby)).GetData("vers"); string data2 = ((Lobby)(ref lobby)).GetData("MaxPlayers"); if (!Utility.IsNullOrWhiteSpace(data2) || !int.TryParse(data2, out var result)) { result = 20; } result = Math.Min(Math.Max(result, 4), 100); if (((Lobby)(ref lobby)).MemberCount >= result || ((Lobby)(ref lobby)).MemberCount < 1) { Debug.Log((object)$"Lobby join denied! Too many members in lobby! {((Lobby)(ref lobby)).Id}"); Object.FindObjectOfType<MenuManager>().SetLoadingScreen(false, (RoomEnter)4, "The server is full!"); return false; } if (data != __instance.gameVersionNum.ToString()) { Debug.Log((object)$"Lobby join denied! Attempted to join vers.{data} lobby id: {((Lobby)(ref lobby)).Id}"); Object.FindObjectOfType<MenuManager>().SetLoadingScreen(false, (RoomEnter)2, $"The server host is playing on version {data} while you are on version {__instance.gameVersionNum}."); __result = false; return false; } if (((Lobby)(ref lobby)).GetData("joinable") == "false") { Debug.Log((object)"Lobby join denied! Host lobby is not joinable"); Object.FindObjectOfType<MenuManager>().SetLoadingScreen(false, (RoomEnter)2, "The server host has already landed their ship, or they are still loading in."); __result = false; return false; } Debug.Log((object)"AEAELOGGINGNUMBER"); Debug.Log((object)result); Plugin.MaxPlayers = result; __result = true; return false; } } [HarmonyPatch] internal class PlayerObjects { private static StartOfRound startOfRound; private static bool instantiating; private static int nextClientId; private static PlayerControllerB referencePlayer; [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPrefix] public static void ResizeLists(ref StartOfRound __instance) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown __instance.allPlayerObjects = Helper.ResizeArray(__instance.allPlayerObjects, Plugin.MaxPlayers); __instance.allPlayerScripts = Helper.ResizeArray(__instance.allPlayerScripts, Plugin.MaxPlayers); __instance.gameStats.allPlayerStats = Helper.ResizeArray(__instance.gameStats.allPlayerStats, Plugin.MaxPlayers); __instance.playerSpawnPositions = Helper.ResizeArray(__instance.playerSpawnPositions, Plugin.MaxPlayers); for (int i = 4; i < Plugin.MaxPlayers; i++) { __instance.gameStats.allPlayerStats[i] = new PlayerStats(); __instance.playerSpawnPositions[i] = __instance.playerSpawnPositions[0]; } } [HarmonyPatch(typeof(ForestGiantAI), "Start")] [HarmonyPrefix] public static bool ResizeLists2(ref ForestGiantAI __instance) { __instance.playerStealthMeters = Helper.ResizeArray(__instance.playerStealthMeters, Plugin.MaxPlayers); return true; } [HarmonyPatch(typeof(HUDManager), "Awake")] [HarmonyPostfix] public static void ResizeLists2(ref HUDManager __instance) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown __instance.playerLevels = Helper.ResizeArray(__instance.playerLevels, Plugin.MaxPlayers); for (int i = 4; i < Plugin.MaxPlayers; i++) { __instance.playerLevels[i] = new PlayerLevel(); } } [HarmonyPatch(typeof(SoundManager), "Awake")] [HarmonyPostfix] public static void SoundWake(ref SoundManager __instance) { __instance.playerVoiceMixers = Helper.ResizeArray(__instance.playerVoiceMixers, Plugin.MaxPlayers); for (int i = 4; i < Plugin.MaxPlayers; i++) { __instance.playerVoiceMixers[i] = Object.Instantiate<AudioMixerGroup>(__instance.playerVoiceMixers[0]); } } [HarmonyPatch(typeof(SoundManager), "Start")] [HarmonyPostfix] public static void ResizeSoundManagerLists(ref SoundManager __instance) { __instance.playerVoicePitchLerpSpeed = new float[Plugin.MaxPlayers + 1]; __instance.playerVoicePitchTargets = new float[Plugin.MaxPlayers + 1]; __instance.playerVoiceVolumes = new float[Plugin.MaxPlayers + 1]; __instance.playerVoicePitches = new float[Plugin.MaxPlayers + 1]; for (int i = 1; i < Plugin.MaxPlayers + 1; i++) { __instance.playerVoicePitchLerpSpeed[i] = 3f; __instance.playerVoicePitchTargets[i] = 1f; __instance.playerVoicePitches[i] = 1f; __instance.playerVoiceVolumes[i] = 1f; } } [HarmonyPatch(typeof(StartOfRound), "EndOfGame")] [HarmonyPrefix] public static void EOG(ref StartOfRound __instance, int bodiesInsured = 0, int connectedPlayersOnServer = 0) { Plugin.oldhastime = __instance.currentLevel.planetHasTime; __instance.currentLevel.planetHasTime = false; } [HarmonyPatch(typeof(StartOfRound), "ReviveDeadPlayers")] [HarmonyPrefix] public static void RDP(ref StartOfRound __instance) { __instance.currentLevel.planetHasTime = Plugin.oldhastime; } [HarmonyPatch(typeof(EnemyAI), "EnableEnemyMesh")] [HarmonyPrefix] public static bool EnableEnemyMesh(EnemyAI __instance, bool enable, bool overrideDoNotSet = false) { int layer = ((!enable) ? 23 : 19); for (int i = 0; i < __instance.skinnedMeshRenderers.Length; i++) { if (Object.op_Implicit((Object)(object)__instance.skinnedMeshRenderers[i]) && (!((Component)__instance.skinnedMeshRenderers[i]).CompareTag("DoNotSet") || overrideDoNotSet)) { ((Component)__instance.skinnedMeshRenderers[i]).gameObject.layer = layer; } } for (int j = 0; j < __instance.meshRenderers.Length; j++) { if (Object.op_Implicit((Object)(object)__instance.meshRenderers[j]) && (!((Component)__instance.meshRenderers[j]).CompareTag("DoNotSet") || overrideDoNotSet)) { ((Component)__instance.meshRenderers[j]).gameObject.layer = layer; } } return false; } [HarmonyPatch(typeof(ShipTeleporter), "Awake")] [HarmonyPrefix] public static bool Awake2(ShipTeleporter __instance) { int[] array = new int[Plugin.MaxPlayers]; for (int i = 0; i < Plugin.MaxPlayers; i++) { array[i] = -1; } typeof(ShipTeleporter).GetField("playersBeingTeleported", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, array); __instance.buttonTrigger.interactable = false; typeof(ShipTeleporter).GetField("cooldownTime", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, __instance.cooldownAmount); return false; } [HarmonyPatch(typeof(StartOfRound), "Start")] [HarmonyPrefix] public static bool AddPlayers() { //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) Debug.Log((object)"Ran"); NetworkSceneManager sceneManager = NetworkManager.Singleton.SceneManager; startOfRound = StartOfRound.Instance; if ((Object)(object)startOfRound.allPlayerObjects[Plugin.MaxPlayers - 1] != (Object)null) { return true; } Debug.Log((object)"Adding players"); referencePlayer = startOfRound.allPlayerObjects[0].GetComponent<PlayerControllerB>(); GameObject playerPrefab = startOfRound.playerPrefab; Transform transform = ((Component)startOfRound.playersContainer).transform; FieldInfo field = typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.NonPublic); PropertyInfo property = typeof(NetworkObject).GetProperty("NetworkObjectId", BindingFlags.Instance | BindingFlags.Public); FieldInfo field2 = typeof(NetworkSceneManager).GetField("ScenePlacedObjects", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo[] fields = typeof(NetworkObject).GetFields(BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field3 = typeof(NetworkSceneManager).GetField("NetworkManager", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field4 = typeof(NetworkObject).GetField("NetworkManagerOwner", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo fieldInfo = field4; FieldInfo[] array = fields; foreach (FieldInfo fieldInfo2 in array) { if (fieldInfo2.Name == "<IsSceneObject>k__BackingField") { fieldInfo = fieldInfo2; } } instantiating = true; MethodInfo method = typeof(NetworkSpawnManager).GetMethod("SpawnNetworkObjectLocally", BindingFlags.Instance | BindingFlags.NonPublic, null, CallingConventions.Any, new Type[6] { typeof(NetworkObject), typeof(ulong), typeof(bool), typeof(bool), typeof(ulong), typeof(bool) }, null); for (int j = 4; j < Plugin.MaxPlayers; j++) { nextClientId = j; GameObject val = Object.Instantiate<GameObject>(playerPrefab, transform); PlayerControllerB component = val.GetComponent<PlayerControllerB>(); NetworkObject component2 = val.GetComponent<NetworkObject>(); NetworkObject component3 = ((Component)val.transform.Find("PlayerPhysicsBox")).gameObject.GetComponent<NetworkObject>(); NetworkObject component4 = ((Component)val.transform.Find("ScavengerModel/metarig/ScavengerModelArmsOnly/metarig/spine.003/shoulder.R/arm.R_upper/arm.R_lower/hand.R/LocalItemHolder")).gameObject.GetComponent<NetworkObject>(); NetworkObject component5 = ((Component)val.transform.Find("ScavengerModel/metarig/spine/spine.001/spine.002/spine.003/shoulder.R/arm.R_upper/arm.R_lower/hand.R/ServerItemHolder")).gameObject.GetComponent<NetworkObject>(); component.TeleportPlayer(StartOfRound.Instance.notSpawnedPosition.position, false, 0f, false, true); startOfRound.allPlayerObjects[j] = val; startOfRound.allPlayerScripts[j] = component; uint num = (uint)(6942069 + j); ulong num2 = 6942069uL + (ulong)j; uint num3 = (uint)(123456789 + j); uint num4 = (uint)(987654321 + j); uint num5 = (uint)(124585949 + j); ulong num6 = 123456789uL + (ulong)j; ulong num7 = 987654321uL + (ulong)j; ulong num8 = 124585949uL + (ulong)j; Scene scene = ((Component)component2).gameObject.scene; int handle = ((Scene)(ref scene)).handle; field.SetValue(component2, num); field.SetValue(component3, num3); field.SetValue(component4, num4); field.SetValue(component5, num5); property.SetValue(component2, num2); property.SetValue(component3, num6); property.SetValue(component4, num7); property.SetValue(component5, num8); method.Invoke(NetworkManager.Singleton.SpawnManager, new object[6] { component2, num2, true, true, component2.OwnerClientId, false }); fieldInfo.SetValue(component2, false); field4.SetValue(component2, field3.GetValue(sceneManager)); fieldInfo.SetValue(component3, false); field4.SetValue(component3, field3.GetValue(sceneManager)); fieldInfo.SetValue(component4, false); field4.SetValue(component4, field3.GetValue(sceneManager)); fieldInfo.SetValue(component5, false); field4.SetValue(component5, field3.GetValue(sceneManager)); ManualCameraRenderer[] array2 = Object.FindObjectsByType<ManualCameraRenderer>((FindObjectsInactive)1, (FindObjectsSortMode)0); for (int k = 0; k < array2.Length; k++) { ManualCameraRenderer val2 = array2[k]; val2.AddTransformAsTargetToRadar(((Component)component).transform, "Player #" + k, false); } } instantiating = false; return true; } [HarmonyPatch(typeof(QuickMenuManager), "Start")] [HarmonyPrefix] public static bool RemovePlayerlist(ref QuickMenuManager __instance) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown __instance.playerListSlots = Helper.ResizeArray(__instance.playerListSlots, Plugin.MaxPlayers); for (int i = 4; i < Plugin.MaxPlayers; i++) { PlayerListSlot val = new PlayerListSlot(); val.slotContainer = __instance.playerListSlots[0].slotContainer; val.volumeSliderContainer = __instance.playerListSlots[0].volumeSliderContainer; val.KickUserButton = __instance.playerListSlots[0].KickUserButton; val.isConnected = false; val.usernameHeader = __instance.playerListSlots[0].usernameHeader; val.volumeSlider = __instance.playerListSlots[0].volumeSlider; val.playerSteamId = __instance.playerListSlots[0].playerSteamId; __instance.playerListSlots[i] = val; } __instance.playerListPanel.SetActive(false); return true; } [HarmonyPatch(typeof(ManualCameraRenderer), "Awake")] [HarmonyPrefix] public static bool Mawake(ref ManualCameraRenderer __instance) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown for (int i = 0; i < 4; i++) { __instance.radarTargets.Add(new TransformAndName(((Component)StartOfRound.Instance.allPlayerScripts[i]).transform, StartOfRound.Instance.allPlayerScripts[i].playerUsername, false)); } __instance.targetTransformIndex = 0; __instance.targetedPlayer = StartOfRound.Instance.allPlayerScripts[0]; return false; } [HarmonyPatch(typeof(PlayerControllerB), "Awake")] [HarmonyPrefix] public static bool FixPlayerObject(ref PlayerControllerB __instance) { if (!instantiating) { return true; } ((Object)((Component)__instance).gameObject).name = $"ExtraPlayer{nextClientId}"; __instance.playerClientId = (ulong)nextClientId; __instance.actualClientId = (ulong)nextClientId; StartOfRound.Instance.allPlayerObjects[nextClientId] = ((Component)((Component)__instance).transform.parent).gameObject; StartOfRound.Instance.allPlayerScripts[nextClientId] = __instance; FieldInfo[] fields = typeof(PlayerControllerB).GetFields(); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { object value = fieldInfo.GetValue(__instance); object value2 = fieldInfo.GetValue(referencePlayer); if (value == null && value2 != null) { fieldInfo.SetValue(__instance, value2); } } ((Behaviour)__instance).enabled = true; return true; } [HarmonyPatch(typeof(StartOfRound), "GetPlayerSpawnPosition")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> GetPlayerSpawnPosition(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); list[0].opcode = OpCodes.Ldc_I4_1; return list.AsEnumerable(); } } }