import type { GameLoop } from "./defineGame.js"; import type { SystemDefinition } from "./defineSystem.js"; import { type CompiledSystemSchedule, type CompileSystemScheduleOptions } from "./systemSchedule.js"; import type { GameContext } from "../runtime/gameContext.js"; import type { SnapshotModule } from "../runtime/worldSnapshot.js"; /** @internal */ export interface SystemModuleRegistration { registerSave(module: SnapshotModule): void; registerReplicate(module: SnapshotModule): void; } /** @internal */ export interface InstalledSystems { readonly schedule: CompiledSystemSchedule; /** Advance fixed/frame/interval systems for one game-time step of `dt` seconds. */ tick(ctx: GameContext, dt: number): void; /** Invoke every system's `reset` (scenario/run wipe). */ reset(ctx: GameContext): void; /** Retire once in reverse order; finish cleanup before rethrowing the first error. */ dispose(ctx: GameContext): void; /** Run one manual system by id (no-op if missing or not manual). */ runManual(ctx: GameContext, id: string, dt?: number): void; } /** * Install systems on a live context: `create` → bind events → register save/replicate → `start`. * Call once per world boot. Failed installation retires entered systems and listeners, then rethrows the startup error. * @internal */ export declare function installSystems(ctx: GameContext, systems: readonly SystemDefinition[], options?: CompileSystemScheduleOptions & { modules?: SystemModuleRegistration; }): InstalledSystems; /** * Look up systems installed on `ctx` (if any). Used by hosts that need `reset`/`dispose` after boot. * @internal */ export declare function systemsOf(ctx: GameContext): InstalledSystems | undefined; /** @internal */ export interface ComposeGameLoopOptions extends CompileSystemScheduleOptions { /** * When true, the user loop's `onTick` runs before system ticks (default: systems first, then * residual loop work — the incremental-migration path). */ loopBeforeSystems?: boolean; } /** * Merge a system list with an optional classic `GameLoop` into one loop the shell/runners drive. * Systems install on first `onInit`; classic hooks still run for incremental migration. * * @capability compose-game-loop fold composable systems into the game loop without a manual tick fan-out */ export declare function composeGameLoop(systems: readonly SystemDefinition[] | undefined, loop: GameLoop | undefined, options?: ComposeGameLoopOptions): GameLoop;