API: Expose LimboDebugger for custom BT player implementations

This commit is contained in:
Serhii Snitsaruk 2024-07-31 15:26:24 +02:00
parent 64df43c7c9
commit c498fd90e5
No known key found for this signature in database
GPG Key ID: A965EF8799FFEC2D
5 changed files with 100 additions and 8 deletions

View File

@ -109,6 +109,7 @@ def get_doc_classes():
"BTTimeLimit", "BTTimeLimit",
"BTWait", "BTWait",
"BTWaitTicks", "BTWaitTicks",
"LimboDebugger",
"LimboHSM", "LimboHSM",
"LimboState", "LimboState",
"LimboUtility", "LimboUtility",

View File

@ -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<class_LimboDebugger_method_register_bt_instance>`\ (\ root_task\: :ref:`BTTask<class_BTTask>`, player_path\: ``NodePath``\ ) |
+--------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`unregister_bt_instance<class_LimboDebugger_method_unregister_bt_instance>`\ (\ root_task\: :ref:`BTTask<class_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<class_BTTask>`, player_path\: ``NodePath``\ ) :ref:`🔗<class_LimboDebugger_method_register_bt_instance>`
Registers a :ref:`BehaviorTree<class_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<class_BTTask>`, player_path\: ``NodePath``\ ) :ref:`🔗<class_LimboDebugger_method_unregister_bt_instance>`
Unregisters a :ref:`BehaviorTree<class_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.)`

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="LimboDebugger" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Sends runtime data to LimboAI debugger session.
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
<method name="register_bt_instance">
<return type="void" />
<param index="0" name="root_task" type="BTTask" />
<param index="1" name="player_path" type="NodePath" />
<description>
Registers a [BehaviorTree] instance, so it can be inspected in the debugger. Can be used in custom BT player implementations.
</description>
</method>
<method name="unregister_bt_instance">
<return type="void" />
<param index="0" name="root_task" type="BTTask" />
<param index="1" name="player_path" type="NodePath" />
<description>
Unregisters a [BehaviorTree] instance with the debugger.
</description>
</method>
</methods>
</class>

View File

@ -64,12 +64,8 @@ void LimboDebugger::deinitialize() {
void LimboDebugger::_bind_methods() { void LimboDebugger::_bind_methods() {
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
ClassDB::bind_method(D_METHOD("register_bt_instance", "root_task", "player_path"), &LimboDebugger::register_bt_instance);
#ifdef LIMBOAI_GDEXTENSION ClassDB::bind_method(D_METHOD("unregister_bt_instance", "root_task", "player_path"), &LimboDebugger::unregister_bt_instance);
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);
#endif // ! DEBUG_ENABLED #endif // ! DEBUG_ENABLED
} }

View File

@ -133,9 +133,7 @@ void initialize_limboai_module(ModuleInitializationLevel p_level) {
GDREGISTER_CLASS(BehaviorTreeView); GDREGISTER_CLASS(BehaviorTreeView);
#endif // TOOLS_ENABLED #endif // TOOLS_ENABLED
GDREGISTER_CLASS(BehaviorTreeData); GDREGISTER_CLASS(BehaviorTreeData);
#ifdef LIMBOAI_GDEXTENSION
GDREGISTER_CLASS(LimboDebugger); GDREGISTER_CLASS(LimboDebugger);
#endif
LimboDebugger::initialize(); LimboDebugger::initialize();
GDREGISTER_CLASS(LimboUtility); GDREGISTER_CLASS(LimboUtility);
@ -238,8 +236,10 @@ void initialize_limboai_module(ModuleInitializationLevel p_level) {
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
Engine::get_singleton()->add_singleton(Engine::Singleton("LimboUtility", LimboUtility::get_singleton())); 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 #elif LIMBOAI_GDEXTENSION
Engine::get_singleton()->register_singleton("LimboUtility", LimboUtility::get_singleton()); Engine::get_singleton()->register_singleton("LimboUtility", LimboUtility::get_singleton());
Engine::get_singleton()->register_singleton("LimboDebugger", LimboDebugger::get_singleton());
#endif #endif
LimboStringNames::create(); LimboStringNames::create();