refactor: item use context
This commit is contained in:
parent
dbd6091acc
commit
10289f4c06
|
@ -34,6 +34,7 @@ export default (latus) => class Item extends decorate(Trait) {
|
|||
|
||||
static dependencies() {
|
||||
return [
|
||||
'Behaved',
|
||||
'Pictured',
|
||||
];
|
||||
}
|
||||
|
@ -71,10 +72,10 @@ export default (latus) => class Item extends decorate(Trait) {
|
|||
return this.entity.image(key);
|
||||
},
|
||||
|
||||
use: (context) => {
|
||||
use: () => {
|
||||
const {cooldown} = this.params;
|
||||
const {Script} = latus.get('%resources');
|
||||
const promises = [Script.loadTickingPromise(this.params.useScript, context)];
|
||||
const promises = [Script.loadTickingPromise(this.params.useScript, this.entity.context)];
|
||||
if (cooldown > 0) {
|
||||
promises.push(new Promise((resolve) => {
|
||||
setTimeout(resolve, 1000 * cooldown);
|
||||
|
|
|
@ -96,10 +96,8 @@ export default () => class Wielder extends decorate(Trait) {
|
|||
return undefined;
|
||||
}
|
||||
// Defer until the item actions are finished.
|
||||
this.#itemPromise = item.use({
|
||||
entity: item,
|
||||
wielder: this.entity,
|
||||
});
|
||||
item.context.wielder = this.entity;
|
||||
this.#itemPromise = item.use();
|
||||
this.#itemPromise.then(() => {
|
||||
this.#itemPromise = undefined;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user