Add setting to forbid the usage of pathfinding

This commit is contained in:
Manuel Vögele
2022-01-27 23:29:08 +01:00
parent 7e19fb95b0
commit 9140ef3acf
5 changed files with 26 additions and 2 deletions
+4
View File
@@ -43,6 +43,10 @@
}
},
"settings": {
"allowPathfinding": {
"name": "Wegfindung aktivieren",
"hint": "Aktiviert Drag Ruler's Wegfindungsfunktion. Bitte beachte, dass die Wegfindung Wege durch unerkundeten Nebel des Kriegs und Ätherische Wände berechnen kann. Dies kann deinen Spielern Geheimnisse lüften, von denen sie noch nicht erfahren sollten."
},
"alwaysShowSpeedForPCs": {
"name": "Geschwindigkeit von Spielercharakteren für jeden anzeigen",
"hint": "Wenn diese Einstellung aktiviert ist wird die Färbung der hervorgehobenen Felder bei Spielercharakteren allen Spielern angezeigt, selbst wenn diese keinen Zugriff auf den Charakterbogen haben."
+4
View File
@@ -43,6 +43,10 @@
}
},
"settings": {
"allowPathfinding": {
"name": "Enable pathfinding feature",
"hint": "Enables Drag Ruler's pathfinding functionality in this world. Be aware that pathfinding can route through unexplored fog of war and Ethereal Walls, which might reveal secrets to your players ahead of time."
},
"alwaysShowSpeedForPCs": {
"name": "Show PC speed to everyone",
"hint": "If enabled the coloring based on actor speed for player characters will shown to everyone, even if they don't have observer permission for the character sheet."
+2 -2
View File
@@ -3,7 +3,7 @@ import {getCenterFromGridPositionObj, getGridPositionFromPixels, getGridPosition
import {Line} from "./geometry.js";
import {disableSnap, moveWithoutAnimation} from "./keybindings.js";
import {trackRays} from "./movement_tracking.js"
import {find_path} from "./pathfinding.js";
import {find_path, is_pathfinding_enabled} from "./pathfinding.js";
import {settingsKey} from "./settings.js";
import {recalculate} from "./socket.js";
import {applyTokenSizeOffset, enumeratedZip, getSnapPointForEntity, getSnapPointForToken, getTokenShape, highlightTokenShape, sum} from "./util.js";
@@ -133,7 +133,7 @@ function scheduleMeasurement(destination, event) {
const mt = event._measureTime || 0;
const originalEvent = event.data.originalEvent;
if (Date.now() - mt > measurementInterval) {
this.measure(destination, {snap: !disableSnap, pathfinding: game.settings.get(settingsKey, "autoPathfinding") != game.keyboard.isDown("y")});
this.measure(destination, {snap: !disableSnap, pathfinding: is_pathfinding_enabled()});
event._measureTime = Date.now();
this._state = Ruler.STATES.MEASURING;
cancelScheduledMeasurement.call(this);
+7
View File
@@ -1,8 +1,15 @@
import {getCenterFromGridPositionObj} from "./foundry_fixes.js";
import {settingsKey} from "./settings.js";
// TODO Wipe cache if walls layer is being modified
let cached_nodes = undefined;
export function is_pathfinding_enabled() {
if (!game.settings.get(settingsKey, "allowPathfinding"))
return false;
return game.settings.get(settingsKey, "autoPathfinding") != game.keyboard.isDown("y")
}
function get_node(pos, initialize=true) {
if (!cached_nodes)
// TODO Check if ceil is the right thing to do here
+9
View File
@@ -82,6 +82,15 @@ export function registerSettings() {
default: true,
});
game.settings.register(settingsKey, "allowPathfinding", {
name: "drag-ruler.settings.allowPathfinding.name",
hint: "drag-ruler.settings.allowPathfinding.hint",
scope: "world",
config: true,
type: Boolean,
default: false,
});
game.settings.register(settingsKey, "autoPathfinding", {
name: "drag-ruler.settings.autoPathfinding.name",
hint: "drag-ruler.settings.autoPathfinding.hint",