2024-06-25 05:46:03 -05:00
|
|
|
import Schema from '@/ecs/schema.js';
|
|
|
|
|
|
|
|
export default function(Component) {
|
|
|
|
return class Wielder extends Component {
|
|
|
|
instanceFromSchema() {
|
|
|
|
const Instance = super.instanceFromSchema();
|
|
|
|
const Component = this;
|
|
|
|
Instance.prototype.activeItem = async function () {
|
|
|
|
const {Inventory, Wielder} = Component.ecs.get(this.entity);
|
|
|
|
return Inventory.item(Wielder.activeSlot + 1);
|
|
|
|
};
|
|
|
|
return Instance;
|
|
|
|
}
|
|
|
|
static schema = new Schema({
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
activeSlot: {type: 'uint16'},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|