Пример #1
0
 private void removeIventoryItem(ScriptableBase item)
 {
     if (item == null)
     {
         return;
     }
     if (mInventory.ContainsKey(item))
     {
         mInventory.Remove(item);
         OnInventoryItemChanged?.Invoke(this, new InventoryEventArgs()
         {
             itemRemoved = true, Item = item, amount = 0
         });
     }
 }
Пример #2
0
    //###############
    //##  HELPERS  ##
    //###############

    private void AddInventoryItem(ScriptableBase item, int amount = 1)
    {
        if (item == null)
        {
            return;
        }

        int newAmount = amount;

        if (mInventory.ContainsKey(item))
        {
            mInventory.TryGetValue(item, out newAmount);
            newAmount += amount;
            mInventory.Remove(item);
        }

        mInventory.Add(item, newAmount);
        OnInventoryItemChanged?.Invoke(this, new InventoryEventArgs()
        {
            Item = item, amount = newAmount
        });
    }