Options
All
  • Public
  • Public/Protected
  • All
Menu

The Tokens Container.

Hierarchy

Index

Constructors

Accessors

  • get gridPrecision(): number
  • inheritdoc

    Returns number

  • get hud(): any
  • Token objects on this layer utilize the TokenHUD

    Returns any

  • get ownedTokens(): Token[]
  • An Array of tokens which belong to actors which are owned

    Returns Token[]

  • get documentCollection(): any
  • Obtain a reference to the Collection of embedded Document instances within the currently viewed Scene

    Returns any

  • A convenience method for accessing the placeable object instances contained in this layer

    Returns PlaceableObject[]

  • An Array of placeable objects in this layer which have the _controlled attribute

    Returns PlaceableObject[]

  • Track the set of PlaceableObjects on this layer which are currently controlled.

    Returns Map<string, PlaceableObject>

  • Track the PlaceableObject on this layer which is currently hovered upon.

    Returns PlaceableObject

  • Track the PlaceableObject on this layer which is currently hovered upon.

    Parameters

    Returns void

  • get active(): boolean
  • Is this layer currently active

    Returns boolean

  • get name(): string
  • The canonical name of the CanvasLayer

    Returns string

  • get layerOptions(): any
  • inheritdoc

    Returns any

  • get placeableClass(): Function
  • Obtain a reference to the PlaceableObject class definition which represents the Document type in this layer.

    Returns Function

  • Return a reference to the active instance of this canvas layer

    Returns CanvasLayer

Methods

  • _draw(options: any): Promise<void>
  • _tearDown(options: any): Promise<void>
  • _activate(): void
  • _deactivate(): void
  • targetObjects(rectangle: { x: number; y: number; width: number; height: number }, [options]?: { releaseOthers: boolean }): number
  • Target all Token instances which fall within a coordinate rectangle.

    Parameters

    • rectangle: { x: number; y: number; width: number; height: number }

      The selection rectangle.

      • x: number

        The top-left x-coordinate of the selection rectangle

      • y: number

        The top-left y-coordinate of the selection rectangle

      • width: number

        The width of the selection rectangle

      • height: number

        The height of the selection rectangle

    • [options]: { releaseOthers: boolean } = {}

      Additional options to configure targeting behaviour.

      • releaseOthers: boolean

    Returns number

    The number of Token instances which were targeted.

  • cycleTokens(forwards: boolean, reset: boolean): Token
  • Cycle the controlled token by rotating through the list of Owned Tokens that are available within the Scene Tokens are currently sorted in order of their TokenID

    Parameters

    • forwards: boolean

      Which direction to cycle. A truthy value cycles forward, while a false value cycles backwards.

    • reset: boolean

      Restart the cycle order back at the beginning?

    Returns Token

    The Token object which was cycled to, or null

  • Add or remove the set of currently controlled Tokens from the active combat encounter

    Parameters

    • state: boolean = true

      The desired combat state which determines if each Token is added (true) or removed (false)

    • combat: Combat = null

      A Combat encounter from which to add or remove the Token

    • [token]: Token = {}

      A specific Token which is the origin of the group toggle request

    Returns Promise<Combatant[]>

    The Combatants added or removed

  • concludeAnimation(): void
  • Immediately conclude the animation of any/all tokens

    Returns void

  • _onClickLeft(event: any): any
  • getDocuments(): Document[]
  • Obtain an iterable of objects which should be added to this PlaceableLayer

    Returns Document[]

  • _sortObjectsByElevation(): void
  • clearPreviewContainer(): void
  • Get a PlaceableObject contained in this layer by its ID. Returns undefined if the object doesn't exist or if the canvas is not rendering a Scene.

    Parameters

    • objectId: string

      The ID of the contained object to retrieve

    Returns PlaceableObject

    The object instance, or undefined

  • Acquire control over all PlaceableObject instances which are visible and controllable within the layer.

    Parameters

    • options: any = {}

      Options passed to the control method of each object

    Returns PlaceableObject[]

    An array of objects that were controlled

  • releaseAll(options?: any): number
  • Release all controlled PlaceableObject instance from this layer.

    Parameters

    • options: any = {}

      Options passed to the release method of each object

    Returns number

    The number of PlaceableObject instances which were released

  • rotateMany(options?: { angle: number; delta: number; snap: number; ids: any[] }): Promise<PlaceableObject[]>
  • Simultaneously rotate multiple PlaceableObjects using a provided angle or incremental. This executes a single database operation using Scene.update. If rotating only a single object, it is better to use the PlaceableObject.rotate instance method.

    Parameters

    • options: { angle: number; delta: number; snap: number; ids: any[] } = {}

      Options which configure how multiple objects are rotated

      • angle: number
      • delta: number
      • snap: number
      • ids: any[]

    Returns Promise<PlaceableObject[]>

    An array of objects which were rotated

  • moveMany(options?: { dx: number; dy: number; rotate: boolean; ids: any[] }): Promise<PlaceableObject[]>
  • Simultaneously move multiple PlaceableObjects via keyboard movement offsets. This executes a single database operation using Scene.update. If moving only a single object, this will delegate to PlaceableObject.update for performance reasons.

    Parameters

    • options: { dx: number; dy: number; rotate: boolean; ids: any[] } = {}

      Options which configure how multiple objects are moved

      • dx: number
      • dy: number
      • rotate: boolean
      • ids: any[]

    Returns Promise<PlaceableObject[]>

    An array of objects which were moved during the operation

  • undoHistory(): Promise<Document[]>
  • Undo a change to the objects in this layer This method is typically activated using CTRL+Z while the layer is active

    Returns Promise<Document[]>

    An array of documents which were modified by the undo operation

  • deleteAll(): Promise<Document[]>
  • A helper method to prompt for deletion of all PlaceableObject instances within the Scene Renders a confirmation dialogue to confirm with the requester that all objects will be deleted

    Returns Promise<Document[]>

    An array of Document objects which were deleted by the operation

  • storeHistory(type: string, data: any[]): void
  • Record a new CRUD event in the history log so that it can be undone later

    Parameters

    • type: string

      The event type (create, update, delete)

    • data: any[]

      The object data

    Returns void

  • Copy currently controlled PlaceableObjects to a temporary Array, ready to paste back into the scene later

    Returns PlaceableObject[]

    The Array of copied PlaceableObject instances

  • pasteObjects(position: Point, [options]?: { hidden: boolean; snap: boolean }): Promise<Document[]>
  • Paste currently copied PlaceableObjects back to the layer by creating new copies

    Parameters

    • position: Point

      The destination position for the copied data.

    • [options]: { hidden: boolean; snap: boolean } = {}

      Options which modify the paste operation

      • hidden: boolean
      • snap: boolean

    Returns Promise<Document[]>

    An Array of created Document instances

  • selectObjects(__namedParameters?: number, __namedParameters?: number): boolean
  • Select all PlaceableObject instances which fall within a coordinate rectangle.

    Parameters

    • __namedParameters: number = {}
    • __namedParameters: number = {}

    Returns boolean

    A boolean for whether the controlled set was changed in the operation

  • updateAll(transformation: any, condition?: Function, options?: any): Promise<Document[]>
  • Update all objects in this layer with a provided transformation. Conditionally filter to only apply to objects which match a certain condition.

    Parameters

    • transformation: any

      An object of data or function to apply to all matched objects

    • condition: Function = null

      A function which tests whether to target each object

    • options: any = {}

    Returns Promise<Document[]>

    An array of updated data once the operation is complete

  • _onDragLeftStart(event: any): Promise<void>
  • _onDragLeftMove(event: any): void
  • _onDragLeftDrop(event: any): Promise<any>
  • _onDragLeftCancel(event: any): void
  • _onClickRight(event: any): void
  • _onDeleteKey(event: any): Promise<any>
  • Activate the InteractionLayer, deactivating other layers and marking this layer's children as interactive.

    Parameters

    • [options]: { tool: string } = {}

      Options which configure layer activation

      • tool: string

    Returns InteractionLayer

    The layer instance, now activated

  • getZIndex(): number
  • Get the zIndex that should be used for ordering this layer vertically relative to others in the same Container.

    Returns number

  • Draw the canvas layer, rendering its internal components and returning a Promise. The Promise resolves to the drawn layer once its contents are successfully rendered.

    Parameters

    • options: any = {}

    Returns Promise<CanvasLayer>

  • Deconstruct data used in the current layer in preparation to re-draw the canvas

    Parameters

    • options: any = {}

    Returns Promise<CanvasLayer>

  • _getOccludableTokens(): any
  • Provide an array of Tokens which are eligible subjects for overhead tile occlusion. By default, only tokens which are currently controlled or owned by a player are included as subjects.

    Returns any

  • _canvasCoordinatesFromDrop(event: DragEvent, __namedParameters?: any): boolean | number[]
  • Get the world-transformed drop position.

    Parameters

    • event: DragEvent
    • __namedParameters: any = {}

    Returns boolean | number[]

    Returns the transformed x, y co-ordinates, or false if the drag event was outside the canvas.

  • _createPreview(createData: any, position: { top: number; left: number }): Promise<any>
  • Create a preview of this layer's object type from a world document and show its sheet so it can be finalized.

    Parameters

    • createData: any

      The data to create the object with.

    • position: { top: number; left: number }

      The position to render the sheet at.

      • top: number
      • left: number

    Returns Promise<any>

  • _onClickLeft2(event: InteractionEvent): void
  • _getCycleOrder(): Token[]
  • Get the tab cycle order for tokens by sorting observable tokens based on their distance from top-left.

    Returns Token[]

  • _animateTargets(): void
  • Animate targeting arrows on targeted tokens.

    Returns void

  • _onDropActorData(event: any, data: any): Promise<any>
  • Handle dropping of Actor data onto the Scene canvas

    Parameters

    • event: any
    • data: any

    Returns Promise<any>

Properties

_t: number
objects: any = null

Placeable Layer Objects

preview: any = null

Preview Object Placement

history: CanvasHistory[] = []

Keep track of history so that CTRL+Z can undo changes

_highlight: boolean = false

Track whether "highlight all objects" is currently active

_copy: PlaceableObject[] = []

Keep track of an object copied with CTRL+C which can be pasted later

quadtree: Quadtree = ...

A Quadtree which partitions and organizes Walls into quadrants for efficient target identification.

visible: boolean
sortDirty: boolean
zIndex: number
interactive: boolean
interactiveChildren: boolean
hitArea: any
options: { name: string } = ...

Options for this layer instance.

Type declaration

  • name: string
renderable: boolean
_tabIndex: number = null

The current index position in the tab cycle

#hover: any = null
documentName: string = "Token"

A reference to the named Document type which is contained within this Canvas Layer.

CREATION_STATES: { NONE: number; POTENTIAL: number; CONFIRMED: number; COMPLETED: number } = ...

Creation states affected to placeables during their construction.

Type declaration

  • NONE: number
  • POTENTIAL: number
  • CONFIRMED: number
  • COMPLETED: number