TinyAdventure/inventory.gd

28 lines
420 B
GDScript
Raw Normal View History

2024-07-09 22:33:38 +02:00
class_name Inventory
var _content:Array[Item] = []
func add_item(item:Item):
_content.append(item)
func remove_item(item:Item):
_content.erase(item)
func get_items() -> Array[Item]:
return _content
2024-08-15 20:24:41 +02:00
func clear() -> void:
_content.clear()
2024-07-09 22:33:38 +02:00
func has_all(items:Array[Item]) -> bool:
var needed:Array[Item] = items.duplicate()
for available in _content:
needed.erase(available)
return needed.is_empty()