Updated so that we grab all tokens on the scene regardless of level with the clowncar

This commit is contained in:
WBHarry 2026-04-11 19:34:25 +02:00
parent 338a78250b
commit 92d91ed3e0

View file

@ -122,15 +122,14 @@ export default class DHTokenHUD extends foundry.applications.hud.TokenHUD {
async toggleClowncar(actors) {
const animationDuration = 500;
const activeTokens = actors.flatMap(member => member.getActiveTokens());
const scene = game.scenes.get(game.user.viewedScene);
/* getDependentTokens returns already removed tokens with id = null. Need to filter that until it's potentially fixed from Foundry */
const activeTokens = actors.flatMap(member => member.getDependentTokens({ scenes: scene }).filter(x => x._id));
const { x: actorX, y: actorY } = this.document;
if (activeTokens.length > 0) {
for (let token of activeTokens) {
await token.document.update(
{ x: actorX, y: actorY, alpha: 0 },
{ animation: { duration: animationDuration } }
);
setTimeout(() => token.document.delete(), animationDuration);
await token.update({ x: actorX, y: actorY, alpha: 0 }, { animation: { duration: animationDuration } });
setTimeout(() => token.delete(), animationDuration);
}
} else {
const activeScene = game.scenes.find(x => x.id === game.user.viewedScene);