2025-11-25 08:19:33 -05:00
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Groups
{
2026-06-27 12:52:03 -04:00
using Opsive.BehaviorDesigner.Runtime.Utility ;
2025-11-25 08:19:33 -05:00
using Unity.Entities ;
/// <summary>
/// Main group for the systems that are responsible for traversing the behavior tree.
/// </summary>
[UpdateInGroup(typeof(BehaviorTreeSystemGroup))]
[UpdateAfter(typeof(InterruptSystemGroup))]
public partial class TraversalSystemGroup : ComponentSystemGroup
{
/// <summary>
/// Updates the systems. Determines if the systems need to keep being evaluated.
/// </summary>
protected override void OnUpdate ( )
{
#if UNITY_EDITOR
var count = 0 ;
#endif
bool evaluate ;
do {
base . OnUpdate ( ) ;
2026-06-27 12:52:03 -04:00
evaluate = BehaviorTreeExecution . CompleteTraversal ( World , EntityManager ) ;
2025-11-25 08:19:33 -05:00
#if UNITY_EDITOR
if ( evaluate ) {
count + + ;
if ( count = = ushort . MaxValue / 10 ) {
UnityEngine . Debug . LogWarning ( "An infinite loop would have been caused by the TraversalSystemGroup. Please email support@opsive.com with steps to reproduce this error." ) ;
break ;
}
}
#endif
} while ( evaluate ) ;
}
/// <summary>
/// The group has stopped running.
/// </summary>
protected override void OnStopRunning ( )
{
base . OnStopRunning ( ) ;
2026-06-27 12:52:03 -04:00
BehaviorTreeExecution . CompleteEvaluation ( World , EntityManager , true ) ;
2025-11-25 08:19:33 -05:00
}
}
}
2026-06-27 12:52:03 -04:00
#endif