///
import { EventEmitter } from 'events';
import { Vertex2D } from '../math/vertex2d';
import { Vertex3D } from '../math/vertex3d';
import { Pool } from '../util/object-pool';
import { Ball } from '../vpt/ball/ball';
import { ItemState } from '../vpt/item-state';
import { Table } from '../vpt/table/table';
import { IEmulator } from './iemulator';
import { AssignKey } from './key-code';
import { PlayerPhysics } from './player-physics';
export declare class Player extends EventEmitter {
private readonly table;
private readonly pinInput;
private readonly physics;
private isInitialized;
get balls(): Ball[];
private previousStates;
private currentStates;
private simulatedTimeMs;
width: number;
height: number;
constructor(table: Table);
init(scope?: {}): this;
private setupTableElements;
private setupStates;
/**
* This is only used for tests, and simulates time by running the physics
* loop as well as the animations every frame.
* @param dTime Time to simulate in ms
*/
simulateTime(dTime: number): void;
/**
* Runs the physics calculation since last time called.
*
* This is the method the host app should run in its physics loop.
*
* @param dTime Optionally override current time
*/
updatePhysics(dTime?: number): number;
/**
* Updates animations and returns the changed state since last frame.
*
* This is the method the host app should be calling on each frame before
* updating the scene.
*/
onFrame(): ChangedStates;
/**
* Runs one animation cycle for the given time. If more than one cycle has
* to be run over a longer period, this method needs to be called multiple
* times.
*
* @param timeMs Absolute current time
*/
updateAnimations(timeMs: number): void;
/**
* Returns the changed states and clears them.
*
* Note that the returned object is recycled and should be released after
* usage.
*/
popStates(): ChangedStates;
onKeyUp(event: {
code: string;
key: string;
ts: number;
}): void;
onKeyDown(event: {
code: string;
key: string;
ts: number;
}): void;
createBall(ballCreator: IBallCreationPosition, radius?: number, mass?: number): Ball;
destroyBall(ball: Ball): void;
getActiveBall(): Ball | undefined;
getGameTime(): number;
getBalls(): Ball[];
getKey(key: AssignKey): number;
getPhysics(): PlayerPhysics;
setGravity(slopeDeg: number, strength: number): void;
setEmulator(emu: IEmulator): void;
hasDmd(): boolean;
getDmdDimensions(): Vertex2D;
getDmdFrame(): Uint8Array;
setCabinetInput(keyNr: number): void;
setSwitchInput(switchNr: number, optionalEnableSwitch?: boolean): void;
/**
* Sets the dimensions of the render frame.
*
* The host app should call this whenever resizing happens. If you're
* wondering why we would care about render dimensions in the lib, well,
* the script API exposes it!
*
* @param width Width of the render frame in pixels
* @param height Height of the render frame in pixels
*/
setDimensions(width: number, height: number): void;
pause(): void;
resume(): void;
}
export interface IBallCreationPosition {
getBallCreationPosition(table: Table): Vertex3D;
getBallCreationVelocity(table: Table): Vertex3D;
onBallCreated(physics: PlayerPhysics, ball: Ball): void;
}
export declare class ChangedStates {
static readonly POOL: Pool>;
changedStates: {
[key: string]: STATE;
};
get keys(): string[];
get states(): STATE[];
static claim(): ChangedStates;
setState(name: string, state: STATE): void;
getState(name: string): S;
release(): void;
}