From c498fd90e5daecbeb2c6d05dd2bb9cf6395ac6ea Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Wed, 31 Jul 2024 15:26:24 +0200 Subject: [PATCH] API: Expose LimboDebugger for custom BT player implementations --- config.py | 1 + doc/source/classes/class_limbodebugger.rst | 67 ++++++++++++++++++++++ doc_classes/LimboDebugger.xml | 28 +++++++++ editor/debugger/limbo_debugger.cpp | 8 +-- register_types.cpp | 4 +- 5 files changed, 100 insertions(+), 8 deletions(-) create mode 100644 doc/source/classes/class_limbodebugger.rst create mode 100644 doc_classes/LimboDebugger.xml diff --git a/config.py b/config.py index fe81b90f..8d40e32 100644 --- a/config.py +++ b/config.py @@ -109,6 +109,7 @@ def get_doc_classes(): "BTTimeLimit", "BTWait", "BTWaitTicks", + "LimboDebugger", "LimboHSM", "LimboState", "LimboUtility", diff --git a/doc/source/classes/class_limbodebugger.rst b/doc/source/classes/class_limbodebugger.rst new file mode 100644 index 0000000..227ca25 --- /dev/null +++ b/doc/source/classes/class_limbodebugger.rst @@ -0,0 +1,67 @@ +:github_url: hide + +.. DO NOT EDIT THIS FILE!!! +.. Generated automatically from Godot engine sources. +.. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. +.. XML source: https://github.com/godotengine/godot/tree/master/modules/limboai/doc_classes/LimboDebugger.xml. + +.. _class_LimboDebugger: + +LimboDebugger +============= + +**Inherits:** + +Sends runtime data to LimboAI debugger session. + +.. rst-class:: classref-reftable-group + +Methods +------- + +.. table:: + :widths: auto + + +--------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | |void| | :ref:`register_bt_instance`\ (\ root_task\: :ref:`BTTask`, player_path\: ``NodePath``\ ) | + +--------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | |void| | :ref:`unregister_bt_instance`\ (\ root_task\: :ref:`BTTask`, player_path\: ``NodePath``\ ) | + +--------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. rst-class:: classref-section-separator + +---- + +.. rst-class:: classref-descriptions-group + +Method Descriptions +------------------- + +.. _class_LimboDebugger_method_register_bt_instance: + +.. rst-class:: classref-method + +|void| **register_bt_instance**\ (\ root_task\: :ref:`BTTask`, player_path\: ``NodePath``\ ) :ref:`🔗` + +Registers a :ref:`BehaviorTree` instance, so it can be inspected in the debugger. Can be used in custom BT player implementations. + +.. rst-class:: classref-item-separator + +---- + +.. _class_LimboDebugger_method_unregister_bt_instance: + +.. rst-class:: classref-method + +|void| **unregister_bt_instance**\ (\ root_task\: :ref:`BTTask`, player_path\: ``NodePath``\ ) :ref:`🔗` + +Unregisters a :ref:`BehaviorTree` instance with the debugger. + +.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` +.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` +.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` +.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` +.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` +.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)` +.. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)` +.. |void| replace:: :abbr:`void (No return value.)` diff --git a/doc_classes/LimboDebugger.xml b/doc_classes/LimboDebugger.xml new file mode 100644 index 0000000..92c3643 --- /dev/null +++ b/doc_classes/LimboDebugger.xml @@ -0,0 +1,28 @@ + + + + Sends runtime data to LimboAI debugger session. + + + + + + + + + + + + Registers a [BehaviorTree] instance, so it can be inspected in the debugger. Can be used in custom BT player implementations. + + + + + + + + Unregisters a [BehaviorTree] instance with the debugger. + + + + diff --git a/editor/debugger/limbo_debugger.cpp b/editor/debugger/limbo_debugger.cpp index 9b28333..b241aa5 100644 --- a/editor/debugger/limbo_debugger.cpp +++ b/editor/debugger/limbo_debugger.cpp @@ -64,12 +64,8 @@ void LimboDebugger::deinitialize() { void LimboDebugger::_bind_methods() { #ifdef DEBUG_ENABLED - -#ifdef LIMBOAI_GDEXTENSION - ClassDB::bind_method(D_METHOD("parse_message_gdext"), &LimboDebugger::parse_message_gdext); -#endif - ClassDB::bind_method(D_METHOD("_on_bt_updated", "status", "path"), &LimboDebugger::_on_bt_updated); - ClassDB::bind_method(D_METHOD("_on_state_updated", "delta", "path"), &LimboDebugger::_on_state_updated); + ClassDB::bind_method(D_METHOD("register_bt_instance", "root_task", "player_path"), &LimboDebugger::register_bt_instance); + ClassDB::bind_method(D_METHOD("unregister_bt_instance", "root_task", "player_path"), &LimboDebugger::unregister_bt_instance); #endif // ! DEBUG_ENABLED } diff --git a/register_types.cpp b/register_types.cpp index 967f7e9..262a5f5 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -133,9 +133,7 @@ void initialize_limboai_module(ModuleInitializationLevel p_level) { GDREGISTER_CLASS(BehaviorTreeView); #endif // TOOLS_ENABLED GDREGISTER_CLASS(BehaviorTreeData); -#ifdef LIMBOAI_GDEXTENSION GDREGISTER_CLASS(LimboDebugger); -#endif LimboDebugger::initialize(); GDREGISTER_CLASS(LimboUtility); @@ -238,8 +236,10 @@ void initialize_limboai_module(ModuleInitializationLevel p_level) { #ifdef LIMBOAI_MODULE Engine::get_singleton()->add_singleton(Engine::Singleton("LimboUtility", LimboUtility::get_singleton())); + Engine::get_singleton()->add_singleton(Engine::Singleton("LimboDebugger", LimboDebugger::get_singleton())); #elif LIMBOAI_GDEXTENSION Engine::get_singleton()->register_singleton("LimboUtility", LimboUtility::get_singleton()); + Engine::get_singleton()->register_singleton("LimboDebugger", LimboDebugger::get_singleton()); #endif LimboStringNames::create();