Skip to content
This repository was archived by the owner on Sep 24, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions GameModes/FFAManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@ public static void ReceiveRPCSyncNameNotify(MessageReader reader)
{
var name = reader.ReadString();
NameNotify.Remove(PlayerControl.LocalPlayer.PlayerId);
if (name != null && name != string.Empty)
if (!name.IsNullOrWhiteSpace())
NameNotify.Add(PlayerControl.LocalPlayer.PlayerId, (name, 0));
}
public static Dictionary<byte, (string TEXT, long TIMESTAMP)> NameNotify = [];
public static void GetNameNotify(PlayerControl player, ref string name)
{
if (Options.CurrentGameMode != CustomGameMode.FFA || player == null) return;
if (Options.CurrentGameMode != CustomGameMode.FFA || !player) return;
if (NameNotify.ContainsKey(player.PlayerId))
{
name = NameNotify[player.PlayerId].TEXT;
Expand Down Expand Up @@ -186,7 +186,7 @@ public static string GetHudText()
}
public static void OnPlayerAttack(PlayerControl killer, PlayerControl target)
{
if (killer == null || target == null || Options.CurrentGameMode != CustomGameMode.FFA) return;
if (!killer || !target || Options.CurrentGameMode != CustomGameMode.FFA) return;
if (target.inVent)
{
Logger.Info("Target is in a vent, kill blocked", "FFA");
Expand Down Expand Up @@ -385,7 +385,7 @@ public static bool CheckCoEnterVent(PlayerPhysics physics, int ventId)

public static void CoExitVent(PlayerControl player)
{
if (player == null) return;
if (!player) return;

var now = Utils.GetTimeStamp();
byte playerId = player.PlayerId;
Expand All @@ -403,7 +403,7 @@ public static void CoExitVent(PlayerControl player)
public static string GetPlayerArrow(PlayerControl seer, PlayerControl target = null)
{
if (GameStates.IsMeeting) return string.Empty;
if (target != null && seer.PlayerId != target.PlayerId) return string.Empty;
if (target && seer.PlayerId != target.PlayerId) return string.Empty;
if (Main.AllAlivePlayerControls.Count != 2) return string.Empty;

string arrows = string.Empty;
Expand All @@ -413,7 +413,7 @@ public static string GetPlayerArrow(PlayerControl seer, PlayerControl target = n
otherPlayer = pc;
break;
}
if (otherPlayer == null) return string.Empty;
if (!otherPlayer) return string.Empty;

var arrow = TargetArrow.GetArrows(seer, otherPlayer.PlayerId);
arrows += Utils.ColorString(Utils.GetRoleColor(CustomRoles.Killer), arrow);
Expand Down Expand Up @@ -496,7 +496,7 @@ public static void Postfix()

foreach (PlayerControl pc in Main.EnumerateAlivePlayerControls())
{
if (pc == null) return;
if (!pc) return;

bool sync = false;

Expand Down
2 changes: 1 addition & 1 deletion GameModes/SpeedRun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ public override string GetMarkOthers(PlayerControl seer, PlayerControl seen, boo

public override string GetSuffix(PlayerControl seer, PlayerControl target, bool isForMeeting = false)
{
if (target != null && seer.PlayerId != target.PlayerId) return "";
if (target && seer.PlayerId != target.PlayerId) return "";
if (!seer.IsAlive() || !SpeedRun.SpeedRun_ArrowPlayers.GetBool()) return "";

var listing = Main.EnumerateAlivePlayerControls().Where(x => x.Is(CustomRoles.Runner));
Expand Down
4 changes: 2 additions & 2 deletions Helpers/EnumHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public static List<TEnum[]> Achunk<TEnum>(int chunkSize, bool shuffle = false, F
{
List<TEnum[]> chunkedList = [];
TEnum[] allValues = GetAllValues<TEnum>();
if (shuffle) allValues = allValues.Shuffle().ToArray();
if (exclude != null) allValues = allValues.Where(exclude).ToArray();
if (shuffle) allValues = [.. allValues.Shuffle()];
if (exclude != null) allValues = [.. allValues.Where(exclude)];

for (int i = 0; i < allValues.Length; i += chunkSize)
{
Expand Down
4 changes: 2 additions & 2 deletions Helpers/ObjectHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public static class ObjectHelper
public static void DestroyTranslator(this GameObject obj)
{
var translator = obj.GetComponent<TextTranslatorTMP>();
if (translator != null)
if (translator)
{
Object.Destroy(translator);
}
Expand All @@ -21,7 +21,7 @@ public static bool HasParentInHierarchy(this GameObject obj, string parentPath)
int pathIndex = pathParts.Length - 1;
Transform current = obj.transform;

while (current != null)
while (current)
{
if (current.name == pathParts[pathIndex])
{
Expand Down
4 changes: 2 additions & 2 deletions Modules/AFKDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static void SetupCustomOption()

public static void RecordPosition(PlayerControl pc)
{
if (!EnableDetector.GetBool() || !GameStates.IsInTask || pc == null || ExemptedPlayers.Contains(pc.PlayerId) || Options.CurrentGameMode is CustomGameMode.FFA) return;
if (!EnableDetector.GetBool() || !GameStates.IsInTask || !pc || ExemptedPlayers.Contains(pc.PlayerId) || Options.CurrentGameMode is CustomGameMode.FFA) return;

var waitingTime = 10f;
if (!pc.IsAlive()) waitingTime += 5f;
Expand All @@ -58,7 +58,7 @@ public static void RecordPosition(PlayerControl pc)

public static void OnFixedUpdate(PlayerControl pc)
{
if (!EnableDetector.GetBool() || !GameStates.IsInTask || ExileController.Instance || Main.AllAlivePlayerControls.Count < MinPlayersToActivate.GetInt() || pc == null || !PlayerData.TryGetValue(pc.PlayerId, out Data data)) return;
if (!EnableDetector.GetBool() || !GameStates.IsInTask || ExileController.Instance || Main.AllAlivePlayerControls.Count < MinPlayersToActivate.GetInt() || !pc || !PlayerData.TryGetValue(pc.PlayerId, out Data data)) return;

if (Vector2.Distance(pc.GetCustomPosition(), data.LastPosition) > 0.1f && !TempIgnoredPlayers.Contains(pc.PlayerId))
{
Expand Down
4 changes: 2 additions & 2 deletions Modules/AdminProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static SortedDictionary<SystemTypes, AdminEntry> CalculateAdmin()
{
var roomId = room.RoomId;
// If it's not a passage or a hit-and-run, it's nothing
if (roomId == SystemTypes.Hallway || room.roomArea == null)
if (roomId == SystemTypes.Hallway || !room.roomArea)
{
continue;
}
Expand All @@ -50,7 +50,7 @@ public static SortedDictionary<SystemTypes, AdminEntry> CalculateAdmin()
if (collider.CompareTag("DeadBody"))
{
var deadBody = collider.GetComponent<DeadBody>();
if (deadBody != null && countedPlayers.Add(deadBody.ParentId))
if (deadBody && countedPlayers.Add(deadBody.ParentId))
{
totalPlayers++;
numDeadBodies++;
Expand Down
10 changes: 5 additions & 5 deletions Modules/AntiBlackout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static bool CheckBlackOut()
foreach (var pc in Main.EnumerateAlivePlayerControls())
{
// if player is ejected, do not count him as alive
if (lastExiled != null && pc.PlayerId == lastExiled.PlayerId) continue;
if (lastExiled && pc.PlayerId == lastExiled.PlayerId) continue;

// Impostors
if (pc.Is(Custom_Team.Impostor) && !Main.PlayerStates[pc.PlayerId].IsFalseRole && !pc.Is(CustomRoles.Narc))
Expand Down Expand Up @@ -104,7 +104,7 @@ public static void SetIsDead(bool doSend = true, [CallerMemberName] string calle
isDeadCache.Clear();
foreach (var info in GameData.Instance.AllPlayers)
{
if (info == null) continue;
if (!info) continue;
isDeadCache[info.PlayerId] = (info.IsDead, info.Disconnected);
info.IsDead = false;
info.Disconnected = false;
Expand Down Expand Up @@ -168,7 +168,7 @@ public static void RestoreIsDead(bool doSend = true, [CallerMemberName] string c
logger.Info($"RestoreIsDead is called from {callerMethodName}");
foreach (var info in GameData.Instance.AllPlayers)
{
if (info == null) continue;
if (!info) continue;
if (isDeadCache.TryGetValue(info.PlayerId, out var val))
{
info.IsDead = val.isDead;
Expand Down Expand Up @@ -237,7 +237,7 @@ public static void AntiBlackRpcVotingComplete(this MeetingHud __instance, Meetin
sender.Write(voterState.VotedForId);
sender.WriteEndMessage();
}
sender.Write(exiled != null ? exiled.PlayerId : byte.MaxValue);
sender.Write(exiled ? exiled.PlayerId : byte.MaxValue);
sender.Write(tie);
sender.EndRpc();
}
Expand Down Expand Up @@ -315,7 +315,7 @@ public static void SetRealPlayerRoles()
var seer = seerId.GetPlayer();
var target = targetId.GetPlayer();

if (seer == null || target == null) continue;
if (!seer || !target) continue;

var isSelf = seerId == targetId;
var isDead = !target.IsAlive();
Expand Down
6 changes: 3 additions & 3 deletions Modules/BAUPlayersData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public string this[NetworkedPlayerInfo key]
set
{
CleanUpNullEntries();
if (key != null)
if (key)
{
_players[key] = value;
}
Expand All @@ -24,7 +24,7 @@ public string this[NetworkedPlayerInfo key]

private void CleanUpNullEntries()
{
var keysToRemove = _players.Where(kvp => kvp.Key == null).Select(kvp => kvp.Key).ToList();
var keysToRemove = _players.Where(kvp => !kvp.Key).Select(kvp => kvp.Key).ToList();
foreach (var key in keysToRemove)
{
_players.Remove(key);
Expand All @@ -40,7 +40,7 @@ public bool TryGetValue(NetworkedPlayerInfo key, out string value)
public void Add(NetworkedPlayerInfo key, string value)
{
CleanUpNullEntries();
if (key != null)
if (key)
{
_players[key] = value;
}
Expand Down
2 changes: 1 addition & 1 deletion Modules/Camouflague.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public static void CheckCamouflage()
public static void RpcSetSkin(PlayerControl target, bool ForceRevert = false, bool RevertToDefault = false, bool GameEnd = false)
{
if (!(AmongUsClient.Instance.AmHost && (Options.CommsCamouflage.GetBool() || Camouflager.HasEnabled))) return;
if (target == null) return;
if (!target) return;

var targetId = target.PlayerId;

Expand Down
10 changes: 5 additions & 5 deletions Modules/ChatManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public static void SendPreviousMessagesToAll()
for (var j = 2; j < entryParts.Length; j++) senderMessage += ':' + entryParts[j].Trim();

PlayerControl senderPlayer = Utils.GetPlayerById(Convert.ToByte(senderId));
if (senderPlayer == null) continue;
if (!senderPlayer) continue;

chat.AddChat(senderPlayer, senderMessage);
SendRPC(writer, senderPlayer, senderMessage);
Expand Down Expand Up @@ -232,14 +232,14 @@ public static void ClearChat(params PlayerControl[] targets)
{
if (!AmongUsClient.Instance.AmHost) return;
PlayerControl player = GameStates.IsVanillaServer ? PlayerControl.LocalPlayer : Main.EnumerateAlivePlayerControls().MinBy(x => x.PlayerId) ?? Main.EnumeratePlayerControls().MinBy(x => x.PlayerId) ?? PlayerControl.LocalPlayer;
if (player == null) return;
if (!player) return;

if (GameStates.IsVanillaServer)
{
if (targets.Length <= 1 || targets.Length >= Main.AllAlivePlayerControls.Count)
Loop.Times(30, _ => Utils.SendMessage(string.Empty, targets.Length == 1 ? targets[0].PlayerId : byte.MaxValue, "\u200b", force: true, sendOption: SendOption.None));
Loop.Times(30, _ => Utils.SendMessage(string.Empty, targets.Length == 1 ? targets[0].PlayerId : byte.MaxValue, "\u200b", force: true, importance: MessageImportance.Low));
else
targets.Do(x => Loop.Times(30, _ => Utils.SendMessage(string.Empty, x.PlayerId, "\u200b", force: true, sendOption: SendOption.None)));
targets.Do(x => Loop.Times(30, _ => Utils.SendMessage(string.Empty, x.PlayerId, "\u200b", force: true, importance: MessageImportance.Low)));

return;
}
Expand All @@ -250,7 +250,7 @@ public static void ClearChat(params PlayerControl[] targets)

void SendEmptyMessage(PlayerControl receiver)
{
bool toEveryone = receiver == null;
bool toEveryone = receiver;
bool toLocalPlayer = !toEveryone && receiver.AmOwner;
if (HudManager.InstanceExists && (toLocalPlayer || toEveryone)) HudManager.Instance.Chat.AddChat(player, "<size=32767>.");
if (toLocalPlayer) return;
Expand Down
12 changes: 6 additions & 6 deletions Modules/ClientOptionItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private ClientOptionItem(
var mouseMoveToggle = optionsMenuBehaviour.DisableMouseMovement;

// 1つ目のボタンの生成時に背景も生成
if (CustomBackground == null)
if (!CustomBackground)
{
CustomBackground = Object.Instantiate(optionsMenuBehaviour.Background, optionsMenuBehaviour.transform);
CustomBackground.name = "CustomBackground";
Expand All @@ -53,7 +53,7 @@ private ClientOptionItem(
PassiveButton returnButton = null;
foreach (var button in selectableButtons)
{
if (button == null) continue;
if (!button) continue;

if (button.name == "LeaveGameButton")
leaveButton = button.GetComponent<PassiveButton>();
Expand All @@ -75,9 +75,9 @@ private ClientOptionItem(
CustomBackground.gameObject.SetActive(true);
}));

if (leaveButton != null)
if (leaveButton)
leaveButton.transform.localPosition = new(-1.35f, -2.411f, -1f);
if (returnButton != null)
if (returnButton)
returnButton.transform.localPosition = new(1.35f, -2.411f, -1f);

OptionButtons = [];
Expand Down Expand Up @@ -133,7 +133,7 @@ public static void AdjustButtonPositions()
for (int i = 0; i < OptionButtons.Count; i++)
{
var button = OptionButtons[i];
if (button == null) continue;
if (!button) continue;

int row = i / 3;
int col = i % 3;
Expand All @@ -148,7 +148,7 @@ public static void AdjustButtonPositions()

public void UpdateToggle()
{
if (ToggleButton == null) return;
if (!ToggleButton) return;

var color = (Config != null && Config.Value) ? new Color32(255, 192, 203, byte.MaxValue) : new Color32(77, 77, 77, byte.MaxValue);
ToggleButton.Background.color = color;
Expand Down
10 changes: 5 additions & 5 deletions Modules/CriticalErrorManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static void CheckEndGame()
{
Logger.SendInGame(string.Format(GetString("RpcAntiBlackOutIgnored"), player?.Data?.PlayerName));

if (player != null)
if (player)
{
if (GameStates.IsInGame && !GameStates.IsCoStartGame)
{
Expand All @@ -97,7 +97,7 @@ public static void CheckEndGame()
{
_ = new LateTask(() =>
{
if (player == null) return;
if (!player) return;
AmongUsClient.Instance.KickPlayer(player.GetClientId(), false);
Logger.SendInGame(string.Format(GetString("RpcAntiBlackOutKicked"), player?.Data?.PlayerName));
}, 0.5f, "RPC Anti-Black Kicked As Critical Error");
Expand All @@ -107,13 +107,13 @@ public static void CheckEndGame()
}
}
}
else if (GameStartManager.Instance != null)
else if (GameStartManager.Instance)
{
// We imagine rpc is received when starting game in lobby, not fucked yet
if (AmongUsClient.Instance.AmHost)
{
GameStartManager.Instance.ResetStartState();
if (player != null)
if (player)
{
AmongUsClient.Instance.KickPlayer(player.GetClientId(), false);
}
Expand All @@ -139,7 +139,7 @@ public static void CheckEndGame()
RPC.ForceEndGame(CustomWinner.Error);
}, 0.5f, "Anti-Black End Game As Critical Error");
}
else if (GameStartManager.Instance != null)
else if (GameStartManager.Instance)
{
GameStartManager.Instance.ResetStartState();
AmongUsClient.Instance.RemoveUnownedObjects();
Expand Down
4 changes: 2 additions & 2 deletions Modules/CustomNetObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void Despawn()

try
{
if (playerControl != null)
if (playerControl)
{
MessageWriter writer = MessageWriter.Get(SendOption.Reliable);
writer.StartMessage(5);
Expand Down Expand Up @@ -454,7 +454,7 @@ public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] string
{
switch (exception)
{
case true when __instance != null:
case true when __instance:
TOHE.Logger.Warn($"Failed to set name for {__instance.GetRealName()}, trying alternative method", "RawSetNamePatch");
__instance.transform.FindChild("Names").FindChild("NameText_TMP").GetComponent<TextMeshPro>().text = name;
TOHE.Logger.Msg($"Successfully set name for {__instance.GetRealName()}", "RawSetNamePatch");
Expand Down
4 changes: 2 additions & 2 deletions Modules/CustomRolesHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static RoleTypes GetDYRole(this CustomRoles role) // Role has a kill butt

public static bool HasImpKillButton(this PlayerControl player, bool considerVanillaShift = false)
{
if (player == null) return false;
if (!player) return false;

if (Options.CurrentGameMode is CustomGameMode.SpeedRun) return true;

Expand Down Expand Up @@ -592,7 +592,7 @@ public static Dictionary<PlayerControl, List<CustomRoles>> GetAssignableAddons(t
public static bool CheckAddonConfilct(CustomRoles role, PlayerControl pc, bool checkLimitAddons = true, bool checkConditions = true)
{
// Only add-ons
if (!role.IsAdditionRole() || pc == null) return false;
if (!role.IsAdditionRole() || !pc) return false;

if (pc.Is(CustomRoles.GM) || pc.Is(CustomRoles.LazyGuy)) return false;

Expand Down
Loading
Loading