From fe81b90dc140344fb16b49fd0b2455625c9db28b Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Tue, 5 Sep 2023 10:55:17 +0200 Subject: [PATCH] Allow objects in BBNode --- blackboard/bb_param/bb_node.cpp | 6 +++--- bt/tasks/scene/bt_call_method.cpp | 2 +- doc_classes/BBNode.xml | 2 ++ doc_classes/BTCallMethod.xml | 10 +++++----- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/blackboard/bb_param/bb_node.cpp b/blackboard/bb_param/bb_node.cpp index 3e34230..59994ef 100644 --- a/blackboard/bb_param/bb_node.cpp +++ b/blackboard/bb_param/bb_node.cpp @@ -30,12 +30,12 @@ Variant BBNode::get_value(Object *p_agent, const Ref &p_blackboard, ERR_FAIL_COND_V_MSG(agent == nullptr, Variant(), "BBNode: p_agent must be a Node."); return agent->get_node(val); } else { - Node *node = Object::cast_to(val); - if (unlikely(node == nullptr && val.get_type() != Variant::NIL)) { + Object *obj = val; + if (unlikely(obj == nullptr && val.get_type() != Variant::NIL)) { WARN_PRINT("BBNode: Unexpected variant type of a blackboard variable."); return p_default; } else { - return node; + return obj; } } } diff --git a/bt/tasks/scene/bt_call_method.cpp b/bt/tasks/scene/bt_call_method.cpp index 36b08a3..5855176 100644 --- a/bt/tasks/scene/bt_call_method.cpp +++ b/bt/tasks/scene/bt_call_method.cpp @@ -59,7 +59,7 @@ int BTCallMethod::_tick(double p_delta) { 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()); + ERR_FAIL_COND_V_MSG(obj == nullptr, FAILURE, "BTCallMethod: Failed to get object: " + node_param->to_string()); const Variant **argptrs = nullptr; diff --git a/doc_classes/BBNode.xml b/doc_classes/BBNode.xml index 9a932b7..eb15e77 100644 --- a/doc_classes/BBNode.xml +++ b/doc_classes/BBNode.xml @@ -4,6 +4,8 @@ Node-type parameter to be used with BT tasks. See [BBParam]. + Node-type parameter to be used with BT tasks. See [BBParam]. + If blackboard is chosen as source, it allows any [Object]-extended type. diff --git a/doc_classes/BTCallMethod.xml b/doc_classes/BTCallMethod.xml index cb610ec..522fc4d 100644 --- a/doc_classes/BTCallMethod.xml +++ b/doc_classes/BTCallMethod.xml @@ -1,11 +1,11 @@ - BT action that calls a method on the specified [Node]. + BT action that calls a method on a specified [Node] or [Object]. - BTCallMethod calls a method on the specified [Node] and returns [code]SUCCESS[/code]. - Returns [code]FAILURE[/code] if the action fails executing the node's method. + BTCallMethod calls a method on a specified [Node] or [Object] and returns [code]SUCCESS[/code]. + Returns [code]FAILURE[/code] if the action fails executing the method. @@ -14,10 +14,10 @@ Arguments to pass to the method call. - Node's method that will be called. + Method that will be called. - Node parameter that will be used to get the node instance. + Parameter that will be used to get the node/object instance.