Working meta scenes

This commit is contained in:
2025-01-15 22:18:44 -06:00
parent 5344fc4aeb
commit f767dbf966
15 changed files with 144 additions and 86 deletions

View File

@@ -17,7 +17,9 @@ class ItemStackTypeComparator:
# Constants
const ITEM_STACK_SIZE_MAX = 99;
var ITEM_POTION = preload("res://scripts/Item/Potion.gd").new();
static var ITEM_POTION = preload("res://scripts/Item/Potion.gd").new();
# Class
var inventory:Array[ItemStack] = [];
# Methods
@@ -78,6 +80,23 @@ func removeItem(item: Item, quantity: int) -> void:
if quantity == 0:
return
func removeStack(stack: ItemStack) -> void:
self.removeItem(stack.item, stack.quantity);
func hasItem(item: Item, quantity: int = 1) -> bool:
var totalQuantity = 0
for stack in inventory:
if stack.item != item:
continue
totalQuantity += stack.quantity
if totalQuantity >= quantity:
return true
return false
func sortBy(by:ItemSortType) -> void:
match by:
ItemSortType.NAME: