Fix reparenting an agent deactivates its HSM

This commit is contained in:
Serhii Snitsaruk 2024-06-03 14:30:30 +02:00
parent 2c8e0d2da0
commit 06de52492a
No known key found for this signature in database
GPG Key ID: A965EF8799FFEC2D
3 changed files with 5 additions and 6 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -32,6 +32,7 @@ class LimboState : public Node {
GDCLASS(LimboState, Node);
private:
bool active;
Ref<BlackboardPlan> blackboard_plan;
Node *agent;
Ref<Blackboard> 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();