diff --git a/bt/bt_state.cpp b/bt/bt_state.cpp index dd1c659..1202a8a 100644 --- a/bt/bt_state.cpp +++ b/bt/bt_state.cpp @@ -74,7 +74,7 @@ void BTState::_exit() { void BTState::_update(double p_delta) { VCALL_ARGS(_update, p_delta); - if (!active) { + if (!is_active()) { // Bail out if a transition happened in the meantime. return; } diff --git a/hsm/limbo_state.cpp b/hsm/limbo_state.cpp index f704dc1..cf53c4f 100644 --- a/hsm/limbo_state.cpp +++ b/hsm/limbo_state.cpp @@ -185,8 +185,8 @@ void LimboState::_notification(int p_what) { _update_blackboard_plan(); } } break; - case NOTIFICATION_EXIT_TREE: { - if (active) { + case NOTIFICATION_PREDELETE: { + if (is_active()) { _exit(); } } break; diff --git a/hsm/limbo_state.h b/hsm/limbo_state.h index a4d9b00..5c35c0c 100644 --- a/hsm/limbo_state.h +++ b/hsm/limbo_state.h @@ -32,6 +32,7 @@ class LimboState : public Node { GDCLASS(LimboState, Node); private: + bool active; Ref blackboard_plan; Node *agent; Ref blackboard; @@ -43,8 +44,6 @@ private: protected: friend LimboHSM; - bool active; - static void _bind_methods(); void _notification(int p_what); @@ -87,7 +86,7 @@ public: _FORCE_INLINE_ StringName event_finished() const { return LW_NAME(EVENT_FINISHED); } LimboState *get_root() const; _FORCE_INLINE_ bool is_root() const { return !(get_parent() && IS_CLASS(get_parent(), LimboState)); } - bool is_active() const { return active; } + _FORCE_INLINE_ bool is_active() const { return active; } void set_guard(const Callable &p_guard_callable); void clear_guard();