2023-07-21 09:50:06 +00:00
|
|
|
/**
|
|
|
|
* bt_wait.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.h"
|
2023-07-20 16:35:36 +00:00
|
|
|
|
2024-01-06 23:47:46 +00:00
|
|
|
String BTWait::_generate_name() {
|
2023-04-10 05:54:02 +00:00
|
|
|
return vformat("Wait %s sec", Math::snapped(duration, 0.001));
|
2022-08-29 12:06:48 +00:00
|
|
|
}
|
|
|
|
|
2023-09-19 11:43:26 +00:00
|
|
|
BT::Status BTWait::_tick(double p_delta) {
|
2023-04-14 08:16:26 +00:00
|
|
|
if (get_elapsed_time() < duration) {
|
2022-08-29 12:06:48 +00:00
|
|
|
return RUNNING;
|
|
|
|
} else {
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BTWait::_bind_methods() {
|
2024-03-04 20:36:16 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_duration", "duration_sec"), &BTWait::set_duration);
|
2022-08-29 12:06:48 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("get_duration"), &BTWait::get_duration);
|
|
|
|
|
2022-12-15 07:26:52 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "duration"), "set_duration", "get_duration");
|
2022-08-29 12:06:48 +00:00
|
|
|
}
|