StateMachineBase
Base class for state machine implementations.
StateMachineBase provides the core functionality for state machines in Ceramic.
It manages state lifecycle, transitions, and integration with the entity system.
This class is typically not used directly - use StateMachine
Features:
- Automatic state updates via StateMachineSystem
- Pausable state execution
- State locking to prevent transitions
- Component interface for entity attachment
- Observable pattern for state change events
The state machine automatically calls:
- exit() on the previous state
- enter() on the new state
- update(delta) on the active state each frame
Instance Members
observedDirty: BoolDefault is false, automatically set to true when any of this instance's observable variables has changed.
paused: BoolWhen set to true, the state machine will stop calling update() on current state and related.
autoUpdate: BoolWhen set to true (default). This state machine will be updated automatically.
If false, you'll need to call update() manually.
stateDefined: BoolIs true if a state has been assigned, false otherwise.
nextStateDefined: BoolIs true if a nextState has been assigned, false otherwise.
locked: BoolIf set to true, changing state will be forbidden and trigger an error.
initializerName: StringUpdates the current state. Called automatically each frame if autoUpdate is true and not paused.
| Name | Type | Description |
|---|---|---|
delta |
Float | Time elapsed since last update in seconds |
destroy(): Voidnew(): VoidPrivate Members
NO_STATE: DynamicA way to assign null state to generic classes and let final target do what is best as a cast
stateInstances: MapcurrentStateInstance: StateemitObservedDirty(instance: StateMachineBase, fromSerializedField: Bool): VoidEvent when any observable value as changed on this instance.
| Name | Type |
|---|---|
instance |
StateMachineBase |
fromSerializedField |
Bool |
bindAsComponent(): Void| Name | Type |
|---|---|
entity |
Entity |
getEntity(): Entity| Returns |
|---|
| Entity |
Metadata
| Name | Parameters |
|---|---|
:build |
ceramic.macros.ComponentMacro.build() |
:autoBuild |
ceramic.macros.ComponentMacro.build() |
:build |
tracker.macros.ObservableMacro.build() |
:autoBuild |
tracker.macros.ObservableMacro.build() |
:build |
ceramic.macros.EntityMacro.buildForCompletion() |
:autoBuild |
ceramic.macros.EntityMacro.buildForCompletion() |
:build |
tracker.macros.EventsMacro.build() |
:autoBuild |
tracker.macros.EventsMacro.build() |