Add support for difficult terrain via Terrain Ruler module (resolves #1)

This commit is contained in:
Manuel Vögele
2021-03-09 10:02:09 +01:00
parent 0a7d8495c6
commit 384de1a1b5
6 changed files with 62 additions and 3 deletions
+11
View File
@@ -1,3 +1,6 @@
import {getPixelsFromGridPosition} from "./foundry_fixes.js"
import {getColorForDistance} from "./main.js"
export function getHexSizeSupportTokenGridCenter(token) {
const tokenCenterOffset = CONFIG.hexSizeSupport.getCenterOffset(token)
const tokenCenter = {x: token.x + tokenCenterOffset.x, y: token.y + tokenCenterOffset.y}
@@ -17,3 +20,11 @@ export function getHexSizeSupportTokenGridCenter(token) {
}
return tokenCenter
}
export function highlightMeasurementTerrainRuler(ray, startDistance) {
for (const space of ray.terrainRulerVisitedSpaces) {
const [x, y] = getPixelsFromGridPosition(space.x, space.y);
const color = getColorForDistance.call(this, startDistance, space.distance)
canvas.grid.highlightPosition(this.name, {x, y, color: color})
}
}