limboai/doc_classes/LimboState.xml

152 lines
6.1 KiB
XML

<?xml version="1.0" encoding="UTF-8" ?>
<class name="LimboState" inherits="Node" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A state node for Hierarchical State Machines (HSM).
</brief_description>
<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 [method _enter], [method _exit], [method _setup], and [method _update]. Alternatively, you can delegate state implementation to external methods using the [code]call_on_*[/code] methods.
For additional details on state machines, refer to [LimboHSM].
</description>
<tutorials>
</tutorials>
<methods>
<method name="_enter" qualifiers="virtual">
<return type="void" />
<description>
Called when the state is entered.
</description>
</method>
<method name="_exit" qualifiers="virtual">
<return type="void" />
<description>
Called when the state is exited. This happens on a transition to another state, and when the state machine is removed from the scene tree (e.g., when the node is freed with [method Node.queue_free] or the scene changes). Due to implementation details, [method _exit] will not be called on [method Object.free]!
</description>
</method>
<method name="_setup" qualifiers="virtual">
<return type="void" />
<description>
Called once during initialization. Use this method to initialize your state.
</description>
</method>
<method name="_update" qualifiers="virtual">
<return type="void" />
<param index="0" name="delta" type="float" />
<description>
Called during the update. Implement your state's behavior with this method.
</description>
</method>
<method name="add_event_handler">
<return type="void" />
<param index="0" name="event" type="StringName" />
<param index="1" name="handler" type="Callable" />
<description>
Registers a [param handler] to be called when [param event] is dispatched. The handler function should have the following signature:
[codeblock]
func my_event_handler(cargo=null) -&gt; bool:
[/codeblock]
If the handler returns [code]true[/code], the event will be consumed. Cargo is an optional parameter that can be passed to the handler. See also [method dispatch].
</description>
</method>
<method name="call_on_enter">
<return type="LimboState" />
<param index="0" name="callable" type="Callable" />
<description>
A chained method that connects the [signal entered] signal to a [param callable].
</description>
</method>
<method name="call_on_exit">
<return type="LimboState" />
<param index="0" name="callable" type="Callable" />
<description>
A chained method that connects the [signal exited] signal to a [param callable].
</description>
</method>
<method name="call_on_update">
<return type="LimboState" />
<param index="0" name="callable" type="Callable" />
<description>
A chained method that connects the [signal updated] signal to a [param callable].
</description>
</method>
<method name="clear_guard">
<return type="void" />
<description>
Clears the guard function, removing the [Callable] previously set by [method set_guard].
</description>
</method>
<method name="dispatch">
<return type="bool" />
<param index="0" name="event" type="StringName" />
<param index="1" name="cargo" type="Variant" default="null" />
<description>
Recursively dispatches a state machine event named [param event] with an optional argument [param cargo]. Returns [code]true[/code] 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 [method add_event_handler].
</description>
</method>
<method name="get_root" qualifiers="const">
<return type="LimboState" />
<description>
Returns the root [LimboState].
</description>
</method>
<method name="is_active" qualifiers="const">
<return type="bool" />
<description>
Returns [code]true[/code] if it is currently active, meaning it is the active substate of the parent [LimboHSM].
</description>
</method>
<method name="named">
<return type="LimboState" />
<param index="0" name="name" type="String" />
<description>
A chained method for setting the name of this state.
</description>
</method>
<method name="set_guard">
<return type="void" />
<param index="0" name="guard_callable" type="Callable" />
<description>
Sets the guard function, which is a function called each time a transition to this state is considered. If the function returns [code]false[/code], the transition will be disallowed.
</description>
</method>
</methods>
<members>
<member name="EVENT_FINISHED" type="StringName" setter="" getter="event_finished">
A commonly used event that indicates that the state has finished its work.
</member>
<member name="agent" type="Node" setter="set_agent" getter="get_agent">
An agent associated with the state, assigned during initialization.
</member>
<member name="blackboard" type="Blackboard" setter="" getter="get_blackboard">
A key/value data store shared by states within the state machine to which this state belongs.
</member>
<member name="blackboard_plan" type="BlackboardPlan" setter="set_blackboard_plan" getter="get_blackboard_plan">
Stores and manages variables that will be used in constructing new [Blackboard] instances.
</member>
</members>
<signals>
<signal name="entered">
<description>
Emitted when the state is entered.
</description>
</signal>
<signal name="exited">
<description>
Emitted when the state is exited.
</description>
</signal>
<signal name="setup">
<description>
Emitted when the state is initialized.
</description>
</signal>
<signal name="updated">
<param index="0" name="delta" type="float" />
<description>
Emitted when the state is updated.
</description>
</signal>
</signals>
</class>