mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-19 15:51:52 +00:00
Use id structs
This commit is contained in:
1 parent
0a0e5ea983
commit
671db2ed45
14 files changed
+35
-22
No files matched your search
@@ -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<AppearReplayEvent.AppearR
|
||||
if (EventData == null)
|
||||
return;
|
||||
|
||||
var player = Utils.PlayerFromPlayerId(EventData.PlayerId);
|
||||
var player = Utils.PlayerFromPlayerId((PlayerId)EventData.PlayerId);
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using BetterAmongUs.Interfaces;
|
||||
using BetterAmongUs.Utilities;
|
||||
using InnerNet;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace BetterAmongUs.Data.Replay.Events;
|
||||
@@ -18,7 +19,7 @@ internal sealed class ChatEvent : IReplayEvent<ChatEvent.ChatReplayData, ChatEve
|
||||
if (EventData == null)
|
||||
return;
|
||||
|
||||
var player = Utils.PlayerFromPlayerId(EventData.PlayerId);
|
||||
var player = Utils.PlayerFromPlayerId((PlayerId)EventData.PlayerId);
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using BetterAmongUs.Interfaces;
|
||||
using BetterAmongUs.Utilities;
|
||||
using InnerNet;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace BetterAmongUs.Data.Replay.Events;
|
||||
@@ -18,7 +19,7 @@ internal sealed class ChatNoteEvent : IReplayEvent<ChatNoteEvent.ChatNoteReplayD
|
||||
if (EventData == null)
|
||||
return;
|
||||
|
||||
var player = Utils.PlayerFromPlayerId(EventData.PlayerId);
|
||||
var player = Utils.PlayerFromPlayerId((PlayerId)EventData.PlayerId);
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using BetterAmongUs.Interfaces;
|
||||
using BetterAmongUs.Utilities;
|
||||
using InnerNet;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace BetterAmongUs.Data.Replay.Events;
|
||||
@@ -15,11 +16,11 @@ internal sealed class MurderReplayEvent : IReplayEvent<MurderReplayEvent.MurderR
|
||||
|
||||
public void Play()
|
||||
{
|
||||
var killer = Utils.PlayerFromPlayerId(EventData.KillerId);
|
||||
var killer = Utils.PlayerFromPlayerId((PlayerId)EventData.KillerId);
|
||||
if (killer == null)
|
||||
return;
|
||||
|
||||
var target = Utils.PlayerFromPlayerId(EventData.TargetId);
|
||||
var target = Utils.PlayerFromPlayerId((PlayerId)EventData.TargetId);
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -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,11 +20,11 @@ internal sealed class ProtectReplayEvent : IReplayEvent<ProtectReplayEvent.Prote
|
||||
if (EventData == null)
|
||||
return;
|
||||
|
||||
var player = Utils.PlayerFromPlayerId(EventData.PlayerId);
|
||||
var player = Utils.PlayerFromPlayerId((PlayerId)EventData.PlayerId);
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
var target = Utils.PlayerFromPlayerId(EventData.TargetId);
|
||||
var target = Utils.PlayerFromPlayerId((PlayerId)EventData.TargetId);
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using BetterAmongUs.Interfaces;
|
||||
using BetterAmongUs.Utilities;
|
||||
using InnerNet;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace BetterAmongUs.Data.Replay.Events;
|
||||
@@ -18,7 +19,7 @@ internal sealed class ProtectedReplayEvent : IReplayEvent<ProtectedReplayEvent.P
|
||||
if (EventData == null)
|
||||
return;
|
||||
|
||||
var target = Utils.PlayerFromPlayerId(EventData.TargetId);
|
||||
var target = Utils.PlayerFromPlayerId((PlayerId)EventData.TargetId);
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -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 SetRoleEvent : IReplayEvent<SetRoleEvent.SetRoleReplayData
|
||||
if (EventData == null)
|
||||
return;
|
||||
|
||||
var player = Utils.PlayerFromPlayerId(EventData.PlayerId);
|
||||
var player = Utils.PlayerFromPlayerId((PlayerId)EventData.PlayerId);
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -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,11 +20,11 @@ internal sealed class ShapeshiftReplayEvent : IReplayEvent<ShapeshiftReplayEvent
|
||||
if (EventData == null)
|
||||
return;
|
||||
|
||||
var player = Utils.PlayerFromPlayerId(EventData.PlayerId);
|
||||
var player = Utils.PlayerFromPlayerId((PlayerId)EventData.PlayerId);
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
var target = Utils.PlayerFromPlayerId(EventData.TargetId);
|
||||
var target = Utils.PlayerFromPlayerId((PlayerId)EventData.TargetId);
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using BetterAmongUs.Interfaces;
|
||||
using BetterAmongUs.Utilities;
|
||||
using InnerNet;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace BetterAmongUs.Data.Replay.Events;
|
||||
@@ -18,7 +19,7 @@ internal sealed class UpdateSystemReplayEvent : IReplayEvent<UpdateSystemReplayE
|
||||
if (EventData == null)
|
||||
return;
|
||||
|
||||
var player = Utils.PlayerFromPlayerId(EventData.PlayerId);
|
||||
var player = Utils.PlayerFromPlayerId((PlayerId)EventData.PlayerId);
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -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 VanishReplayEvent : IReplayEvent<VanishReplayEvent.VanishR
|
||||
if (EventData == null)
|
||||
return;
|
||||
|
||||
var player = Utils.PlayerFromPlayerId(EventData.PlayerId);
|
||||
var player = Utils.PlayerFromPlayerId((PlayerId)EventData.PlayerId);
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using BetterAmongUs.Interfaces;
|
||||
using BetterAmongUs.Utilities;
|
||||
using InnerNet;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace BetterAmongUs.Data.Replay.Events;
|
||||
@@ -18,7 +19,7 @@ internal sealed class VentReplayEvent : IReplayEvent<VentReplayEvent.VentReplayD
|
||||
if (EventData == null)
|
||||
return;
|
||||
|
||||
var player = Utils.PlayerFromPlayerId(EventData.PlayerId);
|
||||
var player = Utils.PlayerFromPlayerId((PlayerId)EventData.PlayerId);
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using BetterAmongUs.Generated;
|
||||
using BetterAmongUs.Utilities;
|
||||
using BetterAmongUs.Utilities.Extension;
|
||||
using InnerNet;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BetterAmongUs.Modules.OptionItems;
|
||||
@@ -238,7 +239,7 @@ public sealed class OptionPlayerItem : OptionItem<int>
|
||||
{
|
||||
if (Value != -1)
|
||||
{
|
||||
var player = Utils.PlayerFromPlayerId(Value);
|
||||
var player = Utils.PlayerFromPlayerId((PlayerId)Value);
|
||||
if (player != null)
|
||||
return $"{player.GetPlayerNameAndColor()}";
|
||||
else
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ internal static class Utils
|
||||
/// </summary>
|
||||
/// <param name="clientId">The client ID to look up.</param>
|
||||
/// <returns>The ClientData if found, null otherwise.</returns>
|
||||
internal static ClientData? ClientFromClientId(int clientId) =>
|
||||
internal static ClientData? ClientFromClientId(ClientId clientId) =>
|
||||
AmongUsClient.Instance.allClients.FirstOrDefaultIl2Cpp(cd => cd.Id == clientId);
|
||||
|
||||
/// <summary>
|
||||
@@ -85,7 +85,7 @@ internal static class Utils
|
||||
/// </summary>
|
||||
/// <param name="playerId">The player ID to look up.</param>
|
||||
/// <returns>The NetworkedPlayerInfo if found, null otherwise.</returns>
|
||||
internal static NetworkedPlayerInfo? PlayerDataFromPlayerId(int playerId) =>
|
||||
internal static NetworkedPlayerInfo? PlayerDataFromPlayerId(PlayerId playerId) =>
|
||||
GameData.Instance.AllPlayers.FirstOrDefaultIl2Cpp(data => data.PlayerId == playerId);
|
||||
|
||||
/// <summary>
|
||||
@@ -93,7 +93,7 @@ internal static class Utils
|
||||
/// </summary>
|
||||
/// <param name="clientId">The client ID to look up.</param>
|
||||
/// <returns>The NetworkedPlayerInfo if found, null otherwise.</returns>
|
||||
internal static NetworkedPlayerInfo? PlayerDataFromClientId(int clientId) =>
|
||||
internal static NetworkedPlayerInfo? PlayerDataFromClientId(ClientId clientId) =>
|
||||
GameData.Instance.AllPlayers.FirstOrDefaultIl2Cpp(data => data.ClientId == clientId);
|
||||
|
||||
/// <summary>
|
||||
@@ -109,7 +109,7 @@ internal static class Utils
|
||||
/// </summary>
|
||||
/// <param name="playerId">The player ID to look up.</param>
|
||||
/// <returns>The PlayerControl if found, null otherwise.</returns>
|
||||
internal static PlayerControl? PlayerFromPlayerId(int playerId) =>
|
||||
internal static PlayerControl? PlayerFromPlayerId(PlayerId playerId) =>
|
||||
BAUPlugin.AllPlayerControls.FirstOrDefault(player => player.PlayerId == playerId);
|
||||
|
||||
/// <summary>
|
||||
@@ -117,7 +117,7 @@ internal static class Utils
|
||||
/// </summary>
|
||||
/// <param name="clientId">The client ID to look up.</param>
|
||||
/// <returns>The PlayerControl if found, null otherwise.</returns>
|
||||
internal static PlayerControl? PlayerFromClientId(int clientId) =>
|
||||
internal static PlayerControl? PlayerFromClientId(ClientId clientId) =>
|
||||
BAUPlugin.AllPlayerControls.FirstOrDefault(player => player.GetClientId() == clientId);
|
||||
|
||||
/// <summary>
|
||||
@@ -125,7 +125,7 @@ internal static class Utils
|
||||
/// </summary>
|
||||
/// <param name="netId">The network ID to look up.</param>
|
||||
/// <returns>The PlayerControl if found, null otherwise.</returns>
|
||||
internal static PlayerControl? PlayerFromNetId(uint netId) =>
|
||||
internal static PlayerControl? PlayerFromNetId(NetId netId) =>
|
||||
BAUPlugin.AllPlayerControls.FirstOrDefault(player => player.NetId == netId);
|
||||
|
||||
// Chat functionality
|
||||
|
||||
Reference in new issue
Block a user