WorldSave beta
Interface of @v12-engine/engine
export interface WorldSaveA 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
cheats: World['cheats'];The cheats switched on in the world (World.cheats)
delayed
delayed: DelayedSave[];Things scheduled to happen later (World.after), with the time left to each
detached
detached: EntitySave[];Entities that left the world but are still pointed at, like the caster of something that has yet to land
disabled
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
entities: EntitySave[];Everything in the world, in the order it was put there
failure
failure?: WorldFailure;Why the game ended on an error (world.failure), for a save taken of one that did
fog
fog: FogSave;What the fog of war keeps of what was seen
format
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
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
game: string;Id of the game module the world was made with
hash
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
internals: WorldInternals;The world's own counters and bookkeeping that are not entities (WorldInternals)
items
items: GroundItem[];Items lying on the ground
missileHits
missileHits: EntityId[][];What missiles sent together have passed through, which they share
missiles
missiles: MissileSave[];Missiles in flight
navVersion
navVersion: number;Where walkable space was at: movement looks for a new path when it changes
players
players: PlayerSave[];Each player's state: resources, supply, upgrades and the state of modules
projectiles
projectiles: Projectile[];Projectiles in flight
reveals
reveals: Reveal[];Patches of ground revealed to a team for a time
rng
rng: number;The state of the world's random generator (Rng.save), so the loaded game draws the same numbers
sceneryInSight
sceneryInSight: Record<number, EntityId[]>;Scenery each team sees, by team
state
state: Record<string, unknown>;State of game modules and mods for the whole game, by component id (see World.state)
systems
systems?: Record<string, unknown>;What systems keep in themselves (System.save), by their name
terrain
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
tick: number;The tick number the world was at when saved
tickRate
tickRate: number;Ticks per second the world was running at
units
units: EntityId[];The entities that act (World.units), by id
version
version: number;The version of what the game keeps in a save (Rules.saves.version): 1 for a game that says none
winner
winner: number | null;The winning team, or null while the game has none
zones
zones: ZoneSave[];Zones that act on what stands in them for a time