diff --git a/CHANGELOG.md b/CHANGELOG.md index 30f9c6a..b55099c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# Version 10.5 + +Fixed an issue with determining when a token causes difficult terrain. + # Version 10.4 Fixed issue when restoring a Terrain after it's been deleted when using Ctrl-Z. diff --git a/classes/terraininfo.js b/classes/terraininfo.js index dcf47ef..c1e0b03 100644 --- a/classes/terraininfo.js +++ b/classes/terraininfo.js @@ -120,11 +120,19 @@ export class TokenTerrainInfo extends TerrainInfo { } get shape() { - const left = 0; - const top = 0; - const right = left + this.token.width * canvas.dimensions.size; - const bottom = top + this.token.height * canvas.dimensions.size; - return new PIXI.Polygon(left, top, right, top, right, bottom, left, bottom); + if (canvas.grid.type == CONST.GRID_TYPES.GRIDLESS) { + const hw = (this.token.document.width * canvas.dimensions.size) / 2; + const hh = (this.token.document.height * canvas.dimensions.size) / 2; + + return new PIXI.Circle(hw, hh, Math.max(hw, hh)); + } else { + const left = 0; + const top = 0; + const width = this.token.document.width * canvas.dimensions.size; + const height = this.token.document.height * canvas.dimensions.size; + + return new PIXI.Rectangle(left, top, width, height); + } } get environment() { diff --git a/classes/terrainlayer.js b/classes/terrainlayer.js index 0198503..9e62d28 100644 --- a/classes/terrainlayer.js +++ b/classes/terrainlayer.js @@ -19,6 +19,21 @@ export class TerrainLayer extends PlaceablesLayer { this._setting = {}; } + testTerrain() { + let gr = new PIXI.Graphics(); + if (this.debugGr) + canvas.tokens.removeChild(this.debugGr); + this.debugGr = gr; + canvas.tokens.addChild(gr); + + for (let x = canvas.dimensions.sceneX; x < canvas.dimensions.sceneWidth + canvas.dimensions.sceneX; x += 10) { + for (let y = canvas.dimensions.sceneY; y < canvas.dimensions.sceneHeight + canvas.dimensions.sceneY; y += 10) { + let cost = this.cost({ x: x, y: y }, { ignoreGrid: true }); + gr.beginFill(cost == 1 ? 0x0000ff : 0xff0000).drawCircle(x, y, 4).endFill(); + } + } + } + static documentName = "Terrain"; /** @override */ diff --git a/module.json b/module.json index 49feea7..9a7b2c7 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.4", + "version": "10.5", "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.4.zip", + "download": "https://github.com/ironmonk88/enhanced-terrain-layer/archive/10.5.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,