Skip to content

WorldSave beta ​

Interface of @v12-engine/engine

ts
export interface WorldSave

A world saved: everything it takes to carry on with a game later, somewhere else, or from the same moment more than once. Plain data, and with encodeSave text: what is in the world points to definitions by id, and to other entities by id.

What is not in it: - the game module (WorldSave.game names it), which loadWorld is given again; - navigation, which is built again from the terrain and the structures, with the agents put back where they were; - systems added while the game ran (World.addSystem), like a computer player: whoever loads adds them again, and what they keep in themselves (System.save) goes back into them as they are added; - state a game module keeps outside the world, like in a WeakMap keyed by it. Keep it in components instead (World.state, Player.state, Entity.get), which are in here.

Two numbers say how old a save is, and they are not the same thing. format is the engine's: the shape of the save itself, which the engine brings up to date by itself. version is the game's: what the game keeps in a save (its unit types, its components), which the game brings up to date (Rules.saves). A save is read through both (updateSave), the engine's first

Members ​

cheats ​

ts
cheats: World['cheats'];

The cheats switched on in the world (World.cheats)

delayed ​

ts
delayed: DelayedSave[];

Things scheduled to happen later (World.after), with the time left to each

detached ​

ts
detached: EntitySave[];

Entities that left the world but are still pointed at, like the caster of something that has yet to land

disabled ​

ts
disabled?: ErrorSite[];

The parts of the game switched off for having thrown (world.disabled): off again in the world loaded. None when left out

entities ​

ts
entities: EntitySave[];

Everything in the world, in the order it was put there

failure ​

ts
failure?: WorldFailure;

Why the game ended on an error (world.failure), for a save taken of one that did

fog ​

ts
fog: FogSave;

What the fog of war keeps of what was seen

format ​

ts
format: typeof SAVE_FORMAT;

The shape of the save itself (SAVE_FORMAT): the engine's to change, and to bring an older one up to

fromMap ​

ts
fromMap?: [number, EntityId][];

The entity each object of the map became, by the object's id (World.fromMap): as [object, entity]. None when left out

game ​

ts
game: string;

Id of the game module the world was made with

hash ​

ts
hash: string;

Which rules it was made with exactly, mods and code included (see gameHash): whether it can be loaded as it is. What a game does about a save of other rules is its own to say (Rules.saves.onMismatch)

internals ​

ts
internals: WorldInternals;

The world's own counters and bookkeeping that are not entities (WorldInternals)

items ​

ts
items: GroundItem[];

Items lying on the ground

missileHits ​

ts
missileHits: EntityId[][];

What missiles sent together have passed through, which they share

missiles ​

ts
missiles: MissileSave[];

Missiles in flight

ts
navVersion: number;

Where walkable space was at: movement looks for a new path when it changes

players ​

ts
players: PlayerSave[];

Each player's state: resources, supply, upgrades and the state of modules

projectiles ​

ts
projectiles: Projectile[];

Projectiles in flight

reveals ​

ts
reveals: Reveal[];

Patches of ground revealed to a team for a time

rng ​

ts
rng: number;

The state of the world's random generator (Rng.save), so the loaded game draws the same numbers

sceneryInSight ​

ts
sceneryInSight: Record<number, EntityId[]>;

Scenery each team sees, by team

state ​

ts
state: Record<string, unknown>;

State of game modules and mods for the whole game, by component id (see World.state)

systems ​

ts
systems?: Record<string, unknown>;

What systems keep in themselves (System.save), by their name

terrain ​

ts
terrain: SavedGround;

The ground: all of it, or the map the world was made from and what changed of it since (S36, format 3)

tick ​

ts
tick: number;

The tick number the world was at when saved

tickRate ​

ts
tickRate: number;

Ticks per second the world was running at

units ​

ts
units: EntityId[];

The entities that act (World.units), by id

version ​

ts
version: number;

The version of what the game keeps in a save (Rules.saves.version): 1 for a game that says none

winner ​

ts
winner: number | null;

The winning team, or null while the game has none

zones ​

ts
zones: ZoneSave[];

Zones that act on what stands in them for a time