Skip to content

PrefabsArea beta ​

Class of @v12-engine/editor

ts
export declare class PrefabsArea

Prefabs on the map: instances placed, read off their parts, brought up to the prefab's new version, reverted, applied back to the prefab, unpacked. See the note at the top of the file. Made with the document, how each kind is written, many things at once (what a prefab is put down and taken up with) and the areas its parts are of

Members ​

constructor ​

ts
constructor(
    doc: MapDocument, writerOf: (kind: CollectionId) => CollectionWriter, batch: BatchArea, objects: ObjectsArea, markers: MarkersArea, things: ThingsArea);

Constructs a new instance of the PrefabsArea class

appliedPrefab ​

ts
appliedPrefab(instance: PrefabInstance, file: PrefabFile): void;

The instance after Apply: of the file's version, its parts under the prefab's ids as applyPrefab gave them

applyPrefab ​

ts
applyPrefab(instance: PrefabInstance): MapClip;

The prefab as the instance has it now: its parts as they stand, around their middle and turned back as the instance is turned, each under the prefab's own id of it (a part added since gets a new one). What Apply writes to the file; the instance is then of that version (replaceInstance with the file is the caller's)

copyGround ​

ts
copyGround(ids: SelectionIds, margin?: number, falloff?: number): PrefabGround | undefined;

The ground under a selection, as a prefab brings it: the rectangle around the things (their footprints), margin cells wider, against the middle of the things (where copy puts the origin)

doc ​

ts
readonly doc: MapDocument;

The map document the area works on

groundForApply ​

ts
groundForApply(instance: PrefabInstance): PrefabGround | undefined;

The ground under the instance as it stands, for Apply, where the prefab brought ground: the same rectangle, read again

instanceCount ​

ts
instanceCount(instance: PrefabInstance): {
        present: number;
        placed: number;
    };

How many of an instance's parts are on the map, and how many it was made of

instanceOf ​

ts
instanceOf(target: Named): PrefabInstance | undefined;

The instance a thing of the map is a part of, if any

instanceParts ​

ts
instanceParts(instance: PrefabInstance): SelectionIds;

The parts of an instance that are on the map, by kind: what selects it, moves it, deletes it

nestedOf ​

ts
nestedOf(instance: PrefabInstance, id: number, middle: Vec2): NestedPrefab;

An instance as a prefab inside another, around the other's middle: where it stands, how it is turned and sized, and what was changed of it here (its overrides, and the parts it lacks)

placeNested ​

ts
placeNested(file: PrefabFile, nested: NestedPrefab, middle: Vec2): PrefabInstance | null;

A prefab inside another put down as it says, around the outer one's middle, as an instance of its own whose overrides are the designer's changes to it (so that writing the outer one gives them again): on a prefab's stage

placePrefab ​

ts
placePrefab(file: PrefabFile, at: Vec2, pose?: {
        turn?: number;
        scale?: number;
        without?: Partial<Record<string, number[]>>;
    }): PrefabInstance | null;

A prefab put down with its middle at a point, turned and sized as said, as one step: its parts on the map, and the instance recorded. Nothing when none of it fits there

prefabInstance ​

ts
prefabInstance(id: number): PrefabInstance | undefined;

The instance of that id, or undefined when the map has none

prefabInstances ​

ts
prefabInstances(): PrefabInstance[];

The instances of prefabs on the map, as the map keeps them

prefabInstancesOf ​

ts
prefabInstancesOf(name: string): PrefabInstance[];

The instances of one prefab, by its name

prefabPose ​

ts
prefabPose(instance: PrefabInstance, precise?: boolean): PrefabPose;

Where an instance stands, read off its parts: how the parts' places were (around the origin) fit where they are now, as one turn and one size (a best fit over all of them, so one part moved or turned by hand does not turn the instance); for an instance of one part, how that part is turned and sized against how it was placed. The buildings are read for the place only when nothing else is there: each is snapped to its cells, by up to half a cell

prefabProblems ​

ts
prefabProblems(files: ReadonlyMap<string, PrefabFile>): MapProblem[];

What is wrong with the instances: a prefab there is no file of, one behind the file's version, parts gone

renamePrefabInstances ​

ts
renamePrefabInstances(from: string, to: string): void;

The instances of a prefab told its new name, as one step: for a prefab renamed

replacePrefabInstances ​

ts
replacePrefabInstances(ids: Iterable<number>, file: PrefabFile): number;

Instances of a prefab made instances of another (Replace with, FB4): each is placed anew from the other's file where it stands, turned and sized as it was, under the same instance id; what was changed of it is dropped. One step to undo. How many were

unpackPrefab ​

ts
unpackPrefab(instance: PrefabInstance): void;

The instance forgotten: its parts stay on the map as plain things. One step

updatePrefab ​

ts
updatePrefab(instance: PrefabInstance, file: PrefabFile, options?: {
        overrides?: boolean;
    }): void;

The instance brought to the prefab's version: part by part and field by field, what the designer changed since it was placed stays (an override), the rest follows the prefab; a part the designer deleted stays deleted, a part new to the prefab is added, a part the prefab dropped goes unless it was changed. With overrides: false the instance is made anew from the prefab as it is now, where it stands (Revert). One step

wholeInstances ​

ts
wholeInstances(ids: SelectionIds): PrefabInstance[];

The instances every part of which (on the map) is among the ids given