limboai/doc_classes/BTTask.xml

214 lines
9.7 KiB
XML
Raw Permalink Normal View History

2022-11-01 20:31:22 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
<class name="BTTask" inherits="BT" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
2022-11-01 20:31:22 +00:00
<brief_description>
2023-10-20 13:01:41 +00:00
Base class for all [BehaviorTree] tasks.
2022-11-01 20:31:22 +00:00
</brief_description>
<description>
2023-10-20 13:01:41 +00:00
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].
2023-10-26 11:44:09 +00:00
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] &amp; [method _exit].
[b]Note:[/b] Do not extend [BTTask] directly for your own tasks. Instead, extend one of the subtypes mentioned above.
2022-11-01 20:31:22 +00:00
</description>
<tutorials>
</tutorials>
<methods>
<method name="_enter" qualifiers="virtual">
<return type="void" />
<description>
2023-10-20 13:01:41 +00:00
Called when task is "entered", i.e. when task is executed while not having a [code]RUNNING[/code] [member status].
It is called before [method _tick] in the execution order. This method is used when preparation is needed before main work begins, usually when it takes more than one tick to finish the task. See also [method execute].
2022-11-01 20:31:22 +00:00
</description>
</method>
<method name="_exit" qualifiers="virtual">
<return type="void" />
<description>
2023-10-20 13:01:41 +00:00
Called when task is "exited", i.e. after [method _tick] returns [code]SUCCESS[/code] or [code]FAILURE[/code] status. See also [method execute].
2022-11-01 20:31:22 +00:00
</description>
</method>
2023-04-10 14:57:36 +00:00
<method name="_generate_name" qualifiers="virtual const">
2022-11-01 20:31:22 +00:00
<return type="String" />
<description>
2023-10-20 13:01:41 +00:00
Called to generate a display name for the task unless [member custom_name] is set. See [method get_task_name].
2022-11-01 20:31:22 +00:00
</description>
</method>
<method name="_get_configuration_warnings" qualifiers="virtual const">
<return type="PackedStringArray" />
2022-11-01 20:31:22 +00:00
<description>
2023-10-20 13:01:41 +00:00
The string returned by this method is shown as a warning message in the behavior tree editor. Any task script that overrides this method must include [code]@tool[/code] annotation at the top of the file.
2022-11-01 20:31:22 +00:00
</description>
</method>
<method name="_setup" qualifiers="virtual">
<return type="void" />
<description>
2023-10-20 13:01:41 +00:00
Called to initialize a task during initialization step. It is called only once before the task's first execution tick. This method allows you to set up any necessary state or configurations for the task before it begins executing.
2022-11-01 20:31:22 +00:00
</description>
</method>
<method name="_tick" qualifiers="virtual">
2023-09-19 11:44:26 +00:00
<return type="int" enum="BT.Status" />
2023-04-10 14:57:36 +00:00
<param index="0" name="p_delta" type="float" />
2022-11-01 20:31:22 +00:00
<description>
2023-10-20 13:01:41 +00:00
Called when task is "ticked", i.e. executed by [BTPlayer] or [BTState] during an update.
Returns execution status as defined in [enum BT.Status].
[b]Note:[/b] Tasks perform their main function by implementing this method.
2022-11-01 20:31:22 +00:00
</description>
</method>
2023-10-26 14:37:26 +00:00
<method name="abort">
<return type="void" />
<description>
Resets the task and its children recursively. If a task is in the [code]RUNNING[/code] state, it is exited and its status is reset to [code]FRESH[/code].
</description>
</method>
2022-11-01 20:31:22 +00:00
<method name="add_child">
<return type="void" />
2023-04-10 14:57:36 +00:00
<param index="0" name="p_child" type="BTTask" />
2022-11-01 20:31:22 +00:00
<description>
Adds a child task. The [param p_child] is placed at the end of the children list.
2022-11-01 20:31:22 +00:00
</description>
</method>
<method name="add_child_at_index">
<return type="void" />
2023-04-10 14:57:36 +00:00
<param index="0" name="p_child" type="BTTask" />
<param index="1" name="p_idx" type="int" />
2022-11-01 20:31:22 +00:00
<description>
Adds a child task. The [param p_child] is placed at [param p_idx] position in the children list.
2022-11-01 20:31:22 +00:00
</description>
</method>
<method name="clone" qualifiers="const">
<return type="BTTask" />
<description>
2023-10-20 13:01:41 +00:00
Duplicates the task and its children, copying the exported members. Sub-resources are shared for efficiency, except for [BBParam] subtypes, which are always copied. Used by the editor to instantiate [BehaviorTree] and copy-paste tasks.
2022-11-01 20:31:22 +00:00
</description>
</method>
<method name="execute">
2023-09-19 11:44:26 +00:00
<return type="int" enum="BT.Status" />
2023-04-10 14:57:36 +00:00
<param index="0" name="p_delta" type="float" />
2022-11-01 20:31:22 +00:00
<description>
2023-10-20 13:01:41 +00:00
Performs task's execution. The execution follows a specific sequence:
- If task's current [member status] is not [code]RUNNING[/code], the [method _enter] method is called first.
- Next, the [method _tick] method is called next to perform the task's work.
- If the [method _tick] method returns [code]SUCCESS[/code] or [code]FAILURE[/code] status, the [method _exit] method will be called next as part of the execution cleanup.
2022-11-01 20:31:22 +00:00
</description>
</method>
<method name="get_child" qualifiers="const">
<return type="BTTask" />
2023-04-10 14:57:36 +00:00
<param index="0" name="p_idx" type="int" />
2022-11-01 20:31:22 +00:00
<description>
2023-10-20 13:01:41 +00:00
Returns a child task by specifying its index.
2022-11-01 20:31:22 +00:00
</description>
</method>
<method name="get_child_count" qualifiers="const">
<return type="int" />
<description>
Returns the number of child tasks.
2022-11-01 20:31:22 +00:00
</description>
</method>
<method name="get_child_count_excluding_comments" qualifiers="const">
<return type="int" />
<description>
Returns the number of child tasks not counting [BTComment] tasks.
</description>
</method>
<method name="get_index" qualifiers="const">
2022-11-01 20:31:22 +00:00
<return type="int" />
<description>
Returns the task's position in the behavior tree branch. Returns [code]-1[/code] if the task doesn't belong to a task tree, i.e. doesn't have a parent.
2022-11-01 20:31:22 +00:00
</description>
</method>
2023-04-10 14:57:36 +00:00
<method name="get_parent" qualifiers="const">
<return type="BTTask" />
<description>
2023-10-20 13:01:41 +00:00
Returns the task's parent.
2023-04-10 14:57:36 +00:00
</description>
</method>
2022-11-01 20:31:22 +00:00
<method name="get_root" qualifiers="const">
<return type="BTTask" />
<description>
Returns the root task of the behavior tree.
2022-11-01 20:31:22 +00:00
</description>
</method>
<method name="get_task_name">
2022-11-01 20:31:22 +00:00
<return type="String" />
<description>
The string returned by this method is used to represent the task in the editor.
2023-10-20 13:01:41 +00:00
Method [method _generate_name] is called to generate a display name for the task unless [member custom_name] is set.
2022-11-01 20:31:22 +00:00
</description>
</method>
<method name="has_child" qualifiers="const">
<return type="bool" />
2023-04-10 14:57:36 +00:00
<param index="0" name="p_child" type="BTTask" />
2022-11-01 20:31:22 +00:00
<description>
Returns [code]true[/code] if [param p_child] is a child of this task.
2022-11-01 20:31:22 +00:00
</description>
</method>
<method name="initialize">
<return type="void" />
2023-04-10 14:57:36 +00:00
<param index="0" name="p_agent" type="Node" />
<param index="1" name="p_blackboard" type="Blackboard" />
2022-11-01 20:31:22 +00:00
<description>
2023-07-20 20:15:30 +00:00
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.
2022-11-01 20:31:22 +00:00
</description>
</method>
<method name="is_descendant_of" qualifiers="const">
<return type="bool" />
2023-04-10 14:57:36 +00:00
<param index="0" name="p_task" type="BTTask" />
2022-11-01 20:31:22 +00:00
<description>
Returns [code]true[/code] if this task is a descendant of [param p_task]. In other words, this task must be a child of [param p_task] or one of its children or grandchildren.
2022-11-01 20:31:22 +00:00
</description>
</method>
<method name="is_root" qualifiers="const">
<return type="bool" />
<description>
2023-10-20 13:01:41 +00:00
Returns [code]true[/code] if this task is the root task of its behavior tree. A behavior tree can have only one root task.
2022-11-01 20:31:22 +00:00
</description>
</method>
<method name="next_sibling" qualifiers="const">
<return type="BTTask" />
<description>
2023-10-20 13:01:41 +00:00
Returns the next task after this task in the parent's children list.
Returns [code]null[/code] if this task has no parent or it is the last child in the parent's children list.
2022-11-01 20:31:22 +00:00
</description>
</method>
<method name="print_tree">
2022-11-01 20:31:22 +00:00
<return type="void" />
2023-04-10 14:57:36 +00:00
<param index="0" name="p_initial_tabs" type="int" default="0" />
2022-11-01 20:31:22 +00:00
<description>
2023-10-20 13:01:41 +00:00
Prints the subtree that starts with this task to the console.
2022-11-01 20:31:22 +00:00
</description>
</method>
<method name="remove_child">
<return type="void" />
2023-04-10 14:57:36 +00:00
<param index="0" name="p_child" type="BTTask" />
2022-11-01 20:31:22 +00:00
<description>
Removes [param p_child] task from children.
2022-11-01 20:31:22 +00:00
</description>
</method>
<method name="remove_child_at_index">
<return type="void" />
2023-04-10 14:57:36 +00:00
<param index="0" name="p_idx" type="int" />
2022-11-01 20:31:22 +00:00
<description>
2023-10-20 13:01:41 +00:00
Removes a child task at a specified index from children.
2022-11-01 20:31:22 +00:00
</description>
</method>
</methods>
<members>
2023-04-10 14:57:36 +00:00
<member name="agent" type="Node" setter="set_agent" getter="get_agent">
2023-10-20 13:01:41 +00:00
The agent is a contextual object for the task's [BehaviorTree] instance. Usually, agent is the owner of the [BTPlayer] node containing the [BehaviorTree] resource.
2022-11-01 20:31:22 +00:00
</member>
<member name="blackboard" type="Blackboard" setter="" getter="get_blackboard">
2023-10-20 13:01:41 +00:00
Provides access to the [Blackboard]. Blackboard is used to share data among tasks of the associated [BehaviorTree].
See [Blackboard] for additional info.
2022-11-01 20:31:22 +00:00
</member>
<member name="custom_name" type="String" setter="set_custom_name" getter="get_custom_name" default="&quot;&quot;">
User-provided name for the task. If not empty, it is used by the editor to represent the task. See [method get_task_name].
2022-11-01 20:31:22 +00:00
</member>
2023-08-06 10:55:52 +00:00
<member name="elapsed_time" type="float" setter="" getter="get_elapsed_time">
2023-10-20 13:01:41 +00:00
Elapsed time since the task was "entered". See [method _enter].
Returns [code]0[/code] when task is not [code]RUNNING[/code].
2023-07-20 20:15:30 +00:00
</member>
2023-09-19 11:44:26 +00:00
<member name="status" type="int" setter="" getter="get_status" enum="BT.Status">
Last execution [enum BT.Status] returned by [method _tick].
2022-11-01 20:31:22 +00:00
</member>
</members>
</class>