/** * behavior_tree_data.cpp * ============================================================================= * Copyright 2021-2023 Serhii Snitsaruk * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ #include "behavior_tree_data.h" #include "core/templates/list.h" //// BehaviorTreeData BehaviorTreeData::BehaviorTreeData(const Ref &p_instance, const NodePath &p_player_path) { bt_player_path = p_player_path; // Flatten tree into list depth first List> stack; stack.push_back(p_instance); int id = 0; while (stack.size()) { Ref task = stack[0]; stack.pop_front(); int num_children = task->get_child_count(); for (int i = 0; i < num_children; i++) { stack.push_front(task->get_child(num_children - 1 - i)); } String script_path; if (task->get_script()) { Ref