Skip to content

Commit

Permalink
Fixes and Changes:
Browse files Browse the repository at this point in the history
Fixed Secondary and Target animations failing when using the Side Impact option

Changed Hooks.callAll("AutomatedAnimations-WorkflowStart", data); to also allow passing recheckAnimation. This is useful if you wish to change the item being processed before continuing the workflow. If this is used, it will fall back to the original item animation data if none is matched.
  • Loading branch information
otigon committed Feb 4, 2023
1 parent a495f50 commit 5cde085
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/system-handlers/commonSequences.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function secondaryEffect(secondary, seq, targetArray, targetEnabled = fal
thisSeq.delay(options.delay)
}
if (options.rotateSource) {
thisSeq.rotateTowards(sourceToken)
thisSeq.rotateTowards(handler.sourceToken)
thisSeq.rotate(180)
}
if (options.isMasked) {
Expand Down Expand Up @@ -113,7 +113,7 @@ export function targetEffect(targetFX, seq, targetArray, missable = false, handl
thisSeq.atLocation(missable ? `spot ${currentTarget.id}` : currentTarget)
}
if (options.rotateSource) {
thisSeq.rotateTowards(sourceToken)
thisSeq.rotateTowards(handler.sourceToken)
thisSeq.rotate(180)
}
if (options.isMasked) {
Expand Down
44 changes: 34 additions & 10 deletions src/system-handlers/workflow-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,46 @@ export default class AAHandler {
custom_notify("Animations are Disabled from the Automated Animations Settings", true);
return false;
}
const animationData = await handleItem(data);
if (!animationData) {
debug(`No Animation matched for Item`, data )
return false;
}
Hooks.callAll("AutomatedAnimations-WorkflowStart", data);
if (data.stopWorkflow) {
debug(`Animation Workflow was interrupted by an External Source`, data )
// Deep Clones the data sent by the system prep
let clonedData = foundry.utils.deepClone(data);

// Checks the item for any animation data on the item itself, or in the global menu
let animationData = await handleItem(clonedData);

// Hook to signify the start of the A-A workflow;
Hooks.callAll("AutomatedAnimations-WorkflowStart", clonedData, animationData);

// Can be added from the above Hook to stop the A-A workflow
if (clonedData.stopWorkflow) {
debug(`Animation Workflow was interrupted by an External Source`, clonedData )
return;
}
return new AAHandler({...data, animationData});

// recheckAnimation can be passed as a Boolean to let A-A know it needs to recheck for Animations.
// Useful for changing out the Item to be processed mid-stream
let newAnimationData;
if (clonedData.recheckAnimation) {
newAnimationData = await handleItem(clonedData);
// If no Animation data is found for the newly passed Item, resets to the Original Item
if (!newAnimationData) {
clonedData.item = data.item
}
}

// If no Animation data is matched, returns False and stops workflow
if (!animationData && !newAnimationData) {
debug(`No Animation matched for Item`, clonedData )
return false;
}

// Determines the animation data to be used, either original or new.
let finalAnimationData = newAnimationData ? newAnimationData : animationData
return new AAHandler({...clonedData, finalAnimationData});
}
constructor (data) {
debug("Compiling Automated Animations data");

this.animationData = data.animationData;
this.animationData = data.finalAnimationData;

this.isActiveEffect = data.activeEffect ?? false;

Expand Down

0 comments on commit 5cde085

Please sign in to comment.