Skip to content

Commit

Permalink
10.5 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ironmonk88 committed Oct 14, 2022
1 parent a907712 commit 2313376
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
18 changes: 13 additions & 5 deletions classes/terraininfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
15 changes: 15 additions & 0 deletions classes/terrainlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
4 changes: 2 additions & 2 deletions module.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 2313376

Please sign in to comment.