From a9158c8e480b222e7ac5fd5dcccac6ebd59605e6 Mon Sep 17 00:00:00 2001 From: Sara Date: Fri, 20 Mar 2026 19:41:50 +0100 Subject: [PATCH 1/2] feat: signal triggers when current behaviour node changes --- behaviour_tree.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/behaviour_tree.cpp b/behaviour_tree.cpp index 7268f749cf..7b36bc5cbc 100644 --- a/behaviour_tree.cpp +++ b/behaviour_tree.cpp @@ -1,11 +1,14 @@ #include "behaviour_tree.h" #include "behaviour_nodes/behaviour_composite.h" #include "behaviour_nodes/behaviour_node.h" -#include "behaviour_nodes/control_nodes.h" #include "core/config/engine.h" +#include "core/object/class_db.h" +#include "core/object/object.h" #include "core/variant/typed_array.h" -void BehaviourTree::_bind_methods() {} +void BehaviourTree::_bind_methods() { + ADD_SIGNAL(MethodInfo("current_behaviour_changed", PropertyInfo(Variant::OBJECT, "new_behaviour", PROPERTY_HINT_NODE_TYPE, "BehaviourNode"))); +} void BehaviourTree::process() { do { @@ -47,6 +50,7 @@ bool BehaviourTree::execute_next() { } if (this->current->get_parent() != next) { next->enter(); + emit_signal("current_behaviour_changed", next); } this->current = next; return this->current != this->root && (cast_to(this->current) || this->current->get_status() != BehaviourNode::Running); From d51f4da2a9025aed2758b1a68777b191afa186c6 Mon Sep 17 00:00:00 2001 From: Sara Date: Fri, 20 Mar 2026 19:42:09 +0100 Subject: [PATCH 2/2] fix: decorator node always runs --- decorator_nodes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/decorator_nodes.cpp b/decorator_nodes.cpp index b46b41b1af..ea70400652 100644 --- a/decorator_nodes.cpp +++ b/decorator_nodes.cpp @@ -43,7 +43,7 @@ void BehaviourInvertResult::execute() { if (get_child_behaviours().is_empty()) { set_status(Fail); ERR_FAIL_EDMSG("BehaviourInvertResult executed with no children"); - } else if (get_status() == Running) { + } else { Status child_status{ get_child_behaviours().get(0)->get_status() }; switch (child_status) { case Fail: