Don't animate tokens when they are dropped with the alt key being pressed (resolves #3)
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
### New features
|
### New features
|
||||||
- GMs now have an option to reset the movement history for individual tokens in the right click menu of the combat tracker
|
- GMs now have an option to reset the movement history for individual tokens in the right click menu of the combat tracker
|
||||||
|
- When releasing a dragged token while pressing Alt the token will be moved to the target location without an animation
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
- When starting to drag a new token while the previous one is still moving the ruler won't dissappear anymore when the previous token arrives at it's destination.
|
- When starting to drag a new token while the previous one is still moving the ruler won't dissappear anymore when the previous token arrives at it's destination.
|
||||||
|
|||||||
@@ -68,7 +68,9 @@ async function animateTokens(tokens, draggedToken, draggedRays, wasPaused) {
|
|||||||
for (const {token, rays} of tokenAnimationData) {
|
for (const {token, rays} of tokenAnimationData) {
|
||||||
token._noAnimate = true;
|
token._noAnimate = true;
|
||||||
}
|
}
|
||||||
for (let i = 0;i < tokenAnimationData[0].rays.length; i++) {
|
const animate = !game.keyboard.isDown("Alt");
|
||||||
|
const startWaypoint = animate ? 0 : tokenAnimationData[0].rays.length - 1;
|
||||||
|
for (let i = startWaypoint;i < tokenAnimationData[0].rays.length; i++) {
|
||||||
if (!wasPaused && game.paused) break;
|
if (!wasPaused && game.paused) break;
|
||||||
const tokenPaths = tokenAnimationData.map(({token, rays, dx, dy}) => {
|
const tokenPaths = tokenAnimationData.map(({token, rays, dx, dy}) => {
|
||||||
const ray = rays[i];
|
const ray = rays[i];
|
||||||
@@ -79,7 +81,8 @@ async function animateTokens(tokens, draggedToken, draggedRays, wasPaused) {
|
|||||||
const updates = tokenPaths.map(({token, path}) => {
|
const updates = tokenPaths.map(({token, path}) => {
|
||||||
return {x: path.B.x, y: path.B.y, _id: token.id};
|
return {x: path.B.x, y: path.B.y, _id: token.id};
|
||||||
});
|
});
|
||||||
await draggedToken.scene.updateEmbeddedEntity(draggedToken.constructor.embeddedName, updates);
|
await draggedToken.scene.updateEmbeddedEntity(draggedToken.constructor.embeddedName, updates, {animate});
|
||||||
|
if (animate)
|
||||||
await Promise.all(tokenPaths.map(({token, path}) => token.animateMovement(path)));
|
await Promise.all(tokenPaths.map(({token, path}) => token.animateMovement(path)));
|
||||||
}
|
}
|
||||||
for (const {token} of tokenAnimationData) {
|
for (const {token} of tokenAnimationData) {
|
||||||
|
|||||||
Reference in New Issue
Block a user