limboai/doc_classes/BTTask.xml

210 lines
9.0 KiB
XML
Raw Permalink Normal View History

2022-11-01 20:31:22 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
2023-04-10 14:57:36 +00:00
<class name="BTTask" inherits="Resource" version="4.1" 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-04-10 14:57:36 +00:00
Base class for [BehaviorTree] tasks.
2022-11-01 20:31:22 +00:00
</brief_description>
<description>
2023-04-10 14:57:36 +00:00
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].
2023-04-10 14:57:36 +00:00
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.
2022-11-01 20:31:22 +00:00
</description>
<tutorials>
</tutorials>
<methods>
<method name="_enter" qualifiers="virtual">
<return type="void" />
<description>
Called when task is "entered", i.e. when task is executed while not having a [constant RUNNING] [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.
2022-11-01 20:31:22 +00:00
</description>
</method>
<method name="_exit" qualifiers="virtual">
<return type="void" />
<description>
Called when task is "exited", i.e. after [method _tick] returns [constant SUCCESS] or [constant FAILURE] status.
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>
When [member custom_name] is empty, the string returned by this method is used to display the task by the editor. See [method get_task_name].
2022-11-01 20:31:22 +00:00
</description>
</method>
2023-04-10 14:57:36 +00:00
<method name="_get_configuration_warning" qualifiers="virtual const">
2022-11-01 20:31:22 +00:00
<return type="String" />
<description>
The string returned by this method is displayed as a warning in the BT editor if the script that overrides it is a [code]tool[/code] script.
2022-11-01 20:31:22 +00:00
</description>
</method>
<method name="_setup" qualifiers="virtual">
<return type="void" />
<description>
Called when task is initialized during behavior tree initialization.
2022-11-01 20:31:22 +00:00
</description>
</method>
<method name="_tick" qualifiers="virtual">
<return type="int" />
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>
Called when task is "ticked", i.e. executed by [BTPlayer] or [BTState] during update.
Returns [member TaskStatus].
*Note:* Tasks perform their main function by implementing this method.
2022-11-01 20:31:22 +00:00
</description>
</method>
<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 [code]p_child[/code] 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 [code]p_child[/code] is placed at [code]p_idx[/code] position in the children list.
2022-11-01 20:31:22 +00:00
</description>
</method>
<method name="clone" qualifiers="const">
<return type="BTTask" />
<description>
Clones the task and its children with the exported members copied. Sub-resources are shared for efficiency, except for [BBParam] subtypes, which are always copied.
2022-11-01 20:31:22 +00:00
</description>
</method>
<method name="execute">
<return type="int" />
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>
Performs task's execution. During execution [method _enter] is called first, unless current task [member status] is [code]RUNNING[/code]. [method _tick] is called next to perform task's main function. If [constant SUCCESS] or [constant FAILURE] status is returned by [method _tick], [method _exit] will be called next.
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>
Returns a child task by 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_index" qualifiers="const">
<return type="int" />
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 the child task's index. If [code]p_child[/code] is not a child of the task, [code]-1[/code] is returned instead.
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>
Returns task's parent.
</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" qualifiers="const">
<return type="String" />
<description>
The string returned by this method is used to represent the task in the editor.
[member custom_name] value is returned when it is not empty. Otherwise, the string constructed by [method _generate_name] is returned instead.
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 [code]p_child[/code] 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>
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 descendant of [code]p_task[/code]. I.e. this task must be a child of [code]p_task[/code] 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>
Returns [code]true[/code] if this task is the root task of the 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>
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.
2022-11-01 20:31:22 +00:00
</description>
</method>
<method name="print_tree" qualifiers="const">
<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>
Prints the subtree that starts with this task to 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 [code]p_child[/code] 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>
Removes a child task by index.
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">
The agent is a contextual object for the task's behavior tree instance. Usually, agent is the owner of a node with the [BehaviorTree] resource.
2022-11-01 20:31:22 +00:00
</member>
<member name="blackboard" type="Blackboard" setter="" getter="get_blackboard">
Provides access to the blackboard for this task and behavior tree. Blackboard is used to share data among tasks of the associated behavior tree.
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, [code]custom_name[/code] is used by the editor to display the task. See [method get_task_name].
2022-11-01 20:31:22 +00:00
</member>
<member name="status" type="int" setter="" getter="get_status">
Last execution [enum TaskStatus] returned by [method _tick].
2022-11-01 20:31:22 +00:00
</member>
</members>
<constants>
<constant name="FRESH" value="0" enum="TaskStatus">
Task wasn't executed yet or execution was cancelled.
2022-11-01 20:31:22 +00:00
</constant>
<constant name="RUNNING" value="1" enum="TaskStatus">
Task is being performed and hasn't finished yet.
2022-11-01 20:31:22 +00:00
</constant>
<constant name="FAILURE" value="2" enum="TaskStatus">
Task has finished with failure.
2022-11-01 20:31:22 +00:00
</constant>
<constant name="SUCCESS" value="3" enum="TaskStatus">
Task has finished with success.
2022-11-01 20:31:22 +00:00
</constant>
</constants>
</class>