TopDown Engine  v3.6
MoreMountains.Tools.MMCooldown Class Reference

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]
 

Detailed Description

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

Member Enumeration Documentation

◆ CooldownStates

all possible states for the object

Enumerator
Idle 
Consuming 
Stopped 
Refilling 

Member Function Documentation

◆ ChangeState()

virtual void MoreMountains.Tools.MMCooldown.ChangeState ( CooldownStates  newState)
protectedvirtual

Changes the current state of the cooldown and invokes the delegate if needed

Parameters
newState

◆ Initialization()

virtual void MoreMountains.Tools.MMCooldown.Initialization ( )
virtual

An init method that ensures the object is reset

◆ OnStateChangeDelegate()

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; }

◆ Ready()

virtual bool MoreMountains.Tools.MMCooldown.Ready ( )
virtual

Returns true if the cooldown is ready to be consumed, false otherwise

Returns

◆ Start()

virtual void MoreMountains.Tools.MMCooldown.Start ( )
virtual

Starts consuming the cooldown object if possible

◆ Stop()

virtual void MoreMountains.Tools.MMCooldown.Stop ( )
virtual

Stops consuming the object

◆ Update()

virtual void MoreMountains.Tools.MMCooldown.Update ( )
virtual

Processes the object's state machine

Member Data Documentation

◆ _emptyReachedTimestamp

float MoreMountains.Tools.MMCooldown._emptyReachedTimestamp = 0f
protected

◆ CanInterruptRefill

bool MoreMountains.Tools.MMCooldown.CanInterruptRefill = true

whether or not the refill can be interrupted by a new Start instruction

◆ ConsumptionDuration

float MoreMountains.Tools.MMCooldown.ConsumptionDuration = 2f

the time it takes, in seconds, to consume the object

◆ CooldownState

CooldownStates MoreMountains.Tools.MMCooldown.CooldownState = CooldownStates.Idle

the current state of the object

◆ CurrentDurationLeft

float MoreMountains.Tools.MMCooldown.CurrentDurationLeft

the amount of duration left in the object at any given time

◆ OnStateChange

OnStateChangeDelegate MoreMountains.Tools.MMCooldown.OnStateChange

◆ PauseOnEmptyDuration

float MoreMountains.Tools.MMCooldown.PauseOnEmptyDuration = 1f

the pause to apply before refilling once the object's been depleted

◆ RefillDuration

float MoreMountains.Tools.MMCooldown.RefillDuration = 1f

the duration of the refill, in seconds, if uninterrupted

◆ Unlimited

bool MoreMountains.Tools.MMCooldown.Unlimited = false

if this is true, the cooldown won't do anything

Property Documentation

◆ Progress

float MoreMountains.Tools.MMCooldown.Progress
get

The documentation for this class was generated from the following file: