|
Infinite Runner Engine
v2.1
|
A class to handle cooldown related properties and their resource consumption over time Remember to initialize it (once) and update it every frame from another class More...
Public Types | |
| enum | CooldownStates { CooldownStates.Idle, CooldownStates.Consuming, CooldownStates.Stopped, CooldownStates.Refilling } |
| all possible states for the object More... | |
Public Member Functions | |
| delegate void | OnStateChangeDelegate (CooldownStates newState) |
| A public delegate you can listen to for state changes More... | |
| virtual void | Initialization () |
| An init method that ensures the object is reset More... | |
| virtual void | Start () |
| Starts consuming the cooldown object if possible More... | |
| virtual bool | Ready () |
| Returns true if the cooldown is ready to be consumed, false otherwise More... | |
| virtual void | Stop () |
| Stops consuming the object More... | |
| virtual void | Update () |
| Processes the object's state machine More... | |
Public Attributes | |
| bool | Unlimited = false |
| if this is true, the cooldown won't do anything More... | |
| float | ConsumptionDuration = 2f |
| the time it takes, in seconds, to consume the object More... | |
| float | PauseOnEmptyDuration = 1f |
| the pause to apply before refilling once the object's been depleted More... | |
| float | RefillDuration = 1f |
| the duration of the refill, in seconds, if uninterrupted More... | |
| bool | CanInterruptRefill = true |
| whether or not the refill can be interrupted by a new Start instruction More... | |
| CooldownStates | CooldownState = CooldownStates.Idle |
| the current state of the object More... | |
| float | CurrentDurationLeft |
| the amount of duration left in the object at any given time More... | |
| OnStateChangeDelegate | OnStateChange |
Protected Member Functions | |
| virtual void | ChangeState (CooldownStates newState) |
| Changes the current state of the cooldown and invokes the delegate if needed More... | |
Protected Attributes | |
| float | _emptyReachedTimestamp = 0f |
Properties | |
| float | Progress [get] |
A class to handle cooldown related properties and their resource consumption over time Remember to initialize it (once) and update it every frame from another class
|
strong |
|
protectedvirtual |
Changes the current state of the cooldown and invokes the delegate if needed
| newState |
|
virtual |
An init method that ensures the object is reset
| delegate void MoreMountains.Tools.MMCooldown.OnStateChangeDelegate | ( | CooldownStates | newState | ) |
A public delegate you can listen to for state changes
How to use :
private void OnCooldownStateChange(MMCooldown.CooldownStates newState) { if (newState == MMCooldown.CooldownStates.Stopped) { // do something } }
private void OnEnable() { Cooldown.OnStateChange += OnCooldownStateChange; }
private void OnDisable() { Cooldown.OnStateChange -= OnCooldownStateChange; }
|
virtual |
Returns true if the cooldown is ready to be consumed, false otherwise
|
virtual |
Starts consuming the cooldown object if possible
|
virtual |
Stops consuming the object
|
virtual |
Processes the object's state machine
|
protected |
| bool MoreMountains.Tools.MMCooldown.CanInterruptRefill = true |
whether or not the refill can be interrupted by a new Start instruction
| float MoreMountains.Tools.MMCooldown.ConsumptionDuration = 2f |
the time it takes, in seconds, to consume the object
| CooldownStates MoreMountains.Tools.MMCooldown.CooldownState = CooldownStates.Idle |
the current state of the object
| float MoreMountains.Tools.MMCooldown.CurrentDurationLeft |
the amount of duration left in the object at any given time
| OnStateChangeDelegate MoreMountains.Tools.MMCooldown.OnStateChange |
| float MoreMountains.Tools.MMCooldown.PauseOnEmptyDuration = 1f |
the pause to apply before refilling once the object's been depleted
| float MoreMountains.Tools.MMCooldown.RefillDuration = 1f |
the duration of the refill, in seconds, if uninterrupted
| bool MoreMountains.Tools.MMCooldown.Unlimited = false |
if this is true, the cooldown won't do anything
|
get |