From 84c89356a62407b12ab459a208ec2ab5ca5bf5b7 Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Thu, 2 May 2024 12:49:32 +0200 Subject: [PATCH] Print error if agent node is set after initialization --- bt/bt_player.cpp | 7 +++++++ bt/bt_player.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/bt/bt_player.cpp b/bt/bt_player.cpp index bd00b44..e491ec8 100644 --- a/bt/bt_player.cpp +++ b/bt/bt_player.cpp @@ -93,6 +93,13 @@ void BTPlayer::set_behavior_tree(const Ref &p_tree) { } } +void BTPlayer::set_agent_node(const NodePath &p_agent_node) { + agent_node = p_agent_node; + if (tree_instance.is_valid()) { + ERR_PRINT("BTPlayer: Agent node cannot be set after the behavior tree is instantiated. This change will not affect the behavior tree instance."); + } +} + void BTPlayer::set_blackboard_plan(const Ref &p_plan) { blackboard_plan = p_plan; _update_blackboard_plan(); diff --git a/bt/bt_player.h b/bt/bt_player.h index 74b72e2..026185d 100644 --- a/bt/bt_player.h +++ b/bt/bt_player.h @@ -58,7 +58,7 @@ public: void set_behavior_tree(const Ref &p_tree); Ref get_behavior_tree() const { return behavior_tree; }; - void set_agent_node(const NodePath &p_agent_node) { agent_node = p_agent_node; } + void set_agent_node(const NodePath &p_agent_node); NodePath get_agent_node() const { return agent_node; } void set_blackboard_plan(const Ref &p_plan);