Cooldowns could be used like loop time feature (something that must be triggered each X seconds e.g.). So, it was possible to achieve this behaviour by using :
Cooldown _cd = 2; // each 2 seconds
...
if(_cd.IsReady)
{
_cd.Reset();
// Do something
}
This PR introduces a new method to check the IsReady and reset automatically :
Cooldown _cd = 2; // each 2 seconds
...
if(_cd.Restart())
{
// Do something
}
CooldownManager
You could see that Update() is not necessary anymore. That's because every cooldown is registered to a CooldownManager when they are reset ; this manager updates every registered cooldown and clear them when they're ready.
⚠️ If you are using the Cooldown.Update() method, or you still want to use it, you must set the Cooldown.SubscribeToManager to false. Without that, the cooldown would be updated twice.
Cooldown.Restart()
Cooldowns could be used like loop time feature (something that must be triggered each X seconds e.g.). So, it was possible to achieve this behaviour by using :
This PR introduces a new method to check the
IsReady
and reset automatically :CooldownManager
You could see that
Update()
is not necessary anymore. That's because every cooldown is registered to aCooldownManager
when they are reset ; this manager updates every registered cooldown and clear them when they're ready.⚠️ If you are using the
Cooldown.Update()
method, or you still want to use it, you must set theCooldown.SubscribeToManager
to false. Without that, the cooldown would be updated twice.