StateMachine
A flexible state machine implementation for managing state transitions.
StateMachine provides a powerful way to manage complex state logic in your application. It supports string-based or enum-based state identification, automatic state lifecycle management, and type-safe state access.
Features:
- Type-safe state management using enums or strings
- Automatic enter/exit/update lifecycle calls
- State transition events
- Integration with Ceramic's entity system
- Support for pausing/resuming state updates
Example with enum states:
enum PlayerState {
IDLE;
WALKING;
JUMPING;
}
var machine = new StateMachine<PlayerState>();
machine.set(IDLE, new IdleState());
machine.set(WALKING, new WalkingState());
machine.set(JUMPING, new JumpingState());
machine.state = IDLE; // Start in idle state
Example with string states:
var machine = new StateMachine<String>();
machine.set("menu", new MenuState());
machine.set("game", new GameState());
machine.set("pause", new PauseState());
machine.state = "menu";
See: State, StateMachineBase
Instance Members
new(): Void
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() |