Skip to content

Commit b144ebc

Browse files
authored
Do not show warning for NIL type BlackboardPlan variables on BBParam. (#267)
Enable variable mapping for NIL type public BlackboardPlan variables.
1 parent 672f92c commit b144ebc

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

blackboard/blackboard_plan.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ void BlackboardPlan::_get_property_list(List<PropertyInfo> *p_list) const {
200200

201201
#ifdef TOOLS_ENABLED
202202
// * Editor
203-
if (!_is_var_hidden(var_name, var)) {
203+
if (!_is_var_nil(var) || !_is_var_private(var_name, var)) {
204204
if (has_mapping(var_name) || has_property_binding(var_name)) {
205205
p_list->push_back(PropertyInfo(Variant::STRING, var_name, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_READ_ONLY));
206206
} else {
@@ -226,7 +226,7 @@ void BlackboardPlan::_get_property_list(List<PropertyInfo> *p_list) const {
226226
if (is_mapping_enabled()) {
227227
p_list->push_back(PropertyInfo(Variant::NIL, "Mapping", PROPERTY_HINT_NONE, "mapping/", PROPERTY_USAGE_GROUP));
228228
for (const Pair<StringName, BBVariable> &p : var_list) {
229-
if (_is_var_hidden(p.first, p.second)) {
229+
if (_is_var_private(p.first, p.second)) {
230230
continue;
231231
}
232232
if (unlikely(has_property_binding(p.first))) {
@@ -242,7 +242,7 @@ void BlackboardPlan::_get_property_list(List<PropertyInfo> *p_list) const {
242242
// * Binding
243243
p_list->push_back(PropertyInfo(Variant::NIL, "Binding", PROPERTY_HINT_NONE, "binding/", PROPERTY_USAGE_GROUP));
244244
for (const Pair<StringName, BBVariable> &p : var_list) {
245-
if (_is_var_hidden(p.first, p.second)) {
245+
if (_is_var_nil(p.second) || _is_var_private(p.first, p.second)) {
246246
continue;
247247
}
248248
if (unlikely(has_mapping(p.first))) {

blackboard/blackboard_plan.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ class BlackboardPlan : public Resource {
5151
// If true, NodePath variables will be prefetched, so that the vars will contain node pointers instead (upon BB creation/population).
5252
bool prefetch_nodepath_vars = true;
5353

54-
_FORCE_INLINE_ bool _is_var_hidden(const String &p_name, const BBVariable &p_var) const { return p_var.get_type() == Variant::NIL || (is_derived() && p_name.begins_with("_")); }
54+
_FORCE_INLINE_ bool _is_var_nil(const BBVariable &p_var) const { return p_var.get_type() == Variant::NIL; }
55+
_FORCE_INLINE_ bool _is_var_private(const String &p_name, const BBVariable &p_var) const { return is_derived() && p_name.begins_with("_"); }
5556

5657
protected:
5758
static void _bind_methods();

editor/editor_property_variable_name.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void EditorPropertyVariableName::_update_status() {
8989
BUTTON_SET_ICON(status_btn, theme_cache.var_empty_icon);
9090
status_btn->set_tooltip_text(TTR("Variable name not specified.\nClick to open the blackboard plan."));
9191
} else if (plan->has_var(var_name)) {
92-
if (expected_type == Variant::NIL || plan->get_var(var_name).get_type() == expected_type) {
92+
if (expected_type == Variant::NIL || plan->get_var(var_name).get_type() == Variant::NIL || plan->get_var(var_name).get_type() == expected_type) {
9393
BUTTON_SET_ICON(status_btn, theme_cache.var_exists_icon);
9494
status_btn->set_tooltip_text(TTR("This variable is present in the blackboard plan.\nClick to open the blackboard plan."));
9595
} else {

0 commit comments

Comments
 (0)