@geckos.io/snapshot-interpolation
Version:
A Snapshot Interpolation library for Real-Time Multiplayer Games
51 lines • 2.06 kB
TypeScript
import { Snapshot, InterpolatedSnapshot, State } from './types';
import { Vault } from './vault';
interface Config {
autoCorrectTimeOffset?: boolean;
}
/** A Snapshot Interpolation library. */
export declare class SnapshotInterpolation {
/** Access the vault. */
vault: Vault;
private _interpolationBuffer;
private _timeOffset;
/** The current server time based on the current snapshot interpolation. */
serverTime: number;
config: Config;
constructor(serverFPS?: number | null, config?: Config);
get interpolationBuffer(): {
/** Get the Interpolation Buffer time in milliseconds. */
get: () => number;
/** Set the Interpolation Buffer time in milliseconds. */
set: (milliseconds: number) => void;
};
/** Get the current time in milliseconds. */
static Now(): number;
/**
* Get the time offset between client and server (inclusive latency).
* If the client and server time are in sync, timeOffset will be the latency.
*/
get timeOffset(): number;
/** Create a new ID */
static NewId(): string;
get snapshot(): {
/** Create the snapshot on the server. */
create: (state: State | {
[]: State;
}) => Snapshot;
/** Add the snapshot you received from the server to automatically calculate the interpolation with calcInterpolation() */
add: (snapshot: Snapshot) => void;
};
/** Create a new Snapshot */
static CreateSnapshot(state: State | {
[key: string]: State;
}): Snapshot;
private addSnapshot;
/** Interpolate between two snapshots give the percentage or time. */
interpolate(snapshotA: Snapshot, snapshotB: Snapshot, timeOrPercentage: number, parameters: string, deep?: string): InterpolatedSnapshot;
private _interpolate;
/** Get the calculated interpolation on the client. */
calcInterpolation(parameters: string, deep?: string): InterpolatedSnapshot | undefined;
}
export {};
//# sourceMappingURL=snapshot-interpolation.d.ts.map