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 LoadingInfo v1.1.4
LoadingInfo.dll
Decompiled 3 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LoadingInfo.Patches; using Microsoft.CodeAnalysis; using TMPro; using Unity.Collections; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: AssemblyCompany("chuxiaaaa")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("LoadingInfo")] [assembly: AssemblyFileVersion("1.1.4.0")] [assembly: AssemblyInformationalVersion("1.1.4+c42dd3355b2178fc654f9ee072b506932a8d4d77")] [assembly: AssemblyProduct("LoadingInfo")] [assembly: AssemblyTitle("LoadingInfo")] [assembly: AssemblyMetadata("RepositoryUrl", "__PROJECT_URL__")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.4.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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; } } } [BepInPlugin("LoadingInfo", "LoadingInfo", "1.1.4")] public class Plugin : BaseUnityPlugin { public static ManualLogSource Log; public static ConfigEntry<float> LoadTextY { get; set; } public static ConfigEntry<float> LoadingTipsY { get; set; } public static ConfigEntry<int> NameMaxLength { get; set; } public static ConfigEntry<int> MaxPlayerCount { get; set; } private void Awake() { Log = ((BaseUnityPlugin)this).Logger; Harmony.CreateAndPatchAll(typeof(RoundManagerPatch), (string)null); Harmony.CreateAndPatchAll(typeof(StartOfRoundPatch), (string)null); Harmony.CreateAndPatchAll(typeof(HUDManagerPatch), (string)null); Harmony.CreateAndPatchAll(typeof(NetworkManagerPatch), (string)null); LoadTextY = ((BaseUnityPlugin)this).Config.Bind<float>("LoadTipCompat", "LoadTextY", 100f, (ConfigDescription)null); LoadingTipsY = ((BaseUnityPlugin)this).Config.Bind<float>("LoadTipCompat", "LoadingTipsY", 0f, (ConfigDescription)null); NameMaxLength = ((BaseUnityPlugin)this).Config.Bind<int>("LoadingInfo", "NameMaxLength", -1, (ConfigDescription)null); MaxPlayerCount = ((BaseUnityPlugin)this).Config.Bind<int>("LoadingInfo", "MaxPlayerCount", 10, (ConfigDescription)null); Log.LogInfo((object)"Plugin LoadingInfo is loaded!"); } } internal static class LCMPluginInfo { public const string PLUGIN_GUID = "LoadingInfo"; public const string PLUGIN_NAME = "LoadingInfo"; public const string PLUGIN_VERSION = "1.1.4"; } namespace LoadingInfo.Patches { [HarmonyPatch(typeof(RoundManager))] [HarmonyWrapSafe] public static class RoundManagerPatch { public static List<ulong> CallFinishedGeneratingLevelServerRpc { get; set; } = new List<ulong>(); [HarmonyPrefix] [HarmonyPatch("__rpc_handler_192551691")] public static bool FinishedGeneratingLevelServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return FinishedGeneratingLevelServerRpc(RPCHelper.ConvertId(rpcParams.Server.Receive.SenderClientId)); } public static bool FinishedGeneratingLevelServerRpc(ulong clientId) { if (GameNetworkManager.Instance.connectedPlayers == 1) { return true; } if (!((NetworkBehaviour)StartOfRound.Instance).IsHost) { return true; } Plugin.Log.LogInfo((object)$"FinishedGeneratingLevelServerRpc:{clientId}"); if (!CallFinishedGeneratingLevelServerRpc.Contains(clientId) && clientId != NetworkManager.Singleton.LocalClientId) { Plugin.Log.LogInfo((object)$"FinishedGeneratingLevelServerRpc.Add{clientId}"); CallFinishedGeneratingLevelServerRpc.Add(clientId); } int num = RoundManager.Instance.playersFinishedGeneratingFloor.Count + 1; List<string> list = new List<string>(); List<ulong> list2 = new List<ulong>(); PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (val.isPlayerControlled && !val.isHostPlayerObject && !CallFinishedGeneratingLevelServerRpc.Contains(val.playerClientId)) { list.Add(val.playerUsername); list2.Add(val.playerClientId); } } if (num != GameNetworkManager.Instance.connectedPlayers) { if (Plugin.MaxPlayerCount.Value != -1) { list = list.GetRange(0, (list.Count > Plugin.MaxPlayerCount.Value) ? Plugin.MaxPlayerCount.Value : list.Count); } if (Plugin.NameMaxLength.Value != -1) { list = list.Select((string x) => x.Substring(0, (x.Length > Plugin.NameMaxLength.Value) ? Plugin.NameMaxLength.Value : x.Length)).ToList(); } ((TMP_Text)HUDManager.Instance.loadingText).text = string.Format("Random seed: {0}\r\nPlayers loaded: {1}/{2}\r\n{3}", HUDManager.Instance.playersManager.randomMapSeed, num, GameNetworkManager.Instance.connectedPlayers, string.Join(",", list)); Plugin.Log.LogInfo((object)("FinishedGeneratingLevelServerRpc.loadingText:" + ((TMP_Text)HUDManager.Instance.loadingText).text)); if (((NetworkBehaviour)StartOfRound.Instance).IsHost) { LoadingInfoNetwork.SendToAll(1, list2, num, GameNetworkManager.Instance.connectedPlayers); } } else { ((TMP_Text)HUDManager.Instance.loadingText).text = $"Random seed: {HUDManager.Instance.playersManager.randomMapSeed}\r\nAll players loaded!"; CallFinishedGeneratingLevelServerRpc = new List<ulong>(); } return true; } } [HarmonyPatch(typeof(HUDManager))] [HarmonyWrapSafe] public static class HUDManagerPatch { [HarmonyPatch("Start")] [HarmonyPostfix] public static void SetLoadingTips(HUDManager __instance) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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) //IL_009a: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.Find("Systems/UI/Canvas/LoadingText/TextBG"); val.transform.localScale = new Vector3(val.transform.localScale.x, val.transform.localScale.y + 1f, val.transform.localScale.z); GameObject val2 = GameObject.Find("Systems/UI/Canvas/LoadingText/LoadText"); val2.transform.position = new Vector3(val2.transform.position.x, val2.transform.position.y + 0.24f, val2.transform.position.z); } } public class RPCHelper { public static ulong ConvertId(ulong ClientId) { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (((NetworkBehaviour)val).OwnerClientId == ClientId) { return val.playerClientId; } } return ClientId; } } [HarmonyPatch(typeof(StartOfRound))] [HarmonyWrapSafe] public static class StartOfRoundPatch { private static StartMatchLever startMatchLever = null; public static List<ulong> CallPlayerLoadedServerRpc { get; set; } = new List<ulong>(); public static List<ulong> CallPlayerHasRevivedServerRpc { get; set; } = new List<ulong>(); public static bool isWait { get; set; } [HarmonyPrefix] [HarmonyPatch("OnPlayerDC")] public static void OnPlayerDC(int playerObjectNumber, ulong clientId) { if (CallPlayerLoadedServerRpc.Contains((ulong)playerObjectNumber)) { CallPlayerLoadedServerRpc.Remove((ulong)playerObjectNumber); } if (CallPlayerHasRevivedServerRpc.Contains((ulong)playerObjectNumber)) { CallPlayerHasRevivedServerRpc.Remove((ulong)playerObjectNumber); } if (RoundManagerPatch.CallFinishedGeneratingLevelServerRpc.Contains((ulong)playerObjectNumber)) { RoundManagerPatch.CallFinishedGeneratingLevelServerRpc.Remove((ulong)playerObjectNumber); } } [HarmonyPrefix] [HarmonyPatch("__rpc_handler_4249638645")] public static bool PlayerLoadedServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return PlayerLoadedServerRpc(RPCHelper.ConvertId(rpcParams.Server.Receive.SenderClientId)); } public static bool PlayerLoadedServerRpc(ulong clientId) { Plugin.Log.LogInfo((object)$"PlayerLoadedServerRpc:{clientId}"); if (GameNetworkManager.Instance.connectedPlayers == 1) { return true; } if (!((NetworkBehaviour)StartOfRound.Instance).IsHost) { return true; } if (!((Behaviour)HUDManager.Instance.loadingText).enabled) { return true; } if ((Object)(object)startMatchLever == (Object)null) { startMatchLever = Object.FindObjectOfType<StartMatchLever>(); } if (startMatchLever.triggerScript.interactable) { return true; } if (!CallPlayerLoadedServerRpc.Contains(clientId) && clientId != NetworkManager.Singleton.LocalClientId) { Plugin.Log.LogInfo((object)$"PlayerLoadedServerRpc.Add:{clientId}"); CallPlayerLoadedServerRpc.Add(clientId); } int num = StartOfRound.Instance.fullyLoadedPlayers.Count + 1; List<string> list = new List<string>(); List<ulong> list2 = new List<ulong>(); PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (val.isPlayerControlled && !val.isHostPlayerObject && !CallPlayerLoadedServerRpc.Contains(val.playerClientId)) { list.Add(val.playerUsername); list2.Add(val.playerClientId); } } if (num != GameNetworkManager.Instance.connectedPlayers) { if (Plugin.MaxPlayerCount.Value != -1) { list = list.GetRange(0, (list.Count > Plugin.MaxPlayerCount.Value) ? Plugin.MaxPlayerCount.Value : list.Count); } if (Plugin.NameMaxLength.Value != -1) { list = list.Select((string x) => x.Substring(0, (x.Length > Plugin.NameMaxLength.Value) ? Plugin.NameMaxLength.Value : x.Length)).ToList(); } ((TMP_Text)HUDManager.Instance.loadingText).text = string.Format("Waiting for crew...\r\nPlayers loaded: {0}/{1}\r\n{2}", num, GameNetworkManager.Instance.connectedPlayers, string.Join(",", list)); Plugin.Log.LogInfo((object)("loadingText:" + ((TMP_Text)HUDManager.Instance.loadingText).text)); if (((NetworkBehaviour)StartOfRound.Instance).IsHost) { LoadingInfoNetwork.SendToAll(3, list2, num, GameNetworkManager.Instance.connectedPlayers); } } else { ((TMP_Text)HUDManager.Instance.loadingText).text = $"Waiting for crew...\r\nAll players loaded!"; CallPlayerLoadedServerRpc = new List<ulong>(); } return true; } [HarmonyPostfix] [HarmonyPatch("PassTimeToNextDay")] public static void PassTimeToNextDay() { PlayerHasRevivedServerRpc(0uL); } [HarmonyPrefix] [HarmonyPatch("EndOfGameClientRpc")] public static void EndOfGameClientRpc() { isWait = true; } [HarmonyPostfix] [HarmonyPatch("AllPlayersHaveRevivedClientRpc")] public static void AllPlayersHaveRevivedClientRpc() { isWait = false; ((Behaviour)HUDManager.Instance.loadingText).enabled = false; HUDManager.Instance.LoadingScreen.SetBool("IsLoading", false); } [HarmonyPostfix] [HarmonyPatch("EndPlayersFiredSequenceClientRpc")] public static void EndPlayersFiredSequenceClientRpc() { isWait = false; ((Behaviour)HUDManager.Instance.loadingText).enabled = false; HUDManager.Instance.LoadingScreen.SetBool("IsLoading", false); } [HarmonyPostfix] [HarmonyPatch("SetShipReadyToLand")] public static void SetShipReadyToLand() { isWait = false; ((Behaviour)HUDManager.Instance.loadingText).enabled = false; HUDManager.Instance.LoadingScreen.SetBool("IsLoading", false); } [HarmonyPrefix] [HarmonyPatch("__rpc_handler_3083945322")] public static bool PlayerHasRevivedServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return PlayerHasRevivedServerRpc(RPCHelper.ConvertId(rpcParams.Server.Receive.SenderClientId)); } private static bool PlayerHasRevivedServerRpc(ulong clientId) { if (GameNetworkManager.Instance.connectedPlayers == 1) { return true; } if (!((NetworkBehaviour)StartOfRound.Instance).IsHost) { return true; } if (!CallPlayerHasRevivedServerRpc.Contains(clientId) && clientId != NetworkManager.Singleton.LocalClientId) { CallPlayerHasRevivedServerRpc.Add(clientId); } int num = StartOfRound.Instance.playersRevived + 1; List<string> list = new List<string>(); List<ulong> list2 = new List<ulong>(); PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (val.isPlayerControlled && !val.isHostPlayerObject && !CallPlayerHasRevivedServerRpc.Contains(val.playerClientId)) { list.Add(val.playerUsername); list2.Add(val.playerClientId); } } if (num < GameNetworkManager.Instance.connectedPlayers) { if (Plugin.MaxPlayerCount.Value != -1) { list = list.GetRange(0, (list.Count > Plugin.MaxPlayerCount.Value) ? Plugin.MaxPlayerCount.Value : list.Count); } if (Plugin.NameMaxLength.Value != -1) { list = list.Select((string x) => x.Substring(0, (x.Length > Plugin.NameMaxLength.Value) ? Plugin.NameMaxLength.Value : x.Length)).ToList(); } Plugin.Log.LogInfo((object)"Waiting for Client..."); if (isWait) { ((Behaviour)HUDManager.Instance.loadingText).enabled = true; HUDManager.Instance.LoadingScreen.SetBool("IsLoading", true); ((TMP_Text)HUDManager.Instance.loadingText).text = string.Format("Waiting for Client...\r\nPlayers loaded: {0}/{1}\r\n{2}", num, GameNetworkManager.Instance.connectedPlayers, string.Join(",", list)); if (((NetworkBehaviour)StartOfRound.Instance).IsHost) { LoadingInfoNetwork.SendToAll(2, list2, num, GameNetworkManager.Instance.connectedPlayers); } } } else { CallPlayerHasRevivedServerRpc = new List<ulong>(); ((Behaviour)HUDManager.Instance.loadingText).enabled = false; HUDManager.Instance.LoadingScreen.SetBool("IsLoading", false); } return true; } } public static class LoadingInfoNetwork { public static void SendToAll(byte type, List<ulong> playerClientIds, int loaded, int total) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) if (!NetworkManager.Singleton.IsServer) { return; } Plugin.Log.LogInfo((object)string.Format("SendToAll:{0},{1}{2},{3}", type, string.Join("|", playerClientIds), loaded, total)); FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(1024, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref type, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref loaded, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref total, default(ForPrimitives)); int count = playerClientIds.Count; ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref count, default(ForPrimitives)); foreach (ulong playerClientId in playerClientIds) { ulong current = playerClientId; ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref current, default(ForPrimitives)); } foreach (ulong connectedClientsId in NetworkManager.Singleton.ConnectedClientsIds) { if (connectedClientsId != NetworkManager.Singleton.LocalClientId) { NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("LoadingInfo_Update", connectedClientsId, val, (NetworkDelivery)3); } } } finally { ((IDisposable)(FastBufferWriter)(ref val)).Dispose(); } } } public static class NetworkManagerPatch { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func<string, string> <>9__1_1; public static HandleNamedMessageDelegate <>9__1_0; internal void <AfterInitialize>b__1_0(ulong senderClientId, FastBufferReader reader) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) byte b = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b, default(ForPrimitives)); int num = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives)); int num2 = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num2, default(ForPrimitives)); int num3 = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num3, default(ForPrimitives)); List<ulong> list = new List<ulong>(); ulong item = default(ulong); for (int i = 0; i < num3; i++) { ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref item, default(ForPrimitives)); list.Add(item); } List<string> list2 = new List<string>(); foreach (ulong item2 in list) { list2.Add(StartOfRound.Instance.allPlayerScripts[item2].playerUsername); } if (Plugin.MaxPlayerCount.Value != -1) { list2 = list2.Take(Plugin.MaxPlayerCount.Value).ToList(); } if (Plugin.NameMaxLength.Value != -1) { list2 = list2.Select((string x) => x.Substring(0, Math.Min(x.Length, Plugin.NameMaxLength.Value))).ToList(); } switch (b) { case 1: if (list2.Count > 0) { ((TMP_Text)HUDManager.Instance.loadingText).text = string.Format("Random seed: {0}\r\nPlayers loaded: {1}/{2}\r\n{3}", HUDManager.Instance.playersManager.randomMapSeed, num, num2, string.Join(",", list2)); } else { ((TMP_Text)HUDManager.Instance.loadingText).text = $"Random seed: {HUDManager.Instance.playersManager.randomMapSeed}\r\nAll players loaded!"; } break; case 2: if (StartOfRoundPatch.isWait && list2.Count > 0) { ((Behaviour)HUDManager.Instance.loadingText).enabled = true; HUDManager.Instance.LoadingScreen.SetBool("IsLoading", true); ((TMP_Text)HUDManager.Instance.loadingText).text = string.Format("Waiting for Client...\r\nPlayers loaded: {0}/{1}\r\n{2}", num, num2, string.Join(",", list2)); } else { ((Behaviour)HUDManager.Instance.loadingText).enabled = false; HUDManager.Instance.LoadingScreen.SetBool("IsLoading", false); } break; case 3: HUDManager.Instance.LoadingScreen.SetBool("IsLoading", true); if (list2.Count > 0) { ((TMP_Text)HUDManager.Instance.loadingText).text = string.Format("Waiting for crew...\r\nPlayers loaded: {0}/{1}\r\n{2}", num, num2, string.Join(",", list2)); } else { ((TMP_Text)HUDManager.Instance.loadingText).text = "Waiting for crew...\r\nAll players loaded!"; } break; } } internal string <AfterInitialize>b__1_1(string x) { return x.Substring(0, Math.Min(x.Length, Plugin.NameMaxLength.Value)); } } public const string LoadingInfoNameMessage = "LoadingInfo_Update"; [HarmonyPostfix] [HarmonyPatch(typeof(NetworkManager), "Initialize")] private static void AfterInitialize() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; object obj = <>c.<>9__1_0; if (obj == null) { HandleNamedMessageDelegate val = delegate(ulong senderClientId, FastBufferReader reader) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) byte b = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b, default(ForPrimitives)); int num = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives)); int num2 = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num2, default(ForPrimitives)); int num3 = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num3, default(ForPrimitives)); List<ulong> list = new List<ulong>(); ulong item = default(ulong); for (int i = 0; i < num3; i++) { ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref item, default(ForPrimitives)); list.Add(item); } List<string> list2 = new List<string>(); foreach (ulong item2 in list) { list2.Add(StartOfRound.Instance.allPlayerScripts[item2].playerUsername); } if (Plugin.MaxPlayerCount.Value != -1) { list2 = list2.Take(Plugin.MaxPlayerCount.Value).ToList(); } if (Plugin.NameMaxLength.Value != -1) { list2 = list2.Select((string x) => x.Substring(0, Math.Min(x.Length, Plugin.NameMaxLength.Value))).ToList(); } switch (b) { case 1: if (list2.Count > 0) { ((TMP_Text)HUDManager.Instance.loadingText).text = string.Format("Random seed: {0}\r\nPlayers loaded: {1}/{2}\r\n{3}", HUDManager.Instance.playersManager.randomMapSeed, num, num2, string.Join(",", list2)); } else { ((TMP_Text)HUDManager.Instance.loadingText).text = $"Random seed: {HUDManager.Instance.playersManager.randomMapSeed}\r\nAll players loaded!"; } break; case 2: if (StartOfRoundPatch.isWait && list2.Count > 0) { ((Behaviour)HUDManager.Instance.loadingText).enabled = true; HUDManager.Instance.LoadingScreen.SetBool("IsLoading", true); ((TMP_Text)HUDManager.Instance.loadingText).text = string.Format("Waiting for Client...\r\nPlayers loaded: {0}/{1}\r\n{2}", num, num2, string.Join(",", list2)); } else { ((Behaviour)HUDManager.Instance.loadingText).enabled = false; HUDManager.Instance.LoadingScreen.SetBool("IsLoading", false); } break; case 3: HUDManager.Instance.LoadingScreen.SetBool("IsLoading", true); if (list2.Count > 0) { ((TMP_Text)HUDManager.Instance.loadingText).text = string.Format("Waiting for crew...\r\nPlayers loaded: {0}/{1}\r\n{2}", num, num2, string.Join(",", list2)); } else { ((TMP_Text)HUDManager.Instance.loadingText).text = "Waiting for crew...\r\nAll players loaded!"; } break; } }; <>c.<>9__1_0 = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("LoadingInfo_Update", (HandleNamedMessageDelegate)obj); } [HarmonyPostfix] [HarmonyPatch(typeof(GameNetworkManager), "SetInstanceValuesBackToDefault")] public static void SetInstanceValuesBackToDefault() { if (!((Object)(object)NetworkManager.Singleton == (Object)null) && NetworkManager.Singleton.CustomMessagingManager != null) { NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler("LoadingInfo_Update"); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }