public int GetItemSupplyAmount(ItemInfo item) { if (ItemsSupply.ContainsKey(item)) { return(ItemsSupply[item]); } return(0); }
public void AddItemSupply(ItemInfo item, int amount = 1) { if (!ItemsSupply.ContainsKey(item)) { ItemsSupply.Add(item, amount); } else { ItemsSupply[item] += amount; } if (onUpdateItemSupplyAmount != null) { onUpdateItemSupplyAmount.Invoke(item, ItemsSupply[item]); } }
public void RemoveItemSupply(ItemInfo item, int amount = 1) { if (ItemsSupply.ContainsKey(item)) { var current = ItemsSupply[item]; current -= amount; if (current <= 0) { current = 0; ItemsSupply.Remove(item); } else { ItemsSupply[item] = current; } if (onUpdateItemSupplyAmount != null) { onUpdateItemSupplyAmount.Invoke(item, current); } } }