diff --git a/bt/bt_player.cpp b/bt/bt_player.cpp index 55e5a7f..571e8b2 100644 --- a/bt/bt_player.cpp +++ b/bt/bt_player.cpp @@ -90,7 +90,7 @@ void BTPlayer::update(double p_delta) { } void BTPlayer::restart() { - tree_instance->cancel(); + tree_instance->abort(); set_active(true); } diff --git a/bt/bt_state.cpp b/bt/bt_state.cpp index 9f0a711..880e713 100644 --- a/bt/bt_state.cpp +++ b/bt/bt_state.cpp @@ -30,7 +30,7 @@ void BTState::_setup() { void BTState::_exit() { ERR_FAIL_COND(tree_instance == nullptr); - tree_instance->cancel(); + tree_instance->abort(); } void BTState::_update(double p_delta) { diff --git a/bt/tasks/bt_task.cpp b/bt/tasks/bt_task.cpp index 47b4774..dcc8ba0 100644 --- a/bt/tasks/bt_task.cpp +++ b/bt/tasks/bt_task.cpp @@ -161,7 +161,7 @@ BT::Status BTTask::execute(double p_delta) { // Reset children status. if (data.status != FRESH) { for (int i = 0; i < get_child_count(); i++) { - data.children.get(i)->cancel(); + data.children.get(i)->abort(); } } if (!GDVIRTUAL_CALL(_enter)) { @@ -184,9 +184,9 @@ BT::Status BTTask::execute(double p_delta) { return data.status; } -void BTTask::cancel() { +void BTTask::abort() { for (int i = 0; i < data.children.size(); i++) { - get_child(i)->cancel(); + get_child(i)->abort(); } if (data.status == RUNNING) { if (!GDVIRTUAL_CALL(_exit)) { @@ -320,8 +320,7 @@ void BTTask::_bind_methods() { ClassDB::bind_method(D_METHOD("next_sibling"), &BTTask::next_sibling); ClassDB::bind_method(D_METHOD("print_tree", "p_initial_tabs"), &BTTask::print_tree, Variant(0)); ClassDB::bind_method(D_METHOD("get_task_name"), &BTTask::get_task_name); - ClassDB::bind_method(D_METHOD("get_custom_name"), &BTTask::get_custom_name); - ClassDB::bind_method(D_METHOD("set_custom_name", "p_name"), &BTTask::set_custom_name); + ClassDB::bind_method(D_METHOD("abort"), &BTTask::abort); // Properties, setters and getters. ClassDB::bind_method(D_METHOD("get_agent"), &BTTask::get_agent); @@ -332,6 +331,8 @@ void BTTask::_bind_methods() { ClassDB::bind_method(D_METHOD("get_parent"), &BTTask::get_parent); ClassDB::bind_method(D_METHOD("get_status"), &BTTask::get_status); ClassDB::bind_method(D_METHOD("get_elapsed_time"), &BTTask::get_elapsed_time); + ClassDB::bind_method(D_METHOD("get_custom_name"), &BTTask::get_custom_name); + ClassDB::bind_method(D_METHOD("set_custom_name", "p_name"), &BTTask::set_custom_name); ADD_PROPERTY(PropertyInfo(Variant::STRING, "custom_name"), "set_custom_name", "get_custom_name"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "agent", PROPERTY_HINT_RESOURCE_TYPE, "Node", PROPERTY_USAGE_NONE), "set_agent", "get_agent"); diff --git a/bt/tasks/bt_task.h b/bt/tasks/bt_task.h index 7e2685a..da94d8b 100644 --- a/bt/tasks/bt_task.h +++ b/bt/tasks/bt_task.h @@ -103,7 +103,7 @@ public: virtual PackedStringArray get_configuration_warnings() const; Status execute(double p_delta); - void cancel(); + void abort(); Status get_status() const { return data.status; } double get_elapsed_time() const { return data.elapsed; }; diff --git a/bt/tasks/composites/bt_dynamic_selector.cpp b/bt/tasks/composites/bt_dynamic_selector.cpp index af63888..d5f9195 100644 --- a/bt/tasks/composites/bt_dynamic_selector.cpp +++ b/bt/tasks/composites/bt_dynamic_selector.cpp @@ -27,7 +27,7 @@ BT::Status BTDynamicSelector::_tick(double p_delta) { // If the last node ticked is earlier in the tree than the previous runner, // cancel previous runner. if (last_running_idx > i && get_child(last_running_idx)->get_status() == RUNNING) { - get_child(last_running_idx)->cancel(); + get_child(last_running_idx)->abort(); } last_running_idx = i; return status; diff --git a/bt/tasks/composites/bt_dynamic_sequence.cpp b/bt/tasks/composites/bt_dynamic_sequence.cpp index d3902e4..5c6fab5 100644 --- a/bt/tasks/composites/bt_dynamic_sequence.cpp +++ b/bt/tasks/composites/bt_dynamic_sequence.cpp @@ -27,7 +27,7 @@ BT::Status BTDynamicSequence::_tick(double p_delta) { // If the last node ticked is earlier in the tree than the previous runner, // cancel previous runner. if (last_running_idx > i && get_child(last_running_idx)->get_status() == RUNNING) { - get_child(last_running_idx)->cancel(); + get_child(last_running_idx)->abort(); } last_running_idx = i; return status; diff --git a/bt/tasks/composites/bt_parallel.cpp b/bt/tasks/composites/bt_parallel.cpp index 74c192e..8afee63 100644 --- a/bt/tasks/composites/bt_parallel.cpp +++ b/bt/tasks/composites/bt_parallel.cpp @@ -15,7 +15,7 @@ void BTParallel::_enter() { for (int i = 0; i < get_child_count(); i++) { - get_child(i)->cancel(); + get_child(i)->abort(); } } diff --git a/bt/tasks/decorators/bt_time_limit.cpp b/bt/tasks/decorators/bt_time_limit.cpp index 6be1044..1ea3693 100644 --- a/bt/tasks/decorators/bt_time_limit.cpp +++ b/bt/tasks/decorators/bt_time_limit.cpp @@ -26,7 +26,7 @@ BT::Status BTTimeLimit::_tick(double p_delta) { ERR_FAIL_COND_V_MSG(get_child_count() == 0, FAILURE, "BT decorator has no child."); Status status = get_child(0)->execute(p_delta); if (status == RUNNING && get_elapsed_time() >= time_limit) { - get_child(0)->cancel(); + get_child(0)->abort(); return FAILURE; } return status; diff --git a/tests/test_task.h b/tests/test_task.h index e2b7224..2247cd0 100644 --- a/tests/test_task.h +++ b/tests/test_task.h @@ -185,7 +185,7 @@ TEST_CASE("[Modules][LimboAI] BTTask") { CHECK(task->get_elapsed_time() == 0.0); } SUBCASE("When cancelled") { - task->cancel(); + task->abort(); CHECK(task->get_elapsed_time() == 0.0); } } diff --git a/tests/test_wait_actions.h b/tests/test_wait_actions.h index ee15506..ce55c86 100644 --- a/tests/test_wait_actions.h +++ b/tests/test_wait_actions.h @@ -102,7 +102,7 @@ TEST_CASE("[Modules][LimboAI] BTRandomWait") { num_undefined += 1; } break; } - wait->cancel(); + wait->abort(); } // * Expected ~500/500 SUCCESS/RUNNING.