WallsLayer

WallsLayer

The Walls canvas layer which provides a container for Wall objects within the rendered Scene.

Constructor

new WallsLayer()

Source:
See:

Extends

Members

(static) layerOptions

Source:

_chain :boolean

Source:

Track whether we are currently within a chained placement workflow

Type:
  • boolean

_controlled :Object

Source:
Overrides:

Track the set of PlaceableObjects on this layer which are currently controlled by their id

Type:
  • Object

_copy :Array.<object>

Source:
Overrides:

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

Type:

_forceSnap :boolean

Source:

Track whether the layer is currently toggled to snap at exact grid precision

Type:
  • boolean

_hover :PlaceableObject

Source:
Overrides:

Track the PlaceableObject on this layer which is currently being hovered upon

Type:

blockMovement :Array.<Wall>

Source:

An Array of Wall instances in the current Scene which block Token movement. This array includes doors regardless of their current door state.

Type:

blockVision :Array.<Wall>

Source:

An Array of Wall instances in the current Scene which currently block Token vision. This array includes doors regardless of their current door state.

Type:

chain :PIXI.Graphics

Source:

A graphics layer used to display chained Wall selection

Type:
  • PIXI.Graphics

controlled

Source:
Overrides:

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

doors :Array.<Wall>

Source:

An Array of Wall instances in the current Scene which act as Doors.

Type:

endpoints :Array.<PointArray>

Source:

An array of all the unique perception-blocking endpoints which are present in the layer We keep this array cached for faster sight polygon computations

Type:

gridPrecision :number

Source:
Overrides:

Gate the precision of wall snapping to become less precise for small scale maps.

Type:
  • number

history :Array.<object>

Source:
Overrides:

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

Type:

hud :BasePlaceableHUD|null

Source:
Overrides:

If objects on this PlaceableLayer have a HUD UI, provide a reference to its instance

Type:

objects :PIXI.Container

Source:
Overrides:

Placeable Layer Objects

Type:
  • PIXI.Container

options :Object

Source:
Overrides:

PlaceableObject layer options

Type:
  • Object

placeables :Array.<PlaceableObject>

Source:
Overrides:

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

Type:

preview

Source:
Overrides:

Preview Object Placement

quadtree :Quadtree|null

Source:
Overrides:

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

Type:

Methods

(static) getClosestCollision(collisions) → {RayIntersection}

Source:

Identify the closest collision point from an array of collisions

Parameters:
Name Type Description
collisions Array.<RayIntersection>

An array of intersection points

Returns:

The closest blocking intersection

Type
RayIntersection

(static) getClosestEndpoint(point, wall) → {PointArray}

Source:

Given a point and the coordinates of a wall, determine which endpoint is closer to the point

Parameters:
Name Type Description
point Point

The origin point of the new Wall placement

wall Wall

The existing Wall object being chained to

Returns:

The [x,y] coordinates of the starting endpoint

Type
PointArray

(static) getRayCollisions(ray, blockMovementopt, blockSensesopt, modeopt, _performance) → {Array.<object>|object|boolean}

Source:

Get the set of wall collisions for a given Ray

Parameters:
Name Type Attributes Description
ray Ray

The Ray being tested

blockMovement boolean <optional>

Test against walls which block movement?

blockSenses boolean <optional>

Test against walls which block senses?

mode string <optional>

The return mode of the test, one of "all", "closest", or "any"

_performance object

An internal performance object used for debugging

Returns:

An array of collisions, if mode is "all" The closest collision, if mode is "closest" Whether any collision occurred if mode is "any"

Type
Array.<object> | object | boolean

(static) getUniqueEndpoints(walls, bounds, blockMovement, blockSenses) → {Array.<PointArray>}

Source:

Given an array of Wall instances, identify the unique endpoints across all walls.

Parameters:
Name Type Description
walls Array.<Wall>

An array of Wall instances

bounds Rectangle

An optional bounding rectangle within which the endpoint must lie.

blockMovement boolean

Filter for walls that block movement, default is true.

blockSenses boolean

Filter for walls that block perception, default is true.

Returns:

An array of endpoints

Type
Array.<PointArray>

(static) testWall(ray, wall) → {RayIntersection}

Source:

Test a single Ray against a single Wall

Parameters:
Name Type Description
ray Ray

The Ray being cast

wall Wall

The Wall against which to test

Returns:

An intersection, if one occurred

Type
RayIntersection

_onClickLeft()

