Interface IScyllaState<TContext>
Contract for a single state managed by a ScyllaStateMachine<TContext>. A state receives lifecycle callbacks when it becomes active or inactive and tick callbacks while it is the machine's current state.
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public interface IScyllaState<in TContext>
Type Parameters
| Name | Description |
|---|---|
| TContext | The shared context type passed to every state callback. Typically a blackboard object holding the data all states of one machine operate on. |
Remarks
States are plain C# objects with no Unity dependency. One state instance should belong to exactly one machine; sharing instances across machines is not supported because the machine does not isolate per-machine state data.
Prefer deriving from ScyllaStateBase<TContext> instead of implementing this interface directly, so new callbacks added in future versions do not break existing states.
Methods
CanEnter(TContext)
Transition guard. Called by the machine before this state is entered.
Return false to reject the transition; the machine then keeps its
current state.
Declaration
bool CanEnter(TContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| TContext | context | The machine's shared context. |
Returns
| Type | Description |
|---|---|
| bool |
|
OnEnter(TContext)
Called when this state becomes the machine's current state.
Declaration
void OnEnter(TContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| TContext | context | The machine's shared context. |
OnExit(TContext)
Called when this state stops being the machine's current state, before the next state's OnEnter(TContext) runs.
Declaration
void OnExit(TContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| TContext | context | The machine's shared context. |
OnFixedTick(TContext, float)
Called once per FixedTick(float) while this state is current. Intended for fixed-step simulation logic.
Declaration
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. |
OnTick(TContext, float)
Called once per Tick(float) while this state is current. Intended for frame-rate dependent logic.
Declaration
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. |