CooldownManager

@Serializable
data class CooldownManager(completionTime: MutableMap<String, Cooldown> = mutableMapOf())

geary:cooldowns

A component that manages cooldowns for an entity. Each cooldown has a unique key, but may be used to keep track of anything. Typically a good idea to persist this component.

Constructors

Link copied to clipboard
constructor(completionTime: MutableMap<String, Cooldown> = mutableMapOf())

Functions

Link copied to clipboard
fun isDone(key: String): Boolean
Link copied to clipboard
inline fun onCooldown(key: String, length: Duration, run: () -> Unit): Boolean

Runs something if no cooldown is active and starts the cooldown after running it.

Link copied to clipboard
inline fun onCooldownIf(key: String, length: Duration, run: () -> Boolean): Boolean

Runs something if no cooldown is active and starts the cooldown only if run returns true.

Link copied to clipboard
fun reset(key: String)

Clears the cooldown for a key.

Link copied to clipboard
fun start(key: String, length: Long)

Starts a cooldown of a certain length under a key.

Properties

Link copied to clipboard

Calculated map of incomplete cooldowns.