From efd176f7a4e8c3805f0eb4ff9bc0db62c32ff775 Mon Sep 17 00:00:00 2001 From: XtraCube <72575280+XtraCube@users.noreply.github.com> Date: Fri, 4 Apr 2025 12:18:37 -0400 Subject: [PATCH] fix timer bug related to effects --- MiraAPI/Hud/CustomActionButton.cs | 42 ++++++++++++++++++------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/MiraAPI/Hud/CustomActionButton.cs b/MiraAPI/Hud/CustomActionButton.cs index 6a721da..e215fda 100644 --- a/MiraAPI/Hud/CustomActionButton.cs +++ b/MiraAPI/Hud/CustomActionButton.cs @@ -417,9 +417,12 @@ public abstract class CustomActionButton /// The local PlayerControl. public virtual void FixedUpdateHandler(PlayerControl playerControl) { - if (Timer >= 0 && !TimerPaused) + if (Timer >= 0) { - Timer -= Time.deltaTime; + if (!TimerPaused) + { + Timer -= Time.deltaTime; + } } else if (HasEffect && EffectActive) { @@ -428,25 +431,28 @@ public abstract class CustomActionButton OnEffectEnd(); } - if (CanUse()) + if (Button) { - Button?.SetEnabled(); - } - else - { - Button?.SetDisabled(); - } + if (CanUse()) + { + Button.SetEnabled(); + } + else + { + Button.SetDisabled(); + } - if (EffectActive) - { - Button?.SetFillUp(Timer, EffectDuration); + if (EffectActive) + { + Button.SetFillUp(Timer, EffectDuration); - Button!.cooldownTimerText.text = Mathf.CeilToInt(Timer).ToString(NumberFormatInfo.InvariantInfo); - Button!.cooldownTimerText.gameObject.SetActive(true); - } - else - { - Button?.SetCoolDown(Timer, Cooldown); + Button.cooldownTimerText.text = Mathf.CeilToInt(Timer).ToString(NumberFormatInfo.InvariantInfo); + Button.cooldownTimerText.gameObject.SetActive(true); + } + else + { + Button.SetCoolDown(Timer, Cooldown); + } } FixedUpdate(playerControl);