25 lines
470 B
GDScript
25 lines
470 B
GDScript
#Inventory Singleton
|
|
extends Node
|
|
|
|
#game items
|
|
@abstract
|
|
class Item:
|
|
var name: String
|
|
func _init(_name: String):
|
|
name = _name
|
|
|
|
class Wood extends Item:
|
|
func _init():
|
|
super("Wood")
|
|
|
|
class Stone extends Item:
|
|
func _init():
|
|
super("Stone")
|
|
|
|
#inventory controls
|
|
var _inventory_contents: Array[Item] = []
|
|
|
|
func add_item(item: Item) -> void:
|
|
_inventory_contents.push_back(item)
|
|
print("Inventory: ", _inventory_contents.map(func (i: Item) -> String: return i.name))
|