Fix BTCallMethod incompatibility with .NET glue
This commit is contained in:
parent
5a0ff91658
commit
a07654394b
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ class BTCallMethod : public BTAction {
|
|||
TASK_CATEGORY(Scene);
|
||||
|
||||
private:
|
||||
StringName method_name;
|
||||
StringName method;
|
||||
Ref<BBNode> 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<BBNode> p_object);
|
||||
Ref<BBNode> get_node_param() const { return node_param; }
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
<member name="args" type="Array" setter="set_args" getter="get_args" default="[]">
|
||||
Arguments to pass to the method call.
|
||||
</member>
|
||||
<member name="method_name" type="StringName" setter="set_method_name" getter="get_method_name" default="&""">
|
||||
Name of the node's method that will be called.
|
||||
<member name="method" type="StringName" setter="set_method" getter="get_method" default="&""">
|
||||
Node's method that will be called.
|
||||
</member>
|
||||
<member name="node" type="BBNode" setter="set_node_param" getter="get_node_param">
|
||||
Node parameter that will be used to get the node instance.
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="BTComment" inherits="BTTask" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
|
||||
<brief_description>
|
||||
BTComment adds annotations or explanatory notes to the [BehaviorTree].
|
||||
</brief_description>
|
||||
<description>
|
||||
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].
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
</class>
|
|
@ -32,7 +32,7 @@
|
|||
</description>
|
||||
</method>
|
||||
<method name="_get_configuration_warning" qualifiers="virtual const">
|
||||
<return type="String" />
|
||||
<return type="PackedStringArray" />
|
||||
<description>
|
||||
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.
|
||||
</description>
|
||||
|
@ -93,6 +93,12 @@
|
|||
Returns the number of child tasks.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_child_count_excluding_comments" qualifiers="const">
|
||||
<return type="int" />
|
||||
<description>
|
||||
Returns the number of child tasks not counting [BTComment] tasks.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_child_index" qualifiers="const">
|
||||
<return type="int" />
|
||||
<param index="0" name="p_child" type="BTTask" />
|
||||
|
|
Loading…
Reference in New Issue