GameSession beta
Interface of @v12-engine/engine
export interface GameSessionA seat in a game: the only thing a client needs to play
Members
alpha
readonly alpha: number;How far the current frame is between the last two snapshots, 0..1
cameras
readonly cameras: readonly MapCamera[];The views of the map saved under names, for cinematics and a player's first view (see MapCamera)
camps
camps(): readonly CampInfo[];The creep camps the player knows of, with whether each is cleared
can
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
canPlace(unitType: string, point: Vec2): boolean;Whether the player could build this here, as far as they can tell
dispose
dispose(): void;Stops the session and lets go of what it holds
doodads
readonly doodads: readonly MapDoodad[];The scenery of the map, for the screen: none when it has none (see MapDoodad)
environment
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
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
findPath(from: Vec2, to: Vec2, flying?: boolean): Vec2[] | null;Route a unit would take, over the ground the player knows
fog
fog(): FogState;The player's team's fog now, per cell
formationPlaces
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
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
readonly observer?: boolean;Whether the player only watches, and sees everything (every player's resources among it): see LocalSession.observer
paths
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
readonly ping?: number;Milliseconds a message takes to the simulation and back, where it runs elsewhere. Nothing in the page
placeCells
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
readonly playerId: PlayerId;The player this seat plays, or watches from the side of
regions
readonly regions: readonly MapRegion[];The regions of the map, for the screen: what mist in places lies over by name (see MapRegion, AreaRef)
registry
readonly registry: Registry;The definitions of the game the session runs, the same for everyone
send
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
snapshot(): Snapshot;State to start from
team
readonly team: number;The team of that player
terrain
readonly terrain: Terrain;The map and the game data are the same for everyone and known up front
tickRate
readonly tickRate: number;Simulation ticks per second
update
update(dt: number): Snapshot[];Lets time pass. Returns the snapshots that came in since the last call, oldest first