/// <summary> /// Uses the item contained in given slot. /// </summary> /// <param name="slot">Slot to use item from.</param> public void UseItem(InventorySlot slot) { int index = findIndexOf(slot.Content); switch (slot.Content.Type) { case ItemType.Consumable: //Consumable items are always stackable, remove one and update the UIText. if (inventory[index].stackSize > 1) { inventory[index].stackSize--; slot.UpdateItemQuantity(); } else { RemoveItemAt(index); } break; //Fall-through - all equipable items are treated similarly. case ItemType.Weapon: case ItemType.Neck: case ItemType.Offhand: case ItemType.Ring: case ItemType.Armor: //Remove from inventory and add to equipment RemoveItemAt(index); if (eUI != null) { eUI.EquipRightClick(slot.Content); } else { bearer.Equip(slot.Content); } break; default: break; } UI.UpdateItems(inventory); }