chore: tidy

This commit is contained in:
cha0s 2019-10-07 03:12:41 -05:00
parent 1d093253e4
commit 0305106ce5
6 changed files with 16 additions and 14 deletions

View File

@ -24,7 +24,7 @@ export class Item extends decorate(Trait) {
type: 'actions', type: 'actions',
traversals: [], traversals: [],
}, },
slotImages: { slotImageUris: {
default: '/question-mark.png', default: '/question-mark.png',
}, },
}; };
@ -44,16 +44,18 @@ export class Item extends decorate(Trait) {
super(entity, params, state); super(entity, params, state);
const itemActions = this._processedItemActions(); const itemActions = this._processedItemActions();
this._itemActions = behaviorItemFromJSON(itemActions); this._itemActions = behaviorItemFromJSON(itemActions);
this._slotImages = {}; this._slotImageUris = {};
} }
hydrate() { hydrate() {
if (AVOCADO_CLIENT) { if (AVOCADO_CLIENT) {
const promises = []; const promises = [];
for (const index in this.params.slotImages) { for (const index in this.params.slotImageUris) {
promises.push(Image.load(this.params.slotImages[index]).then((image) => { const imageUri = this.params.slotImageUris[index];
this._slotImages[index] = image; const promise = Image.load(imageUri).then((image) => {
})); this._slotImageUris[index] = image;
});
promises.push(promise);
} }
return Promise.all(promises); return Promise.all(promises);
} }
@ -102,11 +104,11 @@ export class Item extends decorate(Trait) {
imageForSlot: () => { imageForSlot: () => {
const qty = this.entity.qty; const qty = this.entity.qty;
if (this._slotImages[qty]) { if (this._slotImageUris[qty]) {
return this._slotImages[qty]; return this._slotImageUris[qty];
} }
else { else {
return this._slotImages['default']; return this._slotImageUris['default'];
} }
}, },

View File

@ -21,7 +21,7 @@ export function hoeJSON() {
buildInvoke(['item', 'useTool']), buildInvoke(['item', 'useTool']),
], ],
}, },
slotImages: { slotImageUris: {
default: '/hoe.png', default: '/hoe.png',
}, },
}, },

View File

@ -38,7 +38,7 @@ export function potionJSON() {
decrement, decrement,
], ],
}, },
slotImages: { slotImageUris: {
default: '/potion.png', default: '/potion.png',
}, },
}, },

View File

@ -51,7 +51,7 @@ export function rockJSON() {
setProjectileBehaving, setProjectileBehaving,
], ],
}, },
slotImages: { slotImageUris: {
default: '/rock.png', default: '/rock.png',
}, },
}, },

View File

@ -20,7 +20,7 @@ export function tomatoSeedsJSON() {
buildInvoke(['item', 'useTool']), buildInvoke(['item', 'useTool']),
], ],
}, },
slotImages: { slotImageUris: {
default: '/seeds.png', default: '/seeds.png',
}, },
}, },

View File

@ -21,7 +21,7 @@ export function wateringCanJSON() {
buildInvoke(['item', 'useTool']), buildInvoke(['item', 'useTool']),
], ],
}, },
slotImages: { slotImageUris: {
default: '/watering-can.png', default: '/watering-can.png',
}, },
}, },