mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-08 06:56:12 +01:00
Fixed collection prep order
This commit is contained in:
parent
6f6ee41f0f
commit
bd5ef8e8d7
4 changed files with 36 additions and 5 deletions
|
|
@ -727,6 +727,19 @@ export default class DhCharacter extends BaseDataActor {
|
|||
}
|
||||
}
|
||||
|
||||
_onUpdate(changes, options, userId) {
|
||||
super._onUpdate(changes, options, userId);
|
||||
|
||||
if (game.user.id === userId) {
|
||||
/* Companion updates */
|
||||
if (this.companion) {
|
||||
if (changes.system.levelData?.level?.current !== undefined) {
|
||||
this.companion.update(this.companion.toObject(), { diff: false, recursive: false });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async _preDelete() {
|
||||
super._preDelete();
|
||||
|
||||
|
|
|
|||
1
module/documents/collections/_module.mjs
Normal file
1
module/documents/collections/_module.mjs
Normal file
|
|
@ -0,0 +1 @@
|
|||
export { default as DhActorCollection } from './actorCollection.mjs';
|
||||
14
module/documents/collections/actorCollection.mjs
Normal file
14
module/documents/collections/actorCollection.mjs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
export default class DhActorCollection extends foundry.documents.collections.Actors {
|
||||
/** Ensure companions are initialized after all other subtypes. */
|
||||
_initialize() {
|
||||
super._initialize();
|
||||
const companions = [];
|
||||
for (const actor of this.values()) {
|
||||
if (actor.type === 'companion') companions.push(actor);
|
||||
}
|
||||
for (const actor of companions) {
|
||||
this.delete(actor.id);
|
||||
this.set(actor.id, actor);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue