diff --git a/bt/decorators/bt_new_scope.cpp b/bt/decorators/bt_new_scope.cpp index 423bde9..8670185 100644 --- a/bt/decorators/bt_new_scope.cpp +++ b/bt/decorators/bt_new_scope.cpp @@ -2,14 +2,28 @@ #include "bt_new_scope.h" #include "core/error_macros.h" +#include "core/os/memory.h" #include "core/ustring.h" +#include "modules/limboai/blackboard.h" void BTNewScope::initialize(Object *p_agent, const Ref &p_blackboard) { ERR_FAIL_COND(p_agent == nullptr); ERR_FAIL_COND(p_blackboard == nullptr); + Ref bb = memnew(Blackboard); + + // if (blackboard_data.empty()) { + // bb->set_parent_scope(p_blackboard); + // } else { + // Ref ro = memnew(Blackboard); + // ro->set_data(blackboard_data); + // ro->set_parent_scope(p_blackboard); + // bb->set_parent_scope(ro); + // } + + bb->set_data(blackboard_data.duplicate()); bb->set_parent_scope(p_blackboard); - bb->set_data(blackboard_data); + BTDecorator::initialize(p_agent, bb); } diff --git a/editor/limbo_ai_editor_plugin.cpp b/editor/limbo_ai_editor_plugin.cpp index f39b109..f070f9d 100644 --- a/editor/limbo_ai_editor_plugin.cpp +++ b/editor/limbo_ai_editor_plugin.cpp @@ -423,7 +423,7 @@ void TaskPanel::_populate_from_user_dir(String p_path, HashMaplist_dir_begin(); String fn = dir->get_next(); while (!fn.empty()) { - if (dir->current_is_dir()) { + if (dir->current_is_dir() && fn != "..") { String full_path; String category; if (fn == ".") { diff --git a/limbo_utility.cpp b/limbo_utility.cpp index 489a97c..20f4056 100644 --- a/limbo_utility.cpp +++ b/limbo_utility.cpp @@ -1,6 +1,7 @@ /* limbo_utility.cpp */ #include "limbo_utility.h" +#include "bt/bt_task.h" #include "core/variant.h" LimboUtility *LimboUtility::singleton = nullptr; @@ -9,7 +10,7 @@ LimboUtility *LimboUtility::get_singleton() { return singleton; } -String LimboUtility::decorate_var(String p_variable) { +String LimboUtility::decorate_var(String p_variable) const { String var = p_variable.trim_prefix("$").trim_prefix("\"").trim_suffix("\""); if (var.find(" ") == -1 and not var.empty()) { return vformat("$%s", var); @@ -18,8 +19,24 @@ String LimboUtility::decorate_var(String p_variable) { } } +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 ""; + } +} + void LimboUtility::_bind_methods() { ClassDB::bind_method(D_METHOD("decorate_var", "p_variable"), &LimboUtility::decorate_var); + ClassDB::bind_method(D_METHOD("get_status_name", "p_status"), &LimboUtility::get_status_name); } LimboUtility::LimboUtility() { diff --git a/limbo_utility.h b/limbo_utility.h index fb9d980..6a39eb2 100644 --- a/limbo_utility.h +++ b/limbo_utility.h @@ -15,7 +15,8 @@ protected: public: static LimboUtility *get_singleton(); - String decorate_var(String p_variable); + String decorate_var(String p_variable) const; + String get_status_name(int p_status) const; LimboUtility(); ~LimboUtility();