prompt_container.gd 527 B

123456789101112131415161718192021222324252627
  1. class_name PromptContainer
  2. extends Control
  3. ## Free itself when no prompt remaining
  4. var _nb_prompts: int
  5. func _ready() -> void:
  6. _nb_prompts = 0
  7. for child in get_children():
  8. if child is InputPrompt:
  9. child.tree_exited.connect(_on_child_exited_tree)
  10. _nb_prompts += 1
  11. func remove_if_no_more_prompt():
  12. _nb_prompts -= 1
  13. print(_nb_prompts, " remaining prompts")
  14. if _nb_prompts <= 0:
  15. # Only label remaining
  16. print("Destruction !")
  17. queue_free()
  18. func _on_child_exited_tree() -> void:
  19. remove_if_no_more_prompt()