-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathToken.js
54 lines (45 loc) · 1.61 KB
/
Token.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* globals
foundry
*/
/* eslint no-unused-vars: ["error", { "argsIgnorePattern": "^_" }] */
import { ConstrainedTokenBorder } from "./ConstrainedTokenBorder.js";
// Patches for the Token class
export const PATCHES = {};
PATCHES.CONSTRAINED_TOKEN_BORDER = {};
// ----- NOTE: Getters ----- //
/**
* New getter: Token.prototype.constrainedTokenBorder
* Determine the constrained border shape for this token.
* @returns {ConstrainedTokenShape|PIXI.Rectangle}
*/
function constrainedTokenBorder() { return ConstrainedTokenBorder.get(this).constrainedBorder(); }
/**
* New getter: Token.prototype.isConstrainedTokenBorder
* Determine whether the border is currently constrained for this token.
* I.e., the token overlaps a wall.
* @returns {boolean}
*/
function isConstrainedTokenBorder() { return !ConstrainedTokenBorder.get(this)._unrestricted; }
/**
* New getter: Token.prototype.tokenBorder
* Determine the correct border shape for this token. Utilize the cached token shape.
* @returns {PIXI.Polygon|PIXI.Rectangle}
*/
function tokenBorder() { return this.getShape().translate(this.document.x, this.document.y); }
/**
* New getter: Token.prototype.tokenShape
* Cache the token shape.
* @type {PIXI.Polygon|PIXI.Rectangle}
*/
function tokenShape() {
const msg = "libGeometry|Token#tokenShape is deprecated. "
+ "If you need the shape of a Token, use Token#shape/getShape instead.";
foundry.utils.logCompatibilityWarning(msg, {since: 12, until: 14, once: true});
return this.shape;
}
PATCHES.CONSTRAINED_TOKEN_BORDER.GETTERS = {
constrainedTokenBorder,
tokenBorder,
tokenShape,
isConstrainedTokenBorder
};