mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
15 lines
632 B
Plaintext
15 lines
632 B
Plaintext
/*
|
|
* Cooldown system based on storing world.time on a variable, plus the cooldown time.
|
|
* Better performance over timer cooldowns, lower control. Same functionality.
|
|
*/
|
|
|
|
#define COOLDOWN_DECLARE(cd_index) var/##cd_index = 0
|
|
|
|
#define COOLDOWN_START(cd_source, cd_index, cd_time) (cd_source.cd_index = world.time + (cd_time))
|
|
|
|
//Returns true if the cooldown has run its course, false otherwise
|
|
#define COOLDOWN_FINISHED(cd_source, cd_index) (cd_source.cd_index < world.time)
|
|
|
|
#define COOLDOWN_RESET(cd_source, cd_index) cd_source.cd_index = 0
|
|
|
|
#define COOLDOWN_TIMELEFT(cd_source, cd_index) (max(0, cd_source.cd_index - world.time)) |