From 0e6e1cbe5e067ca6bcabc20929a5f3b4e3ac3edb Mon Sep 17 00:00:00 2001 From: Stanislav Labzyuk Date: Wed, 12 Jul 2023 21:55:33 +0200 Subject: [PATCH] Show branches created at runtime --- addons/beehave/debug/debugger_tab.gd | 11 ++++++++--- addons/beehave/nodes/beehave_tree.gd | 6 ++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/addons/beehave/debug/debugger_tab.gd b/addons/beehave/debug/debugger_tab.gd index 3987d778..ad48e3da 100644 --- a/addons/beehave/debug/debugger_tab.gd +++ b/addons/beehave/debug/debugger_tab.gd @@ -71,11 +71,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 7a8d145f..1dd51043 100644 --- a/addons/beehave/nodes/beehave_tree.gd +++ b/addons/beehave/nodes/beehave_tree.gd @@ -99,6 +99,8 @@ func _ready() -> void: BeehaveGlobalDebugger.register_tree(self) BeehaveDebuggerMessages.register_tree(_get_debugger_data(self)) + child_entered_tree.connect(_on_child_entered_tree) + func _physics_process(delta: float) -> void: if Engine.is_editor_hint(): @@ -207,6 +209,10 @@ func _get_process_time_metric_value() -> int: return _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 {}