SessionView beta
Class of @v12-engine/engine
export declare class SessionViewA seat's side of a world: whose it is, and what they may know of it now. What the rules that tell a player of the world ask (replicateEvent, SnapshotField, an event of a game's own's replicate), and what a seat keeps for them (keep)
Members
constructor
constructor(
world: World,
player: PlayerId, options?: {
observer?: boolean;
forComputer?: boolean;
mostEffects?: number;
});Constructs a new instance of the SessionView class
events
events: SessionEvent[];What the seat was told since its last snapshot, for the next one
forComputer
readonly forComputer: boolean;Whether the seat is a computer player's, which is told only what a brain reads (LocalSession.forComputer)
isAlly
readonly isAlly: (owner: PlayerId) => boolean;Whether an owner is the player or an ally of theirs: an observer's is everyone
keep
keep<S>(key: object, make: () => S): S;What the seat keeps under a key for what tells it things (the effects it was shown, the score last told): made the first time
knows
readonly knows: (entity: Entity) => boolean;Whether the player's team can see the entity right now: its side's always
memory
get memory(): TeamMemory;What the player's team remembers of what it saw (teamMemory: the structures out of sight as last seen, the camps seen empty), or an observer's own. Looked up again each time: the player may have moved to another team since
mostEffects
readonly mostEffects: number;How many effects of the rules are kept for their stop to be told (LocalSession options' mostEffects)
observer
readonly observer: boolean;Who only watches, and sees everything (LocalSession.observer)
player
readonly player: PlayerId;The seat's player: from whose side it sees, an observer's too
sees
readonly sees: (x: number, z: number) => boolean;Whether the player's team sees a spot of the map right now: an observer sees all of it
takeEvents
takeEvents(): SessionEvent[];Takes what the seat was told since the last snapshot
team
get team(): number;The player's team: theirs now, as the rules may move them to another (setTeam)
world
readonly world: World;The world the session view is a seat's window onto