Table of Contents

Class CooldownController

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Controls and manages ability cooldowns using immutable CooldownInstance based on StartTick + DurationTicks. No per-tick mutation — cooldowns expire automatically via integer comparison: (currentTick - StartTick) >= DurationTicks.

public class CooldownController : CharacterBehaviour, ICooldownController, ICharacterBehaviour, IPredictableController
Inheritance
Object
Component
Behaviour
MonoBehaviour
NetworkBehaviour
CooldownController
Implements
Inherited Members
NetworkBehaviour.IsSpawned
NetworkBehaviour.ComponentIndex
NetworkBehaviour.NetworkObject
NetworkBehaviour.MAXIMUM_NETWORKBEHAVIOURS
NetworkBehaviour.UNSET_NETWORKBEHAVIOUR_ID
NetworkBehaviour.ToString()
NetworkBehaviour.Reset()
NetworkBehaviour.OnValidate()
NetworkBehaviour.IsBehaviourReconciling
NetworkBehaviour.ClearReplicateCache()
NetworkBehaviour.CreateReconcile()
NetworkBehaviour.Reconcile_Reader<T>(PooledReader, ref T)
NetworkBehaviour.OnStartServerCalled
NetworkBehaviour.OnStartClientCalled
NetworkBehaviour.WritePayload(NetworkConnection, Writer)
NetworkBehaviour.ReadPayload(NetworkConnection, Reader)
NetworkBehaviour.OnStopNetwork()
NetworkBehaviour.OnStartServer()
NetworkBehaviour.OnStopServer()
NetworkBehaviour.OnOwnershipServer(NetworkConnection)
NetworkBehaviour.OnSpawnServer(NetworkConnection)
NetworkBehaviour.OnDespawnServer(NetworkConnection)
NetworkBehaviour.OnStartClient()
NetworkBehaviour.OnStopClient()
NetworkBehaviour.OnOwnershipClient(NetworkConnection)
NetworkBehaviour.ClearBuffedRpcs()
NetworkBehaviour.ExcludeOwnerFromUnbufferedObserversRpcs
NetworkBehaviour.IsClientOnly
NetworkBehaviour.IsServerOnly
NetworkBehaviour.IsHost
NetworkBehaviour.IsClient
NetworkBehaviour.IsServer
NetworkBehaviour.IsDeinitializing
NetworkBehaviour.NetworkManager
NetworkBehaviour.ServerManager
NetworkBehaviour.ClientManager
NetworkBehaviour.ObserverManager
NetworkBehaviour.TransportManager
NetworkBehaviour.TimeManager
NetworkBehaviour.SceneManager
NetworkBehaviour.PredictionManager
NetworkBehaviour.RollbackManager
NetworkBehaviour.NetworkObserver
NetworkBehaviour.IsClientInitialized
NetworkBehaviour.IsClientStarted
NetworkBehaviour.IsClientOnlyInitialized
NetworkBehaviour.IsClientOnlyStarted
NetworkBehaviour.IsServerInitialized
NetworkBehaviour.IsServerStarted
NetworkBehaviour.IsServerOnlyInitialized
NetworkBehaviour.IsServerOnlyStarted
NetworkBehaviour.IsHostInitialized
NetworkBehaviour.IsHostStarted
NetworkBehaviour.IsOffline
NetworkBehaviour.IsNetworked
NetworkBehaviour.GetIsNetworked()
NetworkBehaviour.IsManagerReconciling
NetworkBehaviour.Observers
NetworkBehaviour.IsOwner
NetworkBehaviour.IsController
NetworkBehaviour.HasAuthority
NetworkBehaviour.Owner
NetworkBehaviour.OwnerId
NetworkBehaviour.ObjectId
NetworkBehaviour.LocalConnection
NetworkBehaviour.OwnerMatches(NetworkConnection)
NetworkBehaviour.Despawn(GameObject, DespawnType?)
NetworkBehaviour.Despawn(NetworkObject, DespawnType?)
NetworkBehaviour.Despawn(DespawnType?)
NetworkBehaviour.Spawn(GameObject, NetworkConnection, Scene)
NetworkBehaviour.Spawn(NetworkObject, NetworkConnection, Scene)
NetworkBehaviour.RemoveOwnership()
NetworkBehaviour.GiveOwnership(NetworkConnection)
NetworkBehaviour.GetInstance<T>()
NetworkBehaviour.TryRegisterInstance<T>(T)
NetworkBehaviour.UnregisterInstance<T>()
NetworkBehaviour.CanLog(LoggingType)
MonoBehaviour.IsInvoking()
MonoBehaviour.CancelInvoke()
MonoBehaviour.StopCoroutine(Coroutine)
MonoBehaviour.StopAllCoroutines()
MonoBehaviour.destroyCancellationToken
MonoBehaviour.useGUILayout
MonoBehaviour.didStart
MonoBehaviour.didAwake
MonoBehaviour.runInEditMode
Behaviour.enabled
Behaviour.isActiveAndEnabled
Component.GetComponent<T>()
Component.TryGetComponent<T>(out T)
Component.GetComponentInChildren<T>()
Component.GetComponentsInChildren<T>()
Component.GetComponentInParent<T>()
Component.GetComponentsInParent<T>()
Component.GetComponents<T>()
Component.GetComponentIndex()
Component.CompareTag(TagHandle)
Component.transform
Component.transformHandle
Component.gameObject
Component.tag
Object.GetEntityId()
Object.GetInstanceID()
Object.GetHashCode()
Object.InstantiateAsync<T>(T)
Object.InstantiateAsync<T>(T, Transform)
Object.InstantiateAsync<T>(T, Vector3, Quaternion)
Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion, Transform)
Object.Instantiate(Object)
Object.Instantiate(Object, Scene)
Object.Instantiate<T>(T, InstantiateParameters)
Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
Object.Instantiate(Object, Transform)
Object.Instantiate<T>(T)
Object.Instantiate<T>(T, Vector3, Quaternion)
Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
Object.Instantiate<T>(T, Transform)
Object.Destroy(Object)
Object.DestroyImmediate(Object)
Object.DontDestroyOnLoad(Object)
Object.DestroyObject(Object)
Object.FindObjectsOfType<T>()
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindObjectOfType<T>()
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Object.FindObjectsByType<T>()
Object.FindObjectsByType<T>(FindObjectsInactive)
Object.name
Object.hideFlags

Properties

Order

Execution order in the unified prediction pipeline. Runs before AbilityController so newly elapsed cooldowns are removed before ability start checks in the same tick.

public int Order { get; }

Property Value

int

Methods

AddCooldown(long, CooldownInstance)

Adds a cooldown for the specified ability.

public void AddCooldown(long id, CooldownInstance cooldown)

Parameters

id long

Ability ID.

cooldown CooldownInstance

Cooldown instance.

Clear()

Clears all cooldowns.

public void Clear()

CreateReconcileSnapshot()

Creates a reconcile snapshot of all active cooldowns. Returns the cached array when cooldowns haven't changed since the last call. Returns null when no cooldowns are active.

public CooldownReconcileEntry[] CreateReconcileSnapshot()

Returns

CooldownReconcileEntry[]

Remarks

Always allocates a fresh array when dirty, even if the length matches. The delta serializer holds a reference to the previous tick's snapshot; mutating in-place would silently update that reference, making prev == next and masking the change (zero bytes sent when bytes should have been sent).

ExpireElapsed(uint)

public void ExpireElapsed(uint currentTick)

Parameters

currentTick uint

IsOnCooldown(long, uint)

Checks if an ability is on cooldown at the given tick.

public bool IsOnCooldown(long id, uint currentTick)

Parameters

id long

Ability ID.

currentTick uint

The current network tick.

Returns

bool

True if on cooldown, otherwise false.

OnCreateReconcile(ref CharacterReconcileData)

Writes cooldown reconcile state for this tick.

public void OnCreateReconcile(ref CharacterReconcileData reconcileData)

Parameters

reconcileData CharacterReconcileData

Mutable unified reconcile payload.

OnReconcile(CharacterReconcileData, Channel)

Restores cooldowns from authoritative reconcile state.

public void OnReconcile(CharacterReconcileData rd, Channel channel)

Parameters

rd CharacterReconcileData

Unified reconcile payload.

channel Channel

Transport channel.

Remarks

The owner always reconciles — this is the authority for its own cooldown simulation, and the correction that removes a cooldown it mispredicted.

A non-owner only reconciles a forwarded object, because that is the only mode in which it runs the ability simulation at all and therefore the only mode in which a peer's cooldowns mean anything to it. With forwarding off an observer never receives this reconcile, so the guard states the contract rather than defending against a message that cannot arrive — and it keeps the reconcile path aligned with what the spawn payload already decided: AbilityController.WritePayload writes the cooldown block with includeEntries: isOwner, framed with a zero count for everyone else, because observers never read a peer's cooldowns. Without this guard the two paths disagreed about the same fact the moment forwarding was switched on. See ObserverSyncMode.

OnReplicate(ref CharacterReplicateData, ReplicateState, Channel)

Expires elapsed cooldowns deterministically for the current prediction tick.

public void OnReplicate(ref CharacterReplicateData input, ReplicateState state, Channel channel)

Parameters

input CharacterReplicateData

Unified replicate input containing the network tick.

state ReplicateState

Current replicate execution state.

channel Channel

Transport channel.

OnStartNetwork()

Called when the network has initialized this object. May be called for server or client but will only be called once. When as host or server this method will run before OnStartServer. When as client only the method will run before OnStartClient.

public override void OnStartNetwork()

PopulateInput(ref CharacterReplicateData)

Cooldowns do not contribute owner input into CharacterReplicateData.

public void PopulateInput(ref CharacterReplicateData input)

Parameters

input CharacterReplicateData

Unified replicate data for this tick.

Read(Reader, uint)

Reads cooldown data from a network reader.

public void Read(Reader reader, uint currentTick)

Parameters

reader Reader

The network reader.

currentTick uint

Current tick for computing UI-facing remaining time.

RemoveCooldown(long)

Removes the cooldown for the specified ability.

public void RemoveCooldown(long id)

Parameters

id long

Ability ID.

ResetState(bool)

Resets this NetworkBehaviour so that it may be added to an object pool.

public override void ResetState(bool asServer)

Parameters

asServer bool

ResolveAuthoritativeTick(uint)

Maps a raw authoritative tick to the current replicate-domain tick when available.

public uint ResolveAuthoritativeTick(uint serverTick)

Parameters

serverTick uint

Fallback authoritative tick.

Returns

uint

The current replicate-domain tick if one can be derived, otherwise serverTick.

RestoreFromReconcile(CooldownReconcileEntry[])

Restores cooldown state from a reconcile snapshot, replacing current entries only when they differ.

public void RestoreFromReconcile(CooldownReconcileEntry[] entries)

Parameters

entries CooldownReconcileEntry[]

TryGetCooldown(long, uint, out float)

Tries to get the remaining cooldown time in seconds for an ability.

public bool TryGetCooldown(long id, uint currentTick, out float cooldown)

Parameters

id long

Ability ID.

currentTick uint

The current network tick.

cooldown float

Remaining cooldown time in seconds.

Returns

bool

True if found and still on cooldown, otherwise false.

TryGetCooldownInstance(long, out CooldownInstance)

Tries to get the full cooldown instance for an ability or consumable.

public bool TryGetCooldownInstance(long id, out CooldownInstance instance)

Parameters

id long

Ability or consumable template ID.

instance CooldownInstance

The cooldown instance.

Returns

bool

True if a cooldown is tracked for the id.

Write(Writer)

Writes cooldown data to a network writer. Wire format: uint payloadReferenceTick, int count, then per cooldown: long abilityID, uint startTick, uint durationTicks.

public void Write(Writer writer)

Parameters

writer Writer

The network writer.

Remarks

This is a payload / initial-sync path. See Read(Reader, uint) remarks.

Write(Writer, bool)

Writes cooldown data, optionally as an empty block.

public void Write(Writer writer, bool includeEntries)

Parameters

writer Writer

The network writer.

includeEntries bool

False to write an empty, still-framed block.

Remarks

includeEntries is false for connections that are not this character's owner. Cooldowns gate the owner's own activations and drive the owner's hotkey bar; an observer never reads a peer's — IsOnCooldown is only consulted inside the caster's own replicate, which observers do not run for peers. The one case where an observer does run it, forwarded mode, is served by the absolute reconcile FishNet sends on the tick an observer is added, which carries the cooldown array. Writing the same framed block with a zero count keeps Read(Reader, uint) unchanged.