Options
All
  • Public
  • Public/Protected
  • All
Menu

Represents any top-level data type that can be saved to a file.

Currently either a TileMap or a Tileset.

For assets that are loaded in the editor, all modifications and modifications to their contained parts create undo commands. This includes both modifying functions that are called as well as simply assigning to a writable property.

Hierarchy

Index

Constructors

constructor

Properties

Readonly asset

asset: Asset

The asset this object is part of, or null.

Readonly fileName

fileName: string

File name of the asset.

Readonly isTileMap

isTileMap: boolean

Whether the asset is a TileMap.

Readonly isTileset

isTileset: boolean

Whether the asset is a Tileset.

Readonly modified

modified: boolean

Whether the asset was modified after it was saved or loaded.

Readonly readOnly

readOnly: boolean

Whether the object is read-only.

Methods

macro

  • macro<T>(text: string, callback: () => T): T
  • Creates a single undo command that wraps all changes applied to this asset by the given callback. Recommended to avoid spamming the undo stack with small steps that the user does not care about.

    Example function that changes visibility of multiple layers in one step:

    tileMap.macro((visible ? "Show" : "Hide") + " Selected Layers", function() {
        tileMap.selectedLayers.forEach(function(layer) {
            layer.visible = visible
        })
    })
    

    The returned value is whatever the callback function returned.

properties

  • Returns all custom properties set on this object.

    Modifications to the properties will not affect the original object. Does not include inherited values (see resolvedProperties).

property

  • Returns the value of the custom property with the given name, or undefined if no such property is set on the object. Does not include inherited values (see resolvedProperty).

    file properties are returned as FilePath.

    object properties are returned as MapObject when possible, or ObjectRef when the object could not be found.

redo

  • redo(): void
  • Redoes the last change that was undone.

    note

    The undo system is only enabled for assets loaded in the editor!

removeProperty

  • removeProperty(name: string): void

resolvedProperties

  • Returns all custom properties set on this object. Modifications to the properties will not affect the original object. Includes values inherited from object types, templates and tiles where applicable.

resolvedProperty

  • Returns the value of the custom property with the given name, or undefined if no such property is set. Includes values inherited from object types, templates and tiles where applicable.

setProperties

setProperty

  • Sets the value of the custom property with the given name. Supported types are bool, number, string, FilePath, ObjectRef and MapObject.

    When setting a number, the property type will be set to either int or float, depending on whether it is a whole number.

    note

    Support for setting color properties is currently missing.

undo

  • undo(): void
  • Undoes the last applied change.

    note

    The undo system is only enabled for assets loaded in the editor!

Generated using TypeDoc