Skip to content

ObjectsArea beta ​

Class of @v12-engine/editor

ts
export declare class ObjectsArea

What stands on the map: objects and camps, where they may go, whose they are, and what they start as

Members ​

constructor ​

ts
constructor(
    doc: MapDocument);

Constructs a new instance of the ObjectsArea class

addCamp ​

ts
addCamp(point: Vec2, units: string[]): MapCamp | null;

Adds a camp of creeps of the given unit types at a point; gives the camp back, or null when it could not be made

camp ​

ts
camp(id: number): MapCamp | undefined;

The camp with that id, or undefined when the map has none

doc ​

ts
readonly doc: MapDocument;

The map document the area works on

moveCamp ​

ts
moveCamp(id: number, point: Vec2): void;

Moves a camp to a point, as one step of the history

moveObjects ​

ts
moveObjects(moves: {
        id: number;
        x: number;
        z: number;
    }[]): boolean;

Moves objects to new spots, all of them or none when one does not fit

object ​

ts
object(id: number): MapObject | undefined;

The object with that id, or undefined when the map has none

objectsOf ​

ts
objectsOf(ids: Iterable<number>): MapObject[];

The objects of these ids that are on the map

place ​

ts
place(type: string, owner: PlayerId, point: Vec2, facing?: number, looks?: {
        look?: string;
        scale?: number;
    }): MapObject | null;

Puts something on the map. Null when it does not fit there

properties ​

ts
properties(type: string): ObjectProperty[];

The properties that mean something for a type, in the order the inspector shows them. None for a type the game does not have

removeCamps ​

ts
removeCamps(ids: Iterable<number>): void;

Removes the camps with those ids, as one step of the history

removeObjects ​

ts
removeObjects(ids: Iterable<number>): void;

Removes the objects with those ids, as one step of the history

replaceType ​

ts
replaceType(ids: Iterable<number>, to: string): {
        replaced: number[];
        refused: {
            id: number;
            why: string;
        }[];
    };

Objects made another type (Replace with, FB4): each keeps its place (snapped as the type stands), its owner, its facing, its name, its size and the game's fields; the look of its old type goes, and what it started as stays where the new type has it (a hero's level, a building's site), made to fit. One step to undo. An object whose new footprint does not fit where it stands (something in the way, water, off the map) is left as it was, and said

setCampUnits ​

ts
setCampUnits(id: number, units: string[]): void;

Sets the unit types of a camp, as one step of the history

setChances ​

ts
setChances(ids: Iterable<number>, change: Partial<Pick<MapObject, 'random' | 'drops'>>): void;

Which random group objects are drawn from, and which table they drop from: undefined for none (see MapObject.random)

setOwner ​

ts
setOwner(ids: Iterable<number>, owner: PlayerId): void;

Sets the owner of the objects with those ids, as one step of the history

setProperties ​

ts
setProperties(ids: Iterable<number>, change: {
        [K in ObjectProperty]?: ObjectProperties[K];
    }): void;

Sets what objects start as: hurt, at a level, with items. Each property goes to the objects it means something for, made to fit (a level within the hero's, health between nothing and all), and one that is what the type starts with anyway is not kept. undefined puts a property back to that

snap ​

ts
snap(type: string, point: Vec2): Vec2;

Where something of a type ends up when put down at a point: structures sit on whole cells

spots ​

ts
spots(type: string): {
        step: number;
        x: [number, number];
        z: [number, number];
    };

The spots something of a type can stand at along each axis: the first, the last, and how far apart they are. Structures sit on whole cells, so theirs are a cell apart and start half their size in; units stand anywhere. A number input that steps through these never lands between two spots, where snap would put it back

transform ​

ts
transform(ids: Iterable<number>, change: {
        facing?: number;
        turn?: number;
        scale?: number;
    }): void;

Turns and resizes objects

transformAround ​

ts
transformAround(from: readonly ObjectPose[], pivot: Vec2, change: {
        turn?: number;
        scale?: number;
    }, withOthers?: boolean): void;

Turns objects around a point, or makes them bigger or smaller around it: each turns or grows by as much, and they keep their places to each other. from is how they were before, so that a drag can ask again and again as it goes, without what is lost in rounding adding up. When they do not all fit where that puts them, they turn or grow where they stand. One alone turns where it stands, unless it is withOthers: selected with what is not an object, which turns around the same point

whyNot ​

ts
whyNot(type: string, point: Vec2, ignore?: ReadonlySet<number>): string | null;

Why something of a type cannot go at a point, or null when it can. ignore are objects that are being moved

writer ​

ts
writer(kind: 'objects' | 'camps', named: Namer): CollectionWriter;

How objects and camps are written (CollectionWriter): put down as copies, changed, taken away