Class ScyllaCompositeState<TContext>
A state that owns a nested child state machine, forming one level of a hierarchical state machine. Entering the composite starts its child machine at the configured initial child state; exiting stops the child machine; ticks are forwarded to the active child.
Implements
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public class ScyllaCompositeState<TContext> : ScyllaStateBase<TContext>, IScyllaState<TContext>
Type Parameters
| Name | Description |
|---|---|
| TContext | The shared context type passed to every state callback. The child machine shares the parent machine's context. |
Remarks
Composite states can be nested arbitrarily deep by using another ScyllaCompositeState<TContext> as a child state. The active leaf chain can be inspected via GetActivePath(List<IScyllaState<TContext>>).
Each time the composite is entered, the child machine restarts at the initial child state; child state history is not preserved across exits.
Constructors
ScyllaCompositeState(TContext, IScyllaState<TContext>)
Creates a composite state with its own child state machine.
Declaration
public ScyllaCompositeState(TContext context, IScyllaState<TContext> initialChildState)
Parameters
| Type | Name | Description |
|---|---|---|
| TContext | context | The shared context, forwarded to the child machine. Pass the same context the parent machine uses. |
| IScyllaState<TContext> | initialChildState | The child state entered whenever this composite state is entered. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
Properties
ChildMachine
Gets the nested child state machine owned by this composite state.
Declaration
public ScyllaStateMachine<TContext> ChildMachine { get; }
Property Value
| Type | Description |
|---|---|
| ScyllaStateMachine<TContext> |
InitialChildState
Gets the child state entered whenever this composite state is entered.
Declaration
public IScyllaState<TContext> InitialChildState { get; }
Property Value
| Type | Description |
|---|---|
| IScyllaState<TContext> |
Methods
OnEnter(TContext)
Starts the child machine at InitialChildState.
Declaration
public override void OnEnter(TContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| TContext | context | The machine's shared context. |
Overrides
OnExit(TContext)
Stops the child machine, exiting its current child state.
Declaration
public override void OnExit(TContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| TContext | context | The machine's shared context. |
Overrides
OnFixedTick(TContext, float)
Forwards the fixed tick to the child machine's current state.
Declaration
public override void OnFixedTick(TContext context, float fixedDeltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| TContext | context | The machine's shared context. |
| float | fixedDeltaTime | The fixed step duration in seconds. |
Overrides
OnTick(TContext, float)
Forwards the tick to the child machine's current state.
Declaration
public override void OnTick(TContext context, float deltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| TContext | context | The machine's shared context. |
| float | deltaTime | The elapsed time in seconds since the previous tick. |