From 9d3ed0cf0e946a818f509e83ac8b141c4d02b41c Mon Sep 17 00:00:00 2001 From: Brybry Date: Wed, 17 Feb 2021 01:09:45 +0100 Subject: [PATCH] Fixed a nullptrexception + sheriff being able to use the kill button while in meeting --- ReactorSheriff/HudManagerPatch.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ReactorSheriff/HudManagerPatch.cs b/ReactorSheriff/HudManagerPatch.cs index 3f4c699..096f2ff 100644 --- a/ReactorSheriff/HudManagerPatch.cs +++ b/ReactorSheriff/HudManagerPatch.cs @@ -18,6 +18,7 @@ public static class HudManagerPatch static System.Random random = new System.Random(); static string GameSettingsText = null; + public static bool isMeetingHudActive; @@ -55,7 +56,11 @@ public static void updateMeetingHud(MeetingHud __instance) { foreach (PlayerVoteArea playerVoteArea in __instance.playerStates) { - if (playerVoteArea.NameText.Text == PlayerControlPatch.Sheriff.name) + if (PlayerControlPatch.Sheriff == null) + { + SheriffReactorMod.log.LogMessage("PlayerControlPatch.Sheriff IS NULL CT CA MDR"); + } + if (PlayerControlPatch.Sheriff != null && playerVoteArea.NameText.Text == PlayerControlPatch.Sheriff.name) { if (CustomGameOptions.ShowSheriff | PlayerControlPatch.isSheriff(PlayerControl.LocalPlayer)) { @@ -69,7 +74,9 @@ public static void updateMeetingHud(MeetingHud __instance) public static void Postfix(HudManager __instance) { KillButton = __instance.KillButton; - if (MeetingHud.Instance != null) + isMeetingHudActive = MeetingHud.Instance != null; + + if (isMeetingHudActive) { updateMeetingHud(MeetingHud.Instance); } @@ -83,7 +90,7 @@ public static void Postfix(HudManager __instance) { PlayerControl.LocalPlayer.nameText.Color = new Color(1, (float)(204.0 / 255.0), 0, 1); - if (PlayerControl.LocalPlayer.Field_6.IsDead || PlayerControlPatch.sheriffInTask) + if (PlayerControl.LocalPlayer.Field_6.IsDead || PlayerControlPatch.sheriffInTask || isMeetingHudActive) { KillButton.gameObject.SetActive(false); KillButton.isActive = false; @@ -147,7 +154,6 @@ public static void Postfix(MeetingHud __instance) { PlayerControlPatch.lastKilled = DateTime.UtcNow; PlayerControlPatch.lastKilled = PlayerControlPatch.lastKilled.AddSeconds(8); - } } }