Skip to content

GameSession beta ​

Interface of @v12-engine/engine

ts
export interface GameSession

A seat in a game: the only thing a client needs to play

Members ​

alpha ​

ts
readonly alpha: number;

How far the current frame is between the last two snapshots, 0..1

cameras ​

ts
readonly cameras: readonly MapCamera[];

The views of the map saved under names, for cinematics and a player's first view (see MapCamera)

camps ​

ts
camps(): readonly CampInfo[];

The creep camps the player knows of, with whether each is cleared

can ​

ts
readonly can: SessionCan;

What this kind of session can do besides being a seat (SessionCan): hold the pace, save, show the debug tools, tell its timing, serve a computer player. A seat over a wire can none of it; a game in this page most of it

canPlace ​

ts
canPlace(unitType: string, point: Vec2): boolean;

Whether the player could build this here, as far as they can tell

dispose ​

ts
dispose(): void;

Stops the session and lets go of what it holds

doodads ​

ts
readonly doodads: readonly MapDoodad[];

The scenery of the map, for the screen: none when it has none (see MapDoodad)

environment ​

ts
readonly environment?: MapEnvironment;

What the map looks like beyond its ground, for the screen: its water, sky, weather. Nothing when it does not say. As it was when the session began: what the rules change after comes as environment events

failure ​

ts
readonly failure?: {
        message: string;
    } | null;

Why the game ended on an error in its rules, once it has (World.failure): what the player is told. A game that failed does not go on; a client says so, and offers what there is to offer

findPath ​

ts
findPath(from: Vec2, to: Vec2, flying?: boolean): Vec2[] | null;

Route a unit would take, over the ground the player knows

fog ​

ts
fog(): FogState;

The player's team's fog now, per cell

formationPlaces ​

ts
formationPlaces?(units: readonly (FormationUnit & {
        readonly flying?: boolean;
    })[], point: Vec2, facing?: number, formation?: string): Map<EntityId, Vec2>;

Where a group of units would stand if sent to a point in a formation, turned to face a way (facing: the way a right-click was dragged): the ghosts of that drag. By the formation's id, or the one the rules would pick (the session's own where it knows the rules, rows where not). Worked out from what the player's screen knows, over the ground the player knows; the formation hook does not run in it

log ​

ts
readonly log?: Logger;

What the game says about what it does (World.log), where the session has it: a game played in the page. A server's game says it on the server, and a player is not given it

observer ​

ts
readonly observer?: boolean;

Whether the player only watches, and sees everything (every player's resources among it): see LocalSession.observer

paths ​

ts
readonly paths: readonly MapPath[];

The paths of the map (a road), for the screen: a cinematic's camera on a rail along one (see MapPath)

ping ​

ts
readonly ping?: number;

Milliseconds a message takes to the simulation and back, where it runs elsewhere. Nothing in the page

placeCells ​

ts
placeCells?(unitType: string, point: Vec2): readonly boolean[] | undefined;

Which cells of the ground a building would cover there are in the way, as far as the player can tell, row by row from its corner (placementCells): what a preview draws cell by cell. None for one built on a resource, or where the session does not say

playerId ​

ts
readonly playerId: PlayerId;

The player this seat plays, or watches from the side of

regions ​

ts
readonly regions: readonly MapRegion[];

The regions of the map, for the screen: what mist in places lies over by name (see MapRegion, AreaRef)

registry ​

ts
readonly registry: Registry;

The definitions of the game the session runs, the same for everyone

send ​

ts
send(command: PlayerCommand): number;

Sends a command, to be carried out at the next tick. What it gives is told back with how it went (a command event)

snapshot ​

ts
snapshot(): Snapshot;

State to start from

team ​

ts
readonly team: number;

The team of that player

terrain ​

ts
readonly terrain: Terrain;

The map and the game data are the same for everyone and known up front

tickRate ​

ts
readonly tickRate: number;

Simulation ticks per second

update ​

ts
update(dt: number): Snapshot[];

Lets time pass. Returns the snapshots that came in since the last call, oldest first