Change BB variable members to StringName
This commit is contained in:
parent
b7d1bc11ab
commit
350c27abbc
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* bb_param.cpp
|
||||
* =============================================================================
|
||||
* Copyright 2021-2023 Serhii Snitsaruk
|
||||
* Copyright 2021-2024 Serhii Snitsaruk
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
|
@ -49,8 +49,8 @@ void BBParam::set_saved_value(Variant p_value) {
|
|||
emit_changed();
|
||||
}
|
||||
|
||||
void BBParam::set_variable(const String &p_value) {
|
||||
variable = p_value;
|
||||
void BBParam::set_variable(const StringName &p_variable) {
|
||||
variable = p_variable;
|
||||
_update_name();
|
||||
emit_changed();
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ void BBParam::_get_property_list(List<PropertyInfo> *p_list) const {
|
|||
if (value_source == ValueSource::SAVED_VALUE) {
|
||||
p_list->push_back(PropertyInfo(get_type(), "saved_value"));
|
||||
} else {
|
||||
p_list->push_back(PropertyInfo(Variant::STRING, "variable"));
|
||||
p_list->push_back(PropertyInfo(Variant::STRING_NAME, "variable"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ void BBParam::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("get_value", "p_agent", "p_blackboard", "p_default"), &BBParam::get_value, Variant());
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "value_source", PROPERTY_HINT_ENUM, "Saved Value,Blackboard Var"), "set_value_source", "get_value_source");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "variable", PROPERTY_HINT_NONE, "", 0), "set_variable", "get_variable");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "variable", PROPERTY_HINT_NONE, "", 0), "set_variable", "get_variable");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::NIL, "saved_value", PROPERTY_HINT_NONE, "", 0), "set_saved_value", "get_saved_value");
|
||||
|
||||
BIND_ENUM_CONSTANT(SAVED_VALUE);
|
||||
|
@ -120,7 +120,6 @@ void BBParam::_bind_methods() {
|
|||
|
||||
BBParam::BBParam() {
|
||||
value_source = SAVED_VALUE;
|
||||
variable = "";
|
||||
|
||||
_assign_default_value();
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
private:
|
||||
ValueSource value_source;
|
||||
Variant saved_value;
|
||||
String variable;
|
||||
StringName variable;
|
||||
|
||||
_FORCE_INLINE_ void _update_name() {
|
||||
set_name((value_source == SAVED_VALUE) ? String(saved_value) : LimboUtility::get_singleton()->decorate_var(variable));
|
||||
|
@ -70,8 +70,8 @@ public:
|
|||
void set_saved_value(Variant p_value);
|
||||
Variant get_saved_value();
|
||||
|
||||
void set_variable(const String &p_value);
|
||||
String get_variable() const { return variable; }
|
||||
void set_variable(const StringName &p_variable);
|
||||
StringName get_variable() const { return variable; }
|
||||
|
||||
#ifdef LIMBOAI_MODULE
|
||||
virtual String to_string() override;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* bt_check_trigger.cpp
|
||||
* =============================================================================
|
||||
* Copyright 2021-2023 Serhii Snitsaruk
|
||||
* Copyright 2021-2024 Serhii Snitsaruk
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
|
@ -13,28 +13,28 @@
|
|||
|
||||
#include "../../../util/limbo_utility.h"
|
||||
|
||||
void BTCheckTrigger::set_variable(String p_variable) {
|
||||
void BTCheckTrigger::set_variable(const StringName &p_variable) {
|
||||
variable = p_variable;
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
PackedStringArray BTCheckTrigger::get_configuration_warnings() {
|
||||
PackedStringArray warnings = BTCondition::get_configuration_warnings();
|
||||
if (variable.is_empty()) {
|
||||
if (variable == StringName()) {
|
||||
warnings.append("Variable is not set.");
|
||||
}
|
||||
return warnings;
|
||||
}
|
||||
|
||||
String BTCheckTrigger::_generate_name() {
|
||||
if (variable.is_empty()) {
|
||||
if (variable == StringName()) {
|
||||
return "CheckTrigger ???";
|
||||
}
|
||||
return "CheckTrigger " + LimboUtility::get_singleton()->decorate_var(variable);
|
||||
}
|
||||
|
||||
BT::Status BTCheckTrigger::_tick(double p_delta) {
|
||||
ERR_FAIL_COND_V_MSG(variable.is_empty(), FAILURE, "BBCheckVar: `variable` is not set.");
|
||||
ERR_FAIL_COND_V_MSG(variable == StringName(), FAILURE, "BBCheckVar: `variable` is not set.");
|
||||
Variant trigger_value = get_blackboard()->get_var(variable, false);
|
||||
if (trigger_value == Variant(true)) {
|
||||
get_blackboard()->set_var(variable, false);
|
||||
|
@ -47,5 +47,5 @@ void BTCheckTrigger::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_variable", "p_variable"), &BTCheckTrigger::set_variable);
|
||||
ClassDB::bind_method(D_METHOD("get_variable"), &BTCheckTrigger::get_variable);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "variable"), "set_variable", "get_variable");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "variable"), "set_variable", "get_variable");
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* bt_check_trigger.h
|
||||
* =============================================================================
|
||||
* Copyright 2021-2023 Serhii Snitsaruk
|
||||
* Copyright 2021-2024 Serhii Snitsaruk
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
|
@ -19,7 +19,7 @@ class BTCheckTrigger : public BTCondition {
|
|||
TASK_CATEGORY(Blackboard);
|
||||
|
||||
private:
|
||||
String variable;
|
||||
StringName variable;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
@ -28,10 +28,10 @@ protected:
|
|||
virtual Status _tick(double p_delta) override;
|
||||
|
||||
public:
|
||||
void set_variable(String p_variable);
|
||||
String get_variable() const { return variable; }
|
||||
void set_variable(const StringName &p_variable);
|
||||
StringName get_variable() const { return variable; }
|
||||
|
||||
virtual PackedStringArray get_configuration_warnings() override;
|
||||
};
|
||||
|
||||
#endif // BT_CHECK_TRIGGER
|
||||
#endif // BT_CHECK_TRIGGER
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* bt_check_var.cpp
|
||||
* =============================================================================
|
||||
* Copyright 2021-2023 Serhii Snitsaruk
|
||||
* Copyright 2021-2024 Serhii Snitsaruk
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include "bt_check_var.h"
|
||||
|
||||
void BTCheckVar::set_variable(String p_variable) {
|
||||
void BTCheckVar::set_variable(const StringName &p_variable) {
|
||||
variable = p_variable;
|
||||
emit_changed();
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ void BTCheckVar::set_check_type(LimboUtility::CheckType p_check_type) {
|
|||
emit_changed();
|
||||
}
|
||||
|
||||
void BTCheckVar::set_value(Ref<BBVariant> p_value) {
|
||||
void BTCheckVar::set_value(const Ref<BBVariant> &p_value) {
|
||||
value = p_value;
|
||||
emit_changed();
|
||||
if (Engine::get_singleton()->is_editor_hint() && value.is_valid()) {
|
||||
|
@ -31,7 +31,7 @@ void BTCheckVar::set_value(Ref<BBVariant> p_value) {
|
|||
|
||||
PackedStringArray BTCheckVar::get_configuration_warnings() {
|
||||
PackedStringArray warnings = BTCondition::get_configuration_warnings();
|
||||
if (variable.is_empty()) {
|
||||
if (variable == StringName()) {
|
||||
warnings.append("`variable` should be assigned.");
|
||||
}
|
||||
if (!value.is_valid()) {
|
||||
|
@ -41,7 +41,7 @@ PackedStringArray BTCheckVar::get_configuration_warnings() {
|
|||
}
|
||||
|
||||
String BTCheckVar::_generate_name() {
|
||||
if (variable.is_empty()) {
|
||||
if (variable == StringName()) {
|
||||
return "CheckVar ???";
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ String BTCheckVar::_generate_name() {
|
|||
}
|
||||
|
||||
BT::Status BTCheckVar::_tick(double p_delta) {
|
||||
ERR_FAIL_COND_V_MSG(variable.is_empty(), FAILURE, "BTCheckVar: `variable` is not set.");
|
||||
ERR_FAIL_COND_V_MSG(variable == StringName(), FAILURE, "BTCheckVar: `variable` is not set.");
|
||||
ERR_FAIL_COND_V_MSG(!value.is_valid(), FAILURE, "BTCheckVar: `value` is not set.");
|
||||
|
||||
ERR_FAIL_COND_V_MSG(!get_blackboard()->has_var(variable), FAILURE, vformat("BTCheckVar: Blackboard variable doesn't exist: \"%s\". Returning FAILURE.", variable));
|
||||
|
@ -70,7 +70,7 @@ void BTCheckVar::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_value", "p_value"), &BTCheckVar::set_value);
|
||||
ClassDB::bind_method(D_METHOD("get_value"), &BTCheckVar::get_value);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "variable"), "set_variable", "get_variable");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "variable"), "set_variable", "get_variable");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "check_type", PROPERTY_HINT_ENUM, "Equal,Less Than,Less Than Or Equal,Greater Than,Greater Than Or Equal,Not Equal"), "set_check_type", "get_check_type");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "value", PROPERTY_HINT_RESOURCE_TYPE, "BBVariant"), "set_value", "get_value");
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* bt_check_var.h
|
||||
* =============================================================================
|
||||
* Copyright 2021-2023 Serhii Snitsaruk
|
||||
* Copyright 2021-2024 Serhii Snitsaruk
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
|
@ -22,7 +22,7 @@ class BTCheckVar : public BTCondition {
|
|||
TASK_CATEGORY(Blackboard);
|
||||
|
||||
private:
|
||||
String variable;
|
||||
StringName variable;
|
||||
LimboUtility::CheckType check_type = LimboUtility::CheckType::CHECK_EQUAL;
|
||||
Ref<BBVariant> value;
|
||||
|
||||
|
@ -35,14 +35,14 @@ protected:
|
|||
public:
|
||||
virtual PackedStringArray get_configuration_warnings() override;
|
||||
|
||||
void set_variable(String p_variable);
|
||||
String get_variable() const { return variable; }
|
||||
void set_variable(const StringName &p_variable);
|
||||
StringName get_variable() const { return variable; }
|
||||
|
||||
void set_check_type(LimboUtility::CheckType p_check_type);
|
||||
LimboUtility::CheckType get_check_type() const { return check_type; }
|
||||
|
||||
void set_value(Ref<BBVariant> p_value);
|
||||
void set_value(const Ref<BBVariant> &p_value);
|
||||
Ref<BBVariant> get_value() const { return value; }
|
||||
};
|
||||
|
||||
#endif // BT_CHECK_VAR_H
|
||||
#endif // BT_CHECK_VAR_H
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* bt_set_var.cpp
|
||||
* =============================================================================
|
||||
* Copyright 2021-2023 Serhii Snitsaruk
|
||||
* Copyright 2021-2024 Serhii Snitsaruk
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
|
@ -12,7 +12,7 @@
|
|||
#include "bt_set_var.h"
|
||||
|
||||
String BTSetVar::_generate_name() {
|
||||
if (variable.is_empty()) {
|
||||
if (variable == StringName()) {
|
||||
return "SetVar ???";
|
||||
}
|
||||
return vformat("Set %s %s= %s",
|
||||
|
@ -22,7 +22,7 @@ String BTSetVar::_generate_name() {
|
|||
}
|
||||
|
||||
BT::Status BTSetVar::_tick(double p_delta) {
|
||||
ERR_FAIL_COND_V_MSG(variable.is_empty(), FAILURE, "BTSetVar: `variable` is not set.");
|
||||
ERR_FAIL_COND_V_MSG(variable == StringName(), FAILURE, "BTSetVar: `variable` is not set.");
|
||||
ERR_FAIL_COND_V_MSG(!value.is_valid(), FAILURE, "BTSetVar: `value` is not set.");
|
||||
Variant result;
|
||||
Variant error_result = LW_NAME(error_value);
|
||||
|
@ -40,12 +40,12 @@ BT::Status BTSetVar::_tick(double p_delta) {
|
|||
return SUCCESS;
|
||||
};
|
||||
|
||||
void BTSetVar::set_variable(const String &p_variable) {
|
||||
void BTSetVar::set_variable(const StringName &p_variable) {
|
||||
variable = p_variable;
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
void BTSetVar::set_value(Ref<BBVariant> p_value) {
|
||||
void BTSetVar::set_value(const Ref<BBVariant> &p_value) {
|
||||
value = p_value;
|
||||
emit_changed();
|
||||
if (Engine::get_singleton()->is_editor_hint() && value.is_valid()) {
|
||||
|
@ -60,7 +60,7 @@ void BTSetVar::set_operation(LimboUtility::Operation p_operation) {
|
|||
|
||||
PackedStringArray BTSetVar::get_configuration_warnings() {
|
||||
PackedStringArray warnings = BTAction::get_configuration_warnings();
|
||||
if (variable.is_empty()) {
|
||||
if (variable == StringName()) {
|
||||
warnings.append("`variable` should be assigned.");
|
||||
}
|
||||
if (!value.is_valid()) {
|
||||
|
@ -77,7 +77,7 @@ void BTSetVar::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("get_operation"), &BTSetVar::get_operation);
|
||||
ClassDB::bind_method(D_METHOD("set_operation", "p_operation"), &BTSetVar::set_operation);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "variable"), "set_variable", "get_variable");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "variable"), "set_variable", "get_variable");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "value", PROPERTY_HINT_RESOURCE_TYPE, "BBVariant"), "set_value", "get_value");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "operation", PROPERTY_HINT_ENUM, "None,Addition,Subtraction,Multiplication,Division,Modulo,Power,Bitwise Shift Left,Bitwise Shift Right,Bitwise AND,Bitwise OR,Bitwise XOR"), "set_operation", "get_operation");
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* bt_set_var.h
|
||||
* =============================================================================
|
||||
* Copyright 2021-2023 Serhii Snitsaruk
|
||||
* Copyright 2021-2024 Serhii Snitsaruk
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
|
@ -22,7 +22,7 @@ class BTSetVar : public BTAction {
|
|||
TASK_CATEGORY(Blackboard);
|
||||
|
||||
private:
|
||||
String variable;
|
||||
StringName variable;
|
||||
Ref<BBVariant> value;
|
||||
LimboUtility::Operation operation = LimboUtility::OPERATION_NONE;
|
||||
|
||||
|
@ -35,14 +35,14 @@ protected:
|
|||
public:
|
||||
virtual PackedStringArray get_configuration_warnings() override;
|
||||
|
||||
void set_variable(const String &p_variable);
|
||||
String get_variable() const { return variable; }
|
||||
void set_variable(const StringName &p_variable);
|
||||
StringName get_variable() const { return variable; }
|
||||
|
||||
void set_value(Ref<BBVariant> p_value);
|
||||
void set_value(const Ref<BBVariant> &p_value);
|
||||
Ref<BBVariant> get_value() const { return value; }
|
||||
|
||||
void set_operation(LimboUtility::Operation p_operation);
|
||||
LimboUtility::Operation get_operation() const { return operation; }
|
||||
};
|
||||
|
||||
#endif // BT_SET_VAR
|
||||
#endif // BT_SET_VAR
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* bt_cooldown.cpp
|
||||
* =============================================================================
|
||||
* Copyright 2021-2023 Serhii Snitsaruk
|
||||
* Copyright 2021-2024 Serhii Snitsaruk
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
|
@ -41,7 +41,7 @@ void BTCooldown::set_trigger_on_failure(bool p_value) {
|
|||
emit_changed();
|
||||
}
|
||||
|
||||
void BTCooldown::set_cooldown_state_var(String p_value) {
|
||||
void BTCooldown::set_cooldown_state_var(const StringName &p_value) {
|
||||
cooldown_state_var = p_value;
|
||||
emit_changed();
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ String BTCooldown::_generate_name() {
|
|||
}
|
||||
|
||||
void BTCooldown::_setup() {
|
||||
if (cooldown_state_var.is_empty()) {
|
||||
if (cooldown_state_var == StringName()) {
|
||||
cooldown_state_var = vformat("cooldown_%d", rand());
|
||||
}
|
||||
get_blackboard()->set_var(cooldown_state_var, false);
|
||||
|
@ -109,5 +109,5 @@ void BTCooldown::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "process_pause"), "set_process_pause", "get_process_pause");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "start_cooled"), "set_start_cooled", "get_start_cooled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "trigger_on_failure"), "set_trigger_on_failure", "get_trigger_on_failure");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "cooldown_state_var"), "set_cooldown_state_var", "get_cooldown_state_var");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "cooldown_state_var"), "set_cooldown_state_var", "get_cooldown_state_var");
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* bt_cooldown.h
|
||||
* =============================================================================
|
||||
* Copyright 2021-2023 Serhii Snitsaruk
|
||||
* Copyright 2021-2024 Serhii Snitsaruk
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
|
@ -31,7 +31,7 @@ private:
|
|||
bool process_pause = false;
|
||||
bool start_cooled = false;
|
||||
bool trigger_on_failure = false;
|
||||
String cooldown_state_var = "";
|
||||
StringName cooldown_state_var = "";
|
||||
|
||||
Ref<SceneTreeTimer> timer = nullptr;
|
||||
|
||||
|
@ -58,8 +58,8 @@ public:
|
|||
void set_trigger_on_failure(bool p_value);
|
||||
bool get_trigger_on_failure() const { return trigger_on_failure; }
|
||||
|
||||
void set_cooldown_state_var(String p_value);
|
||||
String get_cooldown_state_var() const { return cooldown_state_var; }
|
||||
void set_cooldown_state_var(const StringName &p_value);
|
||||
StringName get_cooldown_state_var() const { return cooldown_state_var; }
|
||||
};
|
||||
|
||||
#endif // BT_COOLDOWN_H
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* bt_for_each.cpp
|
||||
* =============================================================================
|
||||
* Copyright 2021-2023 Serhii Snitsaruk
|
||||
* Copyright 2021-2024 Serhii Snitsaruk
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
|
@ -20,12 +20,12 @@
|
|||
|
||||
//**** Setters / Getters
|
||||
|
||||
void BTForEach::set_array_var(String p_value) {
|
||||
void BTForEach::set_array_var(const StringName &p_value) {
|
||||
array_var = p_value;
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
void BTForEach::set_save_var(String p_value) {
|
||||
void BTForEach::set_save_var(const StringName &p_value) {
|
||||
save_var = p_value;
|
||||
emit_changed();
|
||||
}
|
||||
|
@ -44,8 +44,8 @@ void BTForEach::_enter() {
|
|||
|
||||
BT::Status BTForEach::_tick(double p_delta) {
|
||||
ERR_FAIL_COND_V_MSG(get_child_count() == 0, FAILURE, "ForEach decorator has no child.");
|
||||
ERR_FAIL_COND_V_MSG(save_var.is_empty(), FAILURE, "ForEach save variable is not set.");
|
||||
ERR_FAIL_COND_V_MSG(array_var.is_empty(), FAILURE, "ForEach array variable is not set.");
|
||||
ERR_FAIL_COND_V_MSG(save_var == StringName(), FAILURE, "ForEach save variable is not set.");
|
||||
ERR_FAIL_COND_V_MSG(array_var == StringName(), FAILURE, "ForEach array variable is not set.");
|
||||
|
||||
Array arr = get_blackboard()->get_var(array_var, Variant());
|
||||
if (arr.size() == 0) {
|
||||
|
@ -75,6 +75,6 @@ void BTForEach::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_save_var", "p_variable"), &BTForEach::set_save_var);
|
||||
ClassDB::bind_method(D_METHOD("get_save_var"), &BTForEach::get_save_var);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "array_var"), "set_array_var", "get_array_var");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "save_var"), "set_save_var", "get_save_var");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "array_var"), "set_array_var", "get_array_var");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "save_var"), "set_save_var", "get_save_var");
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* bt_for_each.h
|
||||
* =============================================================================
|
||||
* Copyright 2021-2023 Serhii Snitsaruk
|
||||
* Copyright 2021-2024 Serhii Snitsaruk
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
|
@ -19,8 +19,8 @@ class BTForEach : public BTDecorator {
|
|||
TASK_CATEGORY(Decorators);
|
||||
|
||||
private:
|
||||
String array_var;
|
||||
String save_var;
|
||||
StringName array_var;
|
||||
StringName save_var;
|
||||
|
||||
int current_idx;
|
||||
|
||||
|
@ -32,11 +32,11 @@ protected:
|
|||
virtual Status _tick(double p_delta) override;
|
||||
|
||||
public:
|
||||
void set_array_var(String p_value);
|
||||
String get_array_var() const { return array_var; }
|
||||
void set_array_var(const StringName &p_value);
|
||||
StringName get_array_var() const { return array_var; }
|
||||
|
||||
void set_save_var(String p_value);
|
||||
String get_save_var() const { return save_var; }
|
||||
void set_save_var(const StringName &p_value);
|
||||
StringName get_save_var() const { return save_var; }
|
||||
};
|
||||
|
||||
#endif // BT_FOR_EACH_H
|
||||
|
|
|
@ -21,7 +21,7 @@ void BTAwaitAnimation::set_animation_player(Ref<BBNode> p_animation_player) {
|
|||
}
|
||||
}
|
||||
|
||||
void BTAwaitAnimation::set_animation_name(StringName p_animation_name) {
|
||||
void BTAwaitAnimation::set_animation_name(const StringName &p_animation_name) {
|
||||
animation_name = p_animation_name;
|
||||
emit_changed();
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ PackedStringArray BTAwaitAnimation::get_configuration_warnings() {
|
|||
} else {
|
||||
if (animation_player_param->get_value_source() == BBParam::SAVED_VALUE && animation_player_param->get_saved_value() == Variant()) {
|
||||
warnings.append("Path to AnimationPlayer node is not set.");
|
||||
} else if (animation_player_param->get_value_source() == BBParam::BLACKBOARD_VAR && animation_player_param->get_variable().is_empty()) {
|
||||
} else if (animation_player_param->get_value_source() == BBParam::BLACKBOARD_VAR && animation_player_param->get_variable() == StringName()) {
|
||||
warnings.append("AnimationPlayer blackboard variable is not set.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
void set_animation_player(Ref<BBNode> p_animation_player);
|
||||
Ref<BBNode> get_animation_player() const { return animation_player_param; }
|
||||
|
||||
void set_animation_name(StringName p_animation_name);
|
||||
void set_animation_name(const StringName &p_animation_name);
|
||||
StringName get_animation_name() const { return animation_name; }
|
||||
|
||||
void set_max_time(double p_max_time);
|
||||
|
|
|
@ -30,7 +30,7 @@ PackedStringArray BTPauseAnimation::get_configuration_warnings() {
|
|||
} else {
|
||||
if (animation_player_param->get_value_source() == BBParam::SAVED_VALUE && animation_player_param->get_saved_value() == Variant()) {
|
||||
warnings.append("Path to AnimationPlayer node is not set.");
|
||||
} else if (animation_player_param->get_value_source() == BBParam::BLACKBOARD_VAR && animation_player_param->get_variable().is_empty()) {
|
||||
} else if (animation_player_param->get_value_source() == BBParam::BLACKBOARD_VAR && animation_player_param->get_variable() == StringName()) {
|
||||
warnings.append("AnimationPlayer blackboard variable is not set.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ PackedStringArray BTPlayAnimation::get_configuration_warnings() {
|
|||
} else {
|
||||
if (animation_player_param->get_value_source() == BBParam::SAVED_VALUE && animation_player_param->get_saved_value() == Variant()) {
|
||||
warnings.append("Path to AnimationPlayer node is not set.");
|
||||
} else if (animation_player_param->get_value_source() == BBParam::BLACKBOARD_VAR && animation_player_param->get_variable().is_empty()) {
|
||||
} else if (animation_player_param->get_value_source() == BBParam::BLACKBOARD_VAR && animation_player_param->get_variable() == StringName()) {
|
||||
warnings.append("AnimationPlayer blackboard variable is not set.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ PackedStringArray BTStopAnimation::get_configuration_warnings() {
|
|||
} else {
|
||||
if (animation_player_param->get_value_source() == BBParam::SAVED_VALUE && animation_player_param->get_saved_value() == Variant()) {
|
||||
warnings.append("Path to AnimationPlayer node is not set.");
|
||||
} else if (animation_player_param->get_value_source() == BBParam::BLACKBOARD_VAR && animation_player_param->get_variable().is_empty()) {
|
||||
} else if (animation_player_param->get_value_source() == BBParam::BLACKBOARD_VAR && animation_player_param->get_variable() == StringName()) {
|
||||
warnings.append("AnimationPlayer blackboard variable is not set.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* bt_call_method.cpp
|
||||
* =============================================================================
|
||||
* Copyright 2021-2023 Serhii Snitsaruk
|
||||
* Copyright 2021-2024 Serhii Snitsaruk
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
|
@ -20,12 +20,12 @@
|
|||
|
||||
//**** Setters / Getters
|
||||
|
||||
void BTCallMethod::set_method(StringName p_method_name) {
|
||||
void BTCallMethod::set_method(const StringName &p_method_name) {
|
||||
method = p_method_name;
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
void BTCallMethod::set_node_param(Ref<BBNode> p_object) {
|
||||
void BTCallMethod::set_node_param(const Ref<BBNode> &p_object) {
|
||||
node_param = p_object;
|
||||
emit_changed();
|
||||
if (Engine::get_singleton()->is_editor_hint() && node_param.is_valid()) {
|
||||
|
@ -43,7 +43,7 @@ void BTCallMethod::set_args(TypedArray<BBVariant> p_args) {
|
|||
emit_changed();
|
||||
}
|
||||
|
||||
void BTCallMethod::set_result_var(const String &p_result_var) {
|
||||
void BTCallMethod::set_result_var(const StringName &p_result_var) {
|
||||
result_var = p_result_var;
|
||||
emit_changed();
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ String BTCallMethod::_generate_name() {
|
|||
method != StringName() ? method : "???",
|
||||
args_str,
|
||||
node_param.is_valid() && !node_param->to_string().is_empty() ? node_param->to_string() : "???",
|
||||
result_var.is_empty() ? "" : LimboUtility::get_singleton()->decorate_output_var(result_var));
|
||||
result_var == StringName() ? "" : LimboUtility::get_singleton()->decorate_output_var(result_var));
|
||||
}
|
||||
|
||||
BT::Status BTCallMethod::_tick(double p_delta) {
|
||||
|
@ -124,7 +124,7 @@ BT::Status BTCallMethod::_tick(double p_delta) {
|
|||
result = obj->callv(method, call_args);
|
||||
#endif // LIMBOAI_MODULE & LIMBOAI_GDEXTENSION
|
||||
|
||||
if (!result_var.is_empty()) {
|
||||
if (result_var != StringName()) {
|
||||
get_blackboard()->set_var(result_var, result);
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ void BTCallMethod::_bind_methods() {
|
|||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "BBNode"), "set_node_param", "get_node_param");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "method"), "set_method", "get_method");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "result_var"), "set_result_var", "get_result_var");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "result_var"), "set_result_var", "get_result_var");
|
||||
ADD_GROUP("Arguments", "args_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "args_include_delta"), "set_include_delta", "is_delta_included");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "args", PROPERTY_HINT_ARRAY_TYPE, RESOURCE_TYPE_HINT("BBVariant")), "set_args", "get_args");
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* bt_call_method.h
|
||||
* =============================================================================
|
||||
* Copyright 2021-2023 Serhii Snitsaruk
|
||||
* Copyright 2021-2024 Serhii Snitsaruk
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
|
@ -26,7 +26,7 @@ private:
|
|||
Ref<BBNode> node_param;
|
||||
TypedArray<BBVariant> args;
|
||||
bool include_delta = false;
|
||||
String result_var;
|
||||
StringName result_var;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
@ -35,10 +35,10 @@ protected:
|
|||
virtual Status _tick(double p_delta) override;
|
||||
|
||||
public:
|
||||
void set_method(StringName p_method_name);
|
||||
void set_method(const StringName &p_method_name);
|
||||
StringName get_method() const { return method; }
|
||||
|
||||
void set_node_param(Ref<BBNode> p_object);
|
||||
void set_node_param(const Ref<BBNode> &p_object);
|
||||
Ref<BBNode> get_node_param() const { return node_param; }
|
||||
|
||||
void set_args(TypedArray<BBVariant> p_args);
|
||||
|
@ -47,8 +47,8 @@ public:
|
|||
void set_include_delta(bool p_include_delta);
|
||||
bool is_delta_included() const { return include_delta; }
|
||||
|
||||
void set_result_var(const String &p_result_var);
|
||||
String get_result_var() const { return result_var; }
|
||||
void set_result_var(const StringName &p_result_var);
|
||||
StringName get_result_var() const { return result_var; }
|
||||
|
||||
virtual PackedStringArray get_configuration_warnings() override;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* bt_evaluate_expression.cpp
|
||||
* =============================================================================
|
||||
* Copyright 2021-2023 Serhii Snitsaruk
|
||||
* Copyright 2021-2024 Serhii Snitsaruk
|
||||
* Copyright 2024 Wilson E. Alvarez
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style
|
||||
|
@ -55,7 +55,7 @@ void BTEvaluateExpression::set_input_values(const TypedArray<BBVariant> &p_input
|
|||
emit_changed();
|
||||
}
|
||||
|
||||
void BTEvaluateExpression::set_result_var(const String &p_result_var) {
|
||||
void BTEvaluateExpression::set_result_var(const StringName &p_result_var) {
|
||||
result_var = p_result_var;
|
||||
emit_changed();
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ String BTEvaluateExpression::_generate_name() {
|
|||
return vformat("EvaluateExpression %s node: %s %s",
|
||||
!expression_string.is_empty() ? expression_string : "???",
|
||||
node_param.is_valid() && !node_param->to_string().is_empty() ? node_param->to_string() : "???",
|
||||
result_var.is_empty() ? "" : LimboUtility::get_singleton()->decorate_output_var(result_var));
|
||||
result_var == StringName() ? "" : LimboUtility::get_singleton()->decorate_output_var(result_var));
|
||||
}
|
||||
|
||||
BT::Status BTEvaluateExpression::_tick(double p_delta) {
|
||||
|
@ -122,7 +122,7 @@ BT::Status BTEvaluateExpression::_tick(double p_delta) {
|
|||
Variant result = expression.execute(processed_input_values, obj, false);
|
||||
ERR_FAIL_COND_V_MSG(expression.has_execute_failed(), FAILURE, "BTEvaluateExpression: Failed to execute: " + expression.get_error_text());
|
||||
|
||||
if (!result_var.is_empty()) {
|
||||
if (result_var != StringName()) {
|
||||
get_blackboard()->set_var(result_var, result);
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ void BTEvaluateExpression::_bind_methods() {
|
|||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "BBNode"), "set_node_param", "get_node_param");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "expression_string"), "set_expression_string", "get_expression_string");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "result_var"), "set_result_var", "get_result_var");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "result_var"), "set_result_var", "get_result_var");
|
||||
ADD_GROUP("Inputs", "input_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "input_include_delta"), "set_input_include_delta", "is_input_delta_included");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::PACKED_STRING_ARRAY, "input_names", PROPERTY_HINT_ARRAY_TYPE, "String"), "set_input_names", "get_input_names");
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* bt_evaluate_expression.h
|
||||
* =============================================================================
|
||||
* Copyright 2021-2023 Serhii Snitsaruk
|
||||
* Copyright 2021-2024 Serhii Snitsaruk
|
||||
* Copyright 2024 Wilson E. Alvarez
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style
|
||||
|
@ -39,7 +39,7 @@ private:
|
|||
TypedArray<BBVariant> input_values;
|
||||
bool input_include_delta = false;
|
||||
Array processed_input_values;
|
||||
String result_var;
|
||||
StringName result_var;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
@ -66,8 +66,8 @@ public:
|
|||
void set_input_include_delta(bool p_input_include_delta);
|
||||
bool is_input_delta_included() const { return input_include_delta; }
|
||||
|
||||
void set_result_var(const String &p_result_var);
|
||||
String get_result_var() const { return result_var; }
|
||||
void set_result_var(const StringName &p_result_var);
|
||||
StringName get_result_var() const { return result_var; }
|
||||
|
||||
virtual PackedStringArray get_configuration_warnings() override;
|
||||
|
||||
|
|
Loading…
Reference in New Issue