/** * limbo_ai_editor_plugin.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. * ============================================================================= */ #ifdef TOOLS_ENABLED #include "limbo_ai_editor_plugin.h" #include "action_banner.h" #include "modules/limboai/bt/tasks/bt_comment.h" #include "modules/limboai/bt/tasks/composites/bt_probability_selector.h" #include "modules/limboai/bt/tasks/composites/bt_selector.h" #include "modules/limboai/editor/debugger/limbo_debugger_plugin.h" #include "modules/limboai/editor/editor_property_bb_param.h" #include "modules/limboai/util/limbo_utility.h" #include "core/config/project_settings.h" #include "core/error/error_macros.h" #include "editor/debugger/editor_debugger_node.h" #include "editor/debugger/script_editor_debugger.h" #include "editor/editor_file_system.h" #include "editor/editor_help.h" #include "editor/editor_paths.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" #include "editor/editor_undo_redo_manager.h" #include "editor/inspector_dock.h" #include "editor/plugins/script_editor_plugin.h" #include "editor/project_settings_editor.h" #include "scene/gui/panel_container.h" #include "scene/gui/separator.h" //**** LimboAIEditor _FORCE_INLINE_ String _get_script_template_path() { String templates_search_path = GLOBAL_GET("editor/script/templates_search_path"); return templates_search_path.path_join("BTTask").path_join("custom_task.gd"); } void LimboAIEditor::_add_task(const Ref &p_task) { if (task_tree->get_bt().is_null()) { return; } ERR_FAIL_COND(p_task.is_null()); EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); undo_redo->create_action(TTR("Add BT Task")); Ref parent = task_tree->get_selected(); if (parent.is_null()) { parent = task_tree->get_bt()->get_root_task(); } if (parent.is_null()) { undo_redo->add_do_method(task_tree->get_bt().ptr(), SNAME("set_root_task"), p_task); undo_redo->add_undo_method(task_tree->get_bt().ptr(), SNAME("set_root_task"), task_tree->get_bt()->get_root_task()); } else { undo_redo->add_do_method(parent.ptr(), SNAME("add_child"), p_task); undo_redo->add_undo_method(parent.ptr(), SNAME("remove_child"), p_task); } undo_redo->add_do_method(task_tree, SNAME("update_tree")); undo_redo->add_undo_method(task_tree, SNAME("update_tree")); undo_redo->commit_action(); _mark_as_dirty(true); } Ref LimboAIEditor::_create_task_by_class_or_path(const String &p_class_or_path) const { Ref ret; if (p_class_or_path.begins_with("res:")) { Ref