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(); } }
private bool AddStackableItemToSlot(ItemConfig item, int amount) { bool foundSlotToAdd = false; for (int i = 0; i < inventory.Length; i++) { if (IsEmptySlot(i)) { continue; } if (inventory[i].item.GetItemId() == item.GetItemId()) { AddToSlot(i, item, amount); foundSlotToAdd = true; i = inventory.Length; } } if (OnInventoryUpdate != null) { OnInventoryUpdate(); } return(foundSlotToAdd); }