fix: slots change and mark
This commit is contained in:
parent
41d447a6a3
commit
b21ef309aa
|
@ -101,13 +101,13 @@ class ItemProxy {
|
|||
set qty(qty) {
|
||||
const {instance} = this;
|
||||
if (qty <= 0) {
|
||||
Component.markChange(instance.entity, 'cleared', {[this.slot]: true});
|
||||
this.Component.markChange(instance.entity, 'cleared', {[this.slot]: true});
|
||||
delete instance.slots[this.slot];
|
||||
delete instance.$$items[this.slot];
|
||||
}
|
||||
else {
|
||||
instance.slots[this.slot].qty = qty;
|
||||
Component.markChange(instance.entity, 'qtyUpdated', {[this.slot]: qty});
|
||||
this.Component.markChange(instance.entity, 'qtyUpdated', {[this.slot]: qty});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -148,7 +148,17 @@ export default class Inventory extends Component {
|
|||
}
|
||||
}
|
||||
}
|
||||
return super.insertMany(entities);
|
||||
await super.insertMany(entities);
|
||||
for (const [id, {slots}] of entities) {
|
||||
if (slots) {
|
||||
const instance = this.get(id);
|
||||
instance.$$items = {};
|
||||
for (const slot in slots) {
|
||||
instance.$$items[slot] = new ItemProxy(this, instance, slot);
|
||||
await instance.$$items[slot].load(instance.slots[slot].source);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
instanceFromSchema() {
|
||||
const Instance = super.instanceFromSchema();
|
||||
|
|
Loading…
Reference in New Issue
Block a user