ecspresso
    Preparing search index...

    Interface StateConfig<S, W>

    Configuration for a single state in a state machine definition.

    interface StateConfig<
        S extends string,
        W extends BaseWorld<StateMachineComponentTypes> = StateMachineWorld,
    > {
        on?: Record<
            string,
            S
            | { target: S; guard(ctx: { ecs: W; entityId: number }): boolean },
        >;
        transitions?: readonly {
            target: S;
            guard(ctx: { ecs: W; entityId: number }): boolean;
        }[];
        onEnter?(ctx: { ecs: W; entityId: number }): void;
        onExit?(ctx: { ecs: W; entityId: number }): void;
        onUpdate?(ctx: { dt: number; ecs: W; entityId: number }): void;
    }

    Type Parameters

    • S extends string

      Union of state name strings

    • W extends BaseWorld<StateMachineComponentTypes> = StateMachineWorld

      World interface type for hooks/guards (default: StateMachineWorld)

    Index

    Properties

    on?: Record<
        string,
        S
        | { target: S; guard(ctx: { ecs: W; entityId: number }): boolean },
    >

    Event-based transition map: eventName → target state or guarded transition

    transitions?: readonly {
        target: S;
        guard(ctx: { ecs: W; entityId: number }): boolean;
    }[]

    Guard-based transitions evaluated each tick. First passing guard wins.

    Methods

    • Called when entering this state

      Parameters

      • ctx: { ecs: W; entityId: number }

      Returns void

    • Called when exiting this state

      Parameters

      • ctx: { ecs: W; entityId: number }

      Returns void

    • Called each tick while in this state

      Parameters

      • ctx: { dt: number; ecs: W; entityId: number }

      Returns void