@hiddentao/clockwork-engine
Version:
A TypeScript/PIXI.js game engine for deterministic, replayable games with built-in rendering
64 lines • 2.36 kB
TypeScript
import type { GameEngine } from "./GameEngine";
import type { GameRecording } from "./types";
export declare class ReplayManager {
protected __engine: GameEngine;
protected engine: GameEngine;
protected isReplaying: boolean;
protected deltaTicksIndex: number;
protected recording: GameRecording | null;
protected currentReplayTick: number;
protected accumulatedTicks: number;
constructor(engine: GameEngine);
/**
* Create the proxy GameEngine that intercepts update() calls during replay
* The proxy implements the replay logic and calls the real engine with recorded deltaFrames
*/
protected createProxyEngine(): GameEngine;
/**
* Get the proxy GameEngine (same as this.engine)
*/
getReplayEngine(): GameEngine;
/**
* Start replaying a recorded game session with full validation
* Validates recording structure, resets engine state, and begins deterministic replay
* @param recording Complete game recording with events, deltaFrames, and metadata
* @throws Error if already replaying or recording is invalid
*/
replay(recording: GameRecording): Promise<void>;
/**
* Stop the current replay and end the engine
* Preserves current frame position for inspection
*/
protected _endReplay(): void;
/**
* Stop the current replay and end the engine
* Preserves current frame position for inspection
*/
stopReplay(): void;
/**
* Check if currently replaying a recording
* @returns True if replay is active, false otherwise
*/
isCurrentlyReplaying(): boolean;
/**
* Get the current tick number during replay
* @returns Current replay tick position
*/
getCurrentTick(): number;
/**
* Get comprehensive replay progress information
* Provides completion percentage and remaining tick status
* @returns Object containing replay state, progress (0-1), and tick availability
*/
getReplayProgress(): {
isReplaying: boolean;
progress: number;
hasMoreTicks: boolean;
};
/**
* Validate recording structure to ensure it's safe and complete for replay
* @param recording The recording to validate
*/
protected validateRecording(recording: GameRecording): void;
}
//# sourceMappingURL=ReplayManager.d.ts.map