diff --git a/packages/core/src/traits/item.js b/packages/core/src/traits/item.js index d5df552..c3d3bd3 100644 --- a/packages/core/src/traits/item.js +++ b/packages/core/src/traits/item.js @@ -1,6 +1,5 @@ import {Actions, buildInvoke, compile} from '@avocado/behavior'; import {Property} from '@avocado/core'; -import {Image} from '@avocado/graphics'; import {StateProperty, Trait} from '@avocado/traits'; import {compose} from '@latus/core'; @@ -18,11 +17,6 @@ const decorate = compose( export default (latus) => class Item extends decorate(Trait) { - constructor() { - super(); - this._slotImageUris = {}; - } - static defaultParams() { return { cooldown: 0, @@ -31,7 +25,7 @@ export default (latus) => class Item extends decorate(Trait) { expressions: [], }, slotImageUris: { - default: '/question-mark.png', + default: 'default', }, }; } @@ -42,6 +36,12 @@ export default (latus) => class Item extends decorate(Trait) { }; } + static dependencies() { + return [ + 'Pictured', + ]; + } + static children() { return { decrementQuantity: { @@ -69,13 +69,6 @@ export default (latus) => class Item extends decorate(Trait) { await super.load(json); const itemActions = this._processedItemActions(); this._itemActions = new Actions(compile(itemActions, latus)); - if ('client' === process.env.SIDE) { - await Promise.all(Object.entries(this.params.slotImageUris) - .map(async ([slotIndex, uri]) => { - const image = await Image.load(uri); - this._slotImageUris[slotIndex] = image; - })); - } } methods() { @@ -86,8 +79,10 @@ export default (latus) => class Item extends decorate(Trait) { }, imageForSlot: () => { + const {slotImageUris} = this.params; const {qty} = this.entity; - return this._slotImageUris[this._slotImageUris[qty] ? qty : 'default']; + const key = slotImageUris[slotImageUris[qty] ? qty : 'default']; + return this.entity.image(key); }, };