Skip to content

Commit

Permalink
Add hidden setting for adjusting the token size modifier on gridless (r…
Browse files Browse the repository at this point in the history
…esolves #9)
  • Loading branch information
manuelVo committed Jun 26, 2023
1 parent 0368ddb commit 23fe795
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion js/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
14 changes: 14 additions & 0 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 23fe795

Please sign in to comment.