Add GetDebugInfo to BT nodes for debugging

This commit is contained in:
Wojtek Figat
2023-09-19 20:57:19 +02:00
parent f845344d03
commit 336fe46e03
12 changed files with 225 additions and 20 deletions

View File

@@ -166,3 +166,25 @@ void Behavior::OnDisable()
{
BehaviorServiceInstance.UpdateList.Remove(this);
}
#if USE_EDITOR
String Behavior::GetNodeDebugInfo(BehaviorTreeNode* node, Behavior* behavior)
{
if (!node)
return String::Empty;
BehaviorUpdateContext context;
Platform::MemoryClear(&context, sizeof(context));
if (behavior && behavior->_knowledge.RelevantNodes.Get(node->_executionIndex))
{
// Pass behavior and knowledge data only for relevant nodes to properly access it
context.Behavior = behavior;
context.Knowledge = &behavior->_knowledge;
context.Memory = behavior->_knowledge.Memory;
context.RelevantNodes = &behavior->_knowledge.RelevantNodes;
context.Time = behavior->_totalTime;
}
return node->GetDebugInfo(context);
}
#endif