Interface ICooldownController
Interface for a cooldown controller using immutable CooldownInstance
based on StartTick + DurationTicks. No per-tick mutation is needed — cooldowns
are evaluated via (currentTick - StartTick) < DurationTicks.
public interface ICooldownController : ICharacterBehaviour
- Inherited Members
Fields
OnAddCooldown
Event invoked when a cooldown is added.
public static Action<long, CooldownInstance> OnAddCooldown
Field Value
OnRemoveCooldown
Event invoked when a cooldown is removed (expired or explicitly cleared).
public static Action<long> OnRemoveCooldown
Field Value
OnUpdateCooldown
Event invoked when a cooldown is updated (e.g., remaining time changes due to reconcile).
public static Action<long, CooldownInstance> OnUpdateCooldown
Field Value
Methods
AddCooldown(long, CooldownInstance)
Adds a cooldown for the specified ability.
void AddCooldown(long id, CooldownInstance cooldown)
Parameters
idlongAbility ID.
cooldownCooldownInstanceCooldown instance.
Clear()
Clears all cooldowns.
void Clear()
CreateReconcileSnapshot()
Creates a reconcile snapshot of all active cooldowns. Returns null when no cooldowns are active.
CooldownReconcileEntry[] CreateReconcileSnapshot()
Returns
ExpireElapsed(uint)
Removes all cooldowns that have expired as of currentTick.
Called from the Replicate loop. Safe during replay because the same tick
value produces the same expiration decisions deterministically.
void ExpireElapsed(uint currentTick)
Parameters
currentTickuintThe current network tick.
IsOnCooldown(long, uint)
Checks if an ability is on cooldown at the given tick.
bool IsOnCooldown(long id, uint currentTick)
Parameters
Returns
- bool
True if on cooldown, otherwise false.
Read(Reader, uint)
Reads cooldown data from a network reader.
void Read(Reader reader, uint currentTick)
Parameters
readerReaderThe network reader.
currentTickuintCurrent tick for computing UI-facing remaining time.
RemoveCooldown(long)
Removes the cooldown for the specified ability.
void RemoveCooldown(long id)
Parameters
idlongAbility ID.
ResolveAuthoritativeTick(uint)
Maps a raw authoritative tick to the controller's current replicate-tick domain when a replicate tick is available.
uint ResolveAuthoritativeTick(uint serverTick)
Parameters
serverTickuintFallback authoritative tick used before any replicate tick exists.
Returns
- uint
The effective tick to use for cooldown comparisons.
RestoreFromReconcile(CooldownReconcileEntry[])
Restores cooldown state from a reconcile snapshot.
void RestoreFromReconcile(CooldownReconcileEntry[] entries)
Parameters
entriesCooldownReconcileEntry[]
TryGetCooldown(long, uint, out float)
Tries to get the remaining cooldown time in seconds for an ability.
bool TryGetCooldown(long id, uint currentTick, out float cooldown)
Parameters
idlongAbility ID.
currentTickuintThe current network tick.
cooldownfloatRemaining cooldown time in seconds.
Returns
- bool
True if found and still on cooldown, otherwise false.
TryGetCooldownInstance(long, out CooldownInstance)
Tries to get the full CooldownInstance for an ability or consumable, whether or not it is still running.
bool TryGetCooldownInstance(long id, out CooldownInstance instance)
Parameters
idlongAbility or consumable template ID.
instanceCooldownInstanceThe cooldown instance.
Returns
- bool
True if a cooldown is tracked for the id.
Remarks
TryGetCooldown(long, uint, out float) reports only the REMAINING seconds, which is not enough to draw a sweep — a sweep needs the fraction, and a fraction needs the total the cooldown started from. The UI previously took its total from the instance handed to OnAddCooldown and then never updated, which is what made the hotkey bar's sweep binary rather than animated.
Write(Writer)
Writes cooldown data to a network writer.
void Write(Writer writer)
Parameters
writerWriterThe network writer.
Write(Writer, bool)
Writes cooldown data, or an empty framed block when includeEntries
is false (non-owner connections have no use for a peer's cooldowns).
void Write(Writer writer, bool includeEntries)
Parameters
writerWriterincludeEntriesbool