diff --git a/src/Data/Replay/Events/AppearReplayEvent.cs b/src/Data/Replay/Events/AppearReplayEvent.cs index 8aaad9c..8b2e334 100644 --- a/src/Data/Replay/Events/AppearReplayEvent.cs +++ b/src/Data/Replay/Events/AppearReplayEvent.cs @@ -1,6 +1,7 @@ using AmongUs.GameOptions; using BetterAmongUs.Interfaces; using BetterAmongUs.Utilities; +using InnerNet; using System.Text.Json.Serialization; namespace BetterAmongUs.Data.Replay.Events; @@ -19,7 +20,7 @@ internal sealed class AppearReplayEvent : IReplayEvent { if (Value != -1) { - var player = Utils.PlayerFromPlayerId(Value); + var player = Utils.PlayerFromPlayerId((PlayerId)Value); if (player != null) return $"{player.GetPlayerNameAndColor()}"; else diff --git a/src/MonoScripts/PlayerInfoDisplay.cs b/src/MonoScripts/PlayerInfoDisplay.cs index 9c33aac..c09dbd4 100644 --- a/src/MonoScripts/PlayerInfoDisplay.cs +++ b/src/MonoScripts/PlayerInfoDisplay.cs @@ -10,6 +10,7 @@ using BetterAmongUs.Patches.Gameplay.UI.Settings; using BetterAmongUs.Structs; using BetterAmongUs.Utilities; using Il2CppInterop.Runtime.Attributes; +using InnerNet; using System.Text.RegularExpressions; using TMPro; using UnityEngine; @@ -217,7 +218,7 @@ internal class PlayerInfoDisplay : MonoBehaviour } else { - var targetData = Utils.PlayerDataFromPlayerId(_player.shapeshiftTargetPlayerId); + var targetData = Utils.PlayerDataFromPlayerId((PlayerId)_player.shapeshiftTargetPlayerId); if (targetData == null) return; diff --git a/src/Utilities/Utils.cs b/src/Utilities/Utils.cs index 7897aca..0780249 100644 --- a/src/Utilities/Utils.cs +++ b/src/Utilities/Utils.cs @@ -77,7 +77,7 @@ internal static class Utils /// /// The client ID to look up. /// The ClientData if found, null otherwise. - internal static ClientData? ClientFromClientId(int clientId) => + internal static ClientData? ClientFromClientId(ClientId clientId) => AmongUsClient.Instance.allClients.FirstOrDefaultIl2Cpp(cd => cd.Id == clientId); /// @@ -85,7 +85,7 @@ internal static class Utils /// /// The player ID to look up. /// The NetworkedPlayerInfo if found, null otherwise. - internal static NetworkedPlayerInfo? PlayerDataFromPlayerId(int playerId) => + internal static NetworkedPlayerInfo? PlayerDataFromPlayerId(PlayerId playerId) => GameData.Instance.AllPlayers.FirstOrDefaultIl2Cpp(data => data.PlayerId == playerId); /// @@ -93,7 +93,7 @@ internal static class Utils /// /// The client ID to look up. /// The NetworkedPlayerInfo if found, null otherwise. - internal static NetworkedPlayerInfo? PlayerDataFromClientId(int clientId) => + internal static NetworkedPlayerInfo? PlayerDataFromClientId(ClientId clientId) => GameData.Instance.AllPlayers.FirstOrDefaultIl2Cpp(data => data.ClientId == clientId); /// @@ -109,7 +109,7 @@ internal static class Utils /// /// The player ID to look up. /// The PlayerControl if found, null otherwise. - internal static PlayerControl? PlayerFromPlayerId(int playerId) => + internal static PlayerControl? PlayerFromPlayerId(PlayerId playerId) => BAUPlugin.AllPlayerControls.FirstOrDefault(player => player.PlayerId == playerId); /// @@ -117,7 +117,7 @@ internal static class Utils /// /// The client ID to look up. /// The PlayerControl if found, null otherwise. - internal static PlayerControl? PlayerFromClientId(int clientId) => + internal static PlayerControl? PlayerFromClientId(ClientId clientId) => BAUPlugin.AllPlayerControls.FirstOrDefault(player => player.GetClientId() == clientId); /// @@ -125,7 +125,7 @@ internal static class Utils /// /// The network ID to look up. /// The PlayerControl if found, null otherwise. - internal static PlayerControl? PlayerFromNetId(uint netId) => + internal static PlayerControl? PlayerFromNetId(NetId netId) => BAUPlugin.AllPlayerControls.FirstOrDefault(player => player.NetId == netId); // Chat functionality