/** * limbo_utility.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 "limbo_utility.h" #include "modules/limboai/bt/tasks/bt_task.h" #include "core/object/script_language.h" #include "core/variant/variant.h" #include "scene/resources/texture.h" #ifdef TOOLS_ENABLED #include "editor/editor_node.h" #endif // TOOLS_ENABLED LimboUtility *LimboUtility::singleton = nullptr; LimboUtility *LimboUtility::get_singleton() { return singleton; } String LimboUtility::decorate_var(String p_variable) const { String var = p_variable.trim_prefix("$").trim_prefix("\"").trim_suffix("\""); if (var.find(" ") == -1 && !var.is_empty()) { return vformat("$%s", var); } else { return vformat("$\"%s\"", var); } } String LimboUtility::get_status_name(int p_status) const { switch (p_status) { case BTTask::FRESH: return "FRESH"; case BTTask::RUNNING: return "RUNNING"; case BTTask::FAILURE: return "FAILURE"; case BTTask::SUCCESS: return "SUCCESS"; default: return ""; } } Ref LimboUtility::get_task_icon(String p_class_or_script_path) const { #ifdef TOOLS_ENABLED ERR_FAIL_COND_V_MSG(p_class_or_script_path.is_empty(), Variant(), "BTTask: script path or class cannot be empty."); if (p_class_or_script_path.begins_with("res:")) { Ref