Skip to content

Commit

Permalink
added feature to change item inventory color
Browse files Browse the repository at this point in the history
  • Loading branch information
VietnamNeko committed Jan 26, 2022
1 parent 4ed806c commit 306dfa7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/gameClasses/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,12 @@ var Item = IgeEntityBox2d.extend({
ige.itemUi.updateItemSlot(this, this._stats.slotIndex);
}
break;
case 'inventoryColor':
var owner = self.getOwnerUnit();
if (ige.isClient && ige.client.selectedUnit == owner) {
owner.inventory.update()
}
break;
case 'slotIndex':
var owner = self.getOwnerUnit();
if (ige.isClient && owner) {
Expand Down
5 changes: 5 additions & 0 deletions src/gameClasses/components/InventoryComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,11 @@ var InventoryComponent = IgeEntity.extend({
// item.setState('unselected');
// }
// }
if (item && item._stats && item._stats.inventoryColor) {
$(`#item-${slotIndex}`).css('background-image', 'radial-gradient(rgba(0, 0, 0, 0),' + item._stats.inventoryColor + ')')
} else {
$(`#item-${slotIndex}`).css('background-image', 'none')
}
ige.itemUi.updateItemSlot(item, slotIndex);

// highlight currently selected inventory item (using currentItemIndex)
Expand Down
8 changes: 8 additions & 0 deletions src/gameClasses/components/script/ActionComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,14 @@ var ActionComponent = IgeEntity.extend({
}
break;

case 'changeItemInventoryColor':
var item = ige.variable.getValue(action.item, vars);
var color = ige.variable.getValue(action.string, vars);
if (item && color) {
item.streamUpdateData([{ inventoryColor: color }]);
}
break;

case 'setItemAmmo':
var item = ige.variable.getValue(action.item, vars);
var newAmmo = ige.variable.getValue(action.ammo, vars);
Expand Down

0 comments on commit 306dfa7

Please sign in to comment.