ecspresso
    Preparing search index...

    Interface System<Cfg, WithComponents, WithoutComponents>

    interface System<
        Cfg extends WorldConfig = EmptyConfig,
        WithComponents extends keyof Cfg["components"] = never,
        WithoutComponents extends keyof Cfg["components"] = never,
    > {
        entityQueries?: {
            [queryName: string]: QueryConfig<
                Cfg["components"],
                WithComponents,
                WithoutComponents,
                WithComponents,
            >;
        };
        eventHandlers?: {
            [EventName in string
            | number
            | symbol]?: (
                ctx: { data: Cfg["events"][EventName]; ecs: default<Cfg> },
            ) => void
        };
        excludeScreens?: readonly (keyof Cfg["screens"] & string)[];
        groups?: string[];
        inScreens?: readonly (keyof Cfg["screens"] & string)[];
        label: string;
        onEntityEnter?: Record<
            string,
            (
                ctx: {
                    ecs: default<Cfg>;
                    entity: FilteredEntity<
                        Cfg["components"],
                        WithComponents,
                        WithoutComponents,
                    >;
                },
            ) => void,
        >;
        phase?: SystemPhase;
        priority?: number;
        requiredAssets?: readonly (keyof Cfg["assets"] & string)[];
        runWhenEmpty?: boolean;
        onDetach?(ecs: default<Cfg, string, string, string, string>): void;
        onInitialize?(ecs: default<Cfg>): void | Promise<void>;
        process?(
            ctx: {
                dt: number;
                ecs: default<Cfg>;
                queries: {
                    [queryName: string]: FilteredEntity<
                        Cfg["components"],
                        WithComponents,
                        WithoutComponents,
                        never,
                    >[];
                };
            },
        ): void;
    }

    Type Parameters

    • Cfg extends WorldConfig = EmptyConfig
    • WithComponents extends keyof Cfg["components"] = never
    • WithoutComponents extends keyof Cfg["components"] = never
    Index

    Properties

    entityQueries?: {
        [queryName: string]: QueryConfig<
            Cfg["components"],
            WithComponents,
            WithoutComponents,
            WithComponents,
        >;
    }
    eventHandlers?: {
        [EventName in string | number | symbol]?: (
            ctx: { data: Cfg["events"][EventName]; ecs: default<Cfg> },
        ) => void
    }

    Event handlers for specific event types

    excludeScreens?: readonly (keyof Cfg["screens"] & string)[]

    Screens where this system should NOT run. If specified, system skips when current screen is in this list.

    groups?: string[]

    Groups this system belongs to. If any group is disabled, the system will be skipped.

    inScreens?: readonly (keyof Cfg["screens"] & string)[]

    Screens where this system should run. If specified, system only runs when current screen is in this list.

    label: string
    onEntityEnter?: Record<
        string,
        (
            ctx: {
                ecs: default<Cfg>;
                entity: FilteredEntity<
                    Cfg["components"],
                    WithComponents,
                    WithoutComponents,
                >;
            },
        ) => void,
    >

    Per-query callbacks that fire once per entity the first time it appears in a query's results. Fires before process. Automatic cleanup when entity leaves query (component removed, entity destroyed) so re-entry fires the callback again.

    phase?: SystemPhase

    Execution phase for this system (default: 'update') Systems are grouped by phase and executed in order: preUpdate -> fixedUpdate -> update -> postUpdate -> render

    priority?: number

    System priority - higher values execute first (default: 0) When systems have the same priority, they execute in registration order

    requiredAssets?: readonly (keyof Cfg["assets"] & string)[]

    Assets that must be loaded for this system to run. System will be skipped if any required asset is not loaded.

    runWhenEmpty?: boolean

    When true, the system's process function runs even when all queries return zero entities. Default is false (system is skipped when all queries are empty).

    Methods

    • Lifecycle hook called when the system is detached from the ECS

      Parameters

      • ecs: default<Cfg, string, string, string, string>

        The ECSpresso instance providing access to all ECS functionality

      Returns void

    • Lifecycle hook called when the system is initialized This is called when ECSpresso.initialize() is invoked, after resources are initialized Use this for one-time initialization that depends on resources

      Parameters

      • ecs: default<Cfg>

        The ECSpresso instance providing access to all ECS functionality

      Returns void | Promise<void>

    • Process method that runs during each update cycle. Receives a single context object with queries, dt, and ecs.

      Parameters

      • ctx: {
            dt: number;
            ecs: default<Cfg>;
            queries: {
                [queryName: string]: FilteredEntity<
                    Cfg["components"],
                    WithComponents,
                    WithoutComponents,
                    never,
                >[];
            };
        }

      Returns void