fix: consumption

This commit is contained in:
cha0s 2024-06-24 06:18:58 -05:00
parent b630221f1f
commit f1b6a8b0d8

View File

@ -2,7 +2,6 @@ import Schema from '@/ecs/schema.js';
export default function(Component) {
return class Inventory extends Component {
insertMany(entities) {
for (const [id, {slotChange}] of entities) {
if (slotChange) {
@ -22,7 +21,6 @@ export default function(Component) {
}
return super.insertMany(entities);
}
mergeDiff(original, update) {
if (!update.slotChange) {
return super.mergeDiff(original, update);
@ -57,6 +55,7 @@ export default function(Component) {
target[property] = value;
if ('qty' === property && value <= 0) {
Component.markChange(instance.entity, 'slotChange', {[slot]: false});
delete slots[slot];
}
else {
Component.markChange(instance.entity, 'slotChange', {[slot]: {[property]: value}});