From 2cbbcca1617e9c9b8a6bd290da72562f31f558fd Mon Sep 17 00:00:00 2001 From: ang-xd Date: Thu, 29 Aug 2024 16:46:38 -0400 Subject: [PATCH] oops --- MiraAPI.Example/MiraAPI.Example.csproj | 5 +-- MiraAPI/Hud/CustomActionButton.cs | 45 +++++++++++++++++++++++--- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/MiraAPI.Example/MiraAPI.Example.csproj b/MiraAPI.Example/MiraAPI.Example.csproj index 250d437..b9e314e 100644 --- a/MiraAPI.Example/MiraAPI.Example.csproj +++ b/MiraAPI.Example/MiraAPI.Example.csproj @@ -1,4 +1,4 @@ - + net6.0 latest @@ -9,9 +9,6 @@ Example mod for Mira API Angxl, XtraCube - - - diff --git a/MiraAPI/Hud/CustomActionButton.cs b/MiraAPI/Hud/CustomActionButton.cs index e571134..6cae97d 100644 --- a/MiraAPI/Hud/CustomActionButton.cs +++ b/MiraAPI/Hud/CustomActionButton.cs @@ -59,12 +59,12 @@ public abstract class CustomActionButton /// /// Returns the amount of uses left. /// - public int UsesLeft { get; set; } + public int UsesLeft { get; protected set; } /// /// A timer variable to measure cooldowns and effects. /// - protected float Timer; + public float Timer { get; protected set; } /// /// The button object in game. This is created by Mira API automatically. @@ -134,13 +134,50 @@ public abstract class CustomActionButton Button?.OverrideText(name); } + /// + /// Set the button's timer. + /// + /// The amount you want to set to. + public void SetTimer(float time) + { + Timer = Mathf.Clamp(time, -1, float.MaxValue); + } + + /// + /// Increase the button's timer. + /// + /// The amount you want to increase by. + public void IncreaseTimer(float amount) + { + SetTimer(Timer + amount); + } + + /// + /// Decrease the button's timer. + /// + /// The amount you want to decrease by. + public void DecreaseTimer(float amount) + { + SetTimer(Timer - amount); + } + + + /// + /// Set the amount of uses this button has left. + /// + /// The amount you want to set to. + public void SetUses(int amount) + { + UsesLeft = Mathf.Clamp(amount, 0, int.MaxValue); + } + /// /// Increase the amount of uses this button has left. /// /// The amount you want to increase by. Default: 1 public void IncreaseUses(int amount = 1) { - UsesLeft += amount; + SetUses(UsesLeft + amount); } /// @@ -149,7 +186,7 @@ public abstract class CustomActionButton /// The amount you want to decrease by. Default: 1 public void DecreaseUses(int amount = 1) { - UsesLeft -= amount; + SetUses(UsesLeft - amount); } ///