30 lines
852 B
GDScript
30 lines
852 B
GDScript
extends Node
|
|
|
|
var found_blackbox_count = 0
|
|
var found_blackboxes = []
|
|
var blackbox_dialogues = []
|
|
|
|
func find_blackbox(id: int):
|
|
if found_blackboxes.size() < (id+1):
|
|
found_blackboxes.resize(id+1)
|
|
blackbox_dialogues.resize(id+1)
|
|
if not found_blackboxes[id]:
|
|
found_blackboxes[id] = true
|
|
found_blackbox_count += 1
|
|
|
|
var dialog
|
|
if blackbox_dialogues[id] == null or blackbox_dialogues[id].get_ref() == null:
|
|
dialog = Dialogic.start("blackbox_" + str(id))
|
|
blackbox_dialogues[id] = weakref(dialog)
|
|
else:
|
|
dialog = blackbox_dialogues[id].get_ref()
|
|
|
|
get_tree().root.add_child(dialog)
|
|
|
|
func hide_blackbox_dialogue(id: int):
|
|
if blackbox_dialogues[id] == null or blackbox_dialogues[id].get_ref() == null:
|
|
return
|
|
var dialog = blackbox_dialogues[id].get_ref()
|
|
if get_tree().root.is_a_parent_of(dialog):
|
|
get_tree().root.remove_child(dialog)
|