From 0c2ee8ba8e946d58e315ac563aa3c51852a2d8b4 Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Thu, 20 Jul 2023 22:15:30 +0200 Subject: [PATCH] Update documentation --- blackboard/blackboard.cpp | 2 +- config.py | 10 ++++++++++ doc_classes/BBFloatArray.xml | 2 +- doc_classes/BBQuaternion.xml | 2 +- doc_classes/BBRect2i.xml | 2 +- doc_classes/BBStringName.xml | 2 +- doc_classes/BBTransform3D.xml | 2 +- doc_classes/BBVector2i.xml | 2 +- doc_classes/BBVector3i.xml | 2 +- doc_classes/BBVector4.xml | 2 +- doc_classes/BBVector4i.xml | 2 +- doc_classes/BTCooldown.xml | 3 ++- doc_classes/BTParallel.xml | 6 +++++- doc_classes/BTPlayer.xml | 9 +++++++++ doc_classes/BTProbability.xml | 6 ++++-- doc_classes/BTTask.xml | 10 +++++++--- doc_classes/BTWait.xml | 2 +- doc_classes/BTWaitTicks.xml | 3 ++- doc_classes/LimboUtility.xml | 7 +++++++ register_types.cpp | 6 +++--- util/limbo_utility.cpp | 2 +- 21 files changed, 61 insertions(+), 23 deletions(-) diff --git a/blackboard/blackboard.cpp b/blackboard/blackboard.cpp index 7c605ef..9ccf4a4 100644 --- a/blackboard/blackboard.cpp +++ b/blackboard/blackboard.cpp @@ -57,7 +57,7 @@ void Blackboard::_bind_methods() { ClassDB::bind_method(D_METHOD("has_var", "p_key"), &Blackboard::has_var); ClassDB::bind_method(D_METHOD("set_parent_scope", "p_blackboard"), &Blackboard::set_parent_scope); ClassDB::bind_method(D_METHOD("get_parent_scope"), &Blackboard::get_parent_scope); - ClassDB::bind_method(D_METHOD("erase_var"), &Blackboard::erase_var); + ClassDB::bind_method(D_METHOD("erase_var", "p_key"), &Blackboard::erase_var); ClassDB::bind_method(D_METHOD("prefetch_nodepath_vars", "p_node"), &Blackboard::prefetch_nodepath_vars); ClassDB::bind_method(D_METHOD("top"), &Blackboard::top); } \ No newline at end of file diff --git a/config.py b/config.py index bd07da5..8ceb56a 100644 --- a/config.py +++ b/config.py @@ -28,24 +28,34 @@ def get_doc_classes(): "BBColorArray", "BBDictionary", "BBFloat", + "BBFloatArray", "BBInt", "BBIntArray", "BBNode", "BBParam", "BBPlane", "BBQuat", + "BBQuaternion", "BBRealArray", "BBRect2", + "BBRect2i", "BBString", "BBStringArray", + "BBStringName", "BBTransform", "BBTransform2D", + "BBTransform3D", "BBVariant", "BBVector2", "BBVector2Array", + "BBVector2i", "BBVector3", "BBVector3Array", + "BBVector3i", + "BBVector4", + "BBVector4i", "BehaviorTree", + "BehaviorTreeView", "Blackboard", "BTAction", "BTAlwaysFail", diff --git a/doc_classes/BBFloatArray.xml b/doc_classes/BBFloatArray.xml index b30355f..b32bcd7 100644 --- a/doc_classes/BBFloatArray.xml +++ b/doc_classes/BBFloatArray.xml @@ -1,5 +1,5 @@ - + diff --git a/doc_classes/BBQuaternion.xml b/doc_classes/BBQuaternion.xml index 04cf317..553a876 100644 --- a/doc_classes/BBQuaternion.xml +++ b/doc_classes/BBQuaternion.xml @@ -1,5 +1,5 @@ - + diff --git a/doc_classes/BBRect2i.xml b/doc_classes/BBRect2i.xml index f0551d6..188b919 100644 --- a/doc_classes/BBRect2i.xml +++ b/doc_classes/BBRect2i.xml @@ -1,5 +1,5 @@ - + diff --git a/doc_classes/BBStringName.xml b/doc_classes/BBStringName.xml index fbd7676..9596ded 100644 --- a/doc_classes/BBStringName.xml +++ b/doc_classes/BBStringName.xml @@ -1,5 +1,5 @@ - + diff --git a/doc_classes/BBTransform3D.xml b/doc_classes/BBTransform3D.xml index 62edc71..300c50c 100644 --- a/doc_classes/BBTransform3D.xml +++ b/doc_classes/BBTransform3D.xml @@ -1,5 +1,5 @@ - + diff --git a/doc_classes/BBVector2i.xml b/doc_classes/BBVector2i.xml index 1f1c283..bac866f 100644 --- a/doc_classes/BBVector2i.xml +++ b/doc_classes/BBVector2i.xml @@ -1,5 +1,5 @@ - + diff --git a/doc_classes/BBVector3i.xml b/doc_classes/BBVector3i.xml index 39c17c7..3bd7fb3 100644 --- a/doc_classes/BBVector3i.xml +++ b/doc_classes/BBVector3i.xml @@ -1,5 +1,5 @@ - + diff --git a/doc_classes/BBVector4.xml b/doc_classes/BBVector4.xml index 9950be3..2e92fd3 100644 --- a/doc_classes/BBVector4.xml +++ b/doc_classes/BBVector4.xml @@ -1,5 +1,5 @@ - + diff --git a/doc_classes/BBVector4i.xml b/doc_classes/BBVector4i.xml index bf854d2..5477ae8 100644 --- a/doc_classes/BBVector4i.xml +++ b/doc_classes/BBVector4i.xml @@ -1,5 +1,5 @@ - + diff --git a/doc_classes/BTCooldown.xml b/doc_classes/BTCooldown.xml index 1ba2322..6b21f52 100644 --- a/doc_classes/BTCooldown.xml +++ b/doc_classes/BTCooldown.xml @@ -27,7 +27,8 @@ Start on a cooldown, as if the child was executed before the first BT tick. - Trigger cooldown, if the child returns [code]FAILURE[/code]. + Trigger cooldown, if the child also returns [code]FAILURE[/code]. + Otherwise, cooldown will only be triggered when the child returns [code]SUCCESS[/code] diff --git a/doc_classes/BTParallel.xml b/doc_classes/BTParallel.xml index be938b4..6253f9a 100644 --- a/doc_classes/BTParallel.xml +++ b/doc_classes/BTParallel.xml @@ -6,7 +6,7 @@ BT composite that executes tasks simultaneously until one of the criterea is met. BTParallel will execute each task from first to last at least once before returning a result. If set to [member repeat], the tasks will be executed again, even if they returned [code]SUCCESS[/code] or [code]FAILURE[/code] on the previous tick. - Returns [code]FAILURE[/code] when a required number of tasks return [code]FAILURE[/code]. When not set to [member repeat], if no criteria was met, but all tasks returned [code]SUCCESS[/code] or [code]FAILURE[/code], a [code]FAILURE[/code] will be returned. + Returns [code]FAILURE[/code] when a required number of tasks return [code]FAILURE[/code]. When [member repeat] is set to [code]false[/code], if none of the criteria were met, and all child tasks returned [code]SUCCESS[/code] or [code]FAILURE[/code], [BTParallel] will return [code]FAILURE[/code]. Returns [code]SUCCESS[/code] when a required number of tasks return [code]SUCCESS[/code]. Returns [code]RUNNING[/code] after executing all tasks from first to last, and for as long as the above criterea are not met. @@ -14,10 +14,14 @@ + When the specified number of child tasks return [code]SUCCESS[/code], [BTParallel] will also return [code]SUCCESS[/code]. + When the specified number of child tasks return [code]FAILURE[/code], [BTParallel] will also return [code]FAILURE[/code]. + When [code]true[/code], the tasks will be executed again, even if they returned [code]SUCCESS[/code] or [code]FAILURE[/code] on the previous tick. + When [code]false[/code], if none of the criteria were met, and all child tasks returned [code]SUCCESS[/code] or [code]FAILURE[/code], [BTParallel] will return [code]FAILURE[/code]. diff --git a/doc_classes/BTPlayer.xml b/doc_classes/BTPlayer.xml index 0558eb3..8dd0f13 100644 --- a/doc_classes/BTPlayer.xml +++ b/doc_classes/BTPlayer.xml @@ -46,6 +46,9 @@ [Blackboard] instance that contains data shared by the tasks in [BehaviorTree]. + + Add a performance monitor to "Debugger->Monitors" for each instance of this [BTPlayer]. + 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. @@ -61,6 +64,12 @@ Argument [code]p_status[/code] holds the status returned by the behavior tree. + + + + Emitted when BTPlayer has finished updating/ticking the tree. + + diff --git a/doc_classes/BTProbability.xml b/doc_classes/BTProbability.xml index a59bd75..0ede461 100644 --- a/doc_classes/BTProbability.xml +++ b/doc_classes/BTProbability.xml @@ -1,15 +1,17 @@ - BT decorator that executes child with probability. + BT decorator that executes child with a given probability. - BT decorator that executes its child task with a probability of the [member run_chance]. Returns FAILURE if the execution didn't happen. + BT decorator that executes child with a given probability defined by [member run_chance]. + Returns the result of the child task if it was executed, otherwise returns [code]FAILURE[/code]. + Probability that defines how likely the child task will be executed. diff --git a/doc_classes/BTTask.xml b/doc_classes/BTTask.xml index 59b4e9c..ec46a84 100644 --- a/doc_classes/BTTask.xml +++ b/doc_classes/BTTask.xml @@ -5,7 +5,7 @@ Base class for all [BehaviorTree] tasks. A task is a building block in a [BehaviorTree] that represents a specific behavior or control flow. It is the basic unit of the Behavior Tree (BT) and is used to create complex behaviors by combining and nesting tasks in a hierarchy. - Tasks perform work and return their status with [method _tick]. See [enum TaskStatus]. + Tasks perform work and return their status with [method _tick]. See [enum TaskStatus]. A Task can be an action, a condition, a composite, or a decorator. Each type of task has its own corresponding subclass: [BTAction], [BTCondition], [BTDecorator], [BTComposite]. [b]Note:[/b] Do not extend [code]BTTask[/code] directly for your own tasks, instead extend one of the subtypes above. @@ -131,7 +131,7 @@ - Initilizes the task. Assigns [member agent] and [member blackboard], and calls [method _setup] for the task and its children. + Initilizes the task. Assigns [member agent] and [member blackboard], and calls [method _setup] for the task and its children. The method is called recursively for each child task. @@ -151,7 +151,7 @@ - Returns the next task after this task in the children list of the [member parent]. + Returns the next task after this task in the children list of the [member parent]. Returns [code]null[/code] if this task has no parent or it is the last child in the parent's children list. @@ -188,6 +188,10 @@ User provided name for the task. If not empty, [code]custom_name[/code] is used by the editor to display the task. See [method get_task_name]. + + Elapsed time since the task was entered. + Returns 0 when task is not [code]RUNNING[/code]. + Last execution [enum TaskStatus] returned by [method _tick]. diff --git a/doc_classes/BTWait.xml b/doc_classes/BTWait.xml index 0d33a3c..dbc57e1 100644 --- a/doc_classes/BTWait.xml +++ b/doc_classes/BTWait.xml @@ -1,7 +1,7 @@ - BT action that waits for a [member duration] to pass and returns [code]SUCCESS[/code]. + BT action that waits for a [member duration] to pass and then returns [code]SUCCESS[/code]. diff --git a/doc_classes/BTWaitTicks.xml b/doc_classes/BTWaitTicks.xml index 6a5a83c..97da262 100644 --- a/doc_classes/BTWaitTicks.xml +++ b/doc_classes/BTWaitTicks.xml @@ -1,7 +1,7 @@ - BT action that waits for a number of ticks to pass and returns SUCCESS. + BT action that waits for a specified number of ticks to pass and then returns [code]SUCCESS[/code]. @@ -9,6 +9,7 @@ + Number of ticks to wait before returning [code]SUCCESS[/code]. diff --git a/doc_classes/LimboUtility.xml b/doc_classes/LimboUtility.xml index fbb2f91..a5ff636 100644 --- a/doc_classes/LimboUtility.xml +++ b/doc_classes/LimboUtility.xml @@ -22,5 +22,12 @@ Returns name of a [BTTask] status code. + + + + + Returns the icon texture associated with a task, given its class name or script resource path. + + diff --git a/register_types.cpp b/register_types.cpp index 95ba46b..fb32f41 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -178,9 +178,9 @@ void initialize_limboai_module(ModuleInitializationLevel p_level) { #ifdef TOOLS_ENABLED if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) { EditorPlugins::add_by_type(); - } else if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) { - GDREGISTER_CLASS(BehaviorTreeView); - } + } // else if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) { + // GDREGISTER_CLASS(BehaviorTreeView); + // } #endif } diff --git a/util/limbo_utility.cpp b/util/limbo_utility.cpp index abcd611..6bcbf53 100644 --- a/util/limbo_utility.cpp +++ b/util/limbo_utility.cpp @@ -59,7 +59,7 @@ Ref LimboUtility::get_task_icon(String p_class_or_script_path) const void LimboUtility::_bind_methods() { ClassDB::bind_method(D_METHOD("decorate_var", "p_variable"), &LimboUtility::decorate_var); ClassDB::bind_method(D_METHOD("get_status_name", "p_status"), &LimboUtility::get_status_name); - ClassDB::bind_method(D_METHOD("get_task_icon"), &LimboUtility::get_task_icon); + ClassDB::bind_method(D_METHOD("get_task_icon", "p_class_or_script_path"), &LimboUtility::get_task_icon); } LimboUtility::LimboUtility() {