limboai/doc/source/classes/class_limbostate.rst

392 lines
14 KiB
ReStructuredText
Raw Normal View History

:github_url: hide
.. DO NOT EDIT THIS FILE!!!
.. Generated automatically from Godot engine sources.
.. Generator: https://github.com/godotengine/godot/tree/4.2/doc/tools/make_rst.py.
.. XML source: https://github.com/godotengine/godot/tree/4.2/modules/limboai/doc_classes/LimboState.xml.
.. _class_LimboState:
LimboState
==========
**Inherits:**
**Inherited By:** :ref:`BTState<class_BTState>`, :ref:`LimboHSM<class_LimboHSM>`
A state node for Hierarchical State Machines (HSM).
.. rst-class:: classref-introduction-group
Description
-----------
A LimboAI state node for Hierarchical State Machines (HSM).
You can create your state behavior by extending this class. To implement your state logic, you can override :ref:`_enter<class_LimboState_private_method__enter>`, :ref:`_exit<class_LimboState_private_method__exit>`, :ref:`_setup<class_LimboState_private_method__setup>`, and :ref:`_update<class_LimboState_private_method__update>`. Alternatively, you can delegate state implementation to external methods using the ``call_on_*`` methods.
For additional details on state machines, refer to :ref:`LimboHSM<class_LimboHSM>`.
.. rst-class:: classref-reftable-group
Properties
----------
.. table::
:widths: auto
2024-01-25 13:56:59 +00:00
+---------------------------------------------+-------------------------------------------------------------------+
2024-03-04 15:14:47 +00:00
| StringName | :ref:`EVENT_FINISHED<class_LimboState_property_EVENT_FINISHED>` |
2024-01-25 13:56:59 +00:00
+---------------------------------------------+-------------------------------------------------------------------+
| Node | :ref:`agent<class_LimboState_property_agent>` |
+---------------------------------------------+-------------------------------------------------------------------+
| :ref:`Blackboard<class_Blackboard>` | :ref:`blackboard<class_LimboState_property_blackboard>` |
+---------------------------------------------+-------------------------------------------------------------------+
| :ref:`BlackboardPlan<class_BlackboardPlan>` | :ref:`blackboard_plan<class_LimboState_property_blackboard_plan>` |
+---------------------------------------------+-------------------------------------------------------------------+
.. rst-class:: classref-reftable-group
Methods
-------
.. table::
:widths: auto
2024-03-04 15:14:47 +00:00
+-------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`_enter<class_LimboState_private_method__enter>` **(** **)** |virtual| |
+-------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`_exit<class_LimboState_private_method__exit>` **(** **)** |virtual| |
+-------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`_setup<class_LimboState_private_method__setup>` **(** **)** |virtual| |
+-------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`_update<class_LimboState_private_method__update>` **(** float p_delta **)** |virtual| |
+-------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_event_handler<class_LimboState_method_add_event_handler>` **(** StringName p_event, Callable p_handler **)** |
+-------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| :ref:`LimboState<class_LimboState>` | :ref:`call_on_enter<class_LimboState_method_call_on_enter>` **(** Callable p_callable **)** |
+-------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| :ref:`LimboState<class_LimboState>` | :ref:`call_on_exit<class_LimboState_method_call_on_exit>` **(** Callable p_callable **)** |
+-------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| :ref:`LimboState<class_LimboState>` | :ref:`call_on_update<class_LimboState_method_call_on_update>` **(** Callable p_callable **)** |
+-------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`clear_guard<class_LimboState_method_clear_guard>` **(** **)** |
+-------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| bool | :ref:`dispatch<class_LimboState_method_dispatch>` **(** StringName p_event, Variant p_cargo=null **)** |
+-------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| :ref:`LimboState<class_LimboState>` | :ref:`get_root<class_LimboState_method_get_root>` **(** **)** |const| |
+-------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| bool | :ref:`is_active<class_LimboState_method_is_active>` **(** **)** |const| |
+-------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| :ref:`LimboState<class_LimboState>` | :ref:`named<class_LimboState_method_named>` **(** String p_name **)** |
+-------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_guard<class_LimboState_method_set_guard>` **(** Callable p_guard_callable **)** |
+-------------------------------------+------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Signals
-------
.. _class_LimboState_signal_entered:
.. rst-class:: classref-signal
**entered** **(** **)**
Emitted when the state is entered.
.. rst-class:: classref-item-separator
----
.. _class_LimboState_signal_exited:
.. rst-class:: classref-signal
**exited** **(** **)**
Emitted when the state is exited.
.. rst-class:: classref-item-separator
----
.. _class_LimboState_signal_setup:
.. rst-class:: classref-signal
**setup** **(** **)**
Emitted when the state is initialized.
.. rst-class:: classref-item-separator
----
.. _class_LimboState_signal_updated:
.. rst-class:: classref-signal
**updated** **(** float p_delta **)**
Emitted when the state is updated.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Property Descriptions
---------------------
.. _class_LimboState_property_EVENT_FINISHED:
.. rst-class:: classref-property
2024-03-04 15:14:47 +00:00
StringName **EVENT_FINISHED**
.. rst-class:: classref-property-setget
2024-03-04 15:14:47 +00:00
- StringName **event_finished** **(** **)**
A commonly used event that indicates that the state has finished its work.
.. rst-class:: classref-item-separator
----
.. _class_LimboState_property_agent:
.. rst-class:: classref-property
Node **agent**
.. rst-class:: classref-property-setget
- void **set_agent** **(** Node value **)**
- Node **get_agent** **(** **)**
An agent associated with the state, assigned during initialization.
.. rst-class:: classref-item-separator
----
.. _class_LimboState_property_blackboard:
.. rst-class:: classref-property
:ref:`Blackboard<class_Blackboard>` **blackboard**
.. rst-class:: classref-property-setget
- :ref:`Blackboard<class_Blackboard>` **get_blackboard** **(** **)**
A key/value data store shared by states within the state machine to which this state belongs.
2024-01-25 13:56:59 +00:00
.. rst-class:: classref-item-separator
----
.. _class_LimboState_property_blackboard_plan:
.. rst-class:: classref-property
:ref:`BlackboardPlan<class_BlackboardPlan>` **blackboard_plan**
.. rst-class:: classref-property-setget
- void **set_blackboard_plan** **(** :ref:`BlackboardPlan<class_BlackboardPlan>` value **)**
- :ref:`BlackboardPlan<class_BlackboardPlan>` **get_blackboard_plan** **(** **)**
Stores and manages variables that will be used in constructing new :ref:`Blackboard<class_Blackboard>` instances.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Method Descriptions
-------------------
.. _class_LimboState_private_method__enter:
.. rst-class:: classref-method
void **_enter** **(** **)** |virtual|
Called when the state is entered.
.. rst-class:: classref-item-separator
----
.. _class_LimboState_private_method__exit:
.. rst-class:: classref-method
void **_exit** **(** **)** |virtual|
Called when the state is exited.
.. rst-class:: classref-item-separator
----
.. _class_LimboState_private_method__setup:
.. rst-class:: classref-method
void **_setup** **(** **)** |virtual|
Called once during initialization. Use this method to initialize your state.
.. rst-class:: classref-item-separator
----
.. _class_LimboState_private_method__update:
.. rst-class:: classref-method
void **_update** **(** float p_delta **)** |virtual|
Called during the update. Implement your state's behavior with this method.
.. rst-class:: classref-item-separator
----
.. _class_LimboState_method_add_event_handler:
.. rst-class:: classref-method
2024-03-04 15:14:47 +00:00
void **add_event_handler** **(** StringName p_event, Callable p_handler **)**
2024-03-01 23:10:44 +00:00
Registers a ``p_handler`` to be called when ``p_event`` is dispatched.
.. rst-class:: classref-item-separator
----
.. _class_LimboState_method_call_on_enter:
.. rst-class:: classref-method
:ref:`LimboState<class_LimboState>` **call_on_enter** **(** Callable p_callable **)**
A chained method that connects the :ref:`entered<class_LimboState_signal_entered>` signal to a ``p_callable``.
.. rst-class:: classref-item-separator
----
.. _class_LimboState_method_call_on_exit:
.. rst-class:: classref-method
:ref:`LimboState<class_LimboState>` **call_on_exit** **(** Callable p_callable **)**
A chained method that connects the :ref:`exited<class_LimboState_signal_exited>` signal to a ``p_callable``.
.. rst-class:: classref-item-separator
----
.. _class_LimboState_method_call_on_update:
.. rst-class:: classref-method
:ref:`LimboState<class_LimboState>` **call_on_update** **(** Callable p_callable **)**
A chained method that connects the :ref:`updated<class_LimboState_signal_updated>` signal to a ``p_callable``.
.. rst-class:: classref-item-separator
----
.. _class_LimboState_method_clear_guard:
.. rst-class:: classref-method
void **clear_guard** **(** **)**
Clears the guard function, removing the ``Callable`` previously set by :ref:`set_guard<class_LimboState_method_set_guard>`.
.. rst-class:: classref-item-separator
----
.. _class_LimboState_method_dispatch:
.. rst-class:: classref-method
2024-03-04 15:14:47 +00:00
bool **dispatch** **(** StringName p_event, Variant p_cargo=null **)**
Recursively dispatches a state machine event named ``p_event`` with an optional argument ``p_cargo``. Returns ``true`` if the event was consumed.
Events propagate from the leaf state to the root state, and propagation stops as soon as any state consumes the event. States will consume the event if they have a related transition or event handler. For more information on event handlers, see :ref:`add_event_handler<class_LimboState_method_add_event_handler>`.
.. rst-class:: classref-item-separator
----
.. _class_LimboState_method_get_root:
.. rst-class:: classref-method
:ref:`LimboState<class_LimboState>` **get_root** **(** **)** |const|
Returns the root **LimboState**.
.. rst-class:: classref-item-separator
----
.. _class_LimboState_method_is_active:
.. rst-class:: classref-method
bool **is_active** **(** **)** |const|
Returns ``true`` if it is currently active, meaning it is the active substate of the parent :ref:`LimboHSM<class_LimboHSM>`.
.. rst-class:: classref-item-separator
----
.. _class_LimboState_method_named:
.. rst-class:: classref-method
:ref:`LimboState<class_LimboState>` **named** **(** String p_name **)**
A chained method for setting the name of this state.
.. rst-class:: classref-item-separator
----
.. _class_LimboState_method_set_guard:
.. rst-class:: classref-method
void **set_guard** **(** Callable p_guard_callable **)**
Sets the guard function, which is a function called each time a transition to this state is considered. If the function returns ``false``, the transition will be disallowed.
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
.. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`