28 std::cerr <<
"[BehaviorTreeGraphAdapter] Failed to validate BehaviorTree structure. Conversion aborted.\n";
33 auto taskGraph = std::make_unique<TaskGraphTemplate>();
53 std::cout <<
"[BehaviorTreeGraphAdapter] Successfully adapted BehaviorTree '" <<
btAsset.name
54 <<
"' to TaskGraphTemplate (" <<
taskGraph->Nodes.size() <<
" nodes)\n";
64 output <<
"BehaviorTree Simulation Trace: " <<
btAsset.name <<
"\n";
65 output <<
"==================================================\n\n";
67 const auto& events =
tracer.GetEvents();
70 output <<
"[No execution events recorded]\n";
76 for (
const auto&
event : events) {
84 for (
const auto&
event : events) {
93 if (
event.message.find(
"SUCCESS") != std::string::npos) {
95 }
else if (
event.message.find(
"FAILURE") != std::string::npos) {
97 }
else if (
event.message.find(
"RUNNING") != std::string::npos ||
98 event.message.find(
"Running") != std::string::npos) {
104 std::string
indent(depth * 2,
' ');
113 if (!
event.message.empty()) {
114 output <<
" → " <<
event.message;
120 output <<
"\n==================================================\n";
121 output <<
"Total Events: " << events.size() <<
"\n";
131 std::cout <<
"[BehaviorTreeGraphAdapter] Warning: BehaviorTree is empty (no nodes)\n";
132 return btAsset.rootNodeId == 0;
136 std::map<uint32_t, bool>
seenIds;
139 std::cerr <<
"[BehaviorTreeGraphAdapter] Error: Duplicate node ID: " <<
node.id <<
"\n";
148 std::cerr <<
"[BehaviorTreeGraphAdapter] Error: Root node ID " <<
btAsset.rootNodeId <<
" does not exist in tree\n";
156 if (
btAsset.GetNode(childId) ==
nullptr) {
157 std::cerr <<
"[BehaviorTreeGraphAdapter] Error: Node " <<
node.id <<
" references non-existent child " << childId <<
"\n";
166 std::cerr <<
"[BehaviorTreeGraphAdapter] Error: Cycle detected in BehaviorTree\n";
261 if (nodeId ==
btAsset.rootNodeId) {
304 default:
return "Unknown";
Adapter layer for converting BehaviorTree graphs to generic TaskGraphTemplate format.
BTNodeType
Behavior tree node types.
@ Action
Leaf node - performs an action.
@ Selector
OR node - succeeds if any child succeeds.
@ OnEvent
Phase 38b: OnEvent root - event-driven entry point (orange, event-triggered)
@ Sequence
AND node - succeeds if all children succeed.
@ Inverter
Decorator - inverts child result.
@ Condition
Leaf node - checks a condition.
@ Repeater
Decorator - repeats child N times.
@ Root
Phase 38b: Root node - entry point of behavior tree (green, fixed position)
ComponentTypeID GetComponentTypeID_Static()
static void AddNodeToGraph(const BTNode &btNode, const BehaviorTreeAsset &btAsset, TaskGraphTemplate &outGraph, std::map< uint32_t, int32_t > &btToGraphIdMap)
Helper: Recursively adds a node and its children to the graph.
static uint32_t FindParentNodeId(uint32_t childNodeId, const BehaviorTreeAsset &btAsset)
Helper: Finds parent node ID for a given child node.
static bool ValidateTreeStructure(const BehaviorTreeAsset &btAsset)
Validates BehaviorTree structure before conversion.
static int32_t CalculateNodeDepth(uint32_t nodeId, const BehaviorTreeAsset &btAsset)
Helper: Calculates depth of a node in BT hierarchy.
static std::string GetBTNodeTypeName(uint8_t type)
Helper: Gets BehaviorTree node type name.
static std::unique_ptr< TaskGraphTemplate > AdaptToTaskGraph(const BehaviorTreeAsset &btAsset)
Converts a BehaviorTreeAsset to TaskGraphTemplate format.
static std::string FormatTraceForBehaviorTree(const GraphExecutionTracer &tracer, const BehaviorTreeAsset &btAsset)
Formats generic execution trace back to BehaviorTree-specific context.
Records execution trace during graph simulation.
Immutable, shareable task graph asset.
< Provides AssetID and INVALID_ASSET_ID
@ Selector
Executes children in order; stops on first success.
@ AtomicTask
Leaf node that executes a single atomic task.
@ Sequence
Executes children in order; stops on first failure.
@ Decorator
Wraps a single child and modifies its behaviour.
@ Root
Entry point of the graph (exactly one per template)
Represents a single node in a behavior tree.
Explicit connection between a named exec-out pin of a source node and the exec-in pin of a target nod...
Full description of a single node in the task graph.
int32_t NodeID
Unique ID within this template.