public void RemoveItem(BaseObjectData baseObjectData) { //find the inventory slot for the item var index = Items.FindIndex(inventoryItem => inventoryItem.BaseObjectData == baseObjectData); //update if (index != -1) { Items[index].ChangeAmount(-1); } //notify listeners OnRemove?.Raise(); }
private GameEvent OnReset; //raised whenever we decrement the count for an inventory item (e.g. health) public void AddItem(BaseObjectData baseObjectData) { //find the inventory slot for the item var index = Items.FindIndex(inventoryItem => inventoryItem.BaseObjectData == baseObjectData); //update if (index != -1) { Items[index].ChangeAmount(1); } else { Items.Add(new InventoryItem(baseObjectData, 1, 100)); } //notify listeners OnAdd?.Raise(); }
public InventoryItem(BaseObjectData baseObjectData, int amount, int maxAmount) { BaseObjectData = baseObjectData; Amount = amount; MaxAmount = maxAmount; }