Working meta scenes
This commit is contained in:
@@ -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:
|
||||
|
Reference in New Issue
Block a user