bitbrain / beehave

🐝 behavior tree AI for Godot Engine
https://bitbra.in/beehave
MIT License
1.85k stars 116 forks source link

Fix debugger tab runtime update #301

Closed razcore-rad closed 7 months ago

razcore-rad commented 7 months ago

fixes #203 supersedes #204

I left it on as a Draft PR because the realtime update is not ideal as it unregisters & re-registers the entire tree every node change which can be optimized + unit tests added.

Tested with a modified version of the project from #203: BeehaveBranchBug.zip

https://github.com/bitbrain/beehave/assets/1177508/9356f4fc-2999-4f74-b5e6-f62e7309f5f6

edit: I noticed that all I have to do to update the tree is to re-register it, no other necessary unregister/register steps so I amended the last commit.

So what's left is unit testing.

razcore-rad commented 7 months ago

OK, I'm actually not entirely sure how to write a test for this since the example with the debugger is actually using an instance of the debugger tab at runtime where we already know register_tree() works so adding a scene where we call functions like this:

# test/debug/debugger_test_scene.gd
func _ready() -> void:
    # [...]
    beehave_tree.get_node("SequenceComposite/MockAction").queue_free()
    await get_tree().create_timer(1).timeout
    beehave_debugger_tab.register_tree(beehave_tree._get_debugger_data(beehave_tree))

Is meaningless.

bitbrain commented 7 months ago

Amazing work and nice approach - thanks for your contribution @razcore-rad