diff --git a/doc/source/classes/class_limbohsm.rst b/doc/source/classes/class_limbohsm.rst index bed9f79..4c25f3a 100644 --- a/doc/source/classes/class_limbohsm.rst +++ b/doc/source/classes/class_limbohsm.rst @@ -45,27 +45,27 @@ Methods .. table:: :widths: auto - +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | |void| | :ref:`add_transition`\ (\ from_state\: :ref:`LimboState`, to_state\: :ref:`LimboState`, event\: ``StringName``\ ) | - +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | |void| | :ref:`change_active_state`\ (\ state\: :ref:`LimboState`\ ) | - +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | :ref:`LimboState` | :ref:`get_active_state`\ (\ ) |const| | - +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | :ref:`LimboState` | :ref:`get_leaf_state`\ (\ ) |const| | - +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | :ref:`LimboState` | :ref:`get_previous_active_state`\ (\ ) |const| | - +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | ``bool`` | :ref:`has_transition`\ (\ from_state\: :ref:`LimboState`, event\: ``StringName``\ ) |const| | - +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | |void| | :ref:`initialize`\ (\ agent\: ``Node``, parent_scope\: :ref:`Blackboard` = null\ ) | - +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | |void| | :ref:`remove_transition`\ (\ from_state\: :ref:`LimboState`, event\: ``StringName``\ ) | - +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | |void| | :ref:`set_active`\ (\ active\: ``bool``\ ) | - +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | |void| | :ref:`update`\ (\ delta\: ``float``\ ) | - +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | |void| | :ref:`add_transition`\ (\ from_state\: :ref:`LimboState`, to_state\: :ref:`LimboState`, event\: ``StringName``, guard\: ``Callable`` = Callable()\ ) | + +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | |void| | :ref:`change_active_state`\ (\ state\: :ref:`LimboState`\ ) | + +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | :ref:`LimboState` | :ref:`get_active_state`\ (\ ) |const| | + +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | :ref:`LimboState` | :ref:`get_leaf_state`\ (\ ) |const| | + +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | :ref:`LimboState` | :ref:`get_previous_active_state`\ (\ ) |const| | + +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | ``bool`` | :ref:`has_transition`\ (\ from_state\: :ref:`LimboState`, event\: ``StringName``\ ) |const| | + +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | |void| | :ref:`initialize`\ (\ agent\: ``Node``, parent_scope\: :ref:`Blackboard` = null\ ) | + +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | |void| | :ref:`remove_transition`\ (\ from_state\: :ref:`LimboState`, event\: ``StringName``\ ) | + +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | |void| | :ref:`set_active`\ (\ active\: ``bool``\ ) | + +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | |void| | :ref:`update`\ (\ delta\: ``float``\ ) | + +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator @@ -191,9 +191,16 @@ Method Descriptions .. rst-class:: classref-method -|void| **add_transition**\ (\ from_state\: :ref:`LimboState`, to_state\: :ref:`LimboState`, event\: ``StringName``\ ) :ref:`🔗` +|void| **add_transition**\ (\ from_state\: :ref:`LimboState`, to_state\: :ref:`LimboState`, event\: ``StringName``, guard\: ``Callable`` = Callable()\ ) :ref:`🔗` -Establishes a transition from one state to another when ``event`` is dispatched. Both ``from_state`` and ``to_state`` must be immediate children of this state. +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`. + +:: + + func my_guard() -> bool: + return is_some_condition_met() .. rst-class:: classref-item-separator diff --git a/doc_classes/LimboHSM.xml b/doc_classes/LimboHSM.xml index fc6652f..6efd5ee 100644 --- a/doc_classes/LimboHSM.xml +++ b/doc_classes/LimboHSM.xml @@ -14,8 +14,14 @@ + - Establishes a transition from one state to another when [param event] is dispatched. Both [param from_state] and [param to_state] must be immediate children of this state. + Establishes a transition from one state to another when [param event] is dispatched. Both [param from_state] and [param to_state] must be immediate children of this [LimboHSM]. + Optionally, a [param guard] function can be specified, which must return a boolean value. If the guard function returns [code]false[/code], the transition will not occur. The guard function is called immediately before the transition is considered. For a state-wide guard function, check out [method LimboState.set_guard]. + [codeblock] + func my_guard() -> bool: + return is_some_condition_met() + [/codeblock]