Skip to content

Registry ​

Class of @v12-engine/engine

ts
export declare class Registry

The registry of a game's definitions and behaviours: unit types, abilities, orders, systems, buffs and the rest, by id

Members ​

abilities ​

ts
readonly abilities: Definitions<AbilityDef>;

Every ability there is, of units, heroes and items alike (Rules.abilities)

ability ​

ts
ability(id: string): AbilityDef;

An ability by id: throws for one the game does not have (abilities)

assembly ​

ts
assembly: AssembledGame | null;

The game put together with its packs (assembleGame): set as the registry is made of it

buff ​

ts
buff(id: string): BuffDef;

A buff by id: throws for one the game does not have (buffs)

buffs ​

ts
readonly buffs: Definitions<BuffDef>;

The game's buffs (Rules.buffs)

cellLayers ​

ts
cellLayers: CellLayerDef[];

The game's layers of cells (Rules.cellLayers): what Terrain.cells is keyed by, with what each means

command ​

ts
command(type: string): CommandDef | undefined;

The command type, or undefined for one the game does not have: commands come from outside, and may name anything

commands ​

ts
readonly commands: Definitions<CommandDef<import("./fields").Fields>>;

The commands a world takes, the engine's and the game's, by type

component ​

ts
component(id: string): Component<unknown> | undefined;

A component of this game by its id: one the game lists, or one of the engine's own (coreComponents). None for any other

currency ​

ts
currency: ResourceId | null;

The resource prices, bounties, revives and sales are in: the game's money. Null for a game without one, where there is nothing of that kind to pay with

dataHash ​

ts
get dataHash(): string;

What identifies the game's data: everything but how its code reads (see gameHash). What a server and a player check they share: the two run builds of the same code that print it differently

day ​

ts
day: DayCycle | null;

Null for a game where it is always day

defineParts ​

ts
defineParts(components: readonly Component<unknown>[], events: readonly EventKey<unknown>[]): void;

Takes in the components and events a game lists. Throws for an id that is there twice, another way

effect ​

ts
effect(type: string): EffectHandler;

What an effect type does: throws for one there is not (effects)

effects ​

ts
readonly effects: Definitions<EffectType<keyof import("./defs").EffectTypes>>;

What each type of an ability's effect does, by type

event ​

ts
event(id: string): EventKey<unknown> | undefined;

An event of the game's own by its id: listed, or the engine's (core.), as the engine defined it. One of a game's that it does not list throws (UnlistedError). Never another game's: a process may hold more than one, each defining an id its own way (E7)

file ​

ts
file<T>(def: GameFileDef<T>): T;

What the rules read of a file of the game's own data (Rules.files): throws for one the game does not list

fileDef ​

ts
fileDef(id: string): GameFileDef<unknown> | undefined;

A file of the game's own data by its id (waves.json): what reads it, for an editor that writes it. None for one the game does not list

formation ​

ts
formation(id: string): FormationDef;

A formation by id: throws for one there is not (formations)

formations ​

ts
readonly formations: Definitions<FormationDef>;

How groups line up (Rules.formations)

game ​

ts
game: string;

Id of the game module it was made from

hash ​

ts
get hash(): string;

What identifies the game exactly, mods and code included (see gameHash). Worked out the first time it is asked for

item ​

ts
item(id: string): ItemDef;

An item by id: throws for one the game does not have (items)

items ​

ts
readonly items: Definitions<ItemDef>;

The game's items (Rules.items)

kinds ​

ts
readonly kinds: {
        readonly [K in DataKind]: Definitions<DataDefs[K]>;
    };

The kinds of definition a game's data is kept for (DataKind), each its collection: what the Data panel, mods, saves and a game's reload walk, one loop each

leaving ​

ts
leaving: readonly Component<unknown, unknown>[];

The engine's parts and the game's that call something off as an entity leaves its owner (Component.onLeave)

listedComponents beta ​

ts
listedComponents(): Iterable<Component<unknown, unknown>>;

The components the game lists, for what goes through them all: the map's fields they have

lists ​

ts
lists(kind: 'component' | 'event', id: string): boolean;

Whether the game lists a component or an event, or it is one of the engine's own

log ​

ts
log?: Logger;

The log of the world this is the registry of, once there is one (World.log)

module ​

ts
module: Rules | null;

The game module it was made from

order ​

ts
order<Type extends string>(type: Type): OrderBehavior<OrderStateOf<Type>, OrderInitOf<Type>>;

An order type's behaviour, typed by what its orders keep (OrderStates): throws for one there is not (orders)

orders ​

ts
readonly orders: Definitions<OrderBehavior<Record<string, any>, OrderParams>>;

