Fix precision issues for _generate_name() tasks

This commit is contained in:
Serhii Snitsaruk 2023-04-10 07:54:02 +02:00
parent ec2fd2b143
commit 6fc97c43cd
5 changed files with 12 additions and 5 deletions

View File

@ -1,9 +1,12 @@
/* bt_random_wait.cpp */
#include "bt_random_wait.h"
#include "core/math/math_funcs.h"
String BTRandomWait::_generate_name() const {
return vformat("Wait %s to %s sec", duration_min_max.x, duration_min_max.y);
return vformat("Wait %s to %s sec",
Math::snapped(duration_min_max.x, 0.001),
Math::snapped(duration_min_max.y, 0.001));
}
void BTRandomWait::_enter() {

View File

@ -1,12 +1,13 @@
/* bt_wait.cpp */
#include "bt_wait.h"
#include "core/math/math_funcs.h"
#include "core/object/class_db.h"
#include "core/object/object.h"
#include "core/variant/variant.h"
String BTWait::_generate_name() const {
return vformat("Wait %ss", duration);
return vformat("Wait %s sec", Math::snapped(duration, 0.001));
}
void BTWait::_enter() {

View File

@ -1,12 +1,13 @@
/* bt_cooldown.cpp */
#include "bt_cooldown.h"
#include "core/math/math_funcs.h"
#include "core/object/class_db.h"
#include "core/variant/array.h"
#include "scene/main/scene_tree.h"
String BTCooldown::_generate_name() const {
return vformat("Cooldown %ss", duration);
return vformat("Cooldown %s sec", Math::snapped(duration, 0.001));
}
void BTCooldown::_setup() {

View File

@ -2,13 +2,14 @@
#include "bt_delay.h"
#include "core/error/error_macros.h"
#include "core/math/math_funcs.h"
#include "core/object/class_db.h"
#include "core/object/object.h"
#include "core/variant/array.h"
#include "core/variant/variant.h"
String BTDelay::_generate_name() const {
return vformat("Delay %ss", seconds);
return vformat("Delay %s sec", Math::snapped(seconds, 0.001));
}
void BTDelay::_enter() {

View File

@ -1,9 +1,10 @@
/* bt_time_limit.cpp */
#include "bt_time_limit.h"
#include "core/math/math_funcs.h"
String BTTimeLimit::_generate_name() const {
return vformat("TimeLimit %ss", time_limit);
return vformat("TimeLimit %s sec", Math::snapped(time_limit, 0.001));
}
void BTTimeLimit::_enter() {