Merge branch 'develop' into pathfinding

This commit is contained in:
Manuel Vögele
2022-02-09 11:00:08 +01:00
7 changed files with 42 additions and 3 deletions
+1 -1
View File
@@ -91,7 +91,7 @@ async function animateEntities(entities, draggedEntity, draggedRays, wasPaused)
});
await draggedEntity.scene.updateEmbeddedDocuments(draggedEntity.constructor.embeddedName, updates, {animate});
if (animate)
await Promise.all(entityPaths.map(({entity, path}) => entity.animateMovement(path)));
await Promise.all(entityPaths.map(({entity}) => CanvasAnimation.getAnimation(entity.movementAnimationName)?.promise));
// This is a flag of the "Monk's Active Tile Triggers" module that signals that the movement should be cancelled early
if (this.cancelMovement) {
+2
View File
@@ -107,6 +107,7 @@ function handleDisableSnap(event) {
return false;
ruler.measure(getMeasurePosition(), {snap: !disableSnap});
ruler.dragRulerSendState();
return false;
}
@@ -124,5 +125,6 @@ function handleTogglePathfinding(event) {
return false;
ruler.measure(getMeasurePosition(), {snap: !disableSnap});
ruler.dragRulerSendState();
return false;
}
+5
View File
@@ -101,6 +101,7 @@ async function tokenLayerUndoHistory(wrapped) {
function onEntityLeftDragStart(wrapped, event) {
wrapped(event);
console.warn("start", Date.now());
const isToken = this instanceof Token;
const ruler = canvas.controls.ruler
ruler.draggedEntity = this;
@@ -131,6 +132,7 @@ function onEntityLeftDragMove(wrapped, event) {
function onEntityDragLeftDrop(event) {
const ruler = canvas.controls.ruler
console.warn("stop", ruler._state, Date.now());
if (!ruler.isDragRuler) {
ruler.draggedEntity = undefined;
return false
@@ -141,6 +143,9 @@ function onEntityDragLeftDrop(event) {
// This can happen if the user presses ESC during drag (maybe there are other ways too)
if (selectedTokens.length === 0)
selectedTokens.push(ruler.draggedEntity);
// This can happen if the ruler is being dragged so rapidly that the drag move handler hasn't been called before dropping
if (ruler._state === Ruler.STATES.STARTING)
onMouseMove.call(ruler, event);
ruler._state = Ruler.STATES.MOVING
moveEntities.call(ruler, ruler.draggedEntity, selectedTokens);
return true
+9
View File
@@ -61,6 +61,9 @@ export function extendRuler() {
measure(destination, options={}) {
if (this.isDragRuler) {
// If this is the ruler of a remote user take the waypoints as they were transmitted and don't apply any additional snapping to them
if (this.user !== game.user)
options.snap = false;
return measure.call(this, destination, options);
}
else {
@@ -199,6 +202,12 @@ export function extendRuler() {
if (measureImmediately)
ruler.measure(destination, options);
}
dragRulerSendState() {
game.user.broadcastActivity({
ruler: this.toJSON()
});
}
}
Ruler = DragRulerRuler;