private void UseItem() { Item item = data.inventory.content[data.currentItem].item; if (item is Weapon) { data.player.EquipWeapon((Weapon)item); } if (item is Armor) { data.player.EquipArmor((Armor)item); } if (item is Throwable) { Throwable t = (Throwable)item; data.inventory.content[data.currentItem].count -= 1; // == 0 for potential abuse with items that have a count of < 0 to allow easier unlimited use items bool temp = t.Use(); if (data.inventory.content[data.currentItem].count == 0 && temp) { data.inventory.content.RemoveAt(data.currentItem); data.currentItem = -1; } data.player.actions--; QuitInventory(); } if (item is Usable) { Usable u = (Usable)item; data.inventory.content[data.currentItem].count -= 1; // == 0 for potential abuse with items that have a count of < 0 to allow easier unlimited use items if (data.inventory.content[data.currentItem].count == 0) { data.inventory.content.RemoveAt(data.currentItem); data.currentItem = -1; } u.Use(); data.player.actions--; QuitInventory(); } }