1
Fork 0
mirror of https://github.com/Steffo99/hella-farm.git synced 2024-11-23 00:24:21 +00:00
hella-farm/scenes/game/inventory.gd

20 lines
449 B
GDScript

extends Node
class_name Inventory
signal new_counter_created(kind: StringName, counter: Counter)
@export var counter_scene: PackedScene
func get_counter(kind: StringName) -> Counter:
var path: NodePath = NodePath(kind)
var counter: Counter = get_node_or_null(path)
if counter != null:
return counter
counter = counter_scene.instantiate()
counter.name = kind
add_child(counter)
new_counter_created.emit(kind, counter)
return counter