From 39971b1e1a83486d64db62abb6b0905271989dac Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Thu, 26 Oct 2023 13:44:09 +0200 Subject: [PATCH] Improve BTPlayer doc --- bt/bt_player.cpp | 2 +- doc_classes/BTPlayer.xml | 43 ++++++++++++++++++---------------------- doc_classes/BTTask.xml | 2 +- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/bt/bt_player.cpp b/bt/bt_player.cpp index 05e6b5b..55e5a7f 100644 --- a/bt/bt_player.cpp +++ b/bt/bt_player.cpp @@ -187,7 +187,7 @@ void BTPlayer::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "behavior_tree", PROPERTY_HINT_RESOURCE_TYPE, "BehaviorTree"), "set_behavior_tree", "get_behavior_tree"); ADD_PROPERTY(PropertyInfo(Variant::INT, "update_mode", PROPERTY_HINT_ENUM, "Idle,Physics,Manual"), "set_update_mode", "get_update_mode"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "active"), "set_active", "get_active"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "blackboard", PROPERTY_HINT_NONE, "Blackboard", 0), "", "get_blackboard"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "blackboard", PROPERTY_HINT_NONE, "Blackboard", 0), "set_blackboard", "get_blackboard"); ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "_blackboard_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "_set_blackboard_data", "_get_blackboard_data"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "prefetch_nodepath_vars"), "set_prefetch_nodepath_vars", "get_prefetch_nodepath_vars"); diff --git a/doc_classes/BTPlayer.xml b/doc_classes/BTPlayer.xml index 11e39ea..93cb2a3 100644 --- a/doc_classes/BTPlayer.xml +++ b/doc_classes/BTPlayer.xml @@ -4,7 +4,8 @@ Player of [BehaviorTree] resources. - BTPlayer is used for instantiation and playback of [BehaviorTree] resources at run time. + BTPlayer node is used for the instantiation and playback of [BehaviorTree] resources at runtime. During instantiation, the behavior tree instance is initialized with a reference to the agent and the [member blackboard]. Agent is the owner of the BTPlayer node (see [member Node.owner]). + For an introduction to behavior trees, see [BehaviorTree]. @@ -12,74 +13,68 @@ - Returns last execution status. See [enum BT.Status]. + Returns the behavior tree's last execution status. See [enum BT.Status]. - Cancel execution of the tree and start anew. This method does not reset [Blackboard]. - - - - - - - Assign a [Blackboard] instance. + Resets the behavior tree's execution. Each running task will be aborted and the next tree execution will start anew. This method does not reset [Blackboard]. - Updates the tree by executing the root task. Call this method when [member update_mode] is set to [constant MANUAL]. When [member update_mode] is not set to [constant MANUAL], the tree is updated automatically. See [enum UpdateMode]. + Executes the root task of the behavior tree instance if [member active] is [code]true[/code]. Call this method when [member update_mode] is set to [constant MANUAL]. When [member update_mode] is not [constant MANUAL], the [method update] will be called automatically. See [enum UpdateMode]. - If [code]true[/code], tree is active and will be processed. + If [code]true[/code], the behavior tree will be executed during update. - [BehaviorTree] resource to instantiate and process at run time. + [BehaviorTree] resource to instantiate and execute at runtime. - - [Blackboard] instance that contains data shared by the tasks in [BehaviorTree]. + + Holds data shared by the behavior tree tasks. See [Blackboard]. - Add a performance monitor to "Debugger->Monitors" for each instance of this [BTPlayer]. + If [code]true[/code], adds a performance monitor to "Debugger->Monitors" for each instance of this [BTPlayer] node. - If [code]true[/code], any NodePath variables in the [Blackboard] are replaced with references during tree instantiation. References are retrieved by calling [method Node.get_node] of BTPlayer. + If [code]true[/code], any [NodePath] variables in the [Blackboard] are replaced with [Node] references when the tree is instantiated. References are retrieved by calling [method Node.get_node] on the agent instance (agent is the owner of the BTPlayer node). - Defines when BehaviorTree is executed. See [enum UpdateMode]. + Determines when the behavior tree is executed. See [enum UpdateMode]. - Notifies when behavior tree finishes executing and returns [code]SUCCESS[/code] or [code]FAILURE[/code]. - Argument [code]p_status[/code] holds the status returned by the behavior tree. + Emitted when the behavior tree has finished executing and returned [code]SUCCESS[/code] or [code]FAILURE[/code]. + Argument [code]p_status[/code] holds the status returned by the behavior tree. See [enum BT.Status]. - Emitted when BTPlayer has finished updating/ticking the tree. + Emitted when BTPlayer has finished the behavior tree update. + Argument [code]p_status[/code] holds the status returned by the behavior tree. See [enum BT.Status]. - Process tree during the idle process. + Execute behavior tree during the idle process. - Process tree during the physics process. + Execute behavior tree during the physics process. - Tree is processed manually by calling [method update]. + Behavior tree is executed manually by calling [method update]. diff --git a/doc_classes/BTTask.xml b/doc_classes/BTTask.xml index 6d9bc7e..93f776d 100644 --- a/doc_classes/BTTask.xml +++ b/doc_classes/BTTask.xml @@ -6,7 +6,7 @@ Base class for all [BehaviorTree] tasks. A task is a basic building block in a [BehaviorTree] that represents a specific behavior or control flow. Tasks are used to create complex behaviors by combining and nesting them in a hierarchy. A task can be one of the following types: action, condition, composite, or decorator. Each type of task has its own corresponding subclass: [BTAction], [BTCondition], [BTDecorator], [BTComposite]. - Tasks perform their work and return their status using the [method _tick] method. Status values are defined in [enum BT.Status]. Tasks can be initialized using the [method _setup] method. See also [method _enter] & [method _exit]. + Tasks perform their work and return their status using the [method _tick] method. Status values are defined in [enum BT.Status]. Tasks can be initialized using the [method _setup] method. See also [method _enter] & [method _exit]. [b]Note:[/b] Do not extend [code]BTTask[/code] directly for your own tasks. Instead, extend one of the subtypes mentioned above.