:github_url: hide

.. DO NOT EDIT THIS FILE!!!
.. Generated automatically from Godot engine sources.
.. Generator: https://github.com/godotengine/godot/tree/4.3/doc/tools/make_rst.py.
.. XML source: https://github.com/godotengine/godot/tree/4.3/modules/limboai/doc_classes/LimboHSM.xml.

.. _class_LimboHSM:

LimboHSM
========

**Inherits:** :ref:`LimboState<class_LimboState>`

Event-based Hierarchical State Machine (HSM).

.. rst-class:: classref-introduction-group

Description
-----------

Event-based Hierarchical State Machine (HSM) that manages :ref:`LimboState<class_LimboState>` instances and facilitates transitions between them. LimboHSM is a :ref:`LimboState<class_LimboState>` in itself and can also serve as a child of another LimboHSM node.

.. rst-class:: classref-reftable-group

Properties
----------

.. table::
   :widths: auto

   +---------------------------------------------+-------------------------------------------------------------+-------+
   | :ref:`LimboState<class_LimboState>`         | :ref:`ANYSTATE<class_LimboHSM_property_ANYSTATE>`           |       |
   +---------------------------------------------+-------------------------------------------------------------+-------+
   | :ref:`LimboState<class_LimboState>`         | :ref:`initial_state<class_LimboHSM_property_initial_state>` |       |
   +---------------------------------------------+-------------------------------------------------------------+-------+
   | :ref:`UpdateMode<enum_LimboHSM_UpdateMode>` | :ref:`update_mode<class_LimboHSM_property_update_mode>`     | ``1`` |
   +---------------------------------------------+-------------------------------------------------------------+-------+

.. rst-class:: classref-reftable-group

Methods
-------

.. table::
   :widths: auto

   +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | |void|                              | :ref:`add_transition<class_LimboHSM_method_add_transition>`\ (\ from_state\: :ref:`LimboState<class_LimboState>`, to_state\: :ref:`LimboState<class_LimboState>`, event\: ``StringName``, guard\: ``Callable`` = Callable()\ ) |
   +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | |void|                              | :ref:`change_active_state<class_LimboHSM_method_change_active_state>`\ (\ state\: :ref:`LimboState<class_LimboState>`\ )                                                                                                       |
   +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | :ref:`LimboState<class_LimboState>` | :ref:`get_active_state<class_LimboHSM_method_get_active_state>`\ (\ ) |const|                                                                                                                                                  |
   +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | :ref:`LimboState<class_LimboState>` | :ref:`get_leaf_state<class_LimboHSM_method_get_leaf_state>`\ (\ ) |const|                                                                                                                                                      |
   +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | :ref:`LimboState<class_LimboState>` | :ref:`get_previous_active_state<class_LimboHSM_method_get_previous_active_state>`\ (\ ) |const|                                                                                                                                |
   +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | ``bool``                            | :ref:`has_transition<class_LimboHSM_method_has_transition>`\ (\ from_state\: :ref:`LimboState<class_LimboState>`, event\: ``StringName``\ ) |const|                                                                            |
   +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | |void|                              | :ref:`initialize<class_LimboHSM_method_initialize>`\ (\ agent\: ``Node``, parent_scope\: :ref:`Blackboard<class_Blackboard>` = null\ )                                                                                         |
   +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | |void|                              | :ref:`remove_transition<class_LimboHSM_method_remove_transition>`\ (\ from_state\: :ref:`LimboState<class_LimboState>`, event\: ``StringName``\ )                                                                              |
   +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | |void|                              | :ref:`set_active<class_LimboHSM_method_set_active>`\ (\ active\: ``bool``\ )                                                                                                                                                   |
   +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | |void|                              | :ref:`update<class_LimboHSM_method_update>`\ (\ delta\: ``float``\ )                                                                                                                                                           |
   +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

.. rst-class:: classref-section-separator

----

.. rst-class:: classref-descriptions-group

Signals
-------

.. _class_LimboHSM_signal_active_state_changed:

.. rst-class:: classref-signal

**active_state_changed**\ (\ current\: :ref:`LimboState<class_LimboState>`, previous\: :ref:`LimboState<class_LimboState>`\ ) :ref:`🔗<class_LimboHSM_signal_active_state_changed>`

Emitted when the currently active substate is switched to a different substate.

.. rst-class:: classref-section-separator

----

.. rst-class:: classref-descriptions-group

Enumerations
------------

.. _enum_LimboHSM_UpdateMode:

.. rst-class:: classref-enumeration

enum **UpdateMode**: :ref:`🔗<enum_LimboHSM_UpdateMode>`

.. _class_LimboHSM_constant_IDLE:

.. rst-class:: classref-enumeration-constant

:ref:`UpdateMode<enum_LimboHSM_UpdateMode>` **IDLE** = ``0``

Update the state machine during the idle process.

.. _class_LimboHSM_constant_PHYSICS:

.. rst-class:: classref-enumeration-constant

:ref:`UpdateMode<enum_LimboHSM_UpdateMode>` **PHYSICS** = ``1``

Update the state machine during the physics process.

.. _class_LimboHSM_constant_MANUAL:

.. rst-class:: classref-enumeration-constant

:ref:`UpdateMode<enum_LimboHSM_UpdateMode>` **MANUAL** = ``2``

Manually update the state machine by calling :ref:`update<class_LimboHSM_method_update>` from a script.

.. rst-class:: classref-section-separator

----

.. rst-class:: classref-descriptions-group

Property Descriptions
---------------------

.. _class_LimboHSM_property_ANYSTATE:

.. rst-class:: classref-property

:ref:`LimboState<class_LimboState>` **ANYSTATE** :ref:`🔗<class_LimboHSM_property_ANYSTATE>`

.. rst-class:: classref-property-setget

- :ref:`LimboState<class_LimboState>` **anystate**\ (\ )

Useful for defining a transition from any state.

.. rst-class:: classref-item-separator

----

.. _class_LimboHSM_property_initial_state:

.. rst-class:: classref-property

:ref:`LimboState<class_LimboState>` **initial_state** :ref:`🔗<class_LimboHSM_property_initial_state>`

.. rst-class:: classref-property-setget

- |void| **set_initial_state**\ (\ value\: :ref:`LimboState<class_LimboState>`\ )
- :ref:`LimboState<class_LimboState>` **get_initial_state**\ (\ )

The substate that becomes active when the state machine is activated using the :ref:`set_active<class_LimboHSM_method_set_active>` method. If not explicitly set, the first child of the LimboHSM will be considered the initial state.

.. rst-class:: classref-item-separator

----

.. _class_LimboHSM_property_update_mode:

.. rst-class:: classref-property

:ref:`UpdateMode<enum_LimboHSM_UpdateMode>` **update_mode** = ``1`` :ref:`🔗<class_LimboHSM_property_update_mode>`

.. rst-class:: classref-property-setget

- |void| **set_update_mode**\ (\ value\: :ref:`UpdateMode<enum_LimboHSM_UpdateMode>`\ )
- :ref:`UpdateMode<enum_LimboHSM_UpdateMode>` **get_update_mode**\ (\ )

Specifies when the state machine should be updated. See :ref:`UpdateMode<enum_LimboHSM_UpdateMode>`.

.. rst-class:: classref-section-separator

----

.. rst-class:: classref-descriptions-group

Method Descriptions
-------------------

.. _class_LimboHSM_method_add_transition:

.. rst-class:: classref-method

|void| **add_transition**\ (\ from_state\: :ref:`LimboState<class_LimboState>`, to_state\: :ref:`LimboState<class_LimboState>`, event\: ``StringName``, guard\: ``Callable`` = Callable()\ ) :ref:`🔗<class_LimboHSM_method_add_transition>`

Establishes a transition from one state to another when ``event`` is dispatched. Both ``from_state`` and ``to_state`` must be immediate children of this **LimboHSM**.

Optionally, a ``guard`` function can be specified, which must return a boolean value. If the guard function returns ``false``, the transition will not occur. The guard function is called immediately before the transition is considered. For a state-wide guard function, check out :ref:`LimboState.set_guard<class_LimboState_method_set_guard>`.

::

    func my_guard() -> bool:
        return is_some_condition_met()

.. rst-class:: classref-item-separator

----

.. _class_LimboHSM_method_change_active_state:

.. rst-class:: classref-method

|void| **change_active_state**\ (\ state\: :ref:`LimboState<class_LimboState>`\ ) :ref:`🔗<class_LimboHSM_method_change_active_state>`

Changes the currently active substate to ``state``. If ``state`` is already active, it will be exited and reentered.

\ ``state`` must be a child of this **LimboHSM**.

.. rst-class:: classref-item-separator

----

.. _class_LimboHSM_method_get_active_state:

.. rst-class:: classref-method

:ref:`LimboState<class_LimboState>` **get_active_state**\ (\ ) |const| :ref:`🔗<class_LimboHSM_method_get_active_state>`

Returns the currently active substate.

.. rst-class:: classref-item-separator

----

.. _class_LimboHSM_method_get_leaf_state:

.. rst-class:: classref-method

:ref:`LimboState<class_LimboState>` **get_leaf_state**\ (\ ) |const| :ref:`🔗<class_LimboHSM_method_get_leaf_state>`

Returns the currently active leaf state within the state machine.

.. rst-class:: classref-item-separator

----

.. _class_LimboHSM_method_get_previous_active_state:

.. rst-class:: classref-method

:ref:`LimboState<class_LimboState>` **get_previous_active_state**\ (\ ) |const| :ref:`🔗<class_LimboHSM_method_get_previous_active_state>`

Returns the previously active substate.

.. rst-class:: classref-item-separator

----

.. _class_LimboHSM_method_has_transition:

.. rst-class:: classref-method

``bool`` **has_transition**\ (\ from_state\: :ref:`LimboState<class_LimboState>`, event\: ``StringName``\ ) |const| :ref:`🔗<class_LimboHSM_method_has_transition>`

Returns ``true`` if there is a transition from ``from_state`` for a given ``event``.

.. rst-class:: classref-item-separator

----

.. _class_LimboHSM_method_initialize:

.. rst-class:: classref-method

|void| **initialize**\ (\ agent\: ``Node``, parent_scope\: :ref:`Blackboard<class_Blackboard>` = null\ ) :ref:`🔗<class_LimboHSM_method_initialize>`

Initiates the state and calls :ref:`LimboState._setup<class_LimboState_private_method__setup>` for both itself and all substates.

.. rst-class:: classref-item-separator

----

.. _class_LimboHSM_method_remove_transition:

.. rst-class:: classref-method

|void| **remove_transition**\ (\ from_state\: :ref:`LimboState<class_LimboState>`, event\: ``StringName``\ ) :ref:`🔗<class_LimboHSM_method_remove_transition>`

Removes a transition from a state associated with specific ``event``.

.. rst-class:: classref-item-separator

----

.. _class_LimboHSM_method_set_active:

.. rst-class:: classref-method

|void| **set_active**\ (\ active\: ``bool``\ ) :ref:`🔗<class_LimboHSM_method_set_active>`

When set to ``true``, switches the state to :ref:`initial_state<class_LimboHSM_property_initial_state>` and activates state processing according to :ref:`update_mode<class_LimboHSM_property_update_mode>`.

.. rst-class:: classref-item-separator

----

.. _class_LimboHSM_method_update:

.. rst-class:: classref-method

|void| **update**\ (\ delta\: ``float``\ ) :ref:`🔗<class_LimboHSM_method_update>`

Calls :ref:`LimboState._update<class_LimboState_private_method__update>` on itself and the active substate, with the call cascading down to the leaf state. This method is automatically triggered if :ref:`update_mode<class_LimboHSM_property_update_mode>` is not set to :ref:`MANUAL<class_LimboHSM_constant_MANUAL>`.

.. |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.)`
.. |void| replace:: :abbr:`void (No return value.)`
