MapDocument beta
Class of @v12-engine/editor
export declare class MapDocumentThe 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
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
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
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
cancel(): void;Puts the map back to what it was when the operation began, which leaves no trace in the history
canRedo
get canRedo(): boolean;Whether the history has an operation to do again
canUndo
get canUndo(): boolean;Whether the history has an operation to take back
changed
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
get changing(): boolean;Whether an operation is being made: begun (begin) and not yet committed or cancelled
collections
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
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
doodadsVersion: number;Goes up when the scenery changed (changed('doodads')): with objectsVersion, what lists the map's things reads (the Outliner)
fixedPlayers
get fixedPlayers(): MapPlayer[] | undefined;The players of every map of the game, when the game decides who they are (MapEditorDef.players)
groundChanged
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
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
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
get historyLimit(): number;
set historyLimit(steps: number);How many steps the history keeps (200 when nobody says): the oldest go first
ids
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
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
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
get map(): GameMap;The map open, as it is: changed in place by every edit, another once one is opened (open)
objectsVersion
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
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
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
redo(): Operation | null;Does again the last operation taken back; gives it back, or null when there was none
registry
readonly registry: Registry;The registry of the game's definitions the map is checked and edited against
rng
rng: Rng;Where the brushes that scatter take their chances from: a seed of the clock's, or the one given (seed)
rules
readonly rules: readonly MapRule[];The checks of the map besides the engine's (MapDocumentOptions.rules)
run
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
seed(seed: number): void;The brushes that scatter scatter the same way again from here, for the same strokes
step
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
get steps(): {
undo: string[];
redo: string[];
};What there is to undo and to do again, by name, the nearest first
strangeTiles
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
symmetry: Symmetry;What is done again mirrored or turned, to keep the map fair (see Symmetry)
takeGroundChange
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
readonly terrain: Terrain;The terrain the map's ground and cells are worked out into, for whatever draws it
terrainVersion
terrainVersion: number;Goes up when the ground changed, not only what stands on it
undo
undo(): Operation | null;Takes back the last operation, or the one being made. Returns it, or nothing when there was none
version
version: number;Goes up with every change, for whoever shows the map
whenLetGo
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
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
wholeChanged(): void;After all of the map changed, its size too: the terrain is made anew, in place, and all of it drawn again