StateMachineBase

Entityceramic.StateMachineBase (Class) → StateMachineImpl

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 instead.

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: Bool

Default is false, automatically set to true when any of this instance's observable variables has changed.


paused: Bool

When set to true, the state machine will stop calling update() on current state and related.


autoUpdate: Bool

When set to true (default). This state machine will be updated automatically. If false, you'll need to call update() manually.


stateDefined: Bool

Is true if a state has been assigned, false otherwise.


nextStateDefined: Bool

Is true if a nextState has been assigned, false otherwise.


locked: Bool

If set to true, changing state will be forbidden and trigger an error.


initializerName: String

update(delta: Float): Void

Updates 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(): Void

new(): Void

Private Members

NO_STATE: Dynamic

A way to assign null state to generic classes and let final target do what is best as a cast


stateInstances: Map

currentStateInstance: State

emitObservedDirty(instance: StateMachineBase, fromSerializedField: Bool): Void

Event when any observable value as changed on this instance.

Name Type
instance StateMachineBase
fromSerializedField Bool

bindAsComponent(): Void

setEntity(entity: Entity): 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()