This commit is contained in:
Serhii Snitsaruk 2022-11-01 14:03:20 +01:00
parent a91a9ef9ed
commit 1bc8484454
4 changed files with 36 additions and 4 deletions

View File

@ -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<Blackboard> &p_blackboard) {
ERR_FAIL_COND(p_agent == nullptr);
ERR_FAIL_COND(p_blackboard == nullptr);
Ref<Blackboard> bb = memnew(Blackboard);
// if (blackboard_data.empty()) {
// bb->set_parent_scope(p_blackboard);
// } else {
// Ref<Blackboard> 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);
}

View File

@ -423,7 +423,7 @@ void TaskPanel::_populate_from_user_dir(String p_path, HashMap<String, List<Stri
dir->list_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 == ".") {

View File

@ -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() {

View File

@ -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();