A finite state machine
stateMap: Record<string, State>
state: State | undefined
enterState(name: string ): void
Make the machine enter a state
paramname- The new state
onStateEnter(name: string , cb: (sm: StateMachine , previous: string )=>void ): void
Set a callback for when the machine enters a state
paramname- The state
paramcb- The callback
onStateUpdate(name: string , cb: (sm: StateMachine , current: string )=>void ): void
Set a callback for when the machine updates a state
paramname- The state
paramcb- The callback
onStateDraw(name: string , cb: (sm: StateMachine , current: string )=>void ): void
Set a callback for when the machine draws a state
paramname- The state
paramcb- The callback
onStateExit(name: string , cb: (sm: StateMachine , next: string )=>void ): void
Set a callback for when the machine exits a state
paramname- The state
paramcb- The callback
onStateTransition(from: string , to: string , cb: (sm: StateMachine , from: string , to: string )=>void ): void
Set a callback for when the machine transitions from one state to the other state
paramfrom- The state which is exited
paramto- The state which is entered
paramcb- The callback