Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reparenting an agent deactivates its HSM #131

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bt/bt_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions hsm/limbo_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions hsm/limbo_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class LimboState : public Node {
GDCLASS(LimboState, Node);

private:
bool active;
Ref<BlackboardPlan> blackboard_plan;
Node *agent;
Ref<Blackboard> blackboard;
Expand All @@ -43,8 +44,6 @@ class LimboState : public Node {
protected:
friend LimboHSM;

bool active;

static void _bind_methods();

void _notification(int p_what);
Expand Down Expand Up @@ -87,7 +86,7 @@ class LimboState : public Node {
_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();
Expand Down
Loading