Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show branches created at runtime #204

Closed
11 changes: 8 additions & 3 deletions addons/beehave/debug/debugger_tab.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions addons/beehave/nodes/beehave_tree.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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 {}
Expand Down
Loading