Files
zzz_REBIRTH__Utils/Harmony/Harmony_XUiC_PlayersList.cs
2025-06-04 16:44:53 +09:30

228 lines
17 KiB
C#

using Platform;
using System.Collections.Generic;
namespace Harmony.XUiC_PlayersListPatches
{
[HarmonyPatch(typeof(XUiC_PlayersList))]
[HarmonyPatch("updatePlayersList")]
public class updatePlayersListPatch
{
public static bool Prefix(XUiC_PlayersList __instance)
{
EntityPlayerLocal entityPlayer1 = __instance.xui.playerUI.entityPlayer;
bool hideGamestage = false;
if (RebirthVariables.customInfested == "hidesurprise"
)
{
List<Quest> listCurrentQuests = entityPlayer1.QuestJournal.quests;
for (int index = 0; index < listCurrentQuests.Count; ++index)
{
if (listCurrentQuests[index].CurrentState == Quest.QuestState.InProgress && listCurrentQuests[index].RallyMarkerActivated)
{
hideGamestage = true;
break;
}
}
}
List<XUiC_PlayersList.SEntityIdRef> sentityIdRefList = new List<XUiC_PlayersList.SEntityIdRef>();
for (int index = 0; index < GameManager.Instance.World.Players.list.Count; ++index)
{
EntityPlayer _Ref = GameManager.Instance.World.Players.list[index];
sentityIdRefList.Add(new XUiC_PlayersList.SEntityIdRef(_Ref.entityId, _Ref));
}
__instance.numberOfPlayers.Text = sentityIdRefList.Count.ToString();
__instance.playerPager.SetLastPageByElementsAndPageLength(sentityIdRefList.Count, __instance.playerList.Rows);
if (GameManager.Instance.persistentLocalPlayer.ACL != null)
{
foreach (PlatformUserIdentifierAbs _userIdentifier in GameManager.Instance.persistentLocalPlayer.ACL)
{
PersistentPlayerData playerData = GameManager.Instance.persistentPlayers.GetPlayerData(_userIdentifier);
if (playerData != null && !((UnityEngine.Object)GameManager.Instance.World.GetEntity(playerData.EntityId) != (UnityEngine.Object)null))
sentityIdRefList.Add(new XUiC_PlayersList.SEntityIdRef(playerData));
}
}
sentityIdRefList.Sort((IComparer<XUiC_PlayersList.SEntityIdRef>)new XUiC_PlayersList.PlayersSorter(entityPlayer1));
GameServerInfo gameServerInfo = SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer ? SingletonMonoBehaviour<ConnectionManager>.Instance.LocalServerInfo : SingletonMonoBehaviour<ConnectionManager>.Instance.LastGameServerInfo;
bool _showCrossplay = gameServerInfo != null && gameServerInfo.AllowsCrossplay;
if (!_showCrossplay)
{
EPlayGroup playGroup1 = DeviceFlags.Current.ToPlayGroup();
for (int index = 0; index < sentityIdRefList.Count; ++index)
{
EPlayGroup playGroup2 = sentityIdRefList[index].PlayerData.PlayGroup;
if (playGroup2 != EPlayGroup.Unknown && playGroup2 != playGroup1)
{
_showCrossplay = true;
break;
}
}
}
int index1;
for (index1 = 0; index1 < __instance.playerList.Rows && index1 < sentityIdRefList.Count; ++index1)
{
int index2 = index1 + __instance.playerList.Rows * __instance.playerPager.GetPage();
if (index2 < sentityIdRefList.Count)
{
XUiC_PlayersListEntry playerEntry = __instance.playerEntries[index1];
if (playerEntry != null)
{
EntityPlayer entityPlayer2 = sentityIdRefList[index2].Ref;
bool flag1 = (UnityEngine.Object)entityPlayer2 != (UnityEngine.Object)null && (UnityEngine.Object)entityPlayer2 != (UnityEngine.Object)entityPlayer1 && entityPlayer2.IsInPartyOfLocalPlayer;
bool flag2 = (UnityEngine.Object)entityPlayer2 == (UnityEngine.Object)null || (UnityEngine.Object)entityPlayer2 != (UnityEngine.Object)entityPlayer1 && entityPlayer2.IsFriendOfLocalPlayer;
if (!((UnityEngine.Object)entityPlayer2 == (UnityEngine.Object)null))
{
int entityId = entityPlayer2.entityId;
}
PersistentPlayerData persistentPlayerData = sentityIdRefList[index2].PlayerId != null ? GameManager.Instance.persistentPlayers.GetPlayerData(sentityIdRefList[index2].PlayerId) : GameManager.Instance.persistentPlayers.GetPlayerDataFromEntityID(entityPlayer2.entityId);
if (persistentPlayerData != null)
{
foreach (EBlockType _blockType in (IEnumerable<EBlockType>)EnumUtils.Values<EBlockType>())
playerEntry.playerBlockStateChanged(persistentPlayerData.PlatformData, _blockType, persistentPlayerData.PlatformData.Blocked[_blockType].State);
if ((UnityEngine.Object)entityPlayer2 != (UnityEngine.Object)null)
{
playerEntry.IsOffline = false;
playerEntry.EntityId = entityPlayer2.entityId;
playerEntry.PlayerData = persistentPlayerData;
playerEntry.ViewComponent.IsVisible = true;
playerEntry.PlayerName.UpdatePlayerData(persistentPlayerData.PlayerData, _showCrossplay, persistentPlayerData.PlayerName.DisplayName);
playerEntry.AdminSprite.IsVisible = entityPlayer2.IsAdmin;
playerEntry.TwitchSprite.IsVisible = entityPlayer2.TwitchEnabled && entityPlayer2.TwitchActionsEnabled == EntityPlayer.TwitchActionsStates.Enabled;
playerEntry.TwitchDisabledSprite.IsVisible = entityPlayer2.TwitchActionsEnabled != EntityPlayer.TwitchActionsStates.Enabled || entityPlayer2.TwitchSafe;
playerEntry.TwitchDisabledSprite.SpriteName = entityPlayer2.TwitchActionsEnabled != EntityPlayer.TwitchActionsStates.Enabled ? "ui_game_symbol_twitch_action_disabled" : "ui_game_symbol_brick";
playerEntry.TwitchDisabledSprite.ToolTip = entityPlayer2.TwitchActionsEnabled != EntityPlayer.TwitchActionsStates.Enabled ? XUiC_PlayersList.twitchDisabled : XUiC_PlayersList.twitchSafe;
XUiV_Label zombieKillsText = playerEntry.ZombieKillsText;
int num = entityPlayer2.KilledZombies;
string str1 = num.ToString();
zombieKillsText.Text = str1;
XUiV_Label playerKillsText = playerEntry.PlayerKillsText;
num = entityPlayer2.KilledPlayers;
string str2 = num.ToString();
playerKillsText.Text = str2;
XUiV_Label deathsText = playerEntry.DeathsText;
num = entityPlayer2.Died;
string str3 = num.ToString();
deathsText.Text = str3;
XUiV_Label levelText = playerEntry.LevelText;
num = entityPlayer2.Progression.GetLevel();
string str4 = num.ToString();
levelText.Text = str4;
XUiV_Label gamestageText = playerEntry.GamestageText;
num = entityPlayer2.gameStage;
string str5 = num.ToString();
gamestageText.Text = str5;
if (hideGamestage)
{
gamestageText.Text = "N/A";
}
playerEntry.PingText.Text = !((UnityEngine.Object)entityPlayer2 == (UnityEngine.Object)entityPlayer1) || !SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer ? (entityPlayer2.pingToServer < 0 ? "--" : entityPlayer2.pingToServer.ToString()) : "--";
playerEntry.Voice.IsVisible = (UnityEngine.Object)entityPlayer2 != (UnityEngine.Object)entityPlayer1;
playerEntry.Chat.IsVisible = (UnityEngine.Object)entityPlayer2 != (UnityEngine.Object)entityPlayer1;
playerEntry.IsFriend = flag2;
playerEntry.ShowOnMapEnabled = flag2 | flag1;
if (flag2 | flag1)
{
float magnitude = (entityPlayer2.GetPosition() - entityPlayer1.GetPosition()).magnitude;
playerEntry.DistanceToFriend.Text = ValueDisplayFormatters.Distance(magnitude);
}
else
playerEntry.DistanceToFriend.Text = "--";
playerEntry.buttonReportPlayer.IsVisible = PlatformManager.MultiPlatform.PlayerReporting != null && (UnityEngine.Object)entityPlayer2 != (UnityEngine.Object)entityPlayer1;
playerEntry.AllyStatus = !((UnityEngine.Object)entityPlayer2 == (UnityEngine.Object)entityPlayer1) ? (!flag2 ? (!__instance.invitesReceivedList.Contains(persistentPlayerData.PrimaryId) ? (!__instance.invitesSentList.Contains(persistentPlayerData.PrimaryId) ? XUiC_PlayersListEntry.EnumAllyInviteStatus.NA : XUiC_PlayersListEntry.EnumAllyInviteStatus.Sent) : XUiC_PlayersListEntry.EnumAllyInviteStatus.Received) : XUiC_PlayersListEntry.EnumAllyInviteStatus.Friends) : XUiC_PlayersListEntry.EnumAllyInviteStatus.LocalPlayer;
if ((UnityEngine.Object)entityPlayer2 == (UnityEngine.Object)entityPlayer1)
playerEntry.PartyStatus = !entityPlayer1.partyInvites.Contains(entityPlayer2) ? (!entityPlayer1.IsInParty() ? XUiC_PlayersListEntry.EnumPartyStatus.LocalPlayer_NoParty : ((UnityEngine.Object)entityPlayer1.Party.Leader == (UnityEngine.Object)entityPlayer1 ? XUiC_PlayersListEntry.EnumPartyStatus.LocalPlayer_InPartyAsLead : XUiC_PlayersListEntry.EnumPartyStatus.LocalPlayer_InParty)) : XUiC_PlayersListEntry.EnumPartyStatus.LocalPlayer_Received;
else if (entityPlayer1.IsInParty())
{
bool flag3 = entityPlayer1.IsPartyLead();
playerEntry.PartyStatus = !entityPlayer1.Party.MemberList.Contains(entityPlayer2) ? (!entityPlayer2.IsInParty() || !entityPlayer2.Party.IsFull() ? (flag3 ? XUiC_PlayersListEntry.EnumPartyStatus.OtherPlayer_NoPartyAsLead : XUiC_PlayersListEntry.EnumPartyStatus.OtherPlayer_NoParty) : XUiC_PlayersListEntry.EnumPartyStatus.OtherPlayer_PartyFullAsLead) : (!flag3 ? (entityPlayer2.IsPartyLead() ? XUiC_PlayersListEntry.EnumPartyStatus.OtherPlayer_InPartyIsLead : XUiC_PlayersListEntry.EnumPartyStatus.OtherPlayer_InParty) : XUiC_PlayersListEntry.EnumPartyStatus.OtherPlayer_InPartyAsLead);
}
else if (entityPlayer1.partyInvites.Contains(entityPlayer2))
{
if (entityPlayer2.IsInParty() && entityPlayer2.Party.IsFull())
{
playerEntry.PartyStatus = XUiC_PlayersListEntry.EnumPartyStatus.OtherPlayer_NoPartyAsLead;
entityPlayer1.partyInvites.Remove(entityPlayer2);
}
else
playerEntry.PartyStatus = XUiC_PlayersListEntry.EnumPartyStatus.LocalPlayer_Received;
}
else
{
entityPlayer2.IsInParty();
playerEntry.PartyStatus = XUiC_PlayersListEntry.EnumPartyStatus.OtherPlayer_NoPartyAsLead;
}
}
else
{
playerEntry.IsOffline = true;
playerEntry.EntityId = -1;
playerEntry.PlayerData = persistentPlayerData;
playerEntry.PlayerName.UpdatePlayerData(persistentPlayerData.PlayerData, _showCrossplay, persistentPlayerData.PlayerName.DisplayName ?? sentityIdRefList[index2].PlayerId.CombinedString);
playerEntry.AdminSprite.IsVisible = false;
playerEntry.TwitchSprite.IsVisible = false;
playerEntry.TwitchDisabledSprite.IsVisible = false;
playerEntry.DistanceToFriend.IsVisible = true;
playerEntry.DistanceToFriend.Text = "--";
playerEntry.ZombieKillsText.Text = "--";
playerEntry.PlayerKillsText.Text = "--";
playerEntry.DeathsText.Text = "--";
playerEntry.LevelText.Text = "--";
playerEntry.GamestageText.Text = "--";
playerEntry.PingText.Text = "--";
playerEntry.Voice.IsVisible = false;
playerEntry.Chat.IsVisible = false;
playerEntry.IsOffline = true;
playerEntry.AllyStatus = !((UnityEngine.Object)entityPlayer2 == (UnityEngine.Object)entityPlayer1) ? (!flag2 ? (!__instance.invitesReceivedList.Contains(persistentPlayerData.PrimaryId) ? (!__instance.invitesSentList.Contains(persistentPlayerData.PrimaryId) ? XUiC_PlayersListEntry.EnumAllyInviteStatus.NA : XUiC_PlayersListEntry.EnumAllyInviteStatus.Sent) : XUiC_PlayersListEntry.EnumAllyInviteStatus.Received) : XUiC_PlayersListEntry.EnumAllyInviteStatus.Friends) : XUiC_PlayersListEntry.EnumAllyInviteStatus.LocalPlayer;
playerEntry.PartyStatus = XUiC_PlayersListEntry.EnumPartyStatus.Offline;
playerEntry.labelPartyIcon.IsVisible = true;
playerEntry.buttonReportPlayer.IsVisible = true;
playerEntry.buttonShowOnMap.IsVisible = false;
playerEntry.labelShowOnMap.IsVisible = true;
}
playerEntry.RefreshBindings();
}
}
}
else
break;
}
for (; index1 < __instance.playerList.Rows; ++index1)
{
XUiC_PlayersListEntry playerEntry = __instance.playerEntries[index1];
if (playerEntry != null)
{
playerEntry.EntityId = -1;
playerEntry.PlayerData = (PersistentPlayerData)null;
playerEntry.PlayerName.ClearPlayerData();
playerEntry.AdminSprite.IsVisible = false;
playerEntry.TwitchSprite.IsVisible = false;
playerEntry.TwitchDisabledSprite.IsVisible = false;
playerEntry.ZombieKillsText.Text = string.Empty;
playerEntry.PlayerKillsText.Text = string.Empty;
playerEntry.DeathsText.Text = string.Empty;
playerEntry.LevelText.Text = string.Empty;
playerEntry.GamestageText.Text = string.Empty;
playerEntry.PingText.Text = string.Empty;
playerEntry.Voice.IsVisible = false;
playerEntry.Chat.IsVisible = false;
playerEntry.ShowOnMapEnabled = false;
playerEntry.DistanceToFriend.IsVisible = false;
playerEntry.AllyStatus = XUiC_PlayersListEntry.EnumAllyInviteStatus.Empty;
playerEntry.PartyStatus = XUiC_PlayersListEntry.EnumPartyStatus.Offline;
playerEntry.buttonReportPlayer.IsVisible = false;
playerEntry.labelAllyIcon.IsVisible = false;
playerEntry.labelPartyIcon.IsVisible = false;
playerEntry.labelShowOnMap.IsVisible = false;
}
}
return false;
}
}
}