diff --git a/Modules/AntiCheat.cs b/Modules/AntiCheat.cs
index e8d8153..1fccf3c 100644
--- a/Modules/AntiCheat.cs
+++ b/Modules/AntiCheat.cs
@@ -100,7 +100,7 @@ class AntiCheat
{
MessageReader reader = MessageReader.Get(Oldreader);
- if (player == PlayerControl.LocalPlayer || PlayerControl.LocalPlayer == null || player == null || !IsEnabled) return;
+ if (player.IsLocalPlayer() || player == null || !IsEnabled) return;
if (callId is unchecked((byte)CustomRPC.Sicko) && Main.AntiCheat.Value && BetterGameSettings.DetectCheatClients.GetBool())
{
@@ -182,7 +182,7 @@ class AntiCheat
{
MessageReader reader = MessageReader.Get(Oldreader);
- if (PlayerControl.LocalPlayer == null || player == null || player == PlayerControl.LocalPlayer || player.BetterData().IsBetterHost || reader == null || !IsEnabled || !Main.AntiCheat.Value
+ if (player == null || player.IsLocalPlayer() || player.BetterData().IsBetterHost || reader == null || !IsEnabled || !Main.AntiCheat.Value
|| (GameStates.IsBetterHostLobby && !GameStates.IsHost) || !BetterGameSettings.DetectInvalidRPCs.GetBool()) return;
RoleTypes? Role = player?.Data?.RoleType;
@@ -352,7 +352,7 @@ class AntiCheat
}
}
- if (!GameStates.IsHost || PlayerControl.LocalPlayer == null || player == null || player == PlayerControl.LocalPlayer || player.BetterData().IsBetterHost || !IsEnabled || !Main.AntiCheat.Value
+ if (!GameStates.IsHost || PlayerControl.LocalPlayer == null || player == null || player.IsLocalPlayer() || player.BetterData().IsBetterHost || !IsEnabled || !Main.AntiCheat.Value
|| (GameStates.IsBetterHostLobby && !GameStates.IsHost) || !BetterGameSettings.DetectInvalidRPCs.GetBool()) return true;
if (!BetterGameSettings.CancelInvalidSabotage.GetBool())
@@ -478,7 +478,7 @@ class AntiCheat
{
MessageReader reader = MessageReader.Get(Oldreader);
- if (PlayerControl.LocalPlayer == null || player == null || player == PlayerControl.LocalPlayer || player.BetterData().IsBetterHost || reader == null) return true;
+ if (PlayerControl.LocalPlayer == null || player == null || player.IsLocalPlayer() || player.BetterData().IsBetterHost || reader == null) return true;
// Prevent ban exploit
if (callId is (byte)RpcCalls.MurderPlayer)
@@ -489,7 +489,7 @@ class AntiCheat
if (target != null)
{
- if (target == PlayerControl.LocalPlayer)
+ if (target.IsLocalPlayer())
{
target.BetterData().AntiCheatInfo.TimesAttemptedKilled++;
diff --git a/Modules/BetterHostManager.cs b/Modules/BetterHostManager.cs
index d34d4bd..d34c8fc 100644
--- a/Modules/BetterHostManager.cs
+++ b/Modules/BetterHostManager.cs
@@ -206,7 +206,7 @@ class BetterHostManager
foreach (PlayerControl target in Main.AllPlayerControls)
{
- if (target == null || target == PlayerControl.LocalPlayer) continue;
+ if (target == null || target.IsLocalPlayer()) continue;
string NewName = player.CurrentOutfit.PlayerName;
@@ -224,7 +224,7 @@ class BetterHostManager
if (player.IsDev())
sbTopTag.Append("(Dev)+++");
- if (player == PlayerControl.LocalPlayer)
+ if (player.IsLocalPlayer())
sbTopTag.Append($"Better Host+++");
else if (player.BetterData().IsBetterUser)
sbTopTag.Append("Better User+++");
diff --git a/Modules/ExtendedPlayerControl.cs b/Modules/ExtendedPlayerControl.cs
index f6c5888..25c7015 100644
--- a/Modules/ExtendedPlayerControl.cs
+++ b/Modules/ExtendedPlayerControl.cs
@@ -68,7 +68,6 @@ static class ExtendedPlayerControl
textObj.text = text;
}
}
-
// Reset players over head text
public static void ResetAllPlayerTextInfo(this PlayerControl player)
{
@@ -99,7 +98,6 @@ static class ExtendedPlayerControl
}
return true;
}
-
// Kick player
public static void Kick(this PlayerControl player, bool ban = false, string setReasonInfo = "", bool AntiCheatBan = false)
{
@@ -127,7 +125,7 @@ static class ExtendedPlayerControl
player.BetterData().AntiCheatInfo.BannedByAntiCheat = AntiCheatBan;
}
-
+ // Set color outline on player
public static void SetOutline(this PlayerControl player, bool active, Color? color = null)
{
player.cosmetics.currentBodySprite.BodySprite.material.SetFloat("_Outline", (float)(active ? 1 : 0));
@@ -146,6 +144,7 @@ static class ExtendedPlayerControl
}
}
}
+ // Set color outline on player
public static void SetOutlineByHex(this PlayerControl player, bool active, string hexColor = "")
{
Color color = Utils.HexToColor32(hexColor);
@@ -165,26 +164,27 @@ static class ExtendedPlayerControl
}
}
}
-
// RPCs
+ // Set name for Target
public static void RpcSetNamePrivate(this PlayerControl player, string name, PlayerControl target)
{
if (player == null || target == null) return;
RPC.SetNamePrivate(player, name, target);
}
-
+ // Exile player
public static void RpcExile(this PlayerControl player)
{
if (player == null) return;
RPC.ExileAsync(player);
}
-
+ // Check if player is selecting room to spawn in, for Airship
public static bool IsInRoomSelect(this PlayerControl player)
{
if (player == null) return false;
return GameStates.AirshipIsActive && Vector2.Distance(player.GetTruePosition(), new(-25, 40)) < 5f;
}
-
+ // Check if player controller is self client
+ public static bool IsLocalPlayer(this PlayerControl player) => player != null && PlayerControl.LocalPlayer != null && player == PlayerControl.LocalPlayer;
// Get vent Id that the player is in.
public static int GetPlayerVentId(this PlayerControl player)
{
@@ -196,9 +196,8 @@ static class ExtendedPlayerControl
return ventilationSystem.PlayersInsideVents.TryGetValue(player.PlayerId, out var playerIdVentId) ? playerIdVentId : -1;
}
-
+ // Get true position
public static Vector2 GetCustomPosition(this PlayerControl player) => new(player.transform.position.x, player.transform.position.y);
-
// Check if player is a dev
public static bool IsDev(this PlayerControl player) => player != null && Main.DevUser.Contains($"{Utils.GetHashPuid(player)}+{player.Data.FriendCode}");
// Check if player is alive
@@ -254,7 +253,7 @@ static class ExtendedPlayerControl
// Check if player is a imposter teammate
public static bool IsImpostorTeammate(this PlayerControl player) =>
player != null && PlayerControl.LocalPlayer != null &&
- ((player == PlayerControl.LocalPlayer && PlayerControl.LocalPlayer.IsImpostorTeam()) ||
+ ((player.IsLocalPlayer() && PlayerControl.LocalPlayer.IsImpostorTeam()) ||
(PlayerControl.LocalPlayer.IsImpostorTeam() && player.IsImpostorTeam()));
// Check if player is in the Anti-Cheat list
public static bool IsCheater(this PlayerControl player) =>
diff --git a/Modules/RPC.cs b/Modules/RPC.cs
index e7b50ab..aca33d2 100644
--- a/Modules/RPC.cs
+++ b/Modules/RPC.cs
@@ -98,7 +98,7 @@ internal static class RPC
return;
}
- foreach (var player in Main.AllPlayerControls.Where(pc => pc != PlayerControl.LocalPlayer))
+ foreach (var player in Main.AllPlayerControls.Where(pc => !pc.IsLocalPlayer()))
{
var optionsByteArray = GameOptionsManager.Instance.gameOptionsFactory.ToBytes(GameOptionsManager.Instance.CurrentGameOptions, false);
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.SyncSettings, SendOption.None, player.GetClientId());
@@ -151,7 +151,7 @@ internal static class RPC
public static void HandleCustomRPC(PlayerControl player, byte callId, MessageReader oldReader)
{
- if (PlayerControl.LocalPlayer == null || player == null || player == PlayerControl.LocalPlayer || player.Data == null) return;
+ if (player == null || player.IsLocalPlayer() || player.Data == null) return;
if (!Enum.IsDefined(typeof(CustomRPC), (int)unchecked(callId))) return;
@@ -209,7 +209,7 @@ internal static class RPC
public static void HandleRPC(PlayerControl player, byte callId, MessageReader oldReader)
{
- if (PlayerControl.LocalPlayer == null || player == null || player == PlayerControl.LocalPlayer || player.Data == null) return;
+ if (player == null || player.IsLocalPlayer() || player.Data == null) return;
MessageReader reader = MessageReader.Get(oldReader);
@@ -223,7 +223,7 @@ internal static class RPC
case (byte)RpcCalls.SendChat:
var text = reader.ReadString();
- if (player.IsHost() && player != PlayerControl.LocalPlayer)
+ if (player.IsHost() && !player.IsLocalPlayer())
{
if (text.ToLower() == "/allow")
{
diff --git a/Patches/ChatPatch.cs b/Patches/ChatPatch.cs
index d5669c7..e3adc9c 100644
--- a/Patches/ChatPatch.cs
+++ b/Patches/ChatPatch.cs
@@ -131,7 +131,7 @@ class ChatPatch
pooledBubble.transform.SetParent(__instance.scroller.Inner);
pooledBubble.transform.localScale = Vector3.one;
- bool flag = sourcePlayer == PlayerControl.LocalPlayer;
+ bool flag = sourcePlayer.IsLocalPlayer();
if (flag)
{
pooledBubble.SetRight();
@@ -176,10 +176,10 @@ class ChatPatch
if (sourcePlayer.IsDev())
sbTag.Append("Dev+++");
- if (((sourcePlayer == PlayerControl.LocalPlayer && GameStates.IsHost && Main.BetterHost.Value)
- || (sourcePlayer != PlayerControl.LocalPlayer && sourcePlayer.BetterData().IsBetterHost && sourcePlayer.IsHost())))
+ if (((sourcePlayer.IsLocalPlayer() && GameStates.IsHost && Main.BetterHost.Value)
+ || (!sourcePlayer.IsLocalPlayer() && sourcePlayer.BetterData().IsBetterHost && sourcePlayer.IsHost())))
sbTag.Append("Better Host+++");
- else if ((sourcePlayer == PlayerControl.LocalPlayer || sourcePlayer.BetterData().IsBetterUser))
+ else if ((sourcePlayer.IsLocalPlayer() || sourcePlayer.BetterData().IsBetterUser))
sbTag.Append("Better User+++");
if (!string.IsNullOrEmpty(hashPuid) && AntiCheat.SickoData.ContainsKey(hashPuid) || !string.IsNullOrEmpty(friendCode) && AntiCheat.SickoData.ContainsValue(friendCode))
@@ -192,7 +192,7 @@ class ChatPatch
if (!sourcePlayer.IsImpostorTeammate())
{
- if (PlayerControl.LocalPlayer.IsAlive() && sourcePlayer != PlayerControl.LocalPlayer)
+ if (PlayerControl.LocalPlayer.IsAlive() && !sourcePlayer.IsLocalPlayer())
{
Role = "";
}
diff --git a/Patches/CommandsPatch.cs b/Patches/CommandsPatch.cs
index ec75c48..3334463 100644
--- a/Patches/CommandsPatch.cs
+++ b/Patches/CommandsPatch.cs
@@ -347,7 +347,7 @@ class CommandsPatch
else if (HandlePlayerArgument(command, subArgs) == true)
{
var player = cmdTarget;
- if (player == PlayerControl.LocalPlayer)
+ if (player.IsLocalPlayer())
{
Utils.AddChatPrivate($"{error}\nUnable to use /SetRole for self, use /Role!");
return;
diff --git a/Patches/MeetingHudPatch.cs b/Patches/MeetingHudPatch.cs
index b3d12aa..71ef7dc 100644
--- a/Patches/MeetingHudPatch.cs
+++ b/Patches/MeetingHudPatch.cs
@@ -153,7 +153,7 @@ class MeetingHudUpdatePatch
}
if (!target.IsImpostorTeammate())
{
- if (PlayerControl.LocalPlayer.IsAlive() && target != PlayerControl.LocalPlayer)
+ if (PlayerControl.LocalPlayer.IsAlive() && !target.IsLocalPlayer())
{
if (!DebugMenu.RevealRoles)
{
diff --git a/Patches/PingTrackerPatch.cs b/Patches/PingTrackerPatch.cs
index 741692c..4a64ef4 100644
--- a/Patches/PingTrackerPatch.cs
+++ b/Patches/PingTrackerPatch.cs
@@ -32,7 +32,7 @@ public class PingTrackerPatch
sb.Append($"BetterAmongUs {Main.GetVersionText(true)}\n");
// sb.Append("By The Enhanced Network\n");
- sb.Append($"{Main.Github}\n");
+ sb.Append($"{Main.Github}\n");
if (Main.BetterHost.Value && GameStates.IsHost)
{
diff --git a/Patches/PlayerControlPatch.cs b/Patches/PlayerControlPatch.cs
index b9b116a..53950ef 100644
--- a/Patches/PlayerControlPatch.cs
+++ b/Patches/PlayerControlPatch.cs
@@ -172,11 +172,11 @@ class PlayerControlPatch
if (player.IsDev() && !GameStates.IsInGamePlay)
sbTag.Append("(Dev)+++");
- if (((player == PlayerControl.LocalPlayer && GameStates.IsHost && Main.BetterHost.Value)
- || (player != PlayerControl.LocalPlayer && player.BetterData().IsBetterHost && player.IsHost())) && !GameStates.IsInGamePlay)
- sbTag.Append("Better Host+++");
- else if ((player == PlayerControl.LocalPlayer || player.BetterData().IsBetterUser) && !GameStates.IsInGamePlay)
- sbTag.Append("Better User+++");
+ if (((player.IsLocalPlayer() && GameStates.IsHost && Main.BetterHost.Value)
+ || (!player.IsLocalPlayer() && player.BetterData().IsBetterHost && player.IsHost())) && !GameStates.IsInGamePlay)
+ sbTag.AppendFormat("{0}Better Host+++", player.BetterData().IsVerifiedBetterUser || player.IsLocalPlayer() ? "✓ " : "");
+ else if ((player.IsLocalPlayer() || player.BetterData().IsBetterUser) && !GameStates.IsInGamePlay)
+ sbTag.AppendFormat("{0}Better User+++", player.BetterData().IsVerifiedBetterUser || player.IsLocalPlayer() ? "✓ " : "");
sbTag.Append($"ID: {player.PlayerId}+++");
sbTagTop.Append($"{platform}+++");
@@ -187,7 +187,7 @@ class PlayerControlPatch
}
else if ((GameStates.IsInGame || GameStates.IsFreePlay) && !GameStates.IsHideNSeek)
{
- if (player.IsImpostorTeammate() || player == PlayerControl.LocalPlayer || !PlayerControl.LocalPlayer.IsAlive() || DebugMenu.RevealRoles)
+ if (player.IsImpostorTeammate() || player.IsLocalPlayer() || !PlayerControl.LocalPlayer.IsAlive() || DebugMenu.RevealRoles)
{
string Role = $"{player.GetRoleName()}";
if (!player.IsImpostorTeam() && player.myTasks.Count > 0)
@@ -203,7 +203,7 @@ class PlayerControlPatch
}
else if (GameStates.IsInGame || GameStates.IsFreePlay)
{
- if (player == PlayerControl.LocalPlayer)
+ if (player.IsLocalPlayer())
{
if (player.IsImpostorTeam())
{
@@ -216,7 +216,7 @@ class PlayerControlPatch
}
}
- if (player.IsImpostorTeammate() && player != PlayerControl.LocalPlayer)
+ if (player.IsImpostorTeammate() && !player.IsLocalPlayer())
{
NewName = $"{player.Data.PlayerName}";
}
diff --git a/Patches/RoleManagerPatch.cs b/Patches/RoleManagerPatch.cs
index 10686c2..01f8183 100644
--- a/Patches/RoleManagerPatch.cs
+++ b/Patches/RoleManagerPatch.cs
@@ -92,7 +92,7 @@ public class RoleManagerPatch
// Override player role assignment
if (SetPlayerRole.Keys.Any())
{
- foreach (var kvp in SetPlayerRole.Where(kvp => kvp.Key != null).OrderBy(kvp => kvp.Key == PlayerControl.LocalPlayer ? 0 : 1))
+ foreach (var kvp in SetPlayerRole.Where(kvp => kvp.Key != null).OrderBy(kvp => kvp.Key.IsLocalPlayer() ? 0 : 1))
{
var player = kvp.Key;
var role = kvp.Value;
@@ -311,7 +311,7 @@ public class RoleManagerPatch
// Override player role assignment
if (SetPlayerRole.Keys.Any())
{
- foreach (var kvp in SetPlayerRole.Where(kvp => kvp.Key != null).OrderBy(kvp => kvp.Key == PlayerControl.LocalPlayer ? 0 : 1))
+ foreach (var kvp in SetPlayerRole.Where(kvp => kvp.Key != null).OrderBy(kvp => kvp.Key.IsLocalPlayer() ? 0 : 1))
{
var player = kvp.Key;
var role = kvp.Value;