@hastearcade/snowglobe
Version:
A TypeScript port of CrystalOrb, a high-level Rust game networking library
78 lines • 4.33 kB
TypeScript
import { Analytics } from './analytics';
import { ClockSyncer } from './clock_sync';
import { type Command, CommandBuffer } from './command';
import { type FromInterpolationFn, type Tweened } from './display_state';
import { type Stepper, TimeKeeper } from './fixed_timestepper';
import { type Config } from './lib';
import { type NetworkResource } from './network_resource';
import { OldNew } from './old_new';
import { Simulation } from './simulation';
import * as Timestamp from './timestamp';
import { type Option } from './types';
import { type DisplayState, type Snapshot, type World } from './world';
export declare enum StageState {
SyncingClock = 0,
SyncingInitialState = 1,
Ready = 2
}
export declare enum ReconciliationState {
AwaitingSnapshot = 0,
FastForwardingHealthy = 1,
FastForwardingObsolete = 2,
FastForwardingOvershot = 3,
Blending = 4
}
export interface StageOwned<$Command extends Command, $Snapshot extends Snapshot, $DisplayState extends DisplayState> {
clockSyncer: ClockSyncer;
initStateSync: Option<ActiveClient<$Command, $Snapshot, $DisplayState>>;
ready: Option<ActiveClient<$Command, $Snapshot, $DisplayState>>;
}
export declare class Client<$Command extends Command, $Snapshot extends Snapshot, $DisplayState extends DisplayState> {
private readonly id?;
private _state;
private readonly _stage;
private readonly _makeWorld;
private readonly _config;
fromInterpolation: FromInterpolationFn<$DisplayState>;
constructor(makeWorld: () => World<$Command, $Snapshot, $DisplayState>, config: Config, fromInterpolation: FromInterpolationFn<$DisplayState>, id?: string | undefined);
state(): StageState;
stage(): StageOwned<$Command, $Snapshot, $DisplayState>;
update(deltaSeconds: number, secondsSinceStartup: number, net: NetworkResource<$Command, $Snapshot>): void;
}
export declare class ActiveClient<$Command extends Command, $Snapshot extends Snapshot, $DisplayState extends DisplayState> {
clockSyncer: ClockSyncer;
timekeepingSimulations: TimeKeeper<ClientWorldSimulations<$Command, $Snapshot, $DisplayState>>;
readonly analytics: Analytics;
constructor(makeWorld: (ident?: string) => World<$Command, $Snapshot, $DisplayState>, secondsSinceStartup: number, config: Config, clockSyncer: ClockSyncer, fromInterpolation: FromInterpolationFn<$DisplayState>, id?: string);
lastCompletedTimestamp(): Timestamp.Timestamp;
simulatingTimestamp(): Timestamp.Timestamp;
issueCommand(command: $Command, net: NetworkResource<$Command, $Snapshot>): void;
bufferedCommands(): IterableIterator<[Timestamp.Timestamp, Timestamp.Timestamped<$Command>[]]>;
displayState(): Option<Tweened<$DisplayState>>;
worldSimulations(): OldNew<Simulation<$Command, $Snapshot, $DisplayState>>;
reconciliationStatus(): number;
isReady(): boolean;
update(deltaSeconds: number, secondsSinceStartup: number, net: NetworkResource<$Command, $Snapshot>): void;
}
declare class ClientWorldSimulations<$Command extends Command, $Snapshot extends Snapshot, $DisplayState extends DisplayState> implements Stepper {
private readonly config;
queuedSnapshot: Option<Timestamp.Timestamped<$Snapshot>>;
lastQueuedSnapshotTimestamp: Option<Timestamp.Timestamp>;
lastReceivedSnapshotTimestamp: Option<Timestamp.Timestamp>;
baseCommandBuffer: CommandBuffer<$Command>;
worldSimulations: OldNew<Simulation<$Command, $Snapshot, $DisplayState>>;
displayState: Option<Tweened<$DisplayState>>;
blendOldNewInterpolationT: number;
states: OldNew<Option<Timestamp.Timestamped<$DisplayState>>>;
fromInterpolation: FromInterpolationFn<$DisplayState>;
constructor(makeWorld: (ident?: string) => World<$Command, $Snapshot, $DisplayState>, config: Config, initialTimestamp: Timestamp.Timestamp, fromInterpolation: FromInterpolationFn<$DisplayState>);
get reconciliationStatus(): number;
step(): void;
lastCompletedTimestamp(): Timestamp.Timestamp;
receiveCommand(command: Timestamp.Timestamped<$Command>): void;
receiveSnapshot(snapshot: Timestamp.Timestamped<$Snapshot>): void;
resetLastCompletedTimestamp(correctedTimestamp: Timestamp.Timestamp): void;
postUpdate(timestepOvershootSeconds: number): void;
}
export {};
//# sourceMappingURL=client.d.ts.map