/// <summary> /// Executes the behavior tree /// </summary> /// <param name="ai">AI component</param> public void ExecuteBT(MoonAI ai) { if (BTResult == TaskResult.None | BTResult == TaskResult.Running) { Profiler.BeginSample("MoonBehavior: Execute BehaviorTree (" + ai.name + ")"); BTResult = Root.Execute(ai); Profiler.EndSample(); } }
/// <summary> /// Task Priority /// </summary> public float GetPriority(MoonAI ai) { if (!PriorityLoaded) { m_priority = _Priority.GetValue <float>(ai.Memory); PriorityLoaded = true; } return(m_priority); }
public TaskResult Execute(MoonAI ai) { if (!Inizialized) { OnEnter(ai); _Started = true; } LastResult = OnExecute(ai); if (LastResult == TaskResult.Success || LastResult == TaskResult.Failure) { OnExit(ai); _Started = false; } else { LastResult = TaskResult.Running; } return(LastResult); }
/// <summary> /// Called when tasks returns Success or Failure /// </summary> /// <param name="ai">AI Agent</param> public virtual void OnExit(MoonAI ai) { }
/// <summary> /// Called when enters the task /// </summary> /// <param name="ai">AI agent</param> public virtual void OnEnter(MoonAI ai) { }
/// <summary> /// Execution of the task and it's result /// </summary> /// <returns>Task result</returns> public abstract TaskResult OnExecute(MoonAI ai);