Skip to content

MapDocument beta ​

Class of @v12-engine/editor

ts
export declare class MapDocument

The map being edited and what every part of the editor shares: its terrain, kept in line with the layers, the history every change is a step of, the ids of what is made, and what follows a change (what is drawn again, what is worked out again). Made alone for a script or a test (new MapDocument(map, registry)); the map editor's areas each take it (GroundArea, ObjectsArea...), and MapEditor is it with its areas

Members ​

constructor ​

ts
constructor(map: GameMap, 
    registry: Registry, terrain?: Terrain, options?: MapDocumentOptions);

Constructs a new instance of the MapDocument class

Parameters ​

  • terrain: one of the same size to reuse, so that whatever draws it can stay

begin ​

ts
begin(name: string): void;

Begins an operation that is made over time, like a drag: whatever changes until commit or cancel is part of it

blockingVersion ​

ts
blockingVersion: number;

Goes up when what blocks the cells may be other than it was: what is worked out of it is made again (ObjectsArea)

cancel ​

ts
cancel(): void;

Puts the map back to what it was when the operation began, which leaves no trace in the history

canRedo ​

ts
get canRedo(): boolean;

Whether the history has an operation to do again

canUndo ​

ts
get canUndo(): boolean;

Whether the history has an operation to take back

changed ​

ts
changed(only?: 'doodads' | 'blocking-kept'): void;

After the map changed. doodads where only the scenery did: the objects and where they block are as they were, and what is drawn of them is not made again (OD1: a drag of doodads made a snapshot of 14k trees at each step). blocking-kept where objects changed but none that blocks cells (units moved)

changing ​

ts
get changing(): boolean;

Whether an operation is being made: begun (begin) and not yet committed or cancelled

collections ​

ts
readonly collections: MapCollections;

Every kind of thing on the map as a collection (MapCollection): the editor's own, and the game's (kinds) as they are now. What touches everything on the map goes over it

commit ​

ts
commit(name?: string): Operation | null;

Ends the operation begun: it is one step of the history. name says what it was, when that is only known now

doodadsVersion ​

ts
doodadsVersion: number;

Goes up when the scenery changed (changed('doodads')): with objectsVersion, what lists the map's things reads (the Outliner)

fixedPlayers ​

ts
get fixedPlayers(): MapPlayer[] | undefined;

The players of every map of the game, when the game decides who they are (MapEditorDef.players)

groundChanged ​

ts
groundChanged(area?: CellRect): void;

After the layers changed: the terrain is worked out again where they did (the whole map when it is not said), and what it worked out is kept for whoever draws it (takeGroundChange). area is in cells

history ​

ts
get history(): MapHistory;

The steps of the map open, undone and done again: what every change of the map is made in (run, begin)

historyBytes ​

ts
get historyBytes(): number;

set historyBytes(bytes: number);

About how many bytes of the map's the history keeps (64 MB when nobody says): past it, the oldest steps go first

historyLimit ​

ts
get historyLimit(): number;

set historyLimit(steps: number);

How many steps the history keeps (200 when nobody says): the oldest go first

ids ​

ts
ids: IdSource;

The ids of what is made here, kind by kind: made again for a map opened in this one's place (open)

idSpread ​

ts
readonly idSpread: number;

How far past the highest id the ids of what is made here start, at most (see ID_SPREAD): none, for ids in a row

kinds ​

ts
kinds: readonly MapKind[];

The kinds of thing of the game's own there are on its maps (MapKind): what things are named among, copied and counted with. The editor's client says them (EditorKinds), or whoever makes a MapEditor without one

map ​

ts
get map(): GameMap;

The map open, as it is: changed in place by every edit, another once one is opened (open)

objectsVersion ​

ts
objectsVersion: number;

Goes up when anything but the ground or the scenery changed: the objects, the camps, the markers, the looks (OD1). A stroke of a brush on the ground or a drag of doodads leaves it, so what is drawn of the objects is not made again

onOperation ​

ts
onOperation(listener: (operation: Operation, how: OperationHow) => void): () => void;

Told of each operation as it changes the map: made (done), taken back (undone), done again (redone), or a change being made put back as it was (cancelled), after the map is as the operation leaves it. What the editor's map.changed is made of. Gives back what stops it

open ​

ts
open(map: GameMap, history?: MapHistory): void;

Opens another map in this one's place: the editor, its areas and the very terrain stay (whatever holds on to them, what draws the terrain, keep them), the map is the one given, in the game's terms as one opened is (the one before is left as it was, for whoever kept it). The history starts again (its length and who hears of it as they were), the ids are numbered from the other map's, what a change going on had is let go of and what the areas worked out of the map before is forgotten. Not a step of the history. A history given (the one this map had, kept when another was opened over it) is taken up in the place of a new one, its steps as they were

redo ​

ts
redo(): Operation | null;

Does again the last operation taken back; gives it back, or null when there was none

registry ​

ts
readonly registry: Registry;

The registry of the game's definitions the map is checked and edited against

rng ​

ts
rng: Rng;

Where the brushes that scatter take their chances from: a seed of the clock's, or the one given (seed)

rules ​

ts
readonly rules: readonly MapRule[];

The checks of the map besides the engine's (MapDocumentOptions.rules)

run ​

ts
run<T>(name: string, change: () => T): T;

Makes one operation of everything change does to the map, under one name: deleting objects and camps together, copying a selection. When nothing is different in the end, the history is left as it was. If change throws, the map is put back

seed ​

ts
seed(seed: number): void;

The brushes that scatter scatter the same way again from here, for the same strokes

step ​

ts
step(step: OwnStep): void;

A step of the game's own (OwnStep): done now, part of the operation being made where one is, or an operation by itself; undone and redone with the map's (see EditorHistory.step)

steps ​

ts
get steps(): {
        undo: string[];
        redo: string[];
    };

What there is to undo and to do again, by name, the nearest first

strangeTiles ​

ts
readonly strangeTiles: string[];

Tiles the map is painted with that the game does not have, by name: kept in the map after the game's, drawn as not known, and plain ground in a world made from it

symmetry ​

ts
symmetry: Symmetry;

What is done again mirrored or turned, to keep the map fair (see Symmetry)

takeGroundChange ​

ts
takeGroundChange(): CellRect | 'all' | null;

What of the ground was worked out again since this was last asked, in cells, for whoever draws it: a patch of it, the whole of it (all), or nothing

terrain ​

ts
readonly terrain: Terrain;

The terrain the map's ground and cells are worked out into, for whatever draws it

terrainVersion ​

ts
terrainVersion: number;

Goes up when the ground changed, not only what stands on it

undo ​

ts
undo(): Operation | null;

Takes back the last operation, or the one being made. Returns it, or nothing when there was none

version ​

ts
version: number;

Goes up with every change, for whoever shows the map

whenLetGo ​

ts
whenLetGo(hook: () => void): () => void;

Says what lets go of a change of an area's own going on (a brush's stroke) when the change is cancelled or undone. Gives back what stops it

whenOpened ​

ts
whenOpened(hook: () => void): () => void;

Says what forgets what an area worked out of the map (ids it numbers from, a cache) when another map is opened in its place (open). Gives back what stops it

wholeChanged ​

ts
wholeChanged(): void;

After all of the map changed, its size too: the terrain is made anew, in place, and all of it drawn again