import { PerfTrackName } from "../debug/perf-track.js"; import { World } from "koota"; //#region src/ecs/SystemSchedule.d.ts /** * A system function takes only a world — all context comes from world resource traits. */ type SystemFn = (world: World) => void; /** * Perf label attached at registration. Mandatory so the whole schedule * is tracked — TypeScript guarantees every system carries a track + name. */ interface SystemLabel { track: PerfTrackName; name: string; } /** * Ordered system runner with frame-level idempotency. * * Systems are registered via `add()` and executed in registration order * by `run()`. Calling `run()` multiple times within the same frame is * a no-op after the first — `nextFrame()` advances the frame counter * to allow the next execution. * * Every registration carries a perf label (`{ track, name }`). When * devtools is bundled, `run()` emits a `performance.measure` span per * system plus an outer `ecs:run` span on the Schedule track. In prod * the instrumented branch is dead code (terser folds the devtools build * gate) and `run()` is the plain loop. * * @example * ```typescript * const schedule = new SystemSchedule() * schedule.add(lightSyncSystem, { track: PERF_TRACK.Lighting, name: 'lightSync' }) * schedule.add(batchAssignSystem, { track: PERF_TRACK.Batch, name: 'batchAssign' }) * * // In render loop: * schedule.nextFrame() * schedule.run(world) // executes all systems * schedule.run(world) // no-op (same frame) * ``` */ declare class SystemSchedule { private _systems; private _frameId; private _lastRunFrame; /** Register a system at the end. Execution order matches registration order. */ add(system: SystemFn, label: SystemLabel): this; /** Register a system at the beginning. Used to insert phases before existing systems. */ prepend(system: SystemFn, label: SystemLabel): this; /** Unregister a system. */ remove(system: SystemFn): this; /** Execute all registered systems. Idempotent within a frame. */ run(world: World): void; /** Advance the frame counter, allowing the next `run()` to execute. */ nextFrame(): void; } //#endregion export { SystemFn, SystemLabel, SystemSchedule }; //# sourceMappingURL=SystemSchedule.d.ts.map