LimboHSM
Inherits: LimboState
Event-based Hierarchical State Machine (HSM).
Description
Event-based Hierarchical State Machine (HSM) that manages LimboState instances and facilitates transitions between them. LimboHSM is a LimboState in itself and can also serve as a child of another LimboHSM node.
Properties
|
Methods
void |
add_transition(from_state: LimboState, to_state: LimboState, event: |
void |
change_active_state(state: LimboState) |
get_active_state() const |
|
get_leaf_state() const |
|
get_previous_active_state() const |
|
|
has_transition(from_state: LimboState, event: |
void |
initialize(agent: |
void |
remove_transition(from_state: LimboState, event: |
void |
set_active(active: |
void |
update(delta: |
Signals
active_state_changed(current: LimboState, previous: LimboState) 🔗
Emitted when the currently active substate is switched to a different substate.
Enumerations
enum UpdateMode: 🔗
UpdateMode IDLE = 0
Update the state machine during the idle process.
UpdateMode PHYSICS = 1
Update the state machine during the physics process.
UpdateMode MANUAL = 2
Manually update the state machine by calling update from a script.
Property Descriptions
LimboState ANYSTATE 🔗
LimboState anystate()
Useful for defining a transition from any state.
LimboState initial_state 🔗
void set_initial_state(value: LimboState)
LimboState get_initial_state()
The substate that becomes active when the state machine is activated using the set_active method. If not explicitly set, the first child of the LimboHSM will be considered the initial state.
UpdateMode update_mode = 1 🔗
void set_update_mode(value: UpdateMode)
UpdateMode get_update_mode()
Specifies when the state machine should be updated. See UpdateMode.
Method Descriptions
void add_transition(from_state: LimboState, to_state: LimboState, event: StringName, guard: Callable = Callable()) 🔗
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 LimboState.set_guard.
func my_guard() -> bool:
return is_some_condition_met()
void change_active_state(state: LimboState) 🔗
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.
LimboState get_active_state() const 🔗
Returns the currently active substate.
LimboState get_leaf_state() const 🔗
Returns the currently active leaf state within the state machine.
LimboState get_previous_active_state() const 🔗
Returns the previously active substate.
bool has_transition(from_state: LimboState, event: StringName) const 🔗
Returns true if there is a transition from from_state for a given event.
void initialize(agent: Node, parent_scope: Blackboard = null) 🔗
Initiates the state and calls LimboState._setup for both itself and all substates.
void remove_transition(from_state: LimboState, event: StringName) 🔗
Removes a transition from a state associated with specific event.
void set_active(active: bool) 🔗
When set to true, switches the state to initial_state and activates state processing according to update_mode.
void update(delta: float) 🔗
Calls LimboState._update on itself and the active substate, with the call cascading down to the leaf state. This method is automatically triggered if update_mode is not set to MANUAL.