added when item amount is zero that item gets removed from items Dictionary
This commit is contained in:
parent
6836367207
commit
770de74fbc
2 changed files with 7 additions and 8 deletions
|
|
@ -22,8 +22,8 @@ public class Inventory : MonoBehaviour {
|
|||
public Item[] startItems;
|
||||
public const int inventorySpace = 28;
|
||||
|
||||
public delegate void onItemChanged();
|
||||
public onItemChanged onItemChangedCallback;
|
||||
public delegate void OnItemChanged();
|
||||
public OnItemChanged onItemChangedCallback;
|
||||
|
||||
private void Start() {
|
||||
items ??= new Dictionary<Item, int>();
|
||||
|
|
@ -38,8 +38,6 @@ public class Inventory : MonoBehaviour {
|
|||
return;
|
||||
}
|
||||
|
||||
Debug.Log("ASDADADWDASDWD");
|
||||
|
||||
if(!items.ContainsKey(item)) {
|
||||
items.Add(item, amount);
|
||||
} else {
|
||||
|
|
@ -51,7 +49,11 @@ public class Inventory : MonoBehaviour {
|
|||
}
|
||||
|
||||
public void RemoveItem(Item item, int amount) {
|
||||
items.Add(item, -amount);
|
||||
if(items[item] <= 0) {
|
||||
items.Remove(item);
|
||||
} else {
|
||||
items.Add(item, -amount);
|
||||
}
|
||||
|
||||
onItemChangedCallback?.Invoke();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
using System;
|
||||
using Items.TerraformingTools;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace Tiles
|
||||
{
|
||||
public abstract class BaseTile
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue