public void AddItem(ItemConfig item, int amount) { bool slotFound = false; if (item.IsStackable()) { slotFound = AddStackableItemToSlot(item, amount); if (!slotFound) { slotFound = AddToEmptySlot(item, amount); } } else { slotFound = AddToEmptySlot(item, amount); } if (!slotFound) { Debug.LogError("There's no slot to add " + item.GetDisplayName()); } }
public void RemoveItem(ItemConfig item, int amount) { bool foundItem = false; for (int i = 0; i < inventory.Length; i++) { if (item.GetItemId() == inventory[i].item.GetItemId()) { RemoveFromSlot(i, item, amount); foundItem = true; i = inventory.Length; } } if (!foundItem) { Debug.LogError("Item " + item.GetDisplayName() + " not found on inventory"); } if (OnInventoryUpdate != null) { OnInventoryUpdate(); } }