10#include "../../system/system_utils.h"
18 std::vector<BTValidationMessage>
messages;
20 if (
graph ==
nullptr) {
25 "Create a valid graph document"
80 "Add a root node (Selector or Sequence)"
86 "Multiple root nodes detected",
87 "Connect all nodes to a single root"
103 if (
node !=
nullptr) {
118 "Cycle detected in graph",
119 "Remove circular connections"
126 if (
node->decoratorChild.value != 0) {
137 "Cycle detected in decorator chain",
138 "Remove circular connections"
172 if (
node.decoratorChild.value != 0) {
181 "Too few children (" + std::to_string(
childCount) +
" < " + std::to_string(
typeInfo->minChildren) +
")",
191 "Too many children (" + std::to_string(
childCount) +
" > " + std::to_string(
typeInfo->maxChildren) +
")",
199 if (
graph->GetNodes().empty()) {
204 std::set<uint32_t>
roots;
237 std::vector<uint32_t>
queue;
243 while (!
queue.empty()) {
248 if (
node !=
nullptr) {
254 queue.push_back(childId);
259 if (
node->decoratorChild.value != 0) {
263 queue.push_back(childId);
276 "Orphan node detected (not connected to root)",
277 "Connect this node to the tree or delete it"
293 "Unknown node type: " +
node.type,
294 "Change to valid BT node type"
Validation system for Behavior Tree graph structure.
Registry of all Behavior Tree node types for AIGraphPlugin_BT.
ComponentTypeID GetComponentTypeID_Static()
static void ValidateNodeTypes(const NodeGraph::GraphDocument *graph, std::vector< BTValidationMessage > &messages)
Rule 5: Validate node types are registered.
static void ValidateRootNode(const NodeGraph::GraphDocument *graph, std::vector< BTValidationMessage > &messages)
Rule 1: Check for exactly one root node.
static void ValidateOrphans(const NodeGraph::GraphDocument *graph, std::vector< BTValidationMessage > &messages)
Rule 4: Check for orphan nodes (disconnected from root)
static std::vector< BTValidationMessage > ValidateGraph(const NodeGraph::GraphDocument *graph)
Validate a complete BT graph.
static void ValidateCycles(const NodeGraph::GraphDocument *graph, std::vector< BTValidationMessage > &messages)
Rule 2: Detect cycles in graph.
static void ValidateChildrenCount(const NodeGraph::GraphDocument *graph, std::vector< BTValidationMessage > &messages)
Rule 3: Validate child counts per node type.
static BTNodeRegistry & Get()
Get singleton instance.
Main document class for a node graph.
@ Warning
Warning (non-blocking)
@ Error
Error (blocking compilation)
< Provides AssetID and INVALID_ASSET_ID
Metadata for a behavior tree node type.