UNPKG

@casual-simulation/aux-common

Version:
65 lines 1.93 kB
export declare class StateMachine { readonly name: string; /** * Debug level of this state machine. * 0 = off; 1 = enter, exit; 2 = transitions, 3 = update */ debugLevel: number; /** * Map of available states. state id -> State. */ private _states; /** * Map of transition hash code -> state id */ private _transitions; /** * The currently active state's id. */ private _curStateId; /** * The state id to change to next. */ private _changeStateId; private _curFrame; private _lastUpdateFrame; private _active; get currentState(): State; /** * Create a new state machine. Setup the state machine using `addState` and `addStateTransition`. * Start the state machine using the `start` method. Manually call `update` every frame in order to update the state machine. */ constructor(name: string); start(startingStateId: string, curFrame: number): void; pause(): void; resume(curFrame: number): void; addState(state: State): void; addStateTransition(transition: Transition, nextStateId: string): void; getState(stateId: string): State; update(curFrame: number): void; toString(): string; /** * Call this when getting rid of the state machine. */ dispose(): void; /** * Usually this state machine should be controlled with state transitions, but in some cases we may want to force a state change. */ forceChangeState(stateId: string): void; private _changeState; private getNextStateId; } export declare abstract class State { private _id; get id(): string; constructor(id: string); abstract onStateEnter(): void; abstract onStateUpdate(): string; abstract onStateExit(): void; } interface Transition { stateId: string; command: string; } export {}; //# sourceMappingURL=StateMachine.d.ts.map