From 23fe79585f65c3eedc4f6003cc3ec70f68914f50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Mon, 26 Jun 2023 21:25:27 +0200 Subject: [PATCH] Add hidden setting for adjusting the token size modifier on gridless (resolves #9) --- js/cache.js | 3 ++- js/main.js | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/js/cache.js b/js/cache.js index 240d2e7..7b573ae 100644 --- a/js/cache.js +++ b/js/cache.js @@ -139,7 +139,8 @@ class GridlessCache extends Cache { } let graph = levelGraphs[tokenSize]; if (!graph) { - const tokenCalcSize = tokenSize * canvas.grid.size * 0.9; // TODO Put this multiplicator into a setting + const tokenCalcSize = + tokenSize * canvas.grid.size * game.settings.get("routinglib", "gridlessTokenSizeRatio"); const walls = canvas.walls.placeables; const wallHeightEnabled = isModuleActive("wall-height"); graph = GridlessPathfinding.initializeGraph( diff --git a/js/main.js b/js/main.js index 41d35b6..9284992 100644 --- a/js/main.js +++ b/js/main.js @@ -71,6 +71,20 @@ function calculatePathBlocking(from, to, options = {}) { return pathfinder.postProcessResult(path); } +Hooks.once("init", async () => { + game.settings.register("routinglib", "gridlessTokenSizeRatio", { + scope: "world", + config: false, + type: Number, + default: 0.9, + onChange: () => { + if (canvas.grid.type === CONST.GRID_TYPES.GRIDLESS) { + cache.reset(); + } + }, + }); +}); + Hooks.once("ready", async () => { foundryReady = true; initializeIfReady();