From 8123381e1ed5a11d97eeaf2af28ab060d62b3ca7 Mon Sep 17 00:00:00 2001 From: XtraCube <72575280+XtraCube@users.noreply.github.com> Date: Fri, 13 Sep 2024 20:43:45 -0400 Subject: [PATCH] add some more utility methods to timed modifier --- MiraAPI/Modifiers/Types/TimedModifier.cs | 57 ++++++++++++++++++++---- 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/MiraAPI/Modifiers/Types/TimedModifier.cs b/MiraAPI/Modifiers/Types/TimedModifier.cs index a695b75..286b80a 100644 --- a/MiraAPI/Modifiers/Types/TimedModifier.cs +++ b/MiraAPI/Modifiers/Types/TimedModifier.cs @@ -39,6 +39,9 @@ public abstract class TimedModifier : BaseModifier /// public float TimeRemaining { get; protected set; } + /// + public override bool HideOnUi => !TimerActive; + /// /// Gets the HUD information for Timed Modifier, including the time remaining. /// @@ -64,14 +67,7 @@ public abstract class TimedModifier : BaseModifier } else { - TimerActive = false; - TimeRemaining = Duration; - OnTimerComplete(); - - if (RemoveOnComplete) - { - ModifierComponent?.RemoveModifier(ModifierId); - } + StopTimer(); } } @@ -86,7 +82,52 @@ public abstract class TimedModifier : BaseModifier return; } + TimeRemaining = Duration; TimerActive = true; + } + + /// + /// Stops the timer and calls OnTimerComplete(). + /// + public void StopTimer() + { + if (!TimerActive) + { + return; + } + + TimerActive = false; + TimeRemaining = Duration; + OnTimerComplete(); + + if (RemoveOnComplete) + { + ModifierComponent?.RemoveModifier(ModifierId); + } + } + + /// + /// Resets the timer. Does not call OnTimerComplete(). + /// + public void ResetTimer() + { + TimerActive = false; TimeRemaining = Duration; } + + /// + /// Pauses the timer. + /// + public void PauseTimer() + { + TimerActive = false; + } + + /// + /// Pauses the timer. + /// + public void ResumeTimer() + { + TimerActive = true; + } }