Merge branch 'develop' into pathfinding-difficult-terrain
This commit is contained in:
@@ -175,7 +175,9 @@ export function measure(destination, options={}) {
|
|||||||
const from = getGridPositionFromPixelsObj(this.waypoints[this.waypoints.length - 1]);
|
const from = getGridPositionFromPixelsObj(this.waypoints[this.waypoints.length - 1]);
|
||||||
const to = getGridPositionFromPixelsObj(destination);
|
const to = getGridPositionFromPixelsObj(destination);
|
||||||
let path = findPath(from, to, this.draggedEntity, this.waypoints);
|
let path = findPath(from, to, this.draggedEntity, this.waypoints);
|
||||||
if (path) {
|
if (path)
|
||||||
|
path.shift();
|
||||||
|
if (path && path.length > 0) {
|
||||||
path = path.map(point => getSnapPointForTokenObj(getPixelsFromGridPositionObj(point), this.draggedEntity));
|
path = path.map(point => getSnapPointForTokenObj(getPixelsFromGridPositionObj(point), this.draggedEntity));
|
||||||
|
|
||||||
// If the token is snapped to the grid, the first point of the path is already handled by the ruler
|
// If the token is snapped to the grid, the first point of the path is already handled by the ruler
|
||||||
|
|||||||
+11
-7
@@ -252,7 +252,8 @@ export function findPath(from, to, token, previousWaypoints) {
|
|||||||
let tokenSize = Math.max(token.data.width, token.data.height) * canvas.dimensions.size;
|
let tokenSize = Math.max(token.data.width, token.data.height) * canvas.dimensions.size;
|
||||||
let pathfinder = gridlessPathfinders.get(tokenSize);
|
let pathfinder = gridlessPathfinders.get(tokenSize);
|
||||||
if (!pathfinder) {
|
if (!pathfinder) {
|
||||||
pathfinder = GridlessPathfinding.initialize(canvas.walls.placeables, tokenSize, token.data.elevation, Boolean(game.modules.get("wall-height")?.active));
|
let radiusMultiplier = game.settings.get(settingsKey, "pathfindingRadius");
|
||||||
|
pathfinder = GridlessPathfinding.initialize(canvas.walls.placeables, tokenSize * radiusMultiplier, token.data.elevation, Boolean(game.modules.get("wall-height")?.active));
|
||||||
gridlessPathfinders.set(tokenSize, pathfinder);
|
gridlessPathfinders.set(tokenSize, pathfinder);
|
||||||
}
|
}
|
||||||
paintGridlessPathfindingDebug(pathfinder);
|
paintGridlessPathfindingDebug(pathfinder);
|
||||||
@@ -307,12 +308,12 @@ function buildTokenData(token) {
|
|||||||
// Almost all the information we need is for calculating the snap point
|
// Almost all the information we need is for calculating the snap point
|
||||||
const tokenData = buildSnapPointTokenData(token);
|
const tokenData = buildSnapPointTokenData(token);
|
||||||
|
|
||||||
// If levels is enabled, which walls matter depends on the token's elevation.
|
// If Wall Height is enabled, which walls matter depends on the token's elevation.
|
||||||
// Depending on the settings in levels, the height we care about is either their
|
// Depending on the settings in Wall Height, the height we care about is either their
|
||||||
// Foot height (elevation) or eye height (losHeight).
|
// foot height (elevation) or eye height (losHeight).
|
||||||
if (isModuleActive("levels")) {
|
if (isModuleActive("wall-height")) {
|
||||||
const blockSightMovement = game.settings.get(_levelsModuleName, "blockSightMovement");
|
const blockSightMovement = game.settings.get("wall-height", "blockSightMovement");
|
||||||
tokenData.elevation = blockSightMovement ? token.data.elevation : token.losHeight;
|
tokenData.elevation = blockSightMovement ? token.losHeight : token.data.elevation;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tokenData;
|
return tokenData;
|
||||||
@@ -465,6 +466,9 @@ export function initializePathfinding() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function startBackgroundCaching(token) {
|
export function startBackgroundCaching(token) {
|
||||||
|
// Background caching isn't yet supported for gridless scenes
|
||||||
|
if (canvas.grid.type === CONST.GRID_TYPES.GRIDLESS)
|
||||||
|
return;
|
||||||
if (game.user.isGM || game.settings.get(settingsKey, "allowPathfinding")) {
|
if (game.user.isGM || game.settings.get(settingsKey, "allowPathfinding")) {
|
||||||
cache.startBackgroundCaching(token);
|
cache.startBackgroundCaching(token);
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-2
@@ -1,5 +1,6 @@
|
|||||||
import {availableSpeedProviders, currentSpeedProvider, getDefaultSpeedProvider, updateSpeedProvider} from "./api.js";
|
import {availableSpeedProviders, currentSpeedProvider, getDefaultSpeedProvider, updateSpeedProvider} from "./api.js";
|
||||||
import {SpeedProvider} from "./speed_provider.js"
|
import {SpeedProvider} from "./speed_provider.js"
|
||||||
|
import {wipePathfindingCache} from "./pathfinding.js"
|
||||||
import { early_isGM } from "./util.js";
|
import { early_isGM } from "./util.js";
|
||||||
|
|
||||||
export const settingsKey = "drag-ruler";
|
export const settingsKey = "drag-ruler";
|
||||||
@@ -100,10 +101,18 @@ export function registerSettings() {
|
|||||||
game.settings.register(settingsKey, "autoPathfinding", {
|
game.settings.register(settingsKey, "autoPathfinding", {
|
||||||
name: "drag-ruler.settings.autoPathfinding.name",
|
name: "drag-ruler.settings.autoPathfinding.name",
|
||||||
hint: "drag-ruler.settings.autoPathfinding.hint",
|
hint: "drag-ruler.settings.autoPathfinding.hint",
|
||||||
scpoe: "client",
|
scope: "client",
|
||||||
config: early_isGM() || game.settings.get(settingsKey, "allowPathfinding"),
|
config: early_isGM() || game.settings.get(settingsKey, "allowPathfinding"),
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
defualt: false,
|
default: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
game.settings.register(settingsKey, "pathfindingRadius", {
|
||||||
|
scope: "world",
|
||||||
|
config: false,
|
||||||
|
type: Number,
|
||||||
|
default: 0.9,
|
||||||
|
onChange: wipePathfindingCache,
|
||||||
});
|
});
|
||||||
|
|
||||||
game.settings.register(settingsKey, "lastTerrainRulerHintTime", {
|
game.settings.register(settingsKey, "lastTerrainRulerHintTime", {
|
||||||
|
|||||||
Reference in New Issue
Block a user