Files
Cielonos/Packages/com.opsive.behaviordesigner/Runtime/Groups/TraversalSystemGroup.cs
SoulliesOfficial 9a9e48f8a5
2026-06-27 12:52:03 -04:00

57 lines
1.8 KiB
C#

#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;
/// <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();
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);
}
/// <summary>
/// The group has stopped running.
/// </summary>
protected override void OnStopRunning()
{
base.OnStopRunning();
BehaviorTreeExecution.CompleteEvaluation(World, EntityManager, true);
}
}
}
#endif