Add game.actors.party and refine logic

This commit is contained in:
Carlos Fernandez 2026-04-15 18:29:17 -04:00
parent b08b8b93b6
commit 031f497c33
5 changed files with 22 additions and 18 deletions

View file

@ -117,7 +117,9 @@ export default class DhpActor extends Actor {
}
}
async _preDelete() {
async _preDelete(options, user) {
if ((await super._preDelete(options, user)) === false) return false;
if (this.prototypeToken.actorLink) {
game.system.registeredTriggers.unregisterItemTriggers(this.items);
} else {
@ -125,8 +127,6 @@ export default class DhpActor extends Actor {
game.system.registeredTriggers.unregisterItemTriggers(token.actor.items);
}
}
if(this.system._preDelete() === false) return false;
}
_onDelete(options, userId) {

View file

@ -1,4 +1,11 @@
export default class DhActorCollection extends foundry.documents.collections.Actors {
/** @returns the active party */
get party() {
const id = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.ActiveParty);
const actor = game.actors.get(id);
return actor?.type === "party" ? actor : null;
}
/** Ensure companions are initialized after all other subtypes. */
_initialize() {
super._initialize();