LimboState
Inherits:
Inherited By: BTState, LimboHSM
A state node for Hierarchical State Machines (HSM).
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 _enter, _exit, _setup, and _update. Alternatively, you can delegate state implementation to external methods using the call_on_* methods.
For additional details on state machines, refer to LimboHSM.
Properties
|
|
|
|
Methods
void |
_enter() virtual |
void |
_exit() virtual |
void |
_setup() virtual |
void |
_update(delta: |
void |
add_event_handler(event: |
call_on_enter(callable: |
|
call_on_exit(callable: |
|
call_on_update(callable: |
|
void |
|
|
dispatch(event: |
get_root() const |
|
|
is_active() const |
named(name: |
|
void |
set_guard(guard_callable: |
Signals
entered() 🔗
Emitted when the state is entered.
exited() 🔗
Emitted when the state is exited.
setup() 🔗
Emitted when the state is initialized.
updated(delta: float) 🔗
Emitted when the state is updated.
Property Descriptions
StringName EVENT_FINISHED 🔗
StringNameevent_finished()
A commonly used event that indicates that the state has finished its work.
Node agent 🔗
void set_agent(value:
Node)Nodeget_agent()
An agent associated with the state, assigned during initialization.
Blackboard blackboard 🔗
Blackboard get_blackboard()
A key/value data store shared by states within the state machine to which this state belongs.
BlackboardPlan blackboard_plan 🔗
void set_blackboard_plan(value: BlackboardPlan)
BlackboardPlan get_blackboard_plan()
Stores and manages variables that will be used in constructing new Blackboard instances.
Method Descriptions
void _enter() virtual 🔗
Called when the state is entered.
void _exit() virtual 🔗
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 Node.queue_free or the scene changes). Due to implementation details, _exit will not be called on Object.free!
void _setup() virtual 🔗
Called once during initialization. Use this method to initialize your state.
void _update(delta: float) virtual 🔗
Called during the update. Implement your state’s behavior with this method.
void add_event_handler(event: StringName, handler: Callable) 🔗
Registers a handler to be called when event is dispatched. The handler function should have the following signature:
func my_event_handler(cargo=null) -> bool:
If the handler returns true, the event will be consumed. Cargo is an optional parameter that can be passed to the handler. See also dispatch.
LimboState call_on_enter(callable: Callable) 🔗
A chained method that connects the entered signal to a callable.
LimboState call_on_exit(callable: Callable) 🔗
A chained method that connects the exited signal to a callable.
LimboState call_on_update(callable: Callable) 🔗
A chained method that connects the updated signal to a callable.
void clear_guard() 🔗
Clears the guard function, removing the Callable previously set by set_guard.
bool dispatch(event: StringName, cargo: Variant = null) 🔗
Recursively dispatches a state machine event named event with an optional argument 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 add_event_handler.
LimboState get_root() const 🔗
Returns the root LimboState.
bool is_active() const 🔗
Returns true if it is currently active, meaning it is the active substate of the parent LimboHSM.
LimboState named(name: String) 🔗
A chained method for setting the name of this state.
void set_guard(guard_callable: 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.