class_name PromptContainer
extends Control
## Free itself when every prompt has been used


var _nb_prompts: int


func _ready() -> void:
	_nb_prompts = 0
	for child in get_children():
		if child is InputPrompt:
			child.pressed.connect(child.queue_free)
			child.tree_exited.connect(_on_child_exited_tree)
			_nb_prompts += 1


func remove_if_no_more_prompt():
	_nb_prompts -= 1
	print(_nb_prompts, " remaining prompts")
	if _nb_prompts <= 0:
		# Only label remaining
		print("Destruction !")
		queue_free()


func _on_child_exited_tree() -> void:
	remove_if_no_more_prompt()