diff --git a/addons/beehave/debug/debugger_tab.gd b/addons/beehave/debug/debugger_tab.gd index 64a081b1..d8e6f487 100644 --- a/addons/beehave/debug/debugger_tab.gd +++ b/addons/beehave/debug/debugger_tab.gd @@ -73,11 +73,16 @@ func stop() -> void: func register_tree(data: Dictionary) -> void: - var idx := item_list.add_item(data.name, TREE_ICON) - item_list.set_item_tooltip(idx, data.path) - item_list.set_item_metadata(idx, data.id) + if not active_trees.has(data.id): + var idx := item_list.add_item(data.name, TREE_ICON) + item_list.set_item_tooltip(idx, data.path) + item_list.set_item_metadata(idx, data.id) + active_trees[data.id] = data + if active_tree_id == data.id.to_int(): + graph.beehave_tree = data + func unregister_tree(instance_id: int) -> void: var id := str(instance_id) diff --git a/addons/beehave/nodes/beehave_tree.gd b/addons/beehave/nodes/beehave_tree.gd index e85cc0e2..fa7db82e 100644 --- a/addons/beehave/nodes/beehave_tree.gd +++ b/addons/beehave/nodes/beehave_tree.gd @@ -138,6 +138,8 @@ func _ready() -> void: BeehaveGlobalDebugger.register_tree(self) BeehaveDebuggerMessages.register_tree(_get_debugger_data(self)) + child_entered_tree.connect(_on_child_entered_tree) + # Randomize at what frames tick() will happen to avoid stutters last_tick = randi_range(0, tick_rate - 1) @@ -268,6 +270,10 @@ func _get_process_time_metric_value() -> int: return int(_process_time_metric_value) +func _on_child_entered_tree(node: Node) -> void: + node.ready.connect(func(): BeehaveDebuggerMessages.register_tree(_get_debugger_data(self)), CONNECT_ONE_SHOT) + + func _get_debugger_data(node: Node) -> Dictionary: if not node is BeehaveTree and not node is BeehaveNode: return {}