The orders units can be given, the engine's and the game's, by type

passing ​

ts
passing: readonly Component<unknown, unknown>[];

The engine's parts and the game's that may have a structure stand open, in nobody's way (Component.passable)

prefab ​

ts
prefab(id: string): PrefabDef;

A prefab of the game's by id, for world.spawnPrefab; throws for one there is not

prefabs ​

ts
readonly prefabs: Definitions<PrefabDef>;

The game's prefabs (Rules.prefabs)

race ​

ts
race(id: string): RaceDef;

A race by id: throws for one the game does not have (races)

races ​

ts
readonly races: Definitions<RaceDef>;

The game's races, in its order (Rules.races): none in a game without

replications ​

ts
replications: readonly ReplicatedEvent[];

How each event of the world is told to a player, the engine's then the packs' (replicateEvent), in order

report ​

ts
report: ((world: World, player: PlayerId) => Record<string, unknown>) | null;

What the game tells each player about itself, see Rules.report. Asked by the session that runs the world

resource ​

ts
resource(id: ResourceId): ResourceDef | undefined;

The definition of a resource, or undefined for one the game does not have

resources ​

ts
resources: ResourceDef[];

The resources of the game, in the order players are shown them

saveVersion ​

ts
get saveVersion(): number;

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

score ​

ts
score: ResolvedScore | null;

What the game counts of its players (RuleSettings.score), its stats made: null for a game that counts nothing

setFile ​

ts
setFile<T>(def: GameFileDef<T>, value: T): void;

Puts what a file of the game's is read as, for this registry's world alone: the editor's panel, as it is edited

settings ​

ts
settings: Readonly<RuleSettings>;

The game's numbers that are not about any one unit (Rules.settings)

snapshotFields ​

ts
snapshotFields: readonly SnapshotField[];

The parts of a player's snapshot, the engine's then the packs' (SnapshotField), in order

spawning ​

ts
spawning: readonly Component<unknown, unknown>[];

The engine's parts and the game's that give an entity something as it is made (Component.onSpawn), in order

standsOpen ​

ts
standsOpen(entity: Entity): boolean;

Whether a structure stands open now, in nobody's way, by its parts (Component.passable): a gate opened

statDefaults ​

ts
statDefaults: Readonly<Stats>;

Every stat of the game at 0, its own at their default: what base stats start from

statFields ​

ts
statFields: StatField[];

What the game's packs add to a unit's stats (GamePack.stats): a hero's growth

statKeys ​

ts
statKeys: string[];

Every stat there is in the game, the engine's first

stats ​

ts
stats: StatDef[];

The game's own stats, next to the engine's (Rules.stats)

tags ​

ts
readonly tags: Definitions<TagDef>;

The tags of the game's items named and given a look (Rules.tags): a tag none names is its own word

takeFrom ​

ts
takeFrom(other: Registry): void;

Takes the definitions of another registry of the same game over its own (world.reload): its unit types, abilities, buffs, items, upgrades and races, the code of its effects and orders, its rules, and its module. Those it has that the other has not are kept (a world may have units of them). What the game is made of otherwise (its resources, stats, components, events) stays as it is: a world was made of it

targetings ​

ts
readonly targetings: Definitions<Targeting>;

A game's own ways of aiming an ability (Rules.targetings), by name

tile ​

ts
tile(id: string): number;

The index of a tile of the game, for painting the ground in code: terrain.tiles[cell] = registry.tile('road')

tileIds ​

ts
get tileIds(): string[];

The ids of the game's tiles, in the order of their indices

tiles ​

ts
tiles: TileDef[];

What the ground can be painted with, in the order of their indices: the first is 1 (Rules.tiles)

tunable ​

ts
tunable(id: string): TunableDef | undefined;

A tunable by id, or nothing for one the game does not have

tunables ​

ts
tunables: TunableDef[];

The numbers of the rules to be tuned while the game plays (Rules.tunables)

unit ​

ts
unit(id: string): UnitTypeDef;

A unit type by id: throws for one the game does not have (units)

units ​

ts
readonly units: Definitions<UnitTypeDef>;

The game's unit types, buildings and resources (Rules.units)

upgrade ​

ts
upgrade(id: string): UpgradeDef;

An upgrade by id: throws for one the game does not have (upgrades)

upgrades ​

ts
readonly upgrades: Definitions<UpgradeDef>;

The game's research (Rules.upgrades)

upkeep ​

ts
upkeep: UpkeepTier[];

Lowest threshold first. Empty for a game without upkeep

used ​

ts
used(id: string): Component<unknown>;

A component of this game by its id, as something of the world uses it: throws for one the game does not list (UnlistedError)