Refactor BT nodes methods to always use context structure as input

This commit is contained in:
Wojtek Figat
2023-08-24 16:51:25 +02:00
parent 8c1dfb3087
commit a27cb4e215
4 changed files with 85 additions and 74 deletions

View File

@@ -144,10 +144,17 @@ void BehaviorKnowledge::FreeMemory()
{
// Release any outstanding nodes state and memory
ASSERT_LOW_LAYER(Tree);
BehaviorUpdateContext context;
context.Behavior = Behavior;
context.Knowledge = this;
context.Memory = Memory;
context.RelevantNodes = &RelevantNodes;
context.DeltaTime = 0.0f;
context.Time = 0.0f;
for (const auto& node : Tree->Graph.Nodes)
{
if (node.Instance && node.Instance->_executionIndex != -1 && RelevantNodes[node.Instance->_executionIndex])
node.Instance->ReleaseState(Behavior, Memory);
node.Instance->ReleaseState(context);
}
Allocator::Free(Memory);
Memory = nullptr;