From a9158c8e480b222e7ac5fd5dcccac6ebd59605e6 Mon Sep 17 00:00:00 2001 From: Sara Date: Fri, 20 Mar 2026 19:41:50 +0100 Subject: [PATCH] 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 7268f749..7b36bc5c 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);