Add difficult terrain support for pathfinding on gridded scenes

This commit is contained in:
Manuel Vögele
2022-05-10 08:39:19 +02:00
parent 5904efbdd5
commit 445c03d29a
7 changed files with 171 additions and 25 deletions
+5 -1
View File
@@ -2,7 +2,7 @@ import {measureDistances} from "./compatibility.js";
import {getMovementHistory} from "./movement_tracking.js";
import {GenericSpeedProvider, SpeedProvider} from "./speed_provider.js"
import {settingsKey} from "./settings.js"
import {getTokenShape} from "./util.js";
import {getAreaFromPositionAndShape, getTokenShape} from "./util.js";
export const availableSpeedProviders = {}
export let currentSpeedProvider = undefined
@@ -140,6 +140,10 @@ export function getMovedDistanceFromToken(token) {
return distances.reduce((acc, val) => acc + val, 0);
}
export function buildCostFunction(token, shape) {
return (x, y, costOptions={}) => getCostFromSpeedProvider(token, getAreaFromPositionAndShape({x, y}, shape), costOptions);
}
export function registerModule(moduleId, speedProvider) {
// Check if a module with the given id exists and is currently enabled
const module = game.modules.get(moduleId)