import { AbstractEngine, Scene } from '@babylonjs/core'; import { Disposable } from "../interfaces/lifecycle.d.ts"; import { GameEventBus } from "../classes/eventBus.d.ts"; import { GameEntityManager } from "./entity.d.ts"; import { LevelManager } from "./level.d.ts"; import { UserInputManager } from "./input.d.ts"; import { LoggingUtility } from "../utils/logger.d.ts"; /** * Callback function for frame updates. * Called once per frame with the delta time in seconds. */ export type FrameCallback = (deltaTime: number) => void; export declare class GameManager implements Disposable { private _engine; private _eventBus; private _entityManager; private _inputManager; private _levelManager; private _log; private _boundRenderLoop; private _boundResizeHandler; /** Registered frame callbacks, executed in registration order */ private _frameCallbacks; /** Counter for generating unique callback IDs */ private _nextCallbackId; /** Whether the game is currently paused */ private _paused; started: boolean; constructor(engine: AbstractEngine, eventBus: GameEventBus, entityManager: GameEntityManager, inputManager: UserInputManager, levelManager: LevelManager, logger?: LoggingUtility); get currentScene(): Scene | null; /** * Whether the game is currently paused. * When paused, entity updates and frame callbacks are skipped, but rendering continues. */ get isPaused(): boolean; /** * Register a callback to be called once per frame. * * **Advanced Usage**: This is intended for systems that need frame-by-frame updates * outside of the entity/behavior system. For game logic, prefer using entity behaviors * with their `update()` method instead. * * Callbacks are executed in registration order, after entity updates but before rendering. * Each callback receives the delta time in seconds (typically ~0.016 for 60fps). * * @param callback * @returns A function to unregister the callback * * @example * ```typescript * const unsubscribe = gameManager.registerFrameCallback((deltaTime) => { * // deltaTime is in seconds (e.g., 0.016 for 60fps) * console.log(`Frame delta: ${deltaTime}s`); * }); * * // Later, to stop receiving callbacks: * unsubscribe(); * ``` */ registerFrameCallback(callback: FrameCallback): () => void; private _renderLoop; private _resizeHandler; start(): Promise; stop(): Promise; /** * Pause the game. Entity updates and frame callbacks will be skipped, * but rendering continues (frozen frame). Input is still polled so * the game can be unpaused. * * Emits a 'game:paused' event. * * @param reason - Optional reason for pausing (included in event payload) */ pause(reason?: string): void; /** * Resume the game after being paused. Entity updates and frame callbacks * will resume. * * Emits a 'game:resumed' event. * * @param reason - Optional reason for resuming (included in event payload) */ resume(reason?: string): void; /** * Tears down any resources held by the GameManager * This handles unregistering event listeners and any other cleanup */ $teardown(): Promise; }