Improve Pathfinding: Add background caching (#175)
This commit is contained in:
+16
-1
@@ -7,7 +7,7 @@ import {disableSnap, registerKeybindings} from "./keybindings.js";
|
||||
import {libWrapper} from "./libwrapper_shim.js";
|
||||
import {performMigrations} from "./migration.js"
|
||||
import {removeLastHistoryEntryIfAt, resetMovementHistory} from "./movement_tracking.js";
|
||||
import {wipePathfindingCache, initializePathfinding} from "./pathfinding.js";
|
||||
import {wipePathfindingCache, initializePathfinding, startBackgroundCaching} from "./pathfinding.js";
|
||||
import {extendRuler} from "./ruler.js";
|
||||
import {registerSettings, RightClickAction, settingsKey} from "./settings.js"
|
||||
import {recalculate} from "./socket.js";
|
||||
@@ -28,6 +28,21 @@ initGridlessPathfinding().then(() => {
|
||||
Hooks.on("createWall", wipePathfindingCache);
|
||||
Hooks.on("updateWall", wipePathfindingCache);
|
||||
Hooks.on("deleteWall", wipePathfindingCache);
|
||||
|
||||
// Whenever the current user selects a token, start caching
|
||||
Hooks.on("controlToken", (token, controlled) => {
|
||||
if (controlled) {
|
||||
startBackgroundCaching(token);
|
||||
}
|
||||
});
|
||||
|
||||
// Whenever a token the current user controls updates, start caching
|
||||
Hooks.on("updateToken", (document) => {
|
||||
const token = document.object;
|
||||
if (token._controlled) {
|
||||
startBackgroundCaching(token);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Hooks.once("init", () => {
|
||||
|
||||
Reference in New Issue
Block a user