diff --git a/bt/bt_player.cpp b/bt/bt_player.cpp index ffecd6e..a2999e5 100644 --- a/bt/bt_player.cpp +++ b/bt/bt_player.cpp @@ -151,6 +151,11 @@ void BTPlayer::_notification(int p_notification) { } } break; #ifdef DEBUG_ENABLED + case NOTIFICATION_ENTER_TREE: { + if (tree_instance.is_valid()) { + LimboDebugger::get_singleton()->register_bt_instance(tree_instance, get_path()); + } + } break; case NOTIFICATION_EXIT_TREE: { if (tree_instance.is_valid()) { LimboDebugger::get_singleton()->unregister_bt_instance(tree_instance, get_path()); diff --git a/bt/bt_state.cpp b/bt/bt_state.cpp index cf1c7d7..9f0a711 100644 --- a/bt/bt_state.cpp +++ b/bt/bt_state.cpp @@ -47,6 +47,11 @@ void BTState::_update(double p_delta) { #ifdef DEBUG_ENABLED void BTState::_notification(int p_notification) { switch (p_notification) { + case NOTIFICATION_ENTER_TREE: { + if (tree_instance.is_valid()) { + LimboDebugger::get_singleton()->register_bt_instance(tree_instance, get_path()); + } + } break; case NOTIFICATION_EXIT_TREE: { if (tree_instance.is_valid()) { LimboDebugger::get_singleton()->unregister_bt_instance(tree_instance, get_path()); diff --git a/editor/debugger/limbo_debugger.cpp b/editor/debugger/limbo_debugger.cpp index 6a9fb6d..f184e1b 100644 --- a/editor/debugger/limbo_debugger.cpp +++ b/editor/debugger/limbo_debugger.cpp @@ -69,7 +69,12 @@ Error LimboDebugger::parse_message(void *p_user, const String &p_msg, const Arra } void LimboDebugger::register_bt_instance(Ref p_instance, NodePath p_player_path) { - ERR_FAIL_COND(active_trees.has(p_player_path)); + ERR_FAIL_COND(p_instance.is_null()); + ERR_FAIL_COND(p_player_path.is_empty()); + if (active_trees.has(p_player_path)) { + return; + } + print_line("DEBUG :: register :: ", p_player_path); active_trees.insert(p_player_path, p_instance); if (session_active) { @@ -78,7 +83,9 @@ void LimboDebugger::register_bt_instance(Ref p_instance, NodePath p_play } void LimboDebugger::unregister_bt_instance(Ref p_instance, NodePath p_player_path) { + ERR_FAIL_COND(p_instance.is_null()); ERR_FAIL_COND(p_player_path.is_empty()); + print_line("DEBUG :: unregister :: ", p_player_path); ERR_FAIL_COND(!active_trees.has(p_player_path)); if (tracked_tree == p_player_path) {