diff --git a/CHANGELOG.md b/CHANGELOG.md index 97348fc..8c5c558 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# Version 10.2 + +Fixed issues with checking if the terrain contains a point. + # Version 10.1 Fixed issue with migrating to v10. diff --git a/classes/terraininfo.js b/classes/terraininfo.js index 6cce1ad..3d1323d 100644 --- a/classes/terraininfo.js +++ b/classes/terraininfo.js @@ -58,7 +58,7 @@ export class PolygonTerrainInfo extends TerrainInfo { } get shape() { - return this.terrain.shape; + return this.terrain._pixishape; } } diff --git a/classes/terrainshape.js b/classes/terrainshape.js index a3e0e28..aed2729 100644 --- a/classes/terrainshape.js +++ b/classes/terrainshape.js @@ -52,6 +52,29 @@ export class TerrainShape extends DrawingShape { this.setPosition(); } + get _pixishape() { + let shape; + switch (this.document.shape.type) { + case Drawing.SHAPE_TYPES.RECTANGLE: + shape = new PIXI.Rectangle(this.x, this.y, this.width, this.height); + break; + case Drawing.SHAPE_TYPES.ELLIPSE: + shape = new PIXI.Ellipse(this.x, this.y, this.width / 2, this.height / 2); + break; + case Drawing.SHAPE_TYPES.POLYGON: + shape = new PIXI.Polygon(this.document.shape.points); + break; + } + return shape; + } + + contains(x, y) { + let shape = this._pixishape; + if (shape) + return shape.contains(x, y); + return false; + } + /* -------------------------------------------- */ /** diff --git a/module.json b/module.json index 54ff770..d6bab62 100644 --- a/module.json +++ b/module.json @@ -1,7 +1,7 @@ { "title": "Enhanced Terrain Layer", "description": "A base module that adds a Terrain Layer to Foundry. Used as a library for Rulers and other modules", - "version": "10.1", + "version": "10.2", "authors": [ { "name": "IronMonk", @@ -47,7 +47,7 @@ "css/terrainlayer.css" ], "url": "https://github.com/ironmonk88/enhanced-terrain-layer", - "download": "https://github.com/ironmonk88/enhanced-terrain-layer/archive/10.1.zip", + "download": "https://github.com/ironmonk88/enhanced-terrain-layer/archive/10.2.zip", "manifest": "https://github.com/ironmonk88/enhanced-terrain-layer/releases/latest/download/module.json", "bugs": "https://github.com/ironmonk88/enhanced-terrain-layer/issues", "allowBugReporter": true,