Add infinite loop to behavior tree loop decorator.

This commit is contained in:
Menotdan
2023-12-08 01:46:55 -05:00
parent 526edb83de
commit 4a50111f9b
2 changed files with 12 additions and 6 deletions

View File

@@ -624,8 +624,10 @@ void BehaviorTreeLoopDecorator::PostUpdate(const BehaviorUpdateContext& context,
if (result == BehaviorUpdateResult::Success)
{
auto state = GetState<State>(context.Memory);
state->Loops--;
if (state->Loops > 0)
if (!InfiniteLoop)
state->Loops--;
if (state->Loops > 0 || InfiniteLoop)
{
// Keep running in a loop but reset node's state (preserve self state)
result = BehaviorUpdateResult::Running;