2023-07-21 09:50:06 +00:00
|
|
|
/**
|
|
|
|
* bt_wait_ticks.cpp
|
|
|
|
* =============================================================================
|
2024-03-04 20:36:16 +00:00
|
|
|
* Copyright 2021-2024 Serhii Snitsaruk
|
2023-07-21 09:50:06 +00:00
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style
|
|
|
|
* license that can be found in the LICENSE file or at
|
|
|
|
* https://opensource.org/licenses/MIT.
|
|
|
|
* =============================================================================
|
|
|
|
*/
|
2022-08-29 12:06:48 +00:00
|
|
|
|
|
|
|
#include "bt_wait_ticks.h"
|
2023-07-20 16:35:36 +00:00
|
|
|
|
2024-01-06 23:47:46 +00:00
|
|
|
String BTWaitTicks::_generate_name() {
|
2022-08-29 12:06:48 +00:00
|
|
|
return vformat("WaitTicks x%d", num_ticks);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BTWaitTicks::_enter() {
|
2022-12-17 10:26:48 +00:00
|
|
|
num_passed = 0;
|
2022-08-29 12:06:48 +00:00
|
|
|
}
|
|
|
|
|
2023-09-19 11:43:26 +00:00
|
|
|
BT::Status BTWaitTicks::_tick(double p_delta) {
|
2022-12-17 10:26:48 +00:00
|
|
|
if (num_passed < num_ticks) {
|
2023-09-08 09:19:19 +00:00
|
|
|
num_passed += 1;
|
2022-08-29 12:06:48 +00:00
|
|
|
return RUNNING;
|
|
|
|
} else {
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BTWaitTicks::_bind_methods() {
|
2024-03-04 20:36:16 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_num_ticks", "num_ticks"), &BTWaitTicks::set_num_ticks);
|
2022-08-29 12:06:48 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("get_num_ticks"), &BTWaitTicks::get_num_ticks);
|
|
|
|
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "num_ticks"), "set_num_ticks", "get_num_ticks");
|
|
|
|
}
|