Skip to content

Commit

Permalink
Update logic.js
Browse files Browse the repository at this point in the history
  • Loading branch information
mclemente committed Aug 7, 2024
1 parent 1e06a54 commit f001e42
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/module/logic.js
Original file line number Diff line number Diff line change
@@ -200,21 +200,14 @@ export function onPreUpdateToken(tokenDocument, updates, options, userId) {

let position = {};
// store the direction in the token data
if (!updates.flags) {
updates.flags = {
[MODULE_ID]: {}
};
} else if (!updates.flags[MODULE_ID]) {
updates.flags[MODULE_ID] = {};
}

let tokenDirection;
const { x, y, rotation } = updates;
const { x: tokenX, y: tokenY } = tokenDocument;

if (rotation !== undefined) {
tokenDirection = rotation + 90;
foundry.utils.mergeObject(updates.flags[MODULE_ID], { direction: tokenDirection });
foundry.utils.setProperty(updates, `flags.${MODULE_ID}.direction`, tokenDirection);
if (!options.animation) {
options.animation = { duration: 1000 / 6 };
} else {
@@ -257,7 +250,8 @@ export function onPreUpdateToken(tokenDocument, updates, options, userId) {
if (tokenDirection > 180) tokenDirection -= 360;
}
}
foundry.utils.mergeObject(updates.flags[MODULE_ID], { direction: tokenDirection, prevPos });
foundry.utils.setProperty(updates, `flags.${MODULE_ID}.direction`, tokenDirection);
foundry.utils.setProperty(updates, `flags.${MODULE_ID}.prevPos`, prevPos);
position = { x: diffX, y: diffY };
}

0 comments on commit f001e42

Please sign in to comment.