From 9f975c826374e645f4d5df4d97f46fa9160be4dd Mon Sep 17 00:00:00 2001 From: XtraCube <72575280+XtraCube@users.noreply.github.com> Date: Fri, 30 Aug 2024 11:59:02 -0400 Subject: [PATCH] half finished docs for cusotm action button --- MiraAPI/Hud/CustomActionButton.cs | 54 +++++++++++++++++-------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/MiraAPI/Hud/CustomActionButton.cs b/MiraAPI/Hud/CustomActionButton.cs index 5511a0d..719df23 100644 --- a/MiraAPI/Hud/CustomActionButton.cs +++ b/MiraAPI/Hud/CustomActionButton.cs @@ -11,62 +11,62 @@ namespace MiraAPI.Hud; public abstract class CustomActionButton { /// - /// The name and text of the button. + /// Gets the name and text of the button. /// public abstract string Name { get; } /// - /// How long the button takes to cooldown. + /// Gets the button's cooldown duration in seconds. /// public abstract float Cooldown { get; } /// - /// If the button has an effect ability, how long the effect should last. To disable effects, set to 0. + /// Gets the button's effect duration in seconds. If the button has no effect, set to 0. /// public abstract float EffectDuration { get; } /// - /// If the button has limited uses, how many uses it has. To make the button infinite, set to 0. + /// Gets the maximum amount of uses the button has. If the button has infinite uses, set to 0. /// public abstract int MaxUses { get; } /// - /// The sprite of the button. Use to load a sprite from a resource path. Use to load a sprite from an asset bundle. + /// Gets the sprite of the button. Use to load a sprite from a resource path. Use to load a sprite from an asset bundle. /// public abstract LoadableAsset Sprite { get; } /// - /// The location of the button on the screen + /// Gets the location of the button on the screen /// public virtual ButtonLocation Location => ButtonLocation.BottomLeft; /// - /// Returns true if the button has an effect ability. + /// Gets a value indicating whether the button has an effect ability. /// public bool HasEffect => EffectDuration > 0; /// - /// Returns true if the button has limited uses. + /// Gets a value indicating whether the button has limited uses. /// public bool LimitedUses => MaxUses > 0; /// - /// Returns true if the effect is currently active. + /// Gets or sets a value indicating whether the effect is currently active, if there is one. /// public bool EffectActive { get; protected set; } /// - /// Returns the amount of uses left. + /// Gets or sets the amount of uses left. /// public int UsesLeft { get; protected set; } /// - /// A timer variable to measure cooldowns and effects. + /// Gets or sets the timer variable to measure cooldowns and effects. /// public float Timer { get; protected set; } /// - /// The button object in game. This is created by Mira API automatically. + /// Gets the button object in game. This is created by Mira API automatically. /// protected ActionButton? Button { get; private set; } @@ -83,7 +83,7 @@ public abstract class CustomActionButton Button = Object.Instantiate(HudManager.Instance.AbilityButton, parent); Button.name = Name + "Button"; - Button.OverrideText(Name.ToUpper()); + Button.OverrideText(Name.ToUpperInvariant()); Button.graphic.sprite = Sprite.LoadAsset(); @@ -115,7 +115,7 @@ public abstract class CustomActionButton /// /// A utility function to override the sprite of the button. /// - /// The new sprite to override with + /// The new sprite to override with. public void OverrideSprite(Sprite sprite) { if (Button != null) @@ -127,7 +127,7 @@ public abstract class CustomActionButton /// /// A utility function to override the name of the button. /// - /// The new name to override with + /// The new name to override with. public void OverrideName(string name) { Button?.OverrideText(name); @@ -136,7 +136,7 @@ public abstract class CustomActionButton /// /// Set the button's timer. /// - /// The amount you want to set to. + /// The time you want to set to. public void SetTimer(float time) { Timer = Mathf.Clamp(time, -1, float.MaxValue); @@ -160,7 +160,6 @@ public abstract class CustomActionButton SetTimer(Timer - amount); } - /// /// Set the amount of uses this button has left. /// @@ -173,7 +172,7 @@ public abstract class CustomActionButton /// /// Increase the amount of uses this button has left. /// - /// The amount you want to increase by. Default: 1 + /// The amount you want to increase by. Default: 1. public void IncreaseUses(int amount = 1) { SetUses(UsesLeft + amount); @@ -182,7 +181,7 @@ public abstract class CustomActionButton /// /// Decrease the amount of uses this button has left. /// - /// The amount you want to decrease by. Default: 1 + /// The amount you want to decrease by. Default: 1. public void DecreaseUses(int amount = 1) { SetUses(UsesLeft - amount); @@ -191,8 +190,10 @@ public abstract class CustomActionButton /// /// A utility function that runs with the local PlayerControl's FixedUpdate if the button is enabled. /// - /// the local PlayerControl - protected virtual void FixedUpdate(PlayerControl playerControl) { } + /// the local PlayerControl. + protected virtual void FixedUpdate(PlayerControl playerControl) + { + } /// /// Callback method for the button click event. @@ -204,13 +205,16 @@ public abstract class CustomActionButton /// True means the button is active, false means the button is disabled. /// /// The role of the local player. + /// True if the button is enabled, false otherwise. public abstract bool Enabled(RoleBehaviour? role); /// /// Given that there is an effect, this method runs when the effect ends. ///

THIS IS A CALLBACK METHOD! Use if you want to end the effect. ///
- public virtual void OnEffectEnd() { } + public virtual void OnEffectEnd() + { + } /// /// When the button is enabled, this method is called to determine if the button can be used. @@ -228,7 +232,7 @@ public abstract class CustomActionButton /// The default behavior is to show the button if the parameter and the method return true. /// It can be overridden for custom behavior. /// - /// Passed in from HudManager.SetHudActive, should hud be active? + /// Passed in from HudManager.SetHudActive, should hud be active. /// Passed in from HudManager.SetHudActive, the current role of the player. public virtual void SetActive(bool visible, RoleBehaviour role) { @@ -271,7 +275,7 @@ public abstract class CustomActionButton /// By default, it handles the cooldown and effect timers, and sets the button to enabled or disabled. /// It can be overridden for custom behavior. /// - /// The local PlayerControl + /// The local PlayerControl. public virtual void FixedUpdateHandler(PlayerControl playerControl) { if (Timer >= 0) @@ -354,4 +358,4 @@ public abstract class CustomActionButton : CustomActionButton where T : MonoB return base.CanUse() && Target; } -} \ No newline at end of file +}