#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Groups
{
using Opsive.BehaviorDesigner.Runtime.Utility;
using Unity.Entities;
///
/// Main group for the systems that are responsible for traversing the behavior tree.
///
[UpdateInGroup(typeof(BehaviorTreeSystemGroup))]
[UpdateAfter(typeof(InterruptSystemGroup))]
public partial class TraversalSystemGroup : ComponentSystemGroup
{
///
/// Updates the systems. Determines if the systems need to keep being evaluated.
///
protected override void OnUpdate()
{
#if UNITY_EDITOR
var count = 0;
#endif
bool evaluate;
do {
base.OnUpdate();
evaluate = BehaviorTreeExecution.CompleteTraversal(World, EntityManager);
#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);
}
///
/// The group has stopped running.
///
protected override void OnStopRunning()
{
base.OnStopRunning();
BehaviorTreeExecution.CompleteEvaluation(World, EntityManager, true);
}
}
}
#endif