using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ChuxiaFixes.Patches; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using Patches; using Steamworks; using TMPro; 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("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("EasyTextEffects")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: AssemblyCompany("chuxiaaaa")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("\r\n\t\tA collection of Fixes for the vanilla game.(including LateJoin, Player Name, and various bug fixes.)\r\n\t")] [assembly: AssemblyFileVersion("1.0.5.0")] [assembly: AssemblyInformationalVersion("1.0.5+6eda2929abcbec818f2c5ea7a91b5894050e5957")] [assembly: AssemblyProduct("ChuxiaFixes")] [assembly: AssemblyTitle("ChuxiaFixes")] [assembly: AssemblyMetadata("RepositoryUrl", "__PROJECT_URL__")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.5.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("ChuxiaFixes", "ChuxiaFixes", "1.0.5")] public class Plugin : BaseUnityPlugin { public static ManualLogSource Log; public static ConfigEntry FixPlayerName_Enable { get; set; } public static ConfigEntry FixPlayerName_WorkInterval { get; set; } public static ConfigEntry General_DisableFontWarn { get; set; } public static ConfigEntry General_DisableNetworkAnalyzer { get; set; } public static ConfigEntry General_FixDeathBoxes { get; set; } public static ConfigEntry General_FixGiftBox { get; set; } public static ConfigEntry General_FixNetworkObject { get; set; } private void Awake() { Log = ((BaseUnityPlugin)this).Logger; General_DisableFontWarn = ((BaseUnityPlugin)this).Config.Bind("General", "DisableFontWarn", true, "Disable unknow font warning messages in the console."); General_DisableNetworkAnalyzer = ((BaseUnityPlugin)this).Config.Bind("General", "DisableNetworkAnalyzer", true, "Disable the built-in network analyzer that cause performance issues."); General_FixNetworkObject = ((BaseUnityPlugin)this).Config.Bind("General", "FixNetworkObject", true, "Fixed the issue where NetworkObject's cached parent was not set correctly."); General_FixDeathBoxes = ((BaseUnityPlugin)this).Config.Bind("General", "FixDeathBoxes", true, "Fixed the issue where names and avatars were displayed incorrectly in spectator mode."); General_FixGiftBox = ((BaseUnityPlugin)this).Config.Bind("General", "FixGiftBox", true, "Fixed the bug with the gift box in late joining"); FixPlayerName_Enable = ((BaseUnityPlugin)this).Config.Bind("FixPlayerName", "Enable", true, "Fixed incorrect or unknown player names."); FixPlayerName_WorkInterval = ((BaseUnityPlugin)this).Config.Bind("FixPlayerName", "WorkInterval", 30f, "Interval (in seconds) between each attempt to fix player names."); Harmony.CreateAndPatchAll(typeof(FixPlayerName_Patches), (string)null); Harmony.CreateAndPatchAll(typeof(FixPlayerName_Patches.UpdateMapTargetPostfixPatch), (string)null); Harmony.CreateAndPatchAll(typeof(General_Patches), (string)null); if (General_DisableNetworkAnalyzer.Value) { Harmony.CreateAndPatchAll(typeof(NetworkAnalyzer_Patches), (string)null); } Log.LogInfo((object)"Plugin ChuxiaFixes is loaded!"); } } internal static class LCMPluginInfo { public const string PLUGIN_GUID = "ChuxiaFixes"; public const string PLUGIN_NAME = "ChuxiaFixes"; public const string PLUGIN_VERSION = "1.0.5"; } namespace ChuxiaFixes.Patches { [HarmonyPatch] [HarmonyWrapSafe] public static class NetworkAnalyzer_Patches { [CompilerGenerated] private sealed class d__6 : IEnumerable, IEnumerable, IEnumerator, IEnumerator, IDisposable { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; private IEnumerable instructions; public IEnumerable <>3__instructions; CodeInstruction IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__6(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = new CodeInstruction(OpCodes.Ret, (object)null); <>1__state = 1; return true; case 1: <>1__state = -1; 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(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { d__6 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__6(0); } d__.instructions = <>3__instructions; return d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } public static bool hasPatch { get; set; } public static MethodBase TargetMethod() { Type type = Type.GetType("Unity.Netcode.NetworkMetrics, Unity.Netcode.Runtime"); ConstructorInfo[] constructors = type.GetConstructors(); int num = 0; if (num < constructors.Length) { return constructors[num]; } return null; } private static void Postfix(object __instance) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown if (hasPatch) { return; } hasPatch = true; Harmony val = new Harmony("ChuxiaFixes.NetworkAnalyzer_Patches"); foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(__instance.GetType())) { if (declaredMethod.ReturnType == typeof(void)) { val.Patch((MethodBase)declaredMethod, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(NetworkAnalyzer_Patches), "EmptyMethodTranspiler", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); } } } [IteratorStateMachine(typeof(d__6))] public static IEnumerable EmptyMethodTranspiler(IEnumerable instructions) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__6(-2) { <>3__instructions = instructions }; } } } namespace Patches { [HarmonyWrapSafe] public static class FixPlayerName_Patches { [HarmonyPatch] [HarmonyWrapSafe] public static class UpdateMapTargetPostfixPatch { private static ManualCameraRenderer manualCamera; private static bool Prepare() { return Plugin.FixPlayerName_Enable.Value; } private static MethodBase TargetMethod() { Type type = AccessTools.Inner(typeof(ManualCameraRenderer), "d__74"); return AccessTools.Method(type, "MoveNext", (Type[])null, (Type[])null); } [HarmonyPostfix] public static void Postfix(object __instance, ref bool __result) { if (!__result) { if ((Object)(object)manualCamera == (Object)null) { FieldInfo fieldInfo = AccessTools.Field(__instance.GetType(), "<>4__this"); object? value = fieldInfo.GetValue(__instance); manualCamera = (ManualCameraRenderer)((value is ManualCameraRenderer) ? value : null); } if ((Object)(object)manualCamera != (Object)null && (Object)(object)manualCamera.targetedPlayer != (Object)null && ((TMP_Text)StartOfRound.Instance.mapScreenPlayerName).text != manualCamera.targetedPlayer.playerUsername) { ((TMP_Text)StartOfRound.Instance.mapScreenPlayerName).text = manualCamera.targetedPlayer.playerUsername; } } } } [CompilerGenerated] private sealed class d__12 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__12(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; if (!_isRegistered) { SteamFriends.OnPersonaStateChange += OnPersonaStateChange; _isRegistered = true; } break; case 1: <>1__state = -1; <>2__current = RefreshPlayerNames(); <>1__state = 2; return true; case 2: <>1__state = -1; break; } if ((Object)(object)StartOfRound.Instance?.localPlayerController != (Object)null) { <>2__current = _workInterval; <>1__state = 1; return true; } StopFixCoroutine(); 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(); } } [CompilerGenerated] private sealed class d__13 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; private StartOfRound 5__1; private QuickMenuManager 5__2; private PlayerControllerB[] 5__3; private int 5__4; private PlayerControllerB 5__5; private PlayerListSlot 5__6; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__13(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__2 = null; 5__3 = null; 5__5 = null; 5__6 = null; <>1__state = -2; } private bool MoveNext() { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; 5__5 = null; 5__6 = null; goto IL_016d; } <>1__state = -1; 5__1 = StartOfRound.Instance; if (5__1?.allPlayerScripts == null) { return false; } 5__2 = Object.FindObjectOfType(); if ((Object)(object)5__2 == (Object)null) { return false; } 5__3 = 5__1.allPlayerScripts; 5__4 = 0; goto IL_017f; IL_016d: 5__4++; goto IL_017f; IL_017f: if (5__4 < 5__3.Length) { 5__5 = 5__3[5__4]; 5__6 = 5__2.playerListSlots[5__4]; if (5__5.playerSteamId == 0L || (!5__5.isPlayerControlled && !5__5.isPlayerDead)) { if (5__6.slotContainer.activeSelf) { 5__6.slotContainer.SetActive(false); } goto IL_016d; } if (!5__6.slotContainer.activeSelf) { 5__6.slotContainer.SetActive(true); } <>2__current = UpdatePlayerName(5__5, 5__6); <>1__state = 1; return true; } 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(); } } [CompilerGenerated] private sealed class d__14 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PlayerControllerB player; public PlayerListSlot slot; private Friend 5__1; private string 5__2; private bool 5__3; private Exception 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__14(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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) if (<>1__state != 0) { return false; } <>1__state = -1; try { 5__1 = new Friend(SteamId.op_Implicit(player.playerSteamId)); 5__2 = ((Friend)(ref 5__1)).Name; if (5__2 == "[unknown]") { 5__3 = SteamFriends.RequestUserInformation(SteamId.op_Implicit(player.playerSteamId), true); return false; } if (player.playerUsername != 5__2) { player.playerUsername = 5__2; ((TMP_Text)player.usernameBillboardText).text = 5__2; } if (((TMP_Text)slot.usernameHeader).text != 5__2) { ((TMP_Text)slot.usernameHeader).text = 5__2; slot.playerSteamId = player.playerSteamId; } 5__2 = null; } catch (Exception ex) { 5__4 = ex; Plugin.Log.LogError((object)$"[FixPlayerName] UpdatePlayerName:{5__4}"); } 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 Coroutine? _fixCoroutine; private static bool _isRegistered; private static readonly WaitForSeconds _workInterval = new WaitForSeconds(Plugin.FixPlayerName_WorkInterval.Value); [HarmonyPatch(typeof(QuickMenuManager), "OpenQuickMenu")] [HarmonyPrefix] public static void OpenQuickMenu(QuickMenuManager __instance) { if (__instance.NonHostPlayerSlotsEnabled()) { PlayerName_Refresh(); } } [HarmonyPostfix] [HarmonyPatch(typeof(GameNetworkManager), "SteamMatchmaking_OnLobbyMemberJoined")] public static void SteamMatchmaking_OnLobbyMemberJoinedPostfix() { PlayerName_Refresh(); } private static bool PlayerName_Refresh() { if ((Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)StartOfRound.Instance == (Object)null) { return false; } if (GameNetworkManager.Instance.disableSteam) { return false; } if (!Plugin.FixPlayerName_Enable.Value) { return false; } ((MonoBehaviour)GameNetworkManager.Instance).StartCoroutine(RefreshPlayerNames()); return true; } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerControllerB), "SendNewPlayerValuesClientRpc")] public static void SendNewPlayerValuesClientRpc() { PlayerName_Refresh(); } [HarmonyPostfix] [HarmonyPatch(typeof(StartOfRound), "OnPlayerConnectedClientRpc")] public static void OnPlayerConnectedClientRpc() { PlayerName_Refresh(); } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] public static void ConnectClientToPlayerObjectPostfix(PlayerControllerB __instance) { if (!GameNetworkManager.Instance.disableSteam && Plugin.FixPlayerName_Enable.Value) { StopFixCoroutine((MonoBehaviour)(object)__instance); _fixCoroutine = ((MonoBehaviour)__instance).StartCoroutine(FixPlayerNamesRoutine()); } } [HarmonyPrefix] [HarmonyPatch(typeof(StartOfRound), "OnLocalDisconnect")] public static void OnLocalDisconnect() { StopFixCoroutine(); } private static void StopFixCoroutine(MonoBehaviour behaviour = null) { if (_fixCoroutine != null) { MonoBehaviour val = (MonoBehaviour)(((object)behaviour) ?? ((object)StartOfRound.Instance?.localPlayerController)); if (val != null) { val.StopCoroutine(_fixCoroutine); } if (_isRegistered) { SteamFriends.OnPersonaStateChange -= OnPersonaStateChange; _isRegistered = false; } _fixCoroutine = null; } } [IteratorStateMachine(typeof(d__12))] private static IEnumerator FixPlayerNamesRoutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__12(0); } [IteratorStateMachine(typeof(d__13))] private static IEnumerator RefreshPlayerNames() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__13(0); } [IteratorStateMachine(typeof(d__14))] private static IEnumerator UpdatePlayerName(PlayerControllerB player, PlayerListSlot slot) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__14(0) { player = player, slot = slot }; } private static void OnPersonaStateChange(Friend friend) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) try { StartOfRound instance = StartOfRound.Instance; if (instance?.allPlayerScripts == null) { return; } QuickMenuManager val = Object.FindObjectOfType(); if ((Object)(object)val == (Object)null) { return; } PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; for (int i = 0; i < allPlayerScripts.Length; i++) { PlayerControllerB val2 = allPlayerScripts[i]; if (val2.playerSteamId == friend.Id.Value) { if (((Friend)(ref friend)).Name != val2.playerUsername || ((TMP_Text)val2.usernameBillboardText).text != ((Friend)(ref friend)).Name) { val2.playerUsername = ((Friend)(ref friend)).Name; ((TMP_Text)val2.usernameBillboardText).text = ((Friend)(ref friend)).Name; } PlayerListSlot val3 = val.playerListSlots[i]; ((TMP_Text)val3.usernameHeader).text = ((Friend)(ref friend)).Name; val3.playerSteamId = friend.Id.Value; if (!val3.slotContainer.activeSelf) { val3.slotContainer.SetActive(true); } break; } } } catch (Exception arg) { Plugin.Log.LogError((object)$"[FixPlayerName] OnPersonaStateChange:{arg}"); } } } [HarmonyWrapSafe] public static class General_Patches { [HarmonyPostfix] [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static void warningsDisabled(ref bool __result) { if (Plugin.General_DisableFontWarn.Value) { __result = true; } } [HarmonyPrefix] [HarmonyPatch(typeof(NetworkObject), "GetCachedParent")] public static void GetCachedParent(NetworkObject __instance) { if (Plugin.General_FixNetworkObject.Value && (Object)(object)__instance.m_CachedParent == (Object)null) { __instance.SetCachedParent(((Component)__instance).transform.parent); } } [HarmonyPostfix] [HarmonyPatch(typeof(SceneEventData), "AddSpawnedNetworkObjects")] public static void AddSpawnedNetworkObjects(SceneEventData __instance) { if (!Plugin.General_FixGiftBox.Value || __instance?.m_NetworkObjectsSync == null) { return; } for (int num = __instance.m_NetworkObjectsSync.Count - 1; num >= 0; num--) { NetworkObject val = __instance.m_NetworkObjectsSync[num]; if (!((Object)(object)val == (Object)null)) { GrabbableObject componentInChildren = ((Component)val).GetComponentInChildren(); GiftBoxItem val2 = (GiftBoxItem)(object)((componentInChildren is GiftBoxItem) ? componentInChildren : null); if (val2 != null && val2.hasUsedGift) { Plugin.Log.LogInfo((object)$"[GiftBox] Remove {((Object)val).GetInstanceID()}"); __instance.m_NetworkObjectsSync.RemoveAt(num); Object.Destroy((Object)(object)((Component)val).gameObject); } } } } [HarmonyPostfix] [HarmonyPatch(typeof(StartOfRound), "SetShipReadyToLand")] private static void ResetHUDManager() { if (Plugin.General_FixDeathBoxes.Value) { HUDManager instance = HUDManager.Instance; if (!((Object)(object)instance == (Object)null)) { instance.spectatingPlayerBoxes = new Dictionary(); instance.boxesAdded = 0; } } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }