Compare commits
7 Commits
8f684f4169
...
aa7d8ea50e
Author | SHA1 | Date |
---|---|---|
Wilson E. Alvarez | aa7d8ea50e | |
Wilson E. Alvarez | 1a228ba88e | |
Wilson E. Alvarez | 4fc3f1d9fc | |
Wilson E. Alvarez | facb813b44 | |
Wilson E. Alvarez | 0d34c4e887 | |
Wilson E. Alvarez | 2a4fd275cc | |
Wilson E. Alvarez | 1ba6e861f9 |
|
@ -169,7 +169,7 @@ BBVariable BlackboardPlan::get_var(const StringName &p_name) {
|
||||||
Pair<StringName, BBVariable> BlackboardPlan::get_var_by_index(int p_index) {
|
Pair<StringName, BBVariable> BlackboardPlan::get_var_by_index(int p_index) {
|
||||||
Pair<StringName, BBVariable> ret;
|
Pair<StringName, BBVariable> ret;
|
||||||
ERR_FAIL_INDEX_V(p_index, (int)var_map.size(), ret);
|
ERR_FAIL_INDEX_V(p_index, (int)var_map.size(), ret);
|
||||||
return var_list.get(p_index);
|
return var_list[p_index];
|
||||||
}
|
}
|
||||||
|
|
||||||
PackedStringArray BlackboardPlan::list_vars() const {
|
PackedStringArray BlackboardPlan::list_vars() const {
|
||||||
|
|
|
@ -26,7 +26,7 @@ Array BehaviorTreeData::serialize(const Ref<BTTask> &p_tree_instance, const Node
|
||||||
List<Ref<BTTask>> stack;
|
List<Ref<BTTask>> stack;
|
||||||
stack.push_back(p_tree_instance);
|
stack.push_back(p_tree_instance);
|
||||||
while (stack.size()) {
|
while (stack.size()) {
|
||||||
Ref<BTTask> task = stack.front()->get();
|
Ref<BTTask> task = stack[0];
|
||||||
stack.pop_front();
|
stack.pop_front();
|
||||||
|
|
||||||
int num_children = task->get_child_count();
|
int num_children = task->get_child_count();
|
||||||
|
@ -87,7 +87,7 @@ Ref<BehaviorTreeData> BehaviorTreeData::create_from_tree_instance(const Ref<BTTa
|
||||||
List<Ref<BTTask>> stack;
|
List<Ref<BTTask>> stack;
|
||||||
stack.push_back(p_tree_instance);
|
stack.push_back(p_tree_instance);
|
||||||
while (stack.size()) {
|
while (stack.size()) {
|
||||||
Ref<BTTask> task = stack.front()->get();
|
Ref<BTTask> task = stack[0];
|
||||||
stack.pop_front();
|
stack.pop_front();
|
||||||
|
|
||||||
int num_children = task->get_child_count();
|
int num_children = task->get_child_count();
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
#include "core/object/callable_method_pointer.h"
|
#include "core/object/callable_method_pointer.h"
|
||||||
#include "core/os/time.h"
|
#include "core/os/time.h"
|
||||||
#include "core/typedefs.h"
|
#include "core/typedefs.h"
|
||||||
#include "editor/editor_settings.h"
|
|
||||||
#include "editor/themes/editor_scale.h"
|
#include "editor/themes/editor_scale.h"
|
||||||
|
#include "editor/editor_settings.h"
|
||||||
#include "scene/resources/style_box.h"
|
#include "scene/resources/style_box.h"
|
||||||
#endif // LIMBOAI_MODULE
|
#endif // LIMBOAI_MODULE
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ void BehaviorTreeView::_update_tree(const Ref<BehaviorTreeData> &p_data) {
|
||||||
selected_id = item_get_task_id(tree->get_selected());
|
selected_id = item_get_task_id(tree->get_selected());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last_root_id != 0 && p_data->tasks.size() > 0 && last_root_id == (uint64_t)p_data->tasks.front()->get().id) {
|
if (last_root_id != 0 && p_data->tasks.size() > 0 && last_root_id == (uint64_t)p_data->tasks[0].id) {
|
||||||
// * Update tree.
|
// * Update tree.
|
||||||
// ! Update routine is built on assumption that the behavior tree does NOT mutate. With little work it could detect mutations.
|
// ! Update routine is built on assumption that the behavior tree does NOT mutate. With little work it could detect mutations.
|
||||||
|
|
||||||
|
@ -120,9 +120,9 @@ void BehaviorTreeView::_update_tree(const Ref<BehaviorTreeData> &p_data) {
|
||||||
while (item) {
|
while (item) {
|
||||||
ERR_FAIL_COND(idx >= p_data->tasks.size());
|
ERR_FAIL_COND(idx >= p_data->tasks.size());
|
||||||
|
|
||||||
const BTTask::Status current_status = (BTTask::Status)p_data->tasks.get(idx).status;
|
const BTTask::Status current_status = (BTTask::Status)p_data->tasks[idx].status;
|
||||||
const BTTask::Status last_status = item_get_task_status(item);
|
const BTTask::Status last_status = item_get_task_status(item);
|
||||||
const bool status_changed = last_status != p_data->tasks.get(idx).status;
|
const bool status_changed = last_status != p_data->tasks[idx].status;
|
||||||
|
|
||||||
if (status_changed) {
|
if (status_changed) {
|
||||||
item->set_metadata(1, current_status);
|
item->set_metadata(1, current_status);
|
||||||
|
@ -142,7 +142,7 @@ void BehaviorTreeView::_update_tree(const Ref<BehaviorTreeData> &p_data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status_changed || current_status == BTTask::RUNNING) {
|
if (status_changed || current_status == BTTask::RUNNING) {
|
||||||
_item_set_elapsed_time(item, p_data->tasks.get(idx).elapsed_time);
|
_item_set_elapsed_time(item, p_data->tasks[idx].elapsed_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item->get_first_child()) {
|
if (item->get_first_child()) {
|
||||||
|
@ -165,7 +165,7 @@ void BehaviorTreeView::_update_tree(const Ref<BehaviorTreeData> &p_data) {
|
||||||
} else {
|
} else {
|
||||||
// * Create new tree.
|
// * Create new tree.
|
||||||
|
|
||||||
last_root_id = p_data->tasks.size() > 0 ? p_data->tasks.front()->get().id : 0;
|
last_root_id = p_data->tasks.size() > 0 ? p_data->tasks[0].id : 0;
|
||||||
|
|
||||||
tree->clear();
|
tree->clear();
|
||||||
TreeItem *parent = nullptr;
|
TreeItem *parent = nullptr;
|
||||||
|
@ -174,7 +174,7 @@ void BehaviorTreeView::_update_tree(const Ref<BehaviorTreeData> &p_data) {
|
||||||
// Figure out parent.
|
// Figure out parent.
|
||||||
parent = nullptr;
|
parent = nullptr;
|
||||||
if (parents.size()) {
|
if (parents.size()) {
|
||||||
Pair<TreeItem *, int> &p = parents.front()->get();
|
Pair<TreeItem *, int> &p = parents[0];
|
||||||
parent = p.first;
|
parent = p.first;
|
||||||
if (!(--p.second)) {
|
if (!(--p.second)) {
|
||||||
// No children left, remove it.
|
// No children left, remove it.
|
||||||
|
|
Loading…
Reference in New Issue