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

View File

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

View File

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

View File

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

View File

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

View File

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