mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 15:39:02 +01:00
Active effects are shown on the token
This commit is contained in:
parent
1536098f1e
commit
f33dc8c4af
3 changed files with 38 additions and 0 deletions
|
|
@ -136,6 +136,7 @@ Hooks.once('init', () => {
|
||||||
|
|
||||||
CONFIG.Canvas.rulerClass = placeables.DhRuler;
|
CONFIG.Canvas.rulerClass = placeables.DhRuler;
|
||||||
CONFIG.Canvas.layers.templates.layerClass = placeables.DhTemplateLayer;
|
CONFIG.Canvas.layers.templates.layerClass = placeables.DhTemplateLayer;
|
||||||
|
CONFIG.Token.objectClass = placeables.DhTokenPlaceable;
|
||||||
CONFIG.Combat.documentClass = documents.DhpCombat;
|
CONFIG.Combat.documentClass = documents.DhpCombat;
|
||||||
CONFIG.ui.combat = applications.ui.DhCombatTracker;
|
CONFIG.ui.combat = applications.ui.DhCombatTracker;
|
||||||
CONFIG.ui.chat = applications.ui.DhChatLog;
|
CONFIG.ui.chat = applications.ui.DhChatLog;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
export { default as DhMeasuredTemplate } from './measuredTemplate.mjs';
|
export { default as DhMeasuredTemplate } from './measuredTemplate.mjs';
|
||||||
export { default as DhRuler } from './ruler.mjs';
|
export { default as DhRuler } from './ruler.mjs';
|
||||||
export { default as DhTemplateLayer } from './templateLayer.mjs';
|
export { default as DhTemplateLayer } from './templateLayer.mjs';
|
||||||
|
export { default as DhTokenPlaceable } from './token.mjs';
|
||||||
export { default as DhTokenRuler } from './tokenRuler.mjs';
|
export { default as DhTokenRuler } from './tokenRuler.mjs';
|
||||||
|
|
|
||||||
36
module/canvas/placeables/token.mjs
Normal file
36
module/canvas/placeables/token.mjs
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
export default class DhTokenPlaceable extends foundry.canvas.placeables.Token {
|
||||||
|
/** @inheritDoc */
|
||||||
|
async _drawEffects() {
|
||||||
|
this.effects.renderable = false;
|
||||||
|
|
||||||
|
// Clear Effects Container
|
||||||
|
this.effects.removeChildren().forEach(c => c.destroy());
|
||||||
|
this.effects.bg = this.effects.addChild(new PIXI.Graphics());
|
||||||
|
this.effects.bg.zIndex = -1;
|
||||||
|
this.effects.overlay = null;
|
||||||
|
|
||||||
|
// Categorize effects
|
||||||
|
const activeEffects = Array.from(this.actor.effects);
|
||||||
|
const overlayEffect = activeEffects.findLast(e => e.img && e.getFlag('core', 'overlay'));
|
||||||
|
|
||||||
|
// Draw effects
|
||||||
|
const promises = [];
|
||||||
|
for (const [i, effect] of activeEffects.entries()) {
|
||||||
|
if (!effect.img) continue;
|
||||||
|
const promise =
|
||||||
|
effect === overlayEffect
|
||||||
|
? this._drawOverlay(effect.img, effect.tint)
|
||||||
|
: this._drawEffect(effect.img, effect.tint);
|
||||||
|
promises.push(
|
||||||
|
promise.then(e => {
|
||||||
|
if (e) e.zIndex = i;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
await Promise.allSettled(promises);
|
||||||
|
|
||||||
|
this.effects.sortChildren();
|
||||||
|
this.effects.renderable = true;
|
||||||
|
this.renderFlags.set({ refreshEffects: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue