Union of state name strings, inferred from states keys
Unique identifier for this definition
Initial state and state configurations
A frozen StateMachineDefinition
const enemyFSM = defineStateMachine('enemy', {
initial: 'idle',
states: {
idle: {
onEnter: ({ ecs, entityId }) => { ... },
transitions: [{ target: 'chase', guard: ({ ecs, entityId }) => playerNearby(ecs, entityId) }],
},
chase: {
onUpdate: ({ ecs, entityId, dt }) => { ... },
on: { playerLost: 'idle' },
},
},
});
Define a state machine with type-safe state names.