Table of Contents

Struct AIStateClock

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Schedules a state's updates and reports how much time each one covers.

public struct AIStateClock
Inherited Members

Remarks

A state asks to be updated every updateRate seconds, and the brain ticks far more often than that. The update used to be handed the brain's tick delta — one eighth of a second — as "time elapsed", so every timer a state advanced with it (attack cooldowns, stuck detection, retreat patience, target re-evaluation) ran at the brain rate divided by the state rate: a 1.2 s attack cooldown took ten seconds of wall clock. The clock now accumulates the ticks between updates and hands the state the real interval.

Fields

Elapsed

Seconds accumulated since the previous update.

public float Elapsed

Field Value

float

NextUpdate

Seconds until the next update is due.

public float NextUpdate

Field Value

float

Methods

Advance(float, out float)

Advances by one brain tick.

public bool Advance(float deltaTime, out float elapsed)

Parameters

deltaTime float

Seconds in this brain tick.

elapsed float

When true is returned, the seconds the due update covers.

Returns

bool

True if an update is due now.

Remarks

When an update is due the wait is left alone for the caller to Rearm(float, float); otherwise the tick is counted against it.

Rearm(float, float)

Arms the clock for a state that wants its next update after rate seconds.

public void Rearm(float rate, float deltaTime = 0)

Parameters

rate float

The state's update rate, in seconds.

deltaTime float

The brain tick being processed, already counted against the wait.