Improve prefetching
This commit is contained in:
parent
7de582c4e6
commit
a6e6b53e18
|
@ -74,8 +74,7 @@ void Blackboard::unbind_var(const StringName &p_name) {
|
|||
data[p_name].unbind();
|
||||
}
|
||||
|
||||
void Blackboard::add_var(const StringName &p_name, const BBVariable &p_var) {
|
||||
ERR_FAIL_COND(data.has(p_name));
|
||||
void Blackboard::assign_var(const StringName &p_name, const BBVariable &p_var) {
|
||||
data.insert(p_name, p_var);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
void bind_var_to_property(const StringName &p_name, Object *p_object, const StringName &p_property);
|
||||
void unbind_var(const StringName &p_name);
|
||||
|
||||
void add_var(const StringName &p_name, const BBVariable &p_var);
|
||||
void assign_var(const StringName &p_name, const BBVariable &p_var);
|
||||
|
||||
// TODO: Add serialization API.
|
||||
};
|
||||
|
|
|
@ -284,14 +284,16 @@ inline void bb_add_var_dup_with_prefetch(const Ref<Blackboard> &p_blackboard, co
|
|||
if (n != nullptr) {
|
||||
var.set_value(n);
|
||||
} else {
|
||||
// Print error only if the variable is not present (it can be initialized by the user or in the parent scope).
|
||||
if (!p_blackboard->has_var(p_name)) {
|
||||
if (p_blackboard->has_var(p_name)) {
|
||||
// Not adding: Assuming variable was initialized by the user or in the parent scope.
|
||||
return;
|
||||
}
|
||||
ERR_PRINT(vformat("BlackboardPlan: Prefetch failed for variable $%s with value: %s", p_name, p_var.get_value()));
|
||||
var.set_value(Variant());
|
||||
}
|
||||
}
|
||||
p_blackboard->add_var(p_name, var);
|
||||
p_blackboard->assign_var(p_name, var);
|
||||
} else {
|
||||
p_blackboard->add_var(p_name, p_var.duplicate());
|
||||
p_blackboard->assign_var(p_name, p_var.duplicate());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue