Add BBParam::to_string()

This commit is contained in:
Serhii Snitsaruk 2022-10-25 23:07:27 +02:00
parent c73562a86e
commit ffeb7a2e5e
2 changed files with 12 additions and 1 deletions

View File

@ -5,6 +5,7 @@
#include "core/error_macros.h"
#include "core/object.h"
#include "core/variant.h"
#include "modules/limboai/limbo_utility.h"
VARIANT_ENUM_CAST(BBParam::ValueSource);
@ -35,8 +36,16 @@ void BBParam::set_variable(const String &p_value) {
emit_changed();
}
String BBParam::to_string() {
if (value_source == SAVED_VALUE) {
return String(saved_value);
} else {
return LimboUtility::get_singleton()->decorate_var(variable);
}
}
Variant BBParam::get_value(Object *p_agent, const Ref<Blackboard> &p_blackboard, const Variant &p_default) {
ERR_FAIL_COND_V(p_blackboard.is_valid(), p_default);
ERR_FAIL_COND_V(!p_blackboard.is_valid(), p_default);
if (value_source == SAVED_VALUE) {
return saved_value;

View File

@ -45,6 +45,8 @@ public:
void set_variable(const String &p_value);
String get_variable() const { return variable; }
virtual String to_string();
virtual Variant get_value(Object *p_agent, const Ref<Blackboard> &p_blackboard, const Variant &p_default = Variant());
BBParam();