Fix BTState not honoring API virtual methods

This commit is contained in:
Serhii Snitsaruk 2024-03-02 20:19:38 +01:00
parent c96e2019af
commit f5d21e2669
1 changed files with 6 additions and 3 deletions

View File

@ -46,6 +46,7 @@ void BTState::_update_blackboard_plan() {
} }
void BTState::_setup() { void BTState::_setup() {
LimboState::_setup();
ERR_FAIL_COND_MSG(behavior_tree.is_null(), "BTState: BehaviorTree is not assigned."); ERR_FAIL_COND_MSG(behavior_tree.is_null(), "BTState: BehaviorTree is not assigned.");
tree_instance = behavior_tree->instantiate(get_agent(), get_blackboard()); tree_instance = behavior_tree->instantiate(get_agent(), get_blackboard());
@ -57,19 +58,21 @@ void BTState::_setup() {
} }
void BTState::_exit() { void BTState::_exit() {
ERR_FAIL_COND(tree_instance == nullptr); LimboState::_exit();
ERR_FAIL_NULL(tree_instance);
tree_instance->abort(); tree_instance->abort();
} }
void BTState::_update(double p_delta) { 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); int status = tree_instance->execute(p_delta);
emit_signal(LimboStringNames::get_singleton()->updated, p_delta);
if (status == BTTask::SUCCESS) { if (status == BTTask::SUCCESS) {
get_root()->dispatch(success_event, Variant()); get_root()->dispatch(success_event, Variant());
} else if (status == BTTask::FAILURE) { } else if (status == BTTask::FAILURE) {
get_root()->dispatch(failure_event, Variant()); get_root()->dispatch(failure_event, Variant());
} }
emit_signal(LW_NAME(updated), p_delta);
} }
void BTState::_notification(int p_notification) { void BTState::_notification(int p_notification) {