2021-11-04 19:58:37 +00:00
|
|
|
export default class Item {
|
|
|
|
constructor() {
|
|
|
|
this.id = "item";
|
|
|
|
this.name = "An item";
|
|
|
|
this.description = "You see nothing special about this item";
|
|
|
|
this.usable = true;
|
|
|
|
this.takeable = true;
|
|
|
|
this.useCallback = null;
|
|
|
|
this.takeCallback = null;
|
2021-11-04 21:47:09 +00:00
|
|
|
this.dropCallback = null;
|
2021-11-04 19:58:37 +00:00
|
|
|
this.context = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
async onUse() {
|
|
|
|
if (this.useCallback) return this.useCallback(this.context);
|
|
|
|
}
|
|
|
|
|
|
|
|
async onTake() {
|
|
|
|
if (this.takeCallback) return this.takeCallback();
|
|
|
|
}
|
2021-11-04 21:29:05 +00:00
|
|
|
|
|
|
|
addUseCallback(callback) {
|
|
|
|
this.useCallback = callback.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
addTakeCallback(callback) {
|
|
|
|
this.takeCallback = callback.bind(this);
|
|
|
|
}
|
2021-11-04 21:47:09 +00:00
|
|
|
|
|
|
|
addDropCallback(callback) {
|
|
|
|
this.dropCallback = callback.bind(this);
|
|
|
|
}
|
2021-11-04 19:58:37 +00:00
|
|
|
}
|