Skip to content

PrefabFile beta ​

Interface of @v12-engine/editor

ts
export interface PrefabFile

A prefab's file: what was selected, around its middle, with a name and a version (bumped by every save, so that an instance knows whether it is behind)

Members ​

contents ​

ts
contents: MapClip;

The parts the prefab places, as a clip of the map around its middle

fromCode ​

ts
fromCode?: boolean;

One of the game's own, defined in code (Rules.prefabs): placed as any, never written to

ground ​

ts
ground?: PrefabGround;

The ground under it, when it was saved with it: heights, levels, water, paint, the game's cell layers and the pathing of a rectangle around its parts

name ​

ts
name: string;

The prefab's name, which it is placed by

own ​

ts
own?: MapClip;

What the file itself holds, as the editor has read a variant or a prefab with prefabs inside: contents is then what it places, its source's parts and those of the prefabs inside it as one copy. The editor's, never written

prefabs ​

ts
prefabs?: NestedPrefab[];

The prefabs inside it, each placed with it where it says (unpacked into the instance's parts as it is placed)

sources ​

ts
sources?: Record<string, number>;

The versions of the other prefabs it is made of (its source, the prefabs inside it, theirs), as it was read: the editor's, never written

tags ​

ts
tags?: string[];

Words to find it by

variant ​

ts
variant?: PrefabVariant;

A variant of another prefab: its source's parts, with the fields it overrides and the parts it leaves out; the file's own contents are what it adds. A source changed, its variants and their instances follow

variation ​

ts
variation?: {
        turn?: 'random' | 'quarters';
        chance?: ByCollection<Record<number, number>>;
    };

How placements vary: turned at random ('random') or by quarters, and the chance each part is placed at all (0..1, by kind and the prefab's own id of the part; 1 when not said): the parts left out are as if deleted in that instance

version ​

ts
version: number;

The prefab's version, raised by every save so an instance knows whether it is behind