Add api endpoint to determine the distance that a token has moved already
This commit is contained in:
+10
-1
@@ -1,5 +1,6 @@
|
||||
import {getCostFromSpeedProvider} from "./api.js";
|
||||
import {getColorForDistance} from "./main.js"
|
||||
import {highlightTokenShape} from "./util.js"
|
||||
import {getAreaFromPositionAndShape, highlightTokenShape} from "./util.js";
|
||||
|
||||
export function getHexSizeSupportTokenGridCenter(token) {
|
||||
const tokenCenterOffset = CONFIG.hexSizeSupport.getCenterOffset(token)
|
||||
@@ -12,3 +13,11 @@ export function highlightMeasurementTerrainRuler(ray, startDistance, tokenShape=
|
||||
highlightTokenShape.call(this, space, tokenShape, color, alpha)
|
||||
}
|
||||
}
|
||||
|
||||
export function measureDistances(segments, token, shape, gridSpaces=true) {
|
||||
const terrainRulerAvailable = game.modules.get("terrain-ruler")?.active && canvas.grid.type !== CONST.GRID_TYPES.GRIDLESS;
|
||||
if (terrainRulerAvailable)
|
||||
return game.terrainRuler.measureDistances(segments, {costFunction: (x, y) => getCostFromSpeedProvider(token, getAreaFromPositionAndShape({x, y}, shape), {x, y})});
|
||||
else
|
||||
return canvas.grid.measureDistances(segments, { gridSpaces });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user