From ad25d1f19c1afecce1970672276bde144dfbc9fc Mon Sep 17 00:00:00 2001 From: Galster-dev <46283010+Galster-dev@users.noreply.github.com> Date: Sat, 6 Feb 2021 19:27:46 +0300 Subject: [PATCH] Fix 2 kill button bugs (#7) Co-authored-by: js6pak --- Reactor/Patches/KillButtonPatches.cs | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Reactor/Patches/KillButtonPatches.cs diff --git a/Reactor/Patches/KillButtonPatches.cs b/Reactor/Patches/KillButtonPatches.cs new file mode 100644 index 0000000..adc6f65 --- /dev/null +++ b/Reactor/Patches/KillButtonPatches.cs @@ -0,0 +1,33 @@ +using HarmonyLib; + +namespace Reactor.Patches +{ + /// + /// Fixes kill cooldown resetting for a few frames if anyone on the map got the kill + /// Also fixes invisible kill button if KillCooldown is set to 0 + /// + internal class KillButtonPatches + { + [HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.SetKillTimer))] + [HarmonyPriority(Priority.First)] + public static class SetKillTimerPatch + { + public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] float time) + { + __instance.killTimer = time; + + // Patched because of this - game doesn't check if you're the killer + if (__instance.AmOwner) + { + HudManager.Instance.KillButton.SetCoolDown( + time, + // if MaxTimer is 0, kill button disappears + PlayerControl.GameOptions.KillCooldown <= 0 ? 1 : PlayerControl.GameOptions.KillCooldown + ); + } + + return false; + } + } + } +}