Skip to content

Commit

Permalink
Fix BTState not honoring API virtual methods
Browse files Browse the repository at this point in the history
  • Loading branch information
limbonaut committed Mar 2, 2024
1 parent c96e201 commit f5d21e2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions bt/bt_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void BTState::_update_blackboard_plan() {
}

void BTState::_setup() {
LimboState::_setup();
ERR_FAIL_COND_MSG(behavior_tree.is_null(), "BTState: BehaviorTree is not assigned.");
tree_instance = behavior_tree->instantiate(get_agent(), get_blackboard());

Expand All @@ -57,19 +58,21 @@ void BTState::_setup() {
}

void BTState::_exit() {
ERR_FAIL_COND(tree_instance == nullptr);
LimboState::_exit();
ERR_FAIL_NULL(tree_instance);
tree_instance->abort();
}

void BTState::_update(double p_delta) {
ERR_FAIL_COND(tree_instance == nullptr);
VCALL_ARGS(_update, p_delta);
ERR_FAIL_NULL(tree_instance);
int status = tree_instance->execute(p_delta);
emit_signal(LimboStringNames::get_singleton()->updated, p_delta);
if (status == BTTask::SUCCESS) {
get_root()->dispatch(success_event, Variant());
} else if (status == BTTask::FAILURE) {
get_root()->dispatch(failure_event, Variant());
}
emit_signal(LW_NAME(updated), p_delta);
}

void BTState::_notification(int p_notification) {
Expand Down

0 comments on commit f5d21e2

Please sign in to comment.