-
Notifications
You must be signed in to change notification settings - Fork 1
/
registration.js
145 lines (117 loc) · 4.33 KB
/
registration.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/* globals
CONFIG,
foundry
*/
"use strict";
const VERSION = "0.3.19";
// Foundry utils
import { GEOMETRY_CONFIG } from "./const.js";
import { registerFoundryUtilsMethods } from "./util.js";
// Regular Polygons
import "./RegularPolygon/RegularPolygon.js";
import "./RegularPolygon/EquilateralTriangle.js";
import "./RegularPolygon/Square.js";
import "./RegularPolygon/Hexagon.js";
import "./RegularPolygon/RegularStar.js";
// Centered Polygons
import "./CenteredPolygon/CenteredPolygonBase.js";
import "./CenteredPolygon/CenteredPolygon.js";
import "./CenteredPolygon/CenteredRectangle.js";
// Holed Shapes
import "./ShapeHoled.js";
// 3d
import "./3d/Plane.js";
import "./3d/Point3d.js";
import "./3d/Ray3d.js";
// Draw
import "./Draw.js";
// Ellipse
import "./Ellipse.js";
// Matrix
import "./Matrix.js";
// Shadow
import "./Shadow.js";
// ClipperPaths
import "./ClipperPaths.js";
// Graph
import "./Graph.js";
// Patcher
import { Patcher } from "../Patcher.js";
// PIXI
import { PATCHES as PATCHES_Circle } from "./PIXI/Circle.js";
import { PATCHES as PATCHES_Point } from "./PIXI/Point.js";
import { PATCHES as PATCHES_Polygon } from "./PIXI/Polygon.js";
import { PATCHES as PATCHES_Rectangle } from "./PIXI/Rectangle.js";
// Elevation
import { PATCHES as PATCHES_ELEVATION } from "./elevation.js";
// Constrained Token Border and Edges
import { PATCHES as PATCHES_Token } from "./Token.js";
import { PATCHES as PATCHES_CanvasEdges } from "./CanvasEdges.js";
import { PATCHES as PATCHES_ConstrainedTokenBorder } from "./ConstrainedTokenBorder.js";
import { PATCHES as PATCHES_Edge } from "./Edge.js";
// PixelCache
import "./PixelCache.js";
import { PATCHES as PATCHES_Tile } from "./Tile.js";
// Grid measurement
import "./GridCoordinates.js";
import "./3d/GridCoordinates3d.js";
import "./3d/RegionMovementWaypoint3d.js";
import "./3d/HexGridCoordinates3d.js";
// Cutaway
import "./CutawayPolygon.js";
const PATCHES = {
"PIXI.Circle": PATCHES_Circle,
"PIXI.Point": PATCHES_Point,
"PIXI.Polygon": PATCHES_Polygon,
"PIXI.Rectangle": PATCHES_Rectangle,
// PixelCache
"Tile": PATCHES_Tile,
// Elevation patches.
"foundry.canvas.sources.BaseEffectSource": PATCHES_ELEVATION.PointSource,
"foundry.canvas.sources.PointVisionSource": PATCHES_ELEVATION.VisionSource,
"PlaceableObject": PATCHES_ELEVATION.PlaceableObject,
"Wall": PATCHES_ELEVATION.Wall,
// Elevation and Constrained Token patches
"Token": foundry.utils.mergeObject(PATCHES_ELEVATION.Token, PATCHES_Token),
"foundry.canvas.edges.CanvasEdges": PATCHES_CanvasEdges,
"foundry.canvas.edges.Edge": PATCHES_Edge,
"ConstrainedTokenBorder": PATCHES_ConstrainedTokenBorder
}
export function registerGeometry() {
CONFIG.GeometryLib ??= {};
CONFIG.GeometryLib.registered ??= new Set();
const currentVersion = CONFIG.GeometryLib.version;
if ( currentVersion && !foundry.utils.isNewerVersion(VERSION, currentVersion) ) return;
registerFoundryUtilsMethods();
registerGeometryLibConstants();
foundry.utils.mergeObject(CONFIG.GeometryLib, GEOMETRY_CONFIG);
registerGeometryLibPatches();
CONFIG.GeometryLib.version = VERSION;
}
export function registerGeometryLibConstants() {
CONFIG.GeometryLib ??= {};
CONFIG.GeometryLib.proneStatusId = "prone";
CONFIG.GeometryLib.proneMultiplier = 0.33;
CONFIG.GeometryLib.visionHeightMultiplier = 1;
CONFIG.GeometryLib.pixelCacheResolution = 1;
}
export function registerGeometryLibPatches() {
// If older PATCHER is present, deregister it and remove it.
if ( CONFIG.GeometryLib.PATCHER ) deRegister();
// Create a new Patcher object and register the patches.
CONFIG.GeometryLib.PATCHER = new Patcher();
CONFIG.GeometryLib.PATCHER.addPatchesFromRegistrationObject(PATCHES);
CONFIG.GeometryLib.PATCHER.registerGroup("PIXI");
CONFIG.GeometryLib.PATCHER.registerGroup("CONSTRAINED_TOKEN_BORDER");
CONFIG.GeometryLib.PATCHER.registerGroup("CANVAS_EDGES");
CONFIG.GeometryLib.PATCHER.registerGroup("PIXEL_CACHE");
CONFIG.GeometryLib.PATCHER.registerGroup("ELEVATION");
}
function deRegister() {
CONFIG.GeometryLib.registered?.clear();
CONFIG.GeometryLib.PATCHER.deregisterGroup("ELEVATION");
CONFIG.GeometryLib.PATCHER.deregisterGroup("PIXI");
CONFIG.GeometryLib.PATCHER.deregisterGroup("PIXEL_CACHE");
CONFIG.GeometryLib.PATCHER.deregisterGroup("CANVAS_EDGES");
CONFIG.GeometryLib.PATCHER.deregisterGroup("CONSTRAINED_TOKEN_BORDER");
}