Blackboard: Refactor prefetching

This commit is contained in:
Serhii Snitsaruk 2023-12-16 16:54:42 +01:00
parent 9abf8a084f
commit 1fb92ca412
1 changed files with 6 additions and 5 deletions

View File

@ -47,12 +47,13 @@ void Blackboard::erase_var(const Variant &p_key) {
void Blackboard::prefetch_nodepath_vars(Node *p_node) { void Blackboard::prefetch_nodepath_vars(Node *p_node) {
ERR_FAIL_COND(p_node == nullptr); ERR_FAIL_COND(p_node == nullptr);
for (int i = 0; i < data.size(); i++) { Array keys = data.keys();
Variant value = data.get_value_at_index(i); Array values = data.values();
if (value.get_type() == Variant::NODE_PATH) { for (int i = 0; i < keys.size(); i++) {
Node *fetched_node = p_node->get_node_or_null(value); if (values[i].get_type() == Variant::NODE_PATH) {
Node *fetched_node = p_node->get_node_or_null(values[i]);
if (fetched_node != nullptr) { if (fetched_node != nullptr) {
data[data.get_key_at_index(i)] = fetched_node; data[keys[i]] = fetched_node;
} }
} }
} }