gizgame/maps
the maps of a 3D game as files. A game's world (Game.world) lists its maps, each with its file: JSON of the engine's own Map3D, so a map is written as the code writes one, and the type checks it. A file extends others: one, or a list of mixins taken in order, its own fields over theirs. Objects merge, a list of named items (models, strews) merges by name, anything else is replaced. A file's defaults give each item of its lists what the item does not say ("defaults": { "sets": { "ground": true } }). The host reads the files from the game's folder at each start and checks them (check), so a map changes, or a new one comes (a mod), with no build. A game reads its own fields of the same file (fields) and gives its code (charted).
import * as Maps from "gizgame/maps";Functions
files
function files(game: Game): Vec<string> throws stringEvery file of GAME's world (Game.world): its own, and each map's with what it extends. A host gives them to a page.
Effects: fail, read, write, console, io, alloc.
fields
function fields<T>(game: Game, map: i64): T throws stringThe game's own fields T of map MAP's file (a quest), read as the type T: fields of Map3D are skipped.
mapOf
function mapOf(game: Game, map: i64): Map3D throws stringMap MAP of GAME's world as data (Map3D).
Effects: fail, read, write, console, io, alloc.
schemaOf
function schemaOf(own: Json): JsonThe JSON Schema of a map's file: Map3D's, with the game's own fields OWN (the schema of its type, Json.schema) and
the file's own fields. An editor reads it through a file's $schema.
Effects: fail, read, write, alloc.
worldSchema
function worldSchema(own: Json): JsonThe JSON Schema of a game's world file: Atlas's, with the game's own fields OWN (the same as a map's: what holds for every map) and the schema an editor reads.
Effects: fail, read, write, alloc.
worldFields
function worldFields<T>(game: Game): T throws stringThe game's own fields T of its world file: what holds for every map.
check
function check(game: Game, own: Json): Vec<string> throws stringWhere the files of GAME's world break their type: the world's (Atlas), and each map's, with what it extends and its defaults, against Map3D and the game's own fields OWN (schemaOf), a misspelled field too. One line each, the file's name first.
Effects: fail, read, write, console, io, alloc.
charted
function charted(game: Game, code: (map: i64, data: Map3D) => Scene3D throws string): (map: i64) => Scene3D throws stringThe worlds of GAME's maps (play3D): each map's file with the code the game gives it, CODE of the map and its data (a Scene3D whose map is that data, or more). The kind the map's eye follows starts at the map's start.
Effects: fail, read, write, alloc.
plain
function plain(game: Game): (map: i64) => Scene3D throws stringThe plain world of each map of GAME: its file alone.
Effects: fail, read, write, alloc.