From f286673dde991787b4667fd069e84120442bb3df Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Fri, 11 Aug 2023 22:16:03 +0200 Subject: [PATCH] BT*AgentProperty fixes --- bt/actions/bt_set_agent_property.cpp | 24 +++++++++---------- bt/actions/bt_set_agent_property.h | 6 ++--- bt/conditions/bt_check_agent_property.cpp | 24 +++++++++---------- bt/conditions/bt_check_agent_property.h | 6 ++--- .../agent_properties/bt_agent_properties.tres | 10 ++++---- doc_classes/BTCheckAgentProperty.xml | 4 ++-- doc_classes/BTSetAgentProperty.xml | 2 +- 7 files changed, 38 insertions(+), 38 deletions(-) diff --git a/bt/actions/bt_set_agent_property.cpp b/bt/actions/bt_set_agent_property.cpp index a204f98..f46c49f 100644 --- a/bt/actions/bt_set_agent_property.cpp +++ b/bt/actions/bt_set_agent_property.cpp @@ -11,8 +11,8 @@ #include "bt_set_agent_property.h" -void BTSetAgentProperty::set_property_name(StringName p_prop) { - property_name = p_prop; +void BTSetAgentProperty::set_property(StringName p_prop) { + property = p_prop; emit_changed(); } @@ -29,8 +29,8 @@ String BTSetAgentProperty::get_configuration_warning() const { if (!warning.is_empty()) { warning += "\n"; } - if (property_name == StringName()) { - warning += "`property_name` should be assigned.\n"; + if (property == StringName()) { + warning += "`property` should be assigned.\n"; } if (!value.is_valid()) { warning += "`value` should be assigned.\n"; @@ -39,30 +39,30 @@ String BTSetAgentProperty::get_configuration_warning() const { } String BTSetAgentProperty::_generate_name() const { - if (property_name == StringName()) { + if (property == StringName()) { return "SetAgentProperty ???"; } - return vformat("Set agent.%s = %s", property_name, + return vformat("Set agent.%s = %s", property, value.is_valid() ? Variant(value) : Variant("???")); } int BTSetAgentProperty::_tick(double p_delta) { - ERR_FAIL_COND_V_MSG(property_name == StringName(), FAILURE, "BTSetAgentProperty: `property_name` is not set."); + ERR_FAIL_COND_V_MSG(property == StringName(), FAILURE, "BTSetAgentProperty: `property` is not set."); ERR_FAIL_COND_V_MSG(!value.is_valid(), FAILURE, "BTSetAgentProperty: `value` is not set."); bool r_valid; - get_agent()->set(property_name, value->get_value(get_agent(), get_blackboard()), &r_valid); - ERR_FAIL_COND_V_MSG(!r_valid, FAILURE, vformat("BTSetAgentProperty: Agent doesn't have property named \"%s\"", property_name)); + get_agent()->set(property, value->get_value(get_agent(), get_blackboard()), &r_valid); + ERR_FAIL_COND_V_MSG(!r_valid, FAILURE, vformat("BTSetAgentProperty: Agent doesn't have property named \"%s\"", property)); return SUCCESS; } void BTSetAgentProperty::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_property_name", "p_property_name"), &BTSetAgentProperty::set_property_name); - ClassDB::bind_method(D_METHOD("get_property_name"), &BTSetAgentProperty::get_property_name); + ClassDB::bind_method(D_METHOD("set_property", "p_property"), &BTSetAgentProperty::set_property); + ClassDB::bind_method(D_METHOD("get_property"), &BTSetAgentProperty::get_property); ClassDB::bind_method(D_METHOD("set_value", "p_value"), &BTSetAgentProperty::set_value); ClassDB::bind_method(D_METHOD("get_value"), &BTSetAgentProperty::get_value); - ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "property_name"), "set_property_name", "get_property_name"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "property"), "set_property", "get_property"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "value", PROPERTY_HINT_RESOURCE_TYPE, "BBVariant"), "set_value", "get_value"); } diff --git a/bt/actions/bt_set_agent_property.h b/bt/actions/bt_set_agent_property.h index 5b7d8a8..503d1e2 100644 --- a/bt/actions/bt_set_agent_property.h +++ b/bt/actions/bt_set_agent_property.h @@ -23,7 +23,7 @@ class BTSetAgentProperty : public BTAction { GDCLASS(BTSetAgentProperty, BTAction); private: - StringName property_name; + StringName property; Ref value; protected: @@ -35,8 +35,8 @@ protected: public: virtual String get_configuration_warning() const override; - void set_property_name(StringName p_prop); - StringName get_property_name() const { return property_name; } + void set_property(StringName p_prop); + StringName get_property() const { return property; } void set_value(Ref p_value); Ref get_value() const { return value; } diff --git a/bt/conditions/bt_check_agent_property.cpp b/bt/conditions/bt_check_agent_property.cpp index fc4a07a..0acb61c 100644 --- a/bt/conditions/bt_check_agent_property.cpp +++ b/bt/conditions/bt_check_agent_property.cpp @@ -15,8 +15,8 @@ #include "core/variant/callable.h" -void BTCheckAgentProperty::set_property_name(StringName p_prop) { - property_name = p_prop; +void BTCheckAgentProperty::set_property(StringName p_prop) { + property = p_prop; emit_changed(); } @@ -38,8 +38,8 @@ String BTCheckAgentProperty::get_configuration_warning() const { if (!warning.is_empty()) { warning += "\n"; } - if (property_name == StringName()) { - warning += "`property_name` should be assigned.\n"; + if (property == StringName()) { + warning += "`property` should be assigned.\n"; } if (!value.is_valid()) { warning += "`value` should be assigned.\n"; @@ -48,22 +48,22 @@ String BTCheckAgentProperty::get_configuration_warning() const { } String BTCheckAgentProperty::_generate_name() const { - if (property_name == StringName()) { + if (property == StringName()) { return "CheckAgentProperty ???"; } - return vformat("Check if: agent.%s %s %s", property_name, + return vformat("Check if: agent.%s %s %s", property, LimboUtility::get_singleton()->get_check_operator_string(check_type), value.is_valid() ? Variant(value) : Variant("???")); } int BTCheckAgentProperty::_tick(double p_delta) { - ERR_FAIL_COND_V_MSG(property_name == StringName(), FAILURE, "BTCheckAgentProperty: `property_name` is not set."); + ERR_FAIL_COND_V_MSG(property == StringName(), FAILURE, "BTCheckAgentProperty: `property` is not set."); ERR_FAIL_COND_V_MSG(!value.is_valid(), FAILURE, "BTCheckAgentProperty: `value` is not set."); bool r_valid; - Variant left_value = get_agent()->get(property_name, &r_valid); - ERR_FAIL_COND_V_MSG(r_valid == false, FAILURE, vformat("BTCheckAgentProperty: Agent has no property named \"%s\"", property_name)); + Variant left_value = get_agent()->get(property, &r_valid); + ERR_FAIL_COND_V_MSG(r_valid == false, FAILURE, vformat("BTCheckAgentProperty: Agent has no property named \"%s\"", property)); Variant right_value = value->get_value(get_agent(), get_blackboard()); @@ -71,14 +71,14 @@ int BTCheckAgentProperty::_tick(double p_delta) { } void BTCheckAgentProperty::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_property_name", "p_property_name"), &BTCheckAgentProperty::set_property_name); - ClassDB::bind_method(D_METHOD("get_property_name"), &BTCheckAgentProperty::get_property_name); + ClassDB::bind_method(D_METHOD("set_property", "p_property"), &BTCheckAgentProperty::set_property); + ClassDB::bind_method(D_METHOD("get_property"), &BTCheckAgentProperty::get_property); ClassDB::bind_method(D_METHOD("set_check_type", "p_check_type"), &BTCheckAgentProperty::set_check_type); ClassDB::bind_method(D_METHOD("get_check_type"), &BTCheckAgentProperty::get_check_type); ClassDB::bind_method(D_METHOD("set_value", "p_value"), &BTCheckAgentProperty::set_value); ClassDB::bind_method(D_METHOD("get_value"), &BTCheckAgentProperty::get_value); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "property_name"), "set_property_name", "get_property_name"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "property"), "set_property", "get_property"); 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"); } diff --git a/bt/conditions/bt_check_agent_property.h b/bt/conditions/bt_check_agent_property.h index 10a9fc2..2c1f10d 100644 --- a/bt/conditions/bt_check_agent_property.h +++ b/bt/conditions/bt_check_agent_property.h @@ -24,7 +24,7 @@ class BTCheckAgentProperty : public BTCondition { GDCLASS(BTCheckAgentProperty, BTCondition); private: - StringName property_name; + StringName property; LimboUtility::CheckType check_type = LimboUtility::CheckType::CHECK_EQUAL; Ref value; @@ -37,8 +37,8 @@ protected: public: virtual String get_configuration_warning() const override; - void set_property_name(StringName p_prop); - StringName get_property_name() const { return property_name; } + void set_property(StringName p_prop); + StringName get_property() const { return property; } void set_check_type(LimboUtility::CheckType p_check_type); LimboUtility::CheckType get_check_type() const { return check_type; } diff --git a/demo/tests/agent_properties/bt_agent_properties.tres b/demo/tests/agent_properties/bt_agent_properties.tres index 0477333..a6e6931 100644 --- a/demo/tests/agent_properties/bt_agent_properties.tres +++ b/demo/tests/agent_properties/bt_agent_properties.tres @@ -6,7 +6,7 @@ saved_value = 200.0 type = 3 [sub_resource type="BTCheckAgentProperty" id="BTCheckAgentProperty_0nprx"] -property_name = &"speed" +property = &"speed" value = SubResource("BBVariant_5o8fh") [sub_resource type="BTConsolePrint" id="BTConsolePrint_dlmwi"] @@ -28,7 +28,7 @@ saved_value = 300.0 type = 3 [sub_resource type="BTSetAgentProperty" id="BTSetAgentProperty_lh1xy"] -property_name = &"speed" +property = &"speed" value = SubResource("BBVariant_r2elk") [sub_resource type="BBVariant" id="BBVariant_jhcxn"] @@ -37,7 +37,7 @@ saved_value = 200.0 type = 3 [sub_resource type="BTCheckAgentProperty" id="BTCheckAgentProperty_p20lt"] -property_name = &"speed" +property = &"speed" check_type = 3 value = SubResource("BBVariant_jhcxn") @@ -60,7 +60,7 @@ saved_value = 400.0 type = 3 [sub_resource type="BTCheckAgentProperty" id="BTCheckAgentProperty_avnfr"] -property_name = &"speed" +property = &"speed" check_type = 1 value = SubResource("BBVariant_2aotu") @@ -83,7 +83,7 @@ saved_value = 300.0 type = 3 [sub_resource type="BTCheckAgentProperty" id="BTCheckAgentProperty_sayma"] -property_name = &"speed" +property = &"speed" value = SubResource("BBVariant_28e2y") [sub_resource type="BTConsolePrint" id="BTConsolePrint_xugph"] diff --git a/doc_classes/BTCheckAgentProperty.xml b/doc_classes/BTCheckAgentProperty.xml index f2abc2c..f6e271e 100644 --- a/doc_classes/BTCheckAgentProperty.xml +++ b/doc_classes/BTCheckAgentProperty.xml @@ -12,8 +12,8 @@ Type of check to perform. - - Parameter that specifies the agent's property name which will be compared. + + Parameter that specifies the agent's property which will be compared. Parameter that specifies the value to which an agent's property will be compared. diff --git a/doc_classes/BTSetAgentProperty.xml b/doc_classes/BTSetAgentProperty.xml index aa5e7e0..dde685b 100644 --- a/doc_classes/BTSetAgentProperty.xml +++ b/doc_classes/BTSetAgentProperty.xml @@ -10,7 +10,7 @@ - + Parameter that specifies the agent's property name.