public void HasBeenCollected() { OnItemCollected?.Invoke(this, new SpawnerEventArgs() { Position = transform }); }
public virtual int GiveItem(ItemStack stack) { Item.Type itemType = stack.ItemType; int amount = stack.Amount; Storage inv = GetAppropriateInventory(itemType); int remainingItems = inv.AddItem(itemType, amount); int difference = amount - remainingItems; if (difference != 0) { OnItemCollected?.Invoke(itemType, difference); } return(remainingItems); }
public void OnCollectItem(int itemID) { if (!_itemCollectedCount.ContainsKey(itemID)) { _itemCollectedCount.Add(itemID, 1); } else { _itemCollectedCount[itemID]++; } OnItemCollected?.Invoke(itemID); CheckItems(); }
public virtual int GiveItem(Item.Type itemType) { Storage inv = GetAppropriateInventory(itemType); int remainingItems = inv.AddItem(itemType); if (remainingItems == 0) { OnItemCollected?.Invoke(itemType, 1); } else { Debug.Log($"{remainingItems} {itemType} not added"); } return(remainingItems); }
public static void RaiseOnItemCollected() { OnItemCollected?.Invoke(); }