extends Node

export(PackedScene) var Lifebar

var lifebars: Array

func initiate():
	for lb in lifebars:
		if is_instance_valid(lb):
			lb.queue_free()
	lifebars.clear()
	
	for actor in get_tree().get_nodes_in_group("actor"):
		create_lifebar(actor)
	# no spawners yet
	#for spawner in get_tree().get_nodes_in_group("spawner"): 
	#	spawner.connect("")




func create_lifebar(actor):
	if not (actor.has_node("Health") and actor.has_node("InterfaceHook") and not actor.is_queued_for_deletion()):
		return
	print("create lb")
	var lifebar = Lifebar.instance()
	add_child(lifebar)
	lifebar.initialize(actor)
	lifebars.append(lifebar)
