public void OnUseItem() { if (item is EquippableItem) { playerEquippedItems.EquipItem((EquippableItem)item, out previousItem); if (previousItem != null) { playerInventory.itemsList.Add(previousItem); } OnItemRemove(); equippedItemsChanged.boolState = true; } else if (item is ConsummableItem) { //CHANGE THIS TO CONSUME ITEM OR THIS IS WHY ITEM WILL GET DELETED if (playerItemsToConsume.ConsumeItem((ConsummableItem)item)) { OnItemRemove(); } else { Debug.Log("Item effect cannot eb applied here"); } } else { Debug.Log("Wth is this item"); } }
public InventoryPickupState AddItem(Item item, bool attemptEquip) { InventoryPickupDestination destination = InventoryPickupDestination.none; int slot = -1; if (attemptEquip) { slot = Equipped.EquipItem(item); } if (slot >= 0) { // !!! TODO will need to generalize for different item types destination = slot == Equipped.SelectedWeaponIndex ? InventoryPickupDestination.selected : InventoryPickupDestination.equipped; if (ParentCharacter.IsPlayer) { UpdateInventoryItemUI(InventoryPickupDestination.equipped, slot); } } else { slot = AddToBackpack(item); if (slot >= 0) { destination = InventoryPickupDestination.backpack; if (ParentCharacter.IsPlayer) { UpdateInventoryItemUI(InventoryPickupDestination.backpack, slot); } } } return(new InventoryPickupState(slot, destination)); }