Improve BTComment

Warn user about having comment as root task or having other tasks as children
This commit is contained in:
Serhii Snitsaruk 2023-08-19 12:39:51 +02:00
parent 0ae2b6869a
commit 3f673c6865
2 changed files with 14 additions and 0 deletions

View File

@ -11,9 +11,22 @@
#include "bt_comment.h"
#include "bt_task.h"
Ref<BTTask> BTComment::clone() const {
if (Engine::get_singleton()->is_editor_hint()) {
return BTTask::clone();
}
return nullptr;
}
PackedStringArray BTComment::get_configuration_warnings() const {
PackedStringArray warnings = BTTask::get_configuration_warnings();
if (get_child_count_excluding_comments() > 0) {
warnings.append("Can only have other comment tasks as children.");
}
if (get_parent() == nullptr) {
warnings.append("Can't be the root task.");
}
return warnings;
}

View File

@ -21,6 +21,7 @@ class BTComment : public BTTask {
private:
public:
virtual Ref<BTTask> clone() const override;
virtual PackedStringArray get_configuration_warnings() const override;
};
#endif // BT_COMMENT