Fix 2 kill button bugs (#7)

Co-authored-by: js6pak <kubastaron@hotmail.com>
This commit is contained in:
Galster-devandjs6pak authored and GitHub committed 2021-02-06 17:27:46 +01:00
1 parent e39deea11e
commit ad25d1f19c
1 file changed
+33
+33
View File
@@ -0,0 +1,33 @@
using HarmonyLib;
namespace Reactor.Patches
{
/// <summary>
/// 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
/// </summary>
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;
}
}
}
}