Decompiled source of ChuxiaFixes v1.0.2

ChuxiaFixes.dll

Decompiled 3 days ago
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.\r\n\t")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+3d973df157e6c23cc6c02ffda418d8a7b2950f8b")]
[assembly: AssemblyProduct("ChuxiaFixes")]
[assembly: AssemblyTitle("ChuxiaFixes")]
[assembly: AssemblyMetadata("RepositoryUrl", "__PROJECT_URL__")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.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.2")]
public class Plugin : BaseUnityPlugin
{
	public static ManualLogSource Log;

	public static ConfigEntry<bool> FixPlayerName_Enable { get; set; }

	public static ConfigEntry<float> FixPlayerName_WorkInterval { get; set; }

	public static ConfigEntry<bool> General_DisableFontWarn { get; set; }

	public static ConfigEntry<bool> General_DisableNetworkAnalyzer { get; set; }

	public static ConfigEntry<bool> General_FixDeathBoxes { get; set; }

	public static ConfigEntry<bool> General_FixGiftBox { get; set; }

	public static ConfigEntry<bool> General_FixNetworkObject { get; set; }

	private void Awake()
	{
		Log = ((BaseUnityPlugin)this).Logger;
		General_DisableFontWarn = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableFontWarn", true, "Disable unknow font warning messages in the console.");
		General_DisableNetworkAnalyzer = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableNetworkAnalyzer", true, "Disable the built-in network analyzer that cause performance issues.");
		General_FixNetworkObject = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "FixNetworkObject", true, "Fixed the issue where NetworkObject's cached parent was not set correctly.");
		General_FixDeathBoxes = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "FixDeathBoxes", true, "Fixed the issue where names and avatars were displayed incorrectly in spectator mode.");
		General_FixGiftBox = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "FixGiftBox", true, "Fixed the bug with the gift box in late joining");
		FixPlayerName_Enable = ((BaseUnityPlugin)this).Config.Bind<bool>("FixPlayerName", "Enable", true, "Fixed incorrect or unknown player names.");
		FixPlayerName_WorkInterval = ((BaseUnityPlugin)this).Config.Bind<float>("FixPlayerName", "WorkInterval", 30f, "Interval (in seconds) between each attempt to fix player names.");
		Harmony.CreateAndPatchAll(typeof(FixPlayerName_Patches), (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.2";
}
namespace ChuxiaFixes.Patches
{
	[HarmonyPatch]
	[HarmonyWrapSafe]
	public static class NetworkAnalyzer_Patches
	{
		[CompilerGenerated]
		private sealed class <EmptyMethodTranspiler>d__6 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private CodeInstruction <>2__current;

			private int <>l__initialThreadId;

			private IEnumerable<CodeInstruction> instructions;

			public IEnumerable<CodeInstruction> <>3__instructions;

			CodeInstruction IEnumerator<CodeInstruction>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <EmptyMethodTranspiler>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<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
			{
				<EmptyMethodTranspiler>d__6 <EmptyMethodTranspiler>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<EmptyMethodTranspiler>d__ = this;
				}
				else
				{
					<EmptyMethodTranspiler>d__ = new <EmptyMethodTranspiler>d__6(0);
				}
				<EmptyMethodTranspiler>d__.instructions = <>3__instructions;
				return <EmptyMethodTranspiler>d__;
			}

			[DebuggerHidden]
			IEnumerator IEnumerable.GetEnumerator()
			{
				return ((IEnumerable<CodeInstruction>)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(<EmptyMethodTranspiler>d__6))]
		public static IEnumerable<CodeInstruction> EmptyMethodTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <EmptyMethodTranspiler>d__6(-2)
			{
				<>3__instructions = instructions
			};
		}
	}
}
namespace Patches
{
	[HarmonyWrapSafe]
	public static class FixPlayerName_Patches
	{
		[HarmonyPatch]
		[HarmonyWrapSafe]
		public static class UpdateMapTargetPostfixPatch
		{
			private static MethodBase TargetMethod()
			{
				Type type = AccessTools.Inner(typeof(ManualCameraRenderer), "<updateMapTarget>d__71");
				return AccessTools.Method(type, "MoveNext", (Type[])null, (Type[])null);
			}

			[HarmonyPostfix]
			public static void Postfix(object __instance, ref bool __result)
			{
				if (!__result)
				{
					FieldInfo fieldInfo = AccessTools.Field(__instance.GetType(), "<>4__this");
					object? value = fieldInfo.GetValue(__instance);
					ManualCameraRenderer val = (ManualCameraRenderer)((value is ManualCameraRenderer) ? value : null);
					if ((Object)(object)val != (Object)null && (Object)(object)val.targetedPlayer != (Object)null && ((TMP_Text)StartOfRound.Instance.mapScreenPlayerName).text != val.targetedPlayer.playerUsername)
					{
						Plugin.Log.LogInfo((object)$"[FixPlayerName] ManualCameraRenderer.updateMapTarget -> {val.targetedPlayer.playerUsername}|{val.targetedPlayer.playerSteamId}");
						((TMP_Text)StartOfRound.Instance.mapScreenPlayerName).text = val.targetedPlayer.playerUsername;
					}
				}
			}
		}

		[CompilerGenerated]
		private sealed class <FixPlayerNamesRoutine>d__11 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <FixPlayerNamesRoutine>d__11(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 <RefreshPlayerNames>d__12 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			private StartOfRound <instance>5__1;

			private QuickMenuManager <quickMenu>5__2;

			private PlayerControllerB[] <players>5__3;

			private int <i>5__4;

			private PlayerControllerB <player>5__5;

			private PlayerListSlot <slot>5__6;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <RefreshPlayerNames>d__12(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<instance>5__1 = null;
				<quickMenu>5__2 = null;
				<players>5__3 = null;
				<player>5__5 = null;
				<slot>5__6 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
					<player>5__5 = null;
					<slot>5__6 = null;
					goto IL_015e;
				}
				<>1__state = -1;
				<instance>5__1 = StartOfRound.Instance;
				if (<instance>5__1?.allPlayerScripts == null || <instance>5__1.connectedPlayersAmount == 0)
				{
					return false;
				}
				<quickMenu>5__2 = Object.FindObjectOfType<QuickMenuManager>();
				if ((Object)(object)<quickMenu>5__2 == (Object)null)
				{
					return false;
				}
				<players>5__3 = <instance>5__1.allPlayerScripts;
				<i>5__4 = 0;
				goto IL_0170;
				IL_0170:
				if (<i>5__4 < <players>5__3.Length)
				{
					<player>5__5 = <players>5__3[<i>5__4];
					<slot>5__6 = <quickMenu>5__2.playerListSlots[<i>5__4];
					if (<player>5__5.playerSteamId == 0)
					{
						if (<slot>5__6.slotContainer.activeSelf)
						{
							<slot>5__6.slotContainer.SetActive(false);
						}
						goto IL_015e;
					}
					if (!<slot>5__6.slotContainer.activeSelf)
					{
						<slot>5__6.slotContainer.SetActive(true);
					}
					<>2__current = UpdatePlayerName(<player>5__5, <slot>5__6);
					<>1__state = 1;
					return true;
				}
				return false;
				IL_015e:
				<i>5__4++;
				goto IL_0170;
			}

			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 <UpdatePlayerName>d__13 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PlayerControllerB player;

			public PlayerListSlot slot;

			private Friend <friend>5__1;

			private string <steamName>5__2;

			private bool <requested>5__3;

			private Exception <ex>5__4;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <UpdatePlayerName>d__13(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<steamName>5__2 = null;
				<ex>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
				{
					<friend>5__1 = new Friend(SteamId.op_Implicit(player.playerSteamId));
					<steamName>5__2 = ((Friend)(ref <friend>5__1)).Name;
					if (<steamName>5__2 == "[unknown]")
					{
						<requested>5__3 = SteamFriends.RequestUserInformation(SteamId.op_Implicit(player.playerSteamId), true);
						Plugin.Log.LogInfo((object)$"[FixPlayerName] Requested user info for {player.playerSteamId}: {<requested>5__3}");
						return false;
					}
					if (player.playerUsername != <steamName>5__2)
					{
						player.playerUsername = <steamName>5__2;
						((TMP_Text)player.usernameBillboardText).text = <steamName>5__2;
					}
					if (((TMP_Text)slot.usernameHeader).text != <steamName>5__2)
					{
						((TMP_Text)slot.usernameHeader).text = <steamName>5__2;
						slot.playerSteamId = player.playerSteamId;
					}
					<steamName>5__2 = null;
				}
				catch (Exception ex)
				{
					<ex>5__4 = ex;
					Plugin.Log.LogError((object)$"[FixPlayerName] UpdatePlayerName:{<ex>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);

		[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 || !StartOfRound.Instance.shipHasLanded)
			{
				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(GameNetworkManager), "Disconnect")]
		public static void OnDisconnect()
		{
			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(<FixPlayerNamesRoutine>d__11))]
		private static IEnumerator FixPlayerNamesRoutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <FixPlayerNamesRoutine>d__11(0);
		}

		[IteratorStateMachine(typeof(<RefreshPlayerNames>d__12))]
		private static IEnumerator RefreshPlayerNames()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <RefreshPlayerNames>d__12(0);
		}

		[IteratorStateMachine(typeof(<UpdatePlayerName>d__13))]
		private static IEnumerator UpdatePlayerName(PlayerControllerB player, PlayerListSlot slot)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <UpdatePlayerName>d__13(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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: 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<QuickMenuManager>();
				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)
					{
						Plugin.Log.LogInfo((object)$"[FixPlayerName] OnPersonaStateChange:{friend.Id}|{((Friend)(ref friend)).Name}");
						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<GrabbableObject>();
					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<Animator, PlayerControllerB>();
					instance.boxesAdded = 0;
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}