mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-18 16:09:03 +01:00
Merge branch 'main' into feature/death-moves
This commit is contained in:
commit
3447afc213
22 changed files with 265 additions and 85 deletions
|
|
@ -104,6 +104,16 @@ export default class DhpActor extends Actor {
|
|||
}
|
||||
}
|
||||
|
||||
async _preDelete() {
|
||||
if (this.prototypeToken.actorLink) {
|
||||
game.system.registeredTriggers.unregisterItemTriggers(this.items);
|
||||
} else {
|
||||
for (const token of this.getActiveTokens()) {
|
||||
game.system.registeredTriggers.unregisterItemTriggers(token.actor.items);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_onDelete(options, userId) {
|
||||
super._onDelete(options, userId);
|
||||
for (const party of this.parties) {
|
||||
|
|
|
|||
|
|
@ -208,4 +208,23 @@ export default class DHItem extends foundry.documents.Item {
|
|||
|
||||
cls.create(msg);
|
||||
}
|
||||
|
||||
deleteTriggers() {
|
||||
const actions = Array.from(this.system.actions ?? []);
|
||||
if (!actions.length) return;
|
||||
|
||||
const triggerKeys = actions.flatMap(action => action.triggers.map(x => x.trigger));
|
||||
|
||||
game.system.registeredTriggers.unregisterTriggers(triggerKeys, this.uuid);
|
||||
|
||||
if (!(this.actor.parent instanceof game.system.api.documents.DhToken)) {
|
||||
for (const token of this.actor.getActiveTokens()) {
|
||||
game.system.registeredTriggers.unregisterTriggers(triggerKeys, `${token.document.uuid}.${this.uuid}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async _preDelete() {
|
||||
this.deleteTriggers();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -536,4 +536,10 @@ export default class DHToken extends CONFIG.Token.documentClass {
|
|||
};
|
||||
}
|
||||
//#endregion
|
||||
|
||||
async _preDelete() {
|
||||
if (this.actor && !this.actor.prototypeToken?.actorLink) {
|
||||
game.system.registeredTriggers.unregisterItemTriggers(this.actor.items);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue