using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Steamworks;
using TMPro;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FixPlayerName")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FixPlayerName")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("cccf9fe4-8869-41a6-a0e0-35a6c851f5d7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace FixPlayerList;
[BepInPlugin("FixPlayerName", "FixPlayerName", "1.0.6")]
public class FixPlayerNamePlugin : BaseUnityPlugin
{
public static ManualLogSource ManualLog;
public static ConfigEntry<int> WorkInterval { get; set; }
public void Awake()
{
ManualLog = ((BaseUnityPlugin)this).Logger;
WorkInterval = ((BaseUnityPlugin)this).Config.Bind<int>("Work", "Interval", 30, "Seconds");
Harmony.CreateAndPatchAll(typeof(Patches), (string)null);
}
}
public static class Patches
{
[CompilerGenerated]
private sealed class <Fix>d__10 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
private QuickMenuManager <quick>5__1;
private PlayerControllerB[] <players>5__2;
private int <i>5__3;
private string <name>5__4;
private bool <request>5__5;
private PlayerControllerB[] <>s__6;
private int <>s__7;
private PlayerControllerB <item>5__8;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Fix>d__10(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<quick>5__1 = null;
<players>5__2 = null;
<name>5__4 = null;
<>s__6 = null;
<item>5__8 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: 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)
//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
//IL_02d6: Expected O, but got Unknown
int num = <>1__state;
if (num != 0)
{
if (num != 1)
{
return false;
}
<>1__state = -1;
<name>5__4 = null;
goto IL_02ef;
}
<>1__state = -1;
if (StartOfRound.Instance.connectedPlayersAmount == 0)
{
return false;
}
if (!Reg)
{
SteamFriends.OnPersonaStateChange += SteamFriends_OnPersonaStateChange;
Reg = true;
}
<quick>5__1 = Object.FindObjectOfType<QuickMenuManager>();
<players>5__2 = StartOfRound.Instance.allPlayerScripts;
<i>5__3 = 0;
goto IL_0301;
IL_0301:
if (<i>5__3 < <quick>5__1.playerListSlots.Length)
{
if (<quick>5__1.playerListSlots[<i>5__3].slotContainer.activeSelf)
{
if (<quick>5__1.playerListSlots[<i>5__3].playerSteamId != 0)
{
Friend val = new Friend(SteamId.op_Implicit(<players>5__2[<i>5__3].playerSteamId));
<name>5__4 = ((Friend)(ref val)).Name;
if (<name>5__4 == "[unknown]")
{
<request>5__5 = SteamFriends.RequestUserInformation(SteamId.op_Implicit(<players>5__2[<i>5__3].playerSteamId), true);
FixPlayerNamePlugin.ManualLog.LogInfo((object)$"RequestFixUnknow -> {<request>5__5}");
}
if (((TMP_Text)<quick>5__1.playerListSlots[<i>5__3].usernameHeader).text == "Nameless" && <name>5__4 != "Nameless")
{
<>s__6 = StartOfRound.Instance.allPlayerScripts;
for (<>s__7 = 0; <>s__7 < <>s__6.Length; <>s__7++)
{
<item>5__8 = <>s__6[<>s__7];
if (<item>5__8.playerSteamId != 0)
{
if (<item>5__8.playerSteamId == <quick>5__1.playerListSlots[<i>5__3].playerSteamId)
{
<item>5__8.playerUsername = <name>5__4;
((TMP_Text)<item>5__8.usernameBillboardText).text = <name>5__4;
FixPlayerNamePlugin.ManualLog.LogInfo((object)("FixNameless -> " + <name>5__4));
}
<item>5__8 = null;
}
}
<>s__6 = null;
}
((TMP_Text)<quick>5__1.playerListSlots[<i>5__3].usernameHeader).text = <name>5__4;
<>2__current = (object)new WaitForSeconds(0.1f);
<>1__state = 1;
return true;
}
<quick>5__1.playerListSlots[<i>5__3].slotContainer.SetActive(false);
}
goto IL_02ef;
}
return false;
IL_02ef:
<i>5__3++;
goto IL_0301;
}
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 <doFix>d__9 : IEnumerator<object>, IDisposable, IEnumerator
{
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 <doFix>d__9(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
<>2__current = Fix();
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
break;
}
if ((Object)(object)StartOfRound.Instance.localPlayerController != (Object)null)
{
<>2__current = (object)new WaitForSeconds((float)FixPlayerNamePlugin.WorkInterval.Value);
<>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();
}
}
private static Coroutine doFixCoroutine;
public static bool Reg { get; set; }
[HarmonyPostfix]
[HarmonyPatch(typeof(GameNetworkManager), "SteamMatchmaking_OnLobbyMemberJoined")]
public static void SteamMatchmaking_OnLobbyMemberJoinedPostfix(GameNetworkManager __instance)
{
if (!GameNetworkManager.Instance.disableSteam && StartOfRound.Instance.shipHasLanded)
{
((MonoBehaviour)__instance).StartCoroutine(Fix());
}
}
[HarmonyPriority(0)]
[HarmonyPostfix]
[HarmonyPatch(typeof(StartOfRound), "SetShipReadyToLand")]
private static void EndGamefix()
{
AccessTools.DeclaredField(typeof(HUDManager), "spectatingPlayerBoxes").SetValue(HUDManager.Instance, new Dictionary<Animator, PlayerControllerB>());
AccessTools.DeclaredField(typeof(HUDManager), "boxesAdded").SetValue(HUDManager.Instance, 0);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
public static void ConnectClientToPlayerObjectPostfix(PlayerControllerB __instance)
{
if (!GameNetworkManager.Instance.disableSteam && doFixCoroutine == null)
{
doFixCoroutine = ((MonoBehaviour)__instance).StartCoroutine(doFix());
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(GameNetworkManager), "Disconnect")]
public static void OnDestroy(PlayerControllerB __instance)
{
if (doFixCoroutine != null)
{
((MonoBehaviour)__instance).StopCoroutine(doFixCoroutine);
SteamFriends.OnPersonaStateChange -= SteamFriends_OnPersonaStateChange;
doFixCoroutine = null;
}
}
[IteratorStateMachine(typeof(<doFix>d__9))]
public static IEnumerator doFix()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <doFix>d__9(0);
}
[IteratorStateMachine(typeof(<Fix>d__10))]
private static IEnumerator Fix()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Fix>d__10(0);
}
private static void SteamFriends_OnPersonaStateChange(Friend obj)
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)StartOfRound.Instance != (Object)null) || StartOfRound.Instance.allPlayerScripts == null)
{
return;
}
QuickMenuManager val = Object.FindObjectOfType<QuickMenuManager>();
for (int i = 0; i < val.playerListSlots.Length; i++)
{
if (val.playerListSlots[i].playerSteamId == 0)
{
val.playerListSlots[i].slotContainer.SetActive(false);
}
else if (val.playerListSlots[i].playerSteamId == obj.Id.Value)
{
((TMP_Text)val.playerListSlots[i].usernameHeader).text = ((Friend)(ref obj)).Name;
}
}
PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
foreach (PlayerControllerB val2 in allPlayerScripts)
{
if (val2.playerSteamId != 0 && val2.playerSteamId == obj.Id.Value)
{
val2.playerUsername = ((Friend)(ref obj)).Name;
((TMP_Text)val2.usernameBillboardText).text = ((Friend)(ref obj)).Name;
}
}
}
}