import { GameEventBus } from "../classes/eventBus.d.ts"; /** * A generic finite state machine with optional guard functions, lifecycle callbacks, and event bus integration. * * @template States - A string union of valid state names. */ export declare class StateMachine { private _currentState; private readonly transitions; private readonly wildcardTransitions; private readonly enterCallbacks; private readonly exitCallbacks; private readonly eventBus?; constructor(initialState: States, eventBus?: GameEventBus>); get currentState(): States; /** * Register a valid transition from one state to another, with an optional guard function. */ addTransition(from: States, to: States, guard?: () => boolean): void; /** * Register a wildcard transition: allows transitioning to the given state from any state. */ addTransitionFromAny(to: States, guard?: () => boolean): void; /** * Register a callback to run when entering a state. */ onEnter(state: States, callback: () => void): void; /** * Register a callback to run when exiting a state. */ onExit(state: States, callback: () => void): void; /** * Check if a transition to the given state is defined (ignoring guards). */ canTransition(to: States): boolean; /** * Execute a transition to the target state. * Flow: validate -> run guard -> call exit callbacks -> change state -> call enter callbacks. * * @throws If no transition is defined from the current state to the target, or if a guard rejects. */ transition(to: States): void; }