Fix issues and update docs for BehaviorTreeData/View

This commit is contained in:
Serhii Snitsaruk 2024-02-03 17:28:56 +01:00
parent c5b92aa676
commit 8dc645c9a7
7 changed files with 59 additions and 3 deletions

View File

@ -58,6 +58,7 @@ def get_doc_classes():
"BBVector4", "BBVector4",
"BBVector4i", "BBVector4i",
"BehaviorTree", "BehaviorTree",
"BehaviorTreeData",
"BehaviorTreeView", "BehaviorTreeView",
"Blackboard", "Blackboard",
"BlackboardPlan", "BlackboardPlan",

View File

@ -16,6 +16,12 @@
Returns the behavior tree's last execution status. See [enum BT.Status]. Returns the behavior tree's last execution status. See [enum BT.Status].
</description> </description>
</method> </method>
<method name="get_tree_instance">
<return type="BTTask" />
<description>
Returns the root task of the instantiated behavior tree.
</description>
</method>
<method name="restart"> <method name="restart">
<return type="void" /> <return type="void" />
<description> <description>

View File

@ -8,6 +8,14 @@
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
<methods>
<method name="get_tree_instance" qualifiers="const">
<return type="BTTask" />
<description>
Returns the root task of the instantiated behavior tree.
</description>
</method>
</methods>
<members> <members>
<member name="behavior_tree" type="BehaviorTree" setter="set_behavior_tree" getter="get_behavior_tree"> <member name="behavior_tree" type="BehaviorTree" setter="set_behavior_tree" getter="get_behavior_tree">
A [BehaviorTree] resource that defines state behavior. A [BehaviorTree] resource that defines state behavior.

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="BehaviorTreeData" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Represents current state of a [BehaviorTree] instance.
</brief_description>
<description>
This class is used by the LimboAI debugger for the serialization and deserialization of [BehaviorTree] instance data.
Additionally, it can be used with [BehaviorTreeView] to visualize the current state of a [BehaviorTree] instance. It is meant to be utilized in custom in-game tools.
</description>
<tutorials>
</tutorials>
<methods>
<method name="create_from_tree_instance" qualifiers="static">
<return type="BehaviorTreeData" />
<param index="0" name="p_tree_instance" type="BTTask" />
<description>
Returns current state of the [param p_tree_instance] encoded as a [BehaviorTreeData], suitable for use with [BehaviorTreeView].
Behavior tree instance can be acquired with [method BTPlayer.get_tree_instance].
</description>
</method>
</methods>
</class>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="BehaviorTreeView" inherits="Control" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Visualizes the current state of a [BehaviorTree] instance.
</brief_description>
<description>
Visualizes the current state of a [BehaviorTree] instance. See also [BehaviorTreeData].
</description>
<tutorials>
</tutorials>
<methods>
<method name="update_tree">
<return type="void" />
<param index="0" name="p_behavior_tree_data" type="BehaviorTreeData" />
<description>
Updates the representation of a [BehaviorTree] instance. See also [BehaviorTreeData].
</description>
</method>
</methods>
</class>

View File

@ -120,8 +120,8 @@ Ref<BehaviorTreeData> BehaviorTreeData::create_from_tree_instance(const Ref<BTTa
} }
void BehaviorTreeData::_bind_methods() { void BehaviorTreeData::_bind_methods() {
ClassDB::bind_static_method("BehaviorTreeData", D_METHOD("serialize", "p_tree_instance", "p_player_path", "p_bt_resource_path"), &BehaviorTreeData::serialize); // ClassDB::bind_static_method("BehaviorTreeData", D_METHOD("serialize", "p_tree_instance", "p_player_path", "p_bt_resource_path"), &BehaviorTreeData::serialize);
ClassDB::bind_static_method("BehaviorTreeData", D_METHOD("deserialize", "p_array"), &BehaviorTreeData::deserialize); // ClassDB::bind_static_method("BehaviorTreeData", D_METHOD("deserialize", "p_array"), &BehaviorTreeData::deserialize);
ClassDB::bind_static_method("BehaviorTreeData", D_METHOD("create_from_tree_instance", "p_tree_instance"), &BehaviorTreeData::create_from_tree_instance); ClassDB::bind_static_method("BehaviorTreeData", D_METHOD("create_from_tree_instance", "p_tree_instance"), &BehaviorTreeData::create_from_tree_instance);
} }

View File

@ -186,7 +186,6 @@ void BehaviorTreeView::_notification(int p_what) {
case NOTIFICATION_READY: { case NOTIFICATION_READY: {
tree->connect(LW_NAME(item_collapsed), callable_mp(this, &BehaviorTreeView::_item_collapsed)); tree->connect(LW_NAME(item_collapsed), callable_mp(this, &BehaviorTreeView::_item_collapsed));
} break; } break;
case NOTIFICATION_POSTINITIALIZE:
case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: case NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
case NOTIFICATION_TRANSLATION_CHANGED: case NOTIFICATION_TRANSLATION_CHANGED:
case NOTIFICATION_THEME_CHANGED: { case NOTIFICATION_THEME_CHANGED: {