diff --git a/Patches/IntroPatch.cs b/Patches/IntroPatch.cs index 3fa379c3a..cbbe54fe0 100644 --- a/Patches/IntroPatch.cs +++ b/Patches/IntroPatch.cs @@ -1356,13 +1356,13 @@ internal static class IntroCutsceneDestroyPatch break; } - Utils.CheckAndSetVentInteractions(); - if (AFKDetector.ActivateOnStart.GetBool()) LateTask.New(() => aapc.Do(AFKDetector.RecordPosition), 1f, log: false); LateTask.New(() => Main.Instance.StartCoroutine(Utils.NotifyEveryoneAsync()), 3f, "NotifyEveryoneAsync On Game Start"); LateTask.New(Utils.MarkEveryoneDirtySettings, 0.5f, "SyncAllSettings On Game Start"); LateTask.New(() => Main.Instance.StartCoroutine(ShipStatusFixedUpdatePatch.Postfix()), 5f, "ShipStatusFixedUpdatePatch Postfix Start"); + + Utils.CheckAndSetVentInteractions(); } else { diff --git a/Patches/ShipStatusPatch.cs b/Patches/ShipStatusPatch.cs index 87a2378f7..781519139 100644 --- a/Patches/ShipStatusPatch.cs +++ b/Patches/ShipStatusPatch.cs @@ -5,7 +5,6 @@ using System.Linq; using AmongUs.GameOptions; using BepInEx; using EHR.Gamemodes; -using EHR.Patches; using EHR.Roles; using HarmonyLib; using Hazel; @@ -311,7 +310,7 @@ public static class HauntMenuMinigameSetHauntTargetPatch { if (Options.CurrentGameMode == CustomGameMode.Quiz && Quiz.AllowKills) return false; - if (target == null) + if (!target) { __instance.HauntTarget = null; __instance.NameText.text = ""; @@ -324,7 +323,7 @@ public static class HauntMenuMinigameSetHauntTargetPatch __instance.HauntingText.enabled = true; __instance.NameText.text = Main.AllPlayerNames.GetValueOrDefault(target.PlayerId, target.Data?.GetPlayerName(PlayerOutfitType.Default)); - if (__instance.HauntTarget != null && Options.GhostCanSeeOtherRoles.GetBool() && (!Main.DiedThisRound.Contains(PlayerControl.LocalPlayer.PlayerId) || !Utils.IsRevivingRoleAlive())) + if (__instance.HauntTarget && Options.GhostCanSeeOtherRoles.GetBool() && (!Main.DiedThisRound.Contains(PlayerControl.LocalPlayer.PlayerId) || !Utils.IsRevivingRoleAlive())) __instance.FilterText.text = __instance.HauntTarget.GetCustomRole().ToColoredString(); else __instance.FilterText.text = ""; @@ -408,7 +407,7 @@ internal static class PerformVentOpPatch { if (!AmongUsClient.Instance.AmHost) return true; - if (Utils.GetPlayerById(playerId) == null) return true; + if (!Utils.GetPlayerById(playerId)) return true; switch (op) { @@ -540,7 +539,7 @@ internal static class VentilationSystemDeterioratePatch foreach (NetworkedPlayerInfo playerInfo in GameData.Instance.AllPlayers) { - if (playerInfo != null && !playerInfo.Disconnected) + if (playerInfo && !playerInfo.Disconnected) allPlayers.Add(playerInfo); } @@ -594,7 +593,16 @@ internal static class VentilationSystemDeterioratePatch public static bool BlockVentInteraction(PlayerControl pc) { - return !pc.AmOwner && !pc.IsModdedClient() && !pc.Data.IsDead && pc.GetRoleTypes() is RoleTypes.Engineer or RoleTypes.Impostor or RoleTypes.Shapeshifter or RoleTypes.Phantom && ShipStatus.Instance.AllVents.Any(vent => !pc.CanUseVent(vent.Id)); + try + { + if (!ShipStatus.Instance) return false; + return !pc.AmOwner && !pc.IsModdedClient() && !pc.Data.IsDead && pc.GetRoleTypes() is RoleTypes.Engineer or RoleTypes.Impostor or RoleTypes.Shapeshifter or RoleTypes.Phantom && ShipStatus.Instance.AllVents.Any(vent => !pc.CanUseVent(vent.Id)); + } + catch (Exception e) + { + Utils.ThrowException(e); + return false; + } } public static void SerializeV2(VentilationSystem __instance, PlayerControl player = null) @@ -602,7 +610,7 @@ internal static class VentilationSystemDeterioratePatch foreach (PlayerControl pc in PlayerControl.AllPlayerControls) { if (pc.AmOwner) continue; - if (player != null && pc != player) continue; + if (player && pc != player) continue; MessageWriter writer = MessageWriter.Get(SendOption.Reliable); @@ -619,7 +627,7 @@ internal static class VentilationSystemDeterioratePatch foreach (NetworkedPlayerInfo playerInfo in GameData.Instance.AllPlayers) { - if (playerInfo != null && !playerInfo.Disconnected) + if (playerInfo && !playerInfo.Disconnected) allPlayers.Add(playerInfo); }