Item get event

This commit is contained in:
2025-05-19 07:10:17 -05:00
parent dd783174e8
commit f625415939
9 changed files with 44 additions and 22 deletions

View File

@@ -19,8 +19,8 @@ const ITEM_STACK_SIZE_MAX = 99;
var contents:Array[ItemStack] = [];
func addItem(item: Item, quantity: int = 1) -> void:
if !item.isStackable():
func addItem(item:Item.ItemType, quantity: int = 1) -> void:
if !Item.isStackable(item):
# Item cannot be stacked, add each item to inv
for i in range(quantity):
contents.append(ItemStack.new(item, 1))
@@ -46,7 +46,7 @@ func addItem(item: Item, quantity: int = 1) -> void:
contents.append(ItemStack.new(item, newStackQuantity));
quantity -= newStackQuantity;
func removeItem(item: Item, quantity: int) -> void:
func removeItem(item:Item.ItemType, quantity:int) -> void:
var totalQuantity = 0
# Calculate total quantity of the item in the inventory
@@ -78,7 +78,7 @@ func removeItem(item: Item, quantity: int) -> void:
func removeStack(stack: ItemStack) -> void:
self.removeItem(stack.item, stack.quantity);
func hasItem(item: Item, quantity: int = 1) -> bool:
func hasItem(item:Item.ItemType, quantity: int = 1) -> bool:
var totalQuantity = 0
for stack in contents: