Re-check for grid settings everytime pathfinding is restarted
This commit is contained in:
@@ -7,7 +7,6 @@ import {disableSnap, registerKeybindings} from "./keybindings.js";
|
|||||||
import {libWrapper} from "./libwrapper_shim.js";
|
import {libWrapper} from "./libwrapper_shim.js";
|
||||||
import {performMigrations} from "./migration.js"
|
import {performMigrations} from "./migration.js"
|
||||||
import {removeLastHistoryEntryIfAt, resetMovementHistory} from "./movement_tracking.js";
|
import {removeLastHistoryEntryIfAt, resetMovementHistory} from "./movement_tracking.js";
|
||||||
import { initializePathfinding } from "./pathfinding.js";
|
|
||||||
import {extendRuler} from "./ruler.js";
|
import {extendRuler} from "./ruler.js";
|
||||||
import {registerSettings, RightClickAction, settingsKey} from "./settings.js"
|
import {registerSettings, RightClickAction, settingsKey} from "./settings.js"
|
||||||
import {recalculate} from "./socket.js";
|
import {recalculate} from "./socket.js";
|
||||||
@@ -35,7 +34,6 @@ Hooks.once("init", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Hooks.once("ready", () => {
|
Hooks.once("ready", () => {
|
||||||
initializePathfinding();
|
|
||||||
performMigrations()
|
performMigrations()
|
||||||
checkDependencies();
|
checkDependencies();
|
||||||
Hooks.callAll("dragRuler.ready", SpeedProvider)
|
Hooks.callAll("dragRuler.ready", SpeedProvider)
|
||||||
|
|||||||
+4
-7
@@ -5,13 +5,6 @@ import {settingsKey} from "./settings.js";
|
|||||||
let cachedNodes = undefined;
|
let cachedNodes = undefined;
|
||||||
let use5105 = false;
|
let use5105 = false;
|
||||||
|
|
||||||
export function initializePathfinding() {
|
|
||||||
if (game.system.id === "pf2e")
|
|
||||||
use5105 = true;
|
|
||||||
if (canvas.grid.diagonalRule === "5105")
|
|
||||||
use5105 = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isPathfindingEnabled() {
|
export function isPathfindingEnabled() {
|
||||||
if (canvas.grid.type !== CONST.GRID_TYPES.SQUARE)
|
if (canvas.grid.type !== CONST.GRID_TYPES.SQUARE)
|
||||||
return false;
|
return false;
|
||||||
@@ -92,6 +85,10 @@ function* neighbors(pos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function calculatePath(from, to) {
|
function calculatePath(from, to) {
|
||||||
|
if (game.system.id === "pf2e")
|
||||||
|
use5105 = true;
|
||||||
|
if (canvas.grid.diagonalRule === "5105")
|
||||||
|
use5105 = true;
|
||||||
// On 5/10/5 it's possible that we'd need to start on layer 1 if there is a previous route
|
// On 5/10/5 it's possible that we'd need to start on layer 1 if there is a previous route
|
||||||
// However I cannot think of any case where not doing it would lead to a non-optimal path, so I've ommited that
|
// However I cannot think of any case where not doing it would lead to a non-optimal path, so I've ommited that
|
||||||
const nextNodes = [{node: getNode(to), cost: 0, estimated: estimateCost(to, from), previous: null}];
|
const nextNodes = [{node: getNode(to), cost: 0, estimated: estimateCost(to, from), previous: null}];
|
||||||
|
|||||||
Reference in New Issue
Block a user