fix: clear undefined slots

This commit is contained in:
cha0s 2024-07-24 02:39:25 -05:00
parent a0943c8bbb
commit 49f46b4b00

View File

@ -194,6 +194,12 @@ export default class Inventory extends Component {
const tmp = [$$items[l], slots[l]]; const tmp = [$$items[l], slots[l]];
[$$items[l], slots[l]] = [$$items[r], slots[r]]; [$$items[l], slots[l]] = [$$items[r], slots[r]];
[$$items[r], slots[r]] = tmp; [$$items[r], slots[r]] = tmp;
if (undefined === slots[l]) {
delete slots[l];
}
if (undefined === slots[r]) {
delete slots[r];
}
Component.markChange(this.entity, 'swapped', [[l, r]]); Component.markChange(this.entity, 'swapped', [[l, r]]);
} }
} }