Added Inventory space display and robot alert if not working currently. Added inventory live update.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Godot;
|
||||
|
||||
@@ -6,6 +7,7 @@ public class Inventory
|
||||
public List<Item> items = new();
|
||||
|
||||
public int maxInventorySize = 8;
|
||||
public event EventHandler OnInventoryUpdate;
|
||||
|
||||
public bool AddItem(Item item, int amount)
|
||||
{
|
||||
@@ -13,6 +15,7 @@ public class Inventory
|
||||
if (inventoryItem != null)
|
||||
{
|
||||
inventoryItem.currentAmount += amount;
|
||||
OnInventoryUpdate?.Invoke(this, EventArgs.Empty);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -21,6 +24,7 @@ public class Inventory
|
||||
{
|
||||
items.Add(item);
|
||||
items[items.Count - 1].currentAmount += amount;
|
||||
OnInventoryUpdate?.Invoke(this, EventArgs.Empty);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -49,6 +53,7 @@ public class Inventory
|
||||
if (item != null)
|
||||
{
|
||||
item.currentAmount -= amount;
|
||||
OnInventoryUpdate?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user