Class ScyllaLayeredStateMachine<TContext>
A container for concurrent state machine layers sharing one context. Each layer is an independent ScyllaStateMachine<TContext> with its own current state; ticking the container ticks every layer in index order. Useful for agents that run orthogonal behaviors side by side (for example locomotion, stance, and vocalization).
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public sealed class ScyllaLayeredStateMachine<TContext>
Type Parameters
| Name | Description |
|---|---|
| TContext | The shared context type passed to every state callback of every layer. |
Remarks
Layers are started and driven individually via GetLayer(int) (each
layer's Start, TransitionTo, and events remain fully
accessible); the container only fans out Tick(float) and
FixedTick(float) and offers StopAll(). Stopped layers
no-op their ticks, so mixed running/stopped layers are fine.
Remember that one state instance belongs to exactly one machine; layers must not share state instances.
Constructors
ScyllaLayeredStateMachine(TContext)
Creates a new layered state machine container operating on the given context.
Declaration
public ScyllaLayeredStateMachine(TContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| TContext | context | The shared context passed to every layer's state callbacks. |
Properties
Context
Gets the shared context passed to every layer's state callbacks.
Declaration
public TContext Context { get; }
Property Value
| Type | Description |
|---|---|
| TContext |
LayerCount
Gets the number of layers currently registered.
Declaration
public int LayerCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
AddLayer()
Creates a new plain state machine layer on the shared context, registers it,
and returns it. Start the layer via its own Start method.
Declaration
public ScyllaStateMachine<TContext> AddLayer()
Returns
| Type | Description |
|---|---|
| ScyllaStateMachine<TContext> | The newly created layer. |
AddLayer(ScyllaStateMachine<TContext>)
Registers an externally constructed machine as a layer, for example a ScyllaPushdownStateMachine<TContext>. The machine must operate on the same context as this container.
Declaration
public ScyllaStateMachine<TContext> AddLayer(ScyllaStateMachine<TContext> machine)
Parameters
| Type | Name | Description |
|---|---|---|
| ScyllaStateMachine<TContext> | machine | The machine to register as a layer. |
Returns
| Type | Description |
|---|---|
| ScyllaStateMachine<TContext> | The registered machine, for chaining. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
| ArgumentException | Thrown when the machine's context differs from this container's context. |
FixedTick(float)
Forwards a fixed-rate tick to every layer in index order. Stopped layers no-op.
Declaration
public void FixedTick(float fixedDeltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| float | fixedDeltaTime | The fixed step duration in seconds. |
GetLayer(int)
Returns the layer at the given index, in registration order.
Declaration
public ScyllaStateMachine<TContext> GetLayer(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The zero-based layer index. |
Returns
| Type | Description |
|---|---|
| ScyllaStateMachine<TContext> | The layer at |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when |
StopAll()
Stops every layer. Layers that are not running are skipped (their Stop
is a no-op).
Declaration
public void StopAll()
Tick(float)
Forwards a variable-rate tick to every layer in index order. Stopped layers no-op.
Declaration
public void Tick(float deltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| float | deltaTime | The elapsed time in seconds since the previous tick. |