Show distance labels for points placed by pathfinding
This commit is contained in:
@@ -166,13 +166,17 @@ export function measure(destination, options={}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove waypoints generated by pathfinding
|
// Remove waypoints generated by pathfinding
|
||||||
|
this.waypoints.filter(waypoint => waypoint.isPathfinding).forEach(_ => this.labels.removeChild(this.labels.children.pop()));
|
||||||
this.waypoints = this.waypoints.filter(waypoint => !waypoint.isPathfinding);
|
this.waypoints = this.waypoints.filter(waypoint => !waypoint.isPathfinding);
|
||||||
|
|
||||||
if (isToken && options.pathfinding) {
|
if (isToken && options.pathfinding) {
|
||||||
let path = findPath(getGridPositionFromPixelsObj(this.waypoints[this.waypoints.length - 1]), getGridPositionFromPixelsObj(destination));
|
let path = findPath(getGridPositionFromPixelsObj(this.waypoints[this.waypoints.length - 1]), getGridPositionFromPixelsObj(destination));
|
||||||
if (path) {
|
if (path) {
|
||||||
path = path.map(point => getCenterFromGridPositionObj(point));
|
path = path.map(point => getCenterFromGridPositionObj(point));
|
||||||
path.forEach(point => point.isPathfinding = true);
|
for (const point of path) {
|
||||||
|
point.isPathfinding = true;
|
||||||
|
this.labels.addChild(new PreciseText("", CONFIG.canvasTextStyle));
|
||||||
|
}
|
||||||
this.waypoints = this.waypoints.concat(path);
|
this.waypoints = this.waypoints.concat(path);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user