limboai/bt/actions/bt_wait.cpp

28 lines
687 B
C++
Raw Normal View History

2022-08-29 12:06:48 +00:00
/* bt_wait.cpp */
#include "bt_wait.h"
2023-07-20 16:35:36 +00:00
#include "core/math/math_funcs.h"
#include "core/object/class_db.h"
#include "core/object/object.h"
#include "core/variant/variant.h"
2022-08-29 12:06:48 +00:00
String BTWait::_generate_name() const {
return vformat("Wait %s sec", Math::snapped(duration, 0.001));
2022-08-29 12:06:48 +00:00
}
int BTWait::_tick(double p_delta) {
if (get_elapsed_time() < duration) {
2022-08-29 12:06:48 +00:00
return RUNNING;
} else {
return SUCCESS;
}
}
void BTWait::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_duration", "p_value"), &BTWait::set_duration);
ClassDB::bind_method(D_METHOD("get_duration"), &BTWait::get_duration);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "duration"), "set_duration", "get_duration");
2022-08-29 12:06:48 +00:00
}