newlon/scripts/gui/plant_pick/hotbar.gd
2025-08-03 18:34:54 +05:00

14 lines
419 B
GDScript

extends Node
func _ready() -> void:
LevelEventBus.hotbar_packets_update.connect(on_hotbar_updated)
func on_hotbar_updated(hotbar : Array[SeedpacketResource]):
for child in get_children():
child.queue_free()
for seedpacket in hotbar:
var packet = preload("res://scenes/gui/seedpacket.tscn").instantiate()
packet.held_resource = seedpacket
add_child(packet)
packet.set_handler(HotbarHandler.new(packet))