Source:
Overrides:
See:
  • {Canvas#_onClickLeft}

Handle left mouse-click events which originate from the Canvas stage and are dispatched to this Layer.

_onClickLeft2()

Source:
Overrides:
See:

Handle double left-click events which originate from the Canvas stage and are dispatched to this Layer.

_onClickRight()

Source:
Overrides:
See:
  • {Canvas#_onClickRight}

Handle right mouse-click events which originate from the Canvas stage and are dispatched to this Layer.

_onDragLeftCancel()

Source:
Overrides:
See:
  • {Canvas#_onDragLeftDrop}

Cancel a left-click drag workflow originating from the Canvas stage.

_onDragLeftDrop()

Source:
Overrides:
See:
  • {Canvas#_onDragLeftDrop}

Conclude a left-click drag workflow originating from the Canvas stage.

_onDragLeftMove()

Source:
Overrides:
See:
  • {Canvas#_onDragLeftMove}

Continue a left-click drag workflow originating from the Canvas stage.

_onDragLeftStart()

Source:
Overrides:
See:
  • {Canvas#_onDragLeftStart}

Start a left-click drag workflow originating from the Canvas stage.

_onMouseWheel(event)

Source:
Overrides:

Handle mouse-wheel events at the PlaceableObjects layer level to rotate multiple objects at once. This handler will rotate all controlled objects by some incremental angle.

Parameters:
Name Type Description
event MouseWheelEvent

The mousewheel event which originated the request

activate()

Source:
Inherited From:

checkCollision(ray) → {boolean}

Source:

Test whether movement along a given Ray collides with a Wall.

Parameters:
Name Type Description
ray Ray

The attempted movement

Returns:

Does a collision occur?

Type
boolean

controlAll(options) → {Array.<PlaceableObject>}

Source:
Overrides:

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

Parameters:
Name Type Description
options object

Options passed to the control method of each object

Returns:

An array of objects that were controlled

Type
Array.<PlaceableObject>

copyObjects() → {Array.<PlaceableObject>}

Source:
Overrides:

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

Returns:

The Array of copied PlaceableObject instances

Type
Array.<PlaceableObject>

(async) createMany(data, options) → {Promise.<Array.<object>>}

Source:
Overrides:

Create multiple embedded entities in a parent Entity collection using an Array of provided data

Parameters:
Name Type Description
data Array.<object>

An Array of update data Objects which provide incremental data

options object

Additional options which customize the update workflow

Returns:

A Promise which resolves to the returned socket response (if successful)

Type
Promise.<Array.<object>>

createObject() → {PlaceableObject}

Source:
Overrides:

Draw a single placeable object

Returns:
Type
PlaceableObject

deactivate()

Source:
Overrides:

deleteAll()

Source:
Overrides:

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

(async) deleteMany(ids, options) → {Promise.<Array.<string>>}

Source:
Overrides:

Simultaneously delete multiple PlaceableObjects. This executes a single database operation using Scene.update. If deleting only a single object, this will delegate to PlaceableObject.delete for performance reasons.

Parameters:
Name Type Description
ids Array.<string>

An Array of object IDs to target for deletion

options object

Additional options which customize the update workflow

Returns:

A Promise which resolves to the returned socket response (if successful)

Type
Promise.<Array.<string>>

(async) draw()

Source:
Overrides:

get(objectId) → {PlaceableObject}

Source:
Overrides:

Get a PlaceableObject contained in this layer by it's ID

Parameters:
Name Type Description
objectId string

The ID of the contained object to retrieve

Returns:

The object instance, or undefined

Type
PlaceableObject

highlightControlledSegments()

Source:

Highlight the endpoints of Wall segments which are currently group-controlled on the Walls layer

(async) moveMany(dx, dy, rotate, ids) → {Promise.<Scene>}

Source:
Overrides:

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:
Name Type Description
dx number

The number of incremental grid units in the horizontal direction

dy number

The number of incremental grid units in the vertical direction

rotate boolean

Rotate the token to the keyboard direction instead of moving

ids Array | Set

An Array or Set of object IDs to target for rotation

Returns:

The resulting Promise from the Scene.update operation

Type
Promise.<Scene>

(async) pasteObjects(position, hiddenopt, snapopt) → {Promise.<Array.<PlaceableObject>>}

Source:
Overrides:

Paste currently copied PlaceableObjects back to the layer by creating new copies

Parameters:
Name Type Attributes Description
position Point

The destination position for the copied data.

hidden boolean <optional>

Paste data in a hidden state, if applicable. Default is false.

snap boolean <optional>

Snap the resulting objects to the grid. Default is true.

Returns:

An Array of created PlaceableObject instances

Type
Promise.<Array.<PlaceableObject>>

releaseAll(options) → {number}

Source:
Overrides:

Release all controlled PlaceableObject instance from this layer.

Parameters:
Name Type Description
options object

Options passed to the release method of each object

Returns:

The number of PlaceableObject instances which were released

Type
number

(async) rotateMany(angle, delta, snap, ids) → {Promise.<Scene>}

Source:
Overrides:

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:
Name Type Description
angle number

A target angle of rotation (in degrees) where zero faces "south"

delta number

An incremental angle of rotation (in degrees)

snap number

Snap the resulting angle to a multiple of some increment (in degrees)

ids Array | Set

An Array or Set of object IDs to target for rotation

Returns:

The resulting Promise from the Scene.update operation

Type
Promise.<Scene>

selectObjects(x, y, width, height, releaseOptions, controlOptions) → {boolean}

Source:
Overrides:

Select all PlaceableObject instances which fall within a coordinate rectangle.

Parameters:
Name Type Description
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

releaseOptions Object

Optional arguments provided to any called release() method

controlOptions Object

Optional arguments provided to any called control() method

Returns:

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

Type
boolean

storeHistory(type, data)

Source:
Overrides:

Record a new CRUD event in the history log so that it can be undone later

Parameters:
Name Type Description
type string

The event type (create, update, delete)

data Object

The object data

(async) tearDown()

Source:
Inherited From:

(async) undoHistory() → {Promise.<Scene>}

Source:
Overrides:

Undo a change to the objects in this layer This method is typically activated using CTRL+Z while the layer is active

Returns:
Type
Promise.<Scene>

(async) updateMany(data, options) → {Promise.<Array.<object>>}

Source:
Overrides:

Update multiple embedded entities in a parent Entity collection using an Array of provided data

Parameters:
Name Type Description
data Array.<object>

An Array of update data Objects which provide incremental data

options object

Additional options which customize the update workflow

Returns:

A Promise which resolves to the returned socket response (if successful)

Type
Promise.<Array.<object>>