Skip to content

API reference ​

A page a name, made from the doc comments (Entry points says what each entry is for).

Core ​

The 167 names a game meets first: its rules, its world, its view, its app and its editor. They are @public: kept, and a change to one goes in a changeset.

@v12-engine/client ​

NameWhat
AbilityLooksAbility and buff looks, keyed by the ability's or buff's id
CinematicCinematics: the camera flown along the map, kept on a unit, clips played on units, lines of dialog, with the HUD out of the way and the player's hands off. A cinematic is a script, an async function given a Cut to stage it with: ts const intro: Cinematic = async (cut) => { await cut.camera({ at: { x: 4, z: 30 }, distance: 20 }) await cut.camera({ at: { x: 60, z: 30 }, yaw: 0.4 }, 6) await cut.say('td.commander', 'Here they come.') } client.play(intro, { hold: true }) Every step waits until it is done; steps not waited for go on together. Skipping (Esc) ends every step at once and the script with it. It is the screen's only: the game goes on underneath, or waits (hold) where the simulation runs in the page. What a cinematic changes in the game, it changes with commands like anything else. params is what the rules hand it when they play it (playCinematic(world, id, { params })), or the view does (client.play(id, { params })): what the screen does not know of itself, like the road of the map being played
ClipA clip of a lane: something that starts at at and lasts for seconds (as long as it takes when left out: a line for as long as it is read, a clip of a unit until its animation ends). The rest of its fields are the lane's: a line has a speaker and text, a unit's clip a unit and clip. when is a condition it is played under (A5: on a param, on a ref being alive); ease how it comes in, where the lane eases
defineLaneMakes a lane def: the way to say one, with its item type carried through to its reader and runners
EntityViewAn entity as the player knows it. Positions of the last two snapshots are kept to draw the frames in between
GameClientA game shown and played: what assembleClient makes and a scene, a game's hooks and the HUD hold. It knows the game through its session only: snapshots of what the player may see come in, commands go out
GameViewHow a game looks and sounds, grouped by what is drawn (units, ground, world, fx, pings, HUD); the client side of a game module
hotViewA game's view module's new version, taken while it runs, as hotRules takes its rules: at its end, if (import.meta.hot) import.meta.hot.accept((module) = hotView(import.meta.hot, 'melee', meleeView, module?.meleeView)) What its types look like, are pictured as and say is taken by the games and editors of the page; the rest of a view (its HUD, its parts) a new game takes
HudClientThe client, as a HUD has it (client of each of the HUD's parts, and of what a game draws in them): the HUD's state (ui), the player's hands (controller), the keys, settings, menus, saves and the rest of what is documented. Made by GameClient.forHud(); a test makes one of its own (testHudClient of @v12-engine/client/testing)
launchShows a game on the page and lets the player play it: the world made from the map (or loaded, made in code, or joined: GameSource), the engine that draws it, the client, the loading screen, then the HUD and what floats over it, all inside target. What it gives back ends it again. launch( target: '#game', game ) A game made with createGame is played on its first map, and its start (Game.onStart) run, where the options say neither; its view is fetched as it is got ready. Each step it takes is there on its own for a page that puts a game together another way: prepareGame, assembleClient, runGame (the game from its load to its end, nothing drawn), and GameMount (@v12-engine/client/app, which draws a run). The HUD is loaded when a game is launched, not when this is imported: a game's view names @v12-engine/client, and is read where there is no page too (a server that checks it, a tool that draws a map)
layFilesA game's view with its files laid over what its code says, in the order given (a file laid later is laid over what those before it made of a field: hud.json over the looks looks.json made). Each file's data is read, and throws on what is wrong. layFiles({ fx: presetFx(), ... }, [[FX_FILE, fxJson], [QUALITY_FILE, qualityJson]])
ModelDefA model made elsewhere, a glTF file in public/models
PortraitFramingHow a unit's portrait is framed, lit and played: each field over what the model's bounds give. Distances and heights are in cells, of the model as it is drawn (its scale in)
PortraitLightHow a portrait's light is (PortraitFraming.light): a key light from in front of the face, and the light all round
PortraitLookA unit type's portrait (UnitLook.portrait, looks.json's portrait): its picture, the model its live portrait shows (its own when left out) and how that is framed, lit and played
PortraitRefWhat a portrait is: an image's address, or someone's face (PortraitSpec)
PortraitSpecA portrait of someone (DialogLine.portrait, SpeakerLook.portrait, client.portraits.show): a unit on the map by its name, a ref or its id; a unit type (type: someone not on the map, or the type of a unit not in sight); or a model of its own (model). Live (the model, playing) or a still of the type's model; framed as its type's look says, and as its own fields say over that
presetFloatsThe ready-made floats (PRESET_FLOATS) a game takes for GameView.hud.floats: all of them, or the kinds named, each with fields of the game's over it (presetFloats(['damage', 'heal'], { damage: { style: { color: '#ffe' } } }))
presetFxReady-made effects a game takes into its view's fx (fx: { ...presetFx(['fire', 'smoke']) }): those named, every one when left out, each with its knobs given here over its own ({ fire: { color: '#7fd0ff' } }). The client plays none a game did not take
presetPingsThe ready-made pings (PRESET_PINGS) a game takes for GameView.pings.kinds: all of them in their order, or the kinds named in the order named, each with fields of the game's over it
readCinematicA cinematic from its file, checked and filled in: lanes and markers in order of time. What is wrong throws with its path (td.intro.lanes[2].items[0].at is a number). A lane of a kind the client does not know is kept as it is (it may be a game's own, played by a lane the game registers) and said once in the log, so a typo in a kind is seen and a game's kind is not a wall of warnings
RgbA colour as red, green and blue, each 0 to 1 (and over, for a glow past white)
UnitHudDefThe HUD over a unit (GameView.units.hud.def, UnitLook.unitHud, client.unitHud): a plate with rules around it. Plates by situation (the first whose when holds), for whom, how far from the camera, at which size, how high over the unit, faded in and out. A plain UnitHudPlate is a def of one plate with no rules
UnitLookHow one unit type looks on the screen: its model or shapes, effects, death, construction and more, as data or code
UnitLooksHow the unit types look, by their id. With the ids named, every unit type has its look: one forgotten would be drawn as a plain box

@v12-engine/client/app ​

NameWhat
AppEditorSceneThe map editor's scene as the app's scenes make it (appScenes): its id and name, the game, the map it starts on, the scene that plays its maps and where its way out goes. What the editor's editorScene takes, and more
appScenesThe scenes a game is made of, as a list for startApp: the start screen (home: what the game is, and a button for each scene), the game (play), the settings, a random map when the rules generate one, the map editor and a server when asked. The list is a plain array: a project adds its own scenes to it, or takes one away startApp( target: '#game', game, scenes: appScenes( game, editor, server: true ), start: 'home' ) sceneAsked picks the scene the address names (/?editor), for start
cinematicSceneA scene that is only a cinematic: see the top of this file cinematicScene( id: 'intro', game, world: makeWorld, cinematic: readCinematic(introFile), then: scene: menu )
defineCampaignA campaign put together: a menu with the mission it is at and the missions won with their times, and a scene that plays any of its missions. A mission won is kept at once, with its time and the heroes it ends with; its end has the next mission and a retry, a mission lost has a retry, and both go back to the menu. A mission starts with the heroes carried out of the one before, in place of the ones its map has for them. Of a file (campaign.json, what the editor's Campaign panel writes) with its code beside it (CampaignFromFile): the file's over the code's
exitButtonThe start menu's Exit (appScenes({ menu: { buttons: [exitButton(shell)] } })): out of the game through the shell, shown only where the shell can do it, so that the same page in a browser has no button that does nothing
gameSceneA scene of a game, from what launch takes: the world made from the map (or made in code, loaded from a save, or joined: GameSource), what the game starts on it, and the client that shows it. For an app of scenes (startApp) with a menu before the game and the editor beside it: opened from the editor's Play, it plays the map as it is being edited (SceneArgs.editing), and from a save (SceneArgs.from) it goes on from it gameScene( id: 'play', game, map: () = mapNamed(), onStart, debug: true, exit: label: 'Menu', scene: 'home' )
menuSceneA menu: its title and buttons, what the game is and its facts, a background, and a game scene played behind its buttons (behind: a cinematic that loops, composed in: menuScene({ ..., behind: cinematicScene({ ... }) })); drawn by the client, a component of the game's or an element of its own (MenuDef). A scene like any other (U2): what names it names the menu itself, and what its buttons go to is what it names (Scene.names) const home = menuScene( id: 'home', name: 'Home', title: 'My game', buttons: [ label: 'Play', scene: play ] )
SceneSomething the app shows, one at a time (U2): every scene is this shape, whatever it shows. It draws itself into the element it is given (open) and gives back what takes it away again: going to another scene ends the one shown, a game disposed with everything it holds (its engine, its canvas, its sounds, its listeners), once the next one is ready and has come in over it (SceneOpenContext.hold, SceneTransition). A scene of a game's own (a campaign map, a lobby, a hero draft) is one as it is; a game, a menu and a scene fetched as it opens are ones their makers build (gameScene, menuScene, lazyScene), with more on them
sceneAskedThe scene the page's address asks for, by id: /?editor opens the scene with the id editor, /?server the server's, /?find-game the rooms'; fallback (the start screen) when it names none. For startApp's start
sceneRefA scene named by its id, before it is there to name itself (one made further on, or in another module): A is what it is opened with
startAppStarts an app of scenes on the page: menus, games, map editors and screens of a game's own, one shown at a time, each going to the next with goTo. What a game that is more than one launch is made of: a menu before the game, a campaign's map between its missions, an editor that plays its maps. startApp( target: '#root', scenes: [menu, game, editor], start: 'menu' ) startApp( target: '#game', game ) One game on a page needs none of it: that is launch
StartAppOptionsWhat an app of scenes is started with
StartedAppAn app started: its scenes, to add to in code, and what takes it off the page

@v12-engine/client/common ​

NameWhat
hotViewA game's view module's new version, taken while it runs, as hotRules takes its rules: at its end, if (import.meta.hot) import.meta.hot.accept((module) = hotView(import.meta.hot, 'melee', meleeView, module?.meleeView)) What its types look like, are pictured as and say is taken by the games and editors of the page; the rest of a view (its HUD, its parts) a new game takes
presetFloatsThe ready-made floats (PRESET_FLOATS) a game takes for GameView.hud.floats: all of them, or the kinds named, each with fields of the game's over it (presetFloats(['damage', 'heal'], { damage: { style: { color: '#ffe' } } }))
presetFxReady-made effects a game takes into its view's fx (fx: { ...presetFx(['fire', 'smoke']) }): those named, every one when left out, each with its knobs given here over its own ({ fire: { color: '#7fd0ff' } }). The client plays none a game did not take
presetPingsThe ready-made pings (PRESET_PINGS) a game takes for GameView.pings.kinds: all of them in their order, or the kinds named in the order named, each with fields of the game's over it
readCinematicA cinematic from its file, checked and filled in: lanes and markers in order of time. What is wrong throws with its path (td.intro.lanes[2].items[0].at is a number). A lane of a kind the client does not know is kept as it is (it may be a game's own, played by a lane the game registers) and said once in the log, so a typo in a kind is seen and a game's kind is not a wall of warnings

@v12-engine/client/kit ​

NameWhat
ButtonA button: every button of the client's, the HUD's and the editor's (U7). variant: default, primary, ghost, danger, chosen, face, bare. size: sm, md, lg, icon, icon-sm, square, square-sm, unsized
CheckboxA box to tick, as CheckboxBox, with Ark's parts (Checkbox.Root, Checkbox.Indicator...) for one put together otherwise
cnThe parts that are there, as one class list
ColorFieldA colour, shown, and picked in what opens under it: Ark's colour picker, put together. For one put together otherwise, ColorPicker has its parts
DialogA dialog over everything, as DialogBox, with its parts (Dialog.Root, Dialog.Content...) for one put together otherwise
FieldA row of a form: a label, what it is about, and a note under it
kitThe kit for code that builds the page itself: the looks as classes (kit.classes.button({ variant: 'primary' })), tooltips, and putting a kit component into an element. Messages, questions and menus from code are a place's overlays: an app's (StartedApp.overlays), a game's, the editor's
LabelA label of a field laid out by its own classes (Field is the kit's row of a form): a click on it is a click on what is in it
MenuArk's menu with the kit's look, to put one together: Menu.Root, Menu.Trigger, Menu.ContextTrigger, Menu.Positioner, Menu.Content, Menu.Item, Menu.TriggerItem (for a menu inside a menu), Menu.Separator, Menu.ItemGroup, Menu.ItemGroupLabel, Menu.CheckboxItem, Menu.RadioItem; and Menu.Items, its lines from a list. Ark's other parts are @ark-ui/solid/menu's
MeterA bar that fills, from value out of max (1 when left out). Only its width changes as the value does, so it is fine to give it a value that changes every frame
NumberFieldA number to type, step and drag, as NumberFieldBox, with Ark's parts (NumberField.Root, NumberField.Input...) for one put together otherwise
PanelA panel: stone with an edge. tone: default, raised, flat; selected; padding: none, sm, md, lg
PopoverSomething that opens by what is pressed and floats by it, as PopoverBox, with Ark's parts (Popover.Root, Popover.Content...) for one put together otherwise
ScrollAreaA list that can grow long, with thin scroll bars
SearchFieldWords to type to search a list: a text field with a clear button, which Ctrl+F or / puts the keyboard in while its panel has it, and Escape empties (then gives the keyboard back to the panel). What every list of the editor that is searched by typing has over it, and a panel of a game's own (panel.filter()). Matching is matchWords, filterBy or rankBy
SelectOne of a few options from a list, as SelectBox, with Ark's parts (Select.Root, Select.Trigger...) for one put together otherwise
SliderA slider with its value shown next to it, as SliderBox, with Ark's parts (Slider.Root, Slider.Thumb...) for one put together otherwise
TabsTabs, one shown at a time, as TabsBox, with Ark's parts (Tabs.Root, Tabs.Trigger...) for one put together otherwise
TextFieldWords to type
ToggleAn on-off switch, as ToggleBox, with Ark's parts (Toggle.Root, Toggle.Thumb...) for one put together otherwise
TooltipA tooltip around something, as TooltipBox, with Ark's parts (Tooltip.Root, Tooltip.Content...) for one put together otherwise

@v12-engine/client/vite ​

NameWhat
assetsPackageServes @v12-engine/assets to a game while it is developed, and copies what it uses into a build. See the top of this file, and AssetsPackageOptions

@v12-engine/editor ​

NameWhat
defineEditorExtensionAn extension of the editor, said once: what it brings (EditorExtension), to declare in EditorOptions.extensions or add with editor.extensions.add. The same object back, typed: its new versions, as its module is saved, come through the page's ExtensionRegistry (the dev server's plugin has the module hand them on, hotExtensions)
EditorClientThe map editor: shows a map the way the game would, and changes it with brushes and by putting things down. It draws with the same pieces as the game, fed from the map instead of from a session. What a click does is the picked tool's business (see Tool): the editor holds the scene, the camera, the selection and what is shown, and hands the tool the pointer, the keys and every frame. Everything the editor does is here by name. Much of it is done by its parts, a file each in parts/, which hold what they need to themselves: what is drawn (EditorDrawing), the lines and names over it (EditorLines), the screen and the map (EditorPicking), the pointer and the keys (EditorInput), the selection (EditorSelection), copying (EditorClipboard), the map's files (EditorMapFiles), playing it (EditorPlaying), its checks (EditorChecks) and where the view looks (EditorFraming). A part reaches the editor as host, and another part through it
EditorPanelDefA panel of the editor: one of its own, a game's (EditorOptions.panels) or one code adds (editor.dock.add). It has an icon on a rail of the editor and opens beside that rail when the icon is clicked. Drawn by a component (Solid, on the kit or not) or into an element of its own (mount: any HTML, any framework), which wins when both are said. Each is given the editor and the panel's handle (EditorPanel)
editorSceneThe map editor as a scene of an app (startApp): it plays its maps in the scene it names (play, Play here over the editor), and leaves where exit says, to the list of scenes otherwise. Its code is fetched as it is first opened. A scene of the app like any of a game's own (Scene); appScenes makes one with it startApp( target: '#game', scenes: [menu, play, editorScene( id: 'editor', name: 'Map editor', game, play )] ) appScenes( game, maps, editor: editorScene ) appScenes( game, maps, editor: (scene) = editorScene( ...scene, extensions: [waves] ) )
OpenedEditorA map editor opened: what the page holds of it
openEditorOpens the map editor of a game on the page: its view, tools and panels, with the map being edited played over it (Play here) as launch plays a map. openEditor( target: '#editor', game ) The game's view is fetched before the editor is drawn (loadGame). Maps are kept in the project's files where the page's dev server has the editor's plugin (editorFiles), in the browser otherwise. The editor's code is loaded as it opens, not with the page: its element fills a moment after, and onLoaded says when the editor is there
OpenEditorOptionsWhat a game's map editor is opened with, on a page

@v12-engine/editor/scene ​

NameWhat
editorSceneThe map editor as a scene of an app (startApp): it plays its maps in the scene it names (play, Play here over the editor), and leaves where exit says, to the list of scenes otherwise. Its code is fetched as it is first opened. A scene of the app like any of a game's own (Scene); appScenes makes one with it startApp( target: '#game', scenes: [menu, play, editorScene( id: 'editor', name: 'Map editor', game, play )] ) appScenes( game, maps, editor: editorScene ) appScenes( game, maps, editor: (scene) = editorScene( ...scene, extensions: [waves] ) )

@v12-engine/editor/vite ​

NameWhat
editorFilesThe plugin: plugins: [editorFiles()] in vite.config.ts. A project laid out another way than this repository says how (EditorFilesOptions): editorFiles({ games: 'games', public: 'static' }), or editorFiles({ gameFolder: () => 'src/game' }) for a project that is one game

@v12-engine/engine ​

NameWhat
AbilityDefThe definition of an ability: how it is aimed, what it costs and the effects it has
applyBuffPuts a buff on an entity. Buffs do not stack with themselves: a second one of the same kind renews the first when it lasts longer (BuffDef.stacking says otherwise). Returns the one of it this was about: the one put on, or the one there already that it renewed, replaced or left as it was; none where it was refused (its carrier dead, an unstoppable carrier, the beforeBuff hook). What stacks or shields the buff as it is put on goes by that one: with perSource, the source's own; with independent, the new one
BuffDefSomething lasting on a unit that changes what it can do
checkMapWhat is wrong with a map, before it is played: what the game does not have, names used twice or named and not there, what stands off the map or in deep water, starts that cannot reach each other on foot, mines nobody can walk to, regions outside the map (MAP_RULES); then the checks given (more: the client's of what the map looks like, a game view's own, as the editor runs them); then the game's own (MapEditorDef.check). Errors keep it from being played; the rest are warnings. Runs without the editor, for a test that goes over every map of a project
checkRulesChecks a game's rules against themselves (RulesProblem): run by a game's check() and as a page fetches its view, and in a game's tests (expect(checkRules(rules).filter((p) => p.level === 'error')).toEqual([])). Nothing is thrown
cinematicA step of a sequence that plays one of the view's cinematics: defineSequence( id: 'td.start', steps: [cinematic('td.intro', hold: true ), ...talk(...)] ). It does not wait for it (with hold, the game, and the sequence with it, waits), unless told to: wait: 'ended' goes on once the player it was for has seen it end (or skipped it), any once one of the players it went to has, all once every one of them has. Only players with a screen are waited for (not the computer's); one who left a game of several never says, so a sequence for many waits for any where that matters. With a wait it is two steps, which defineSequence takes as they are
cinematicWith wait: the cinematic played, then a wait for its end (see the other form), as two steps
connectConnects to a host over a transport (the player's end of it), and waits for the welcome: what the session is made of. Fails when the host runs another version of the game, or of the engine's wire (PROTOCOL_VERSION), and when the connection closes before the session is made: while the map is made from the welcome too
createGameMakes a game: one object its units, abilities, systems, hooks and listeners, missions, maps and view are registered on, which every host takes (Game). init is its id and name, and any field of the module underneath said at once: createGame(rules) makes a game of a module written whole
createRegistryEverything a game module defines, looked up by id: with the engine's own components, and those an app keeps in its worlds (own: CreateWorldOptions.components)
createWorldMakes a world from terrain, rules and players; resolves once it is ready to step
createWorldFromMapA world as a map lays it out: its ground, the players it has room for, and everything placed on it. Players with a start location that the map places nothing for get what the game starts everyone with. Throws for a map made for another game (GameMap.game).
defineCellLayerTyped help for writing a layer of cells
defineCommandDefines a command type, for a game module's commands: its type, its fields (see fields.ts), and what it does. command is typed by the fields. ts const sellTower = defineCommand('sellTower', { tower: id }, (world, player, command) => { ... }) session.send(sellTower.make({ tower: 12 }))
defineComponentA typed key for state of a game's own: const wave = defineComponent<WaveState>({ id: 'td.waves', default: () => ... }). Give it a prefix of the game's or the mod's: the engine's own are core.. A game lists its own (Rules.components), and its world finds them by id in its registry: another game of the process may have one of the same id, and a module loaded again (as a dev server does) defines it again. With snapshot and same the component shapes what players are sent of it and how a change is found; with index it is filed for systems to go through; with field the map editor sets it
defineEffectA kind of effect, its type and what it does together: defineEffect({ type: 'pull', run: (context, effect) => ... }), listed in Rules.effects. Its fields are said by declaring the type in EffectTypes (declare module '@v12-engine/engine' { interface EffectTypes { pull: { distance: number } } }), so that a handler reads them typed, and an ability's effect of the type is checked for them
defineEventAn event of a game's own: const through = defineEvent<{ unit: string }>({ id: 'td.invaderThrough', replicate: 'everyone' }). Emitted on world.events like the engine's (world.events.emit(through, { unit })), held to the end of the tick like them, and listened to with defineListener. Ids are shared by every game: give them a prefix of the game's. A replicated event goes to the players' screens, where GameView.on and the renderers get it: what it says has to be plain data then (numbers, text, lists, plain objects), with entities by id, as it may cross a network
defineGameFileA file of the game's own data, for Rules.files: defineGameFile({ id: 'waves.json', data: wavesFile, read: readWaves }), read by the rules with world.registry.file(waves)
defineHookTyped help for writing a hook: defineHook({ hook: 'death', id: 'bounty', run(world, { entity }) { ... } })
defineHookTyped help for a handler of a game's own hook (HookKey), taking the world and the hook's event
defineIdsIds the compiler knows. A game's ids are text to the engine (world.spawn('skeleton', ...)), and a slip of the finger in one is found when the game runs, if it is found. Named once with defineIds, they are checked as they are written, completed by the editor, and renamed in one place: export const UNIT = defineIds('skeleton', 'runner', 'brute') export type TdUnit = IdOftypeof UNIT // 'skeleton' | 'runner' | 'brute' id: UNIT.skeleton, ... // in the unit's definition world.spawn(UNIT.skeletn, ...) // does not compile const view: GameView = units: looks: skeletn: ... // nor does this It is a help, not a rule: plain text works wherever an id goes, and what the compiler cannot see is checked when the game's view is fetched in a page (the client's loadGame)
defineListenerTyped help for writing a listener: defineListener({ event: enteredArea, id: 'td.gate', run(world, { area, entity }) { ... } })
defineObjectiveTyped help for writing one
definePrefabTyped help for writing a prefab
defineRaceA race, as the game lists it (Rules.races)
defineSequenceTyped help: defineSequence<{ hero: number }>({ id: 'td.briefing', steps: [(world) => ..., wait(3), waitFor(constructionFinished)] }). A helper that is several steps (talk, cinematic(id, { wait })) may be given as its list, spread or not
defineStatA stat of the game's own, for RuleSettings.score: defineStat( id: 'towersLost', label: 'Towers lost', category: 'units', from: scoreOn(entityDied, ( entity ) = entity.def.tags?.includes('tower') ? entity.owner : undefined) ). One with no source is counted in code (world.score.add(player, 'towersLost'))
defineTimerTyped help: defineTimer<{ wave: number }>({ id: 'td.waveComes', run: (world, { wave }) => ... })
earnAdds an amount of a resource
EffectDefOne thing an ability does: its type, which picks the handler and says which fields it has (EffectTypes)
enteredAreaA unit walked into an area of the game (Rules.areas)
EntityAnything in the world: a unit, a building, a tree. Fields marked readonly are kept in step with things elsewhere (the navigation, the spatial index, the lookups of the world), so they are changed through the world's functions only: World.setOwner, World.setHidden, World.setLifetime, World.place, startDash, morph (each through the entity's own internal writes: moveTo, retype, changeOwner…). The rest, like health, mana or cooldowns, a game module may change as it likes: nothing is worked out from them that would not notice.
entityDiedSomething died: what killed it, and how. cause: the blow, for what died of damage. how: what the rules made of the death in the death hook, for the screen to show ('exploded', 'burned')
EntityIdThe number an entity has in its world, unique there
GameA game: one object everything of it is registered on, which every host takes (createGame). Its rules are made from what it holds (toRules(), the module underneath that a server, a test and a worker run); its view is fetched as a page first needs it (view(() => import('./view')), toView()), so that the rules are read where nothing draws (a server, a test) without the client. Each method that registers a definition gives it back export const game = createGame( id: 'td', name: 'Tower defense' ) export const archer = game.unit( id: 'archer', name: 'Archer', kind: 'unit', stats: health: 200 ) game.on(entityDied, (world, entity ) = … ) game.onStart((world, map ) = … ) game.maps(mapsFrom(import.meta.glob('./maps/*.vgmap.json', import: 'default' ))) game.view(() = import('./view'))
GameInitWhat a game is made with (createGame): its id and name, and any field of the module underneath (Rules) said at once: a whole Rules is a game too (createGame(rules)). What is registered on the game after comes after what is given here
GameMapA map: the ground and what stands on it when the game begins, as data. The editor makes them, scenes play them. The ground is kept in layers that are edited apart and put together into a Terrain: the height of the land, cliff levels, ramps between levels, water and paint. The layers are what a map file stores, the terrain is derived from them whenever one changes.
GameMapsA game's maps by name (Game.maps): each the map, or what fetches it as it is first asked for (mapsFrom of a lazy glob), so that a page carries none of a map it does not open
GameStartWhat a game does once a world is made, before anyone plays (Game.onStart, a mission's onStart): computer players seated, a mission given, the first wave sent
GameStartContextWhat a game's start is told (Game.onStart): the map its world was made from, the player at the screen (in a page), the lobby's settings (on a server), and whether the world is new (fresh) or loaded from a save, which has everything a start gives already. Each host says what it knows; the rest is left out
HandlerOptionsWhere a listener or a hook's handler registered on a game or a mission goes by: an id of its own, in the place of the one made for it (<game>.on.<event>.<n>, <game>.<mission>.before.<hook>.<n>), and a priority for a hook (lower runs first: before is -1 and after 1 when left out, the engine's own handlers 0)
heroesPackThe heroes pack: what makes a game a classic hero RTS, opted into (Rules.packs: [heroesPack()]). Heroes, with their experience, levels, points and abilities to learn, brought back at an altar (revive) or bought back (buyback), their kills shared with those who assisted, their streaks paid for when they end (HeroSettings); creeps' camps that guard their ground, sleep at night and come back (Camp.respawn); shops that sell (buy, sell) and places that hire (hire). rules change its numbers (HeroSettings: how many heroes, the experience a level takes), the classic RTS numbers for those left out. A game without it pays nothing for any of it: no hero is made of a hero's type, no command of these is taken, no camp is looked at
heroOfWhat a hero has earned: none for what is no hero (heroState)
HookDefA handler and the hook it is for. Its id is how others take it out or put something in its place
hotGameA game's module's new version, taken while it runs (hot reload), as hotRules takes a module's: at the end of the module that makes the game, the call to Vite written out as it is (Vite finds a module that takes its own new versions by it): if (import.meta.hot) import.meta.hot.accept((module) = hotGame(import.meta.hot, game, module?.game)) The rules the hosts were given are made the new version's in place (hotRules); the view, a module of its own, takes its own (the client's hotView). What does not go loads the page again
hotRulesA game's entry module's new version, taken while it runs (hot reload). At the module's end, the call to Vite written out as it is (Vite finds a module that takes its own new versions by it): if (import.meta.hot) import.meta.hot.accept((module) = hotRules(import.meta.hot, melee, module?.melee)) As it or a file it reads (its units, its data.json) is saved in the dev server, the module given is made the new one in place, so that what holds it has the new one, and the games and editors of the page playing it take its definitions and rules (reloadGame, through onNewGameVersion). What does not go loads the page again, saying why (hot.invalidate(reason)): no new module, another game, a component defined another way, or a change to what a running world keeps as it was made (its systems, hooks, components, resources, and withoutSystems and withoutHooks, compared by their code and values). No client is pulled into the rules, which a server reads too
IdOfThe ids of a list made with defineIds, as a type: IdOf<typeof UNIT>
isGameWhether something is a game made by createGame, rather than the module underneath (Rules)
ItemDefThe definition of an item: what it costs, what it gives its carrier and how it is used
learnTeaches the hero one level of an ability and spends a point on it; returns false when canLearn says it cannot
loadWorldA world from a save (see saveWorld), carrying on where it was. A save made before, by an older engine or by the game before a patch, is brought up to date first (updateSave), or refused with a SaveError that says why. Navigation is built again; units come back with the speed and destination they had, but the way they find around each other is worked out anew, so the game from there on is close to, and not quite, the one that was saved
MapEnvironmentWhat a map looks like beyond its ground (design review E8c): the engine carries it (in the map, its file, a save, what players are told as it changes: world.setEnvironment) and reads none of it but the map's own tiles, which are paint like the game's. An open interface: the client adds what it draws by (its water, light, sky, fog, weather, lights and the rest), as a game adds its commands (Commands)
mapsFromThe maps of map files, by the name of each file without its folder and .vgmap.json: ./maps/field.vgmap.json is field. The files by their paths, read (parseMap): imported one by one, or Vite's import.meta.glob('./maps/*.vgmap.json', { eager: true, import: 'default' }) where only a page reads them export const maps = mapsFrom( './maps/field.vgmap.json': field, './maps/hills.vgmap.json': hills ) Given what loads each file in place of the file (import.meta.glob('./maps/*.vgmap.json', { import: 'default' }), not eager; or () => import('./field.vgmap.json')), nothing is fetched or read until a map is asked for: the result is then LazyMaps, each a function giving the map (a promise), and the page carries one chunk a map. appScenes takes both export const maps = mapsFrom(import.meta.glob('./maps/*.vgmap.json', import: 'default' )) const field = await maps.field() Throws for two files of one name, for files some given and some loaded, and with the path of a file that cannot be read
mapsFromThe maps of map files given whole, read at once (see above for loaders)
MissionWhat a mission registers its parts with (Game.mission): each part's id is made of the game's, the mission's and its own ('raze' in the mission homecoming of my-game is my-game.homecoming.raze), and the parts go into the game's rules, so that a save finds them by those ids. Its onStart runs where the world's map is one it plays, or as it is started
objectiveVictoryThe rule of a mission: a player who failed an objective the mission needs is out, and a player who did all of them wins, for their team. Like a melee game, a team whose players are all out loses, and the last team standing wins. A game uses it as its victory
openSocketThe player's end of a connection to a server, over a WebSocket: what connect and a server's lobby talk through. Resolves once the connection is open; fails when it cannot be made
OrderBehaviorLogic behind an order type. Orders are the only way units act, which is what makes queueing work for everything. Game modules can register their own. State is what it keeps in the order (Order.state), every field optional: the order starts with none of them. OrderStates names each order type's, for registry.order(type) to hand back the behaviour typed
OrderOptionsHow an order is given (Entity.order)
parseMapReads a map file, of this format or an older one. Throws with what is wrong with it
PlayerIdThe number of a player in a world
prefabsFromThe prefabs a designer made in the editor (prefabs/<name>.prefab.json of the game's folder), as prefabs of the game's, by their file names: prefabsFrom(import.meta.glob('./prefabs/*.prefab.json', { eager: true })), or any record of name to file. An object of a player's becomes the owner's; scenery, points and paths are left out. A variant is read through its source and a prefab with prefabs inside through those, as the editor places them, from the files given
presetScoreThe engine's score, for RuleSettings.score: a classic RTS score screen. Units produced, killed and lost, buildings built, razed and lost, the army and the largest, heroes killed and lost, the highest hero level, experience, creeps killed, items obtained, abilities cast, damage dealt and taken, healing, and of each resource what was gathered, spent and lost to upkeep, the bounty and what went between allies
RaceDefA side a player can play, with a roster of its own: melee's humans and undead. Optional: a game that lists none (Rules.races) has no race anywhere, no choice of one in the lobby and nothing kept from anyone. A unit type or an upgrade of a race (UnitTypeDef.race, UpgradeDef.race) is only its players' to make; one of none, everyone's. Each player has one (raceOf): chosen in the lobby (a seat setting the server offers by itself, seatSettingsOf), given to the world as it is made (PlayerInit.race, MapWorldOptions.races), or changed by the rules (setRace)
RegistryThe registry of a game's definitions and behaviours: unit types, abilities, orders, systems, buffs and the rest, by id
RulesA game module is the data and rules of one kind of game. The engine knows nothing about peasants or town halls, it gets all of that from here.
saveWorldSaves a world, between two ticks. Throws, saying where, when something in it is not plain data
serveWorldWhat a game's worker file does: serveWorld(game, { onStart }). It waits for the page to say what to play (a map, a save, or nothing for a world made here in code), makes the world, runs it by the clock, and seats the page's player at it. A new game asked for ends the one before: a restart is the same worker, its navigation built already
SpawnAtWhere a new entity goes and whose it is, with what else it starts with (World.spawn(type, { at, owner }))
statsOfThe stats of an entity as they are right now: what its type starts with at this time of day, and on top of that its levels, the research of its owner, what it carries and the buffs on it. The result is shared and must not be changed. It stays the same object for as long as the stats stay the same.
SystemSomething that runs every tick, or every few: moves units, lands attacks, works out what each team sees. When it runs is worked out once, from its phase, then from what it says it comes before and after.
SystemDefA system, or what makes one for each world: for a system that keeps state of its own, which belongs to one game
talkThe steps of a conversation, for a sequence: each line is said and stays for as long as it lasts, then the next. Skipping a line (the skipLine command) goes on to the next at once: defineSequence( id: 'td.beforeTheBoss', steps: [...talk(DEFENDER, [ speaker: 'td.commander', text: 'bossComing' , ...])] )
UnitTypeDefThe definition of a unit type: a unit, building or resource, with its stats, abilities, costs and what it does
UpgradeDefResearch that improves a player's units for the rest of the game
Vec2A point on the ground plane. The simulation is 2D; height always comes from the terrain.
waitWaits seconds before the next step
waitForWaits for an event, the engine's ('constructionFinished') or a game's own, and for test to pass on what it says when there is one. Heard at the end of the tick, like listeners hear events
WorldThe simulation: the ground, entities, players, systems and rules of one game, stepped a tick at a time with step

@v12-engine/engine/ai ​

NameWhat
defineBrainDefines a brain: what a computer player is made of, to seat at a world (world.computers.seat(player, { ...options, brain }), world.computers.seat) and to list in Rules.brains, for a save to find it by its id. Modules that keep state are given as functions of the brain, as systems are of the world
defineModuleA module made for each brain by a function of it, with its id known before it is made: what a brain's without leaves out by name (meleeBrain.with({ without: ['scouting'] })). The kit's modules are all defined so
meleeBrainThe engine's melee computer player as a brain: what world.computers.seat seats where no brain is named and the game lists it first. It thinks as its profile says (the difficulty's every), unless the seat's options say how often. The file's comment lists its modules
missionBrainA computer player for a mission: a brain (defineBrain) of what every mission's computer has (its rules, the words every brain may be told, the goals' picker, squads, micro) and the parts it is given (modules: holdPosition, patrol, guard, ambush, waveFrom, fleeWhen, surrenderWhen, any module of the kit's or of its own). Nothing builds, trains, gathers, scouts or answers raids on its bases unless a module for it is given (economy(), scouting(), defence()). Everything else of BrainDef as for any brain (goals, micro, without, knowledge)

@v12-engine/engine/server ​

NameWhat
GameModeWhat a server runs: a game module, the seats of a game of it, and how its world is made. Each game starts from a world made anew, with the lobby's settings
GameRoomsMany games in a process (S58): game servers that share a port, each a room reached at its name, as a server of its own would be at its port. One process, one thread: each room's games step in turn, so the rooms of a process are as many as its ticks have time for (/metrics says how long they take). A connection to a room there is not is told so and closed. Rooms are added in code (add), or made by players of the kinds it offers (kinds, POST /games) and closed once empty
mapModeA game on a map of it: a seat for each player the map has a start for, and a world made from the map for each game. The game (createGame) or its module (Rules): a game's start (Game.onStart) runs where onStart is left out
startServerStarts a server of a game, and resolves once it listens: a lobby that seats who joins, then games of it, one after the other, each on a world made anew. const server = await startServer( game ) const server = await startServer( rules, map, onStart: (world) = startMission(world) ) // server.port, server.close() The parts are there on their own: GameServer.start with a GameMode, mapMode, SessionHost

@v12-engine/engine/testing ​

NameWhat
checkDeterminismMakes a world twice with make (the same seed, the same commands given in it, as a replay would) and runs them side by side, comparing their fingerprints every tick and their states (and the order each player's entities are filed in) every every ticks; with from, a third is saved at that tick and a fourth loaded from the save, and the two run on side by side. Says, for each, the first tick and thing it differs at, or that it does not. A test of a game's own systems: one that reads Math.random, the clock, or the order of something unordered is found here const report = await checkDeterminism(() = makeMyGame(1), ticks: 1800, from: 300, rules ) expect(report).toEqual( twice: null, fromSave: null )
orderGives units an order, as their owner would: taken up at the next tick. queue adds it after what they are doing
runSteps the world for up to seconds, stopping early once until holds. Returns the time that went by in it
simulatePlays games of a simulation, one from each seed, and gives what each ended in, in the order of the seeds. Given as it is, they are played in this thread. Given as the address of a file (a module whose default, or simulation, is one: a Simulation), each worker thread imports it and plays its share: in Node, from the built packages (a worker loads JavaScript, not the TypeScript of this repository)
SimulationA game to play many times (simulate): the rules, the map, who the computer plays and how, and what to count
testWorldA small world of a game for a test (the game, createGame, or its module, Rules): flat ground, a neutral player and two enemies (TEST_PLAYERS), the same every time (seed 7). Each of them is the test's to say otherwise

Advanced ​

Everything else, by entry: @beta, which may still change.

EntryNames
@v12-engine/client1281
@v12-engine/client/app115
@v12-engine/client/campaign-worker5
@v12-engine/client/common220
@v12-engine/client/debug11
@v12-engine/client/ground35
@v12-engine/client/hud90
@v12-engine/client/kit153
@v12-engine/client/lite-views88
@v12-engine/client/looks-file11
@v12-engine/client/testing20
@v12-engine/client/vite6
@v12-engine/editor648
@v12-engine/editor/map-command4
@v12-engine/editor/scene4
@v12-engine/editor/testing2
@v12-engine/editor/vite9
@v12-engine/engine1592
@v12-engine/engine/ai306
@v12-engine/engine/debug31
@v12-engine/engine/server45
@v12-engine/engine/testing38
@v12-engine/render128
@v12-engine/render/testing15