diff --git a/bt/tasks/scene/bt_call_method.cpp b/bt/tasks/scene/bt_call_method.cpp index ae4fa5d..36b08a3 100644 --- a/bt/tasks/scene/bt_call_method.cpp +++ b/bt/tasks/scene/bt_call_method.cpp @@ -13,8 +13,8 @@ //**** Setters / Getters -void BTCallMethod::set_method_name(StringName p_method_name) { - method_name = p_method_name; +void BTCallMethod::set_method(StringName p_method_name) { + method = p_method_name; emit_changed(); } @@ -35,7 +35,7 @@ void BTCallMethod::set_args(Array p_args) { PackedStringArray BTCallMethod::get_configuration_warnings() const { PackedStringArray warnings = BTAction::get_configuration_warnings(); - if (method_name == StringName()) { + if (method == StringName()) { warnings.append("Method Name is not set."); } if (node_param.is_null()) { @@ -50,13 +50,13 @@ PackedStringArray BTCallMethod::get_configuration_warnings() const { String BTCallMethod::_generate_name() const { return vformat("CallMethod %s(%s) node: %s", - (method_name != StringName() ? method_name : "???"), + (method != StringName() ? method : "???"), (args.size() > 0 ? Variant(args).get_construct_string().trim_prefix("[").trim_suffix("]") : ""), (node_param.is_valid() && !node_param->to_string().is_empty() ? node_param->to_string() : "???")); } int BTCallMethod::_tick(double p_delta) { - ERR_FAIL_COND_V_MSG(method_name == StringName(), FAILURE, "BTCallMethod: Method Name is not set."); + ERR_FAIL_COND_V_MSG(method == StringName(), FAILURE, "BTCallMethod: Method Name is not set."); ERR_FAIL_COND_V_MSG(node_param.is_null(), FAILURE, "BTCallMethod: Node parameter is not set."); Object *obj = node_param->get_value(get_agent(), get_blackboard()); ERR_FAIL_COND_V_MSG(obj == nullptr, FAILURE, "BTCallMethod: Failed to get node: " + node_param->to_string()); @@ -71,9 +71,9 @@ int BTCallMethod::_tick(double p_delta) { } Callable::CallError ce; - obj->callp(method_name, argptrs, args.size(), ce); + obj->callp(method, argptrs, args.size(), ce); if (ce.error != Callable::CallError::CALL_OK) { - ERR_FAIL_V_MSG(FAILURE, "BTCallMethod: Error calling method: " + Variant::get_call_error_text(obj, method_name, argptrs, args.size(), ce) + "."); + ERR_FAIL_V_MSG(FAILURE, "BTCallMethod: Error calling method: " + Variant::get_call_error_text(obj, method, argptrs, args.size(), ce) + "."); } return SUCCESS; @@ -82,14 +82,14 @@ int BTCallMethod::_tick(double p_delta) { //**** Godot void BTCallMethod::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_method_name", "p_method_name"), &BTCallMethod::set_method_name); - ClassDB::bind_method(D_METHOD("get_method_name"), &BTCallMethod::get_method_name); + ClassDB::bind_method(D_METHOD("set_method", "p_method"), &BTCallMethod::set_method); + ClassDB::bind_method(D_METHOD("get_method"), &BTCallMethod::get_method); ClassDB::bind_method(D_METHOD("set_node_param", "p_param"), &BTCallMethod::set_node_param); ClassDB::bind_method(D_METHOD("get_node_param"), &BTCallMethod::get_node_param); ClassDB::bind_method(D_METHOD("set_args", "p_args"), &BTCallMethod::set_args); ClassDB::bind_method(D_METHOD("get_args"), &BTCallMethod::get_args); - ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "method_name"), "set_method_name", "get_method_name"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "method"), "set_method", "get_method"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "BBNode"), "set_node_param", "get_node_param"); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "args"), "set_args", "get_args"); } diff --git a/bt/tasks/scene/bt_call_method.h b/bt/tasks/scene/bt_call_method.h index 8445c3c..e1abb8f 100644 --- a/bt/tasks/scene/bt_call_method.h +++ b/bt/tasks/scene/bt_call_method.h @@ -21,7 +21,7 @@ class BTCallMethod : public BTAction { TASK_CATEGORY(Scene); private: - StringName method_name; + StringName method; Ref node_param; Array args; @@ -32,8 +32,8 @@ protected: virtual int _tick(double p_delta) override; public: - void set_method_name(StringName p_method_name); - StringName get_method_name() const { return method_name; } + void set_method(StringName p_method_name); + StringName get_method() const { return method; } void set_node_param(Ref p_object); Ref get_node_param() const { return node_param; } diff --git a/doc_classes/BTCallMethod.xml b/doc_classes/BTCallMethod.xml index 12c7883..cb610ec 100644 --- a/doc_classes/BTCallMethod.xml +++ b/doc_classes/BTCallMethod.xml @@ -13,8 +13,8 @@ Arguments to pass to the method call. - - Name of the node's method that will be called. + + Node's method that will be called. Node parameter that will be used to get the node instance. diff --git a/doc_classes/BTComment.xml b/doc_classes/BTComment.xml new file mode 100644 index 0000000..9cf1aa4 --- /dev/null +++ b/doc_classes/BTComment.xml @@ -0,0 +1,12 @@ + + + + BTComment adds annotations or explanatory notes to the [BehaviorTree]. + + + BTComment adds annotations or explanatory notes to the [BehaviorTree]. + Comments are not executed as part of the tree. They are removed from runtime instances of the [BehaviorTree]. + + + + diff --git a/doc_classes/BTTask.xml b/doc_classes/BTTask.xml index 002e0e7..ea66c15 100644 --- a/doc_classes/BTTask.xml +++ b/doc_classes/BTTask.xml @@ -32,7 +32,7 @@ - + The string returned by this method is displayed as a warning in the BT editor if the script that overrides it is a [code]tool[/code] script. @@ -93,6 +93,12 @@ Returns the number of child tasks. + + + + Returns the number of child tasks not counting [BTComment] tasks. + +