mirror of
https://github.com/tym1116/BH3.git
synced 2025-12-19 09:54:46 +01:00
129 lines
1.9 KiB
C#
129 lines
1.9 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace BehaviorDesigner.Runtime.Tasks
|
|
{
|
|
public abstract class ParentTask : Task
|
|
{
|
|
[SerializeField]
|
|
protected List<Task> children;
|
|
|
|
public List<Task> Children
|
|
{
|
|
get
|
|
{
|
|
return children;
|
|
}
|
|
private set
|
|
{
|
|
children = value;
|
|
}
|
|
}
|
|
|
|
public virtual int MaxChildren()
|
|
{
|
|
return int.MaxValue;
|
|
}
|
|
|
|
public virtual bool CanRunParallelChildren()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public virtual int CurrentChildIndex()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
public virtual bool CanExecute()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public virtual TaskStatus Decorate(TaskStatus status)
|
|
{
|
|
return status;
|
|
}
|
|
|
|
public virtual bool CanReevaluate()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public virtual bool OnReevaluationStarted()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public virtual void OnReevaluationEnded(TaskStatus status)
|
|
{
|
|
}
|
|
|
|
public virtual void OnChildExecuted(TaskStatus childStatus)
|
|
{
|
|
}
|
|
|
|
public virtual void OnChildExecuted(int childIndex, TaskStatus childStatus)
|
|
{
|
|
}
|
|
|
|
public virtual void OnChildStarted()
|
|
{
|
|
}
|
|
|
|
public virtual void OnChildStarted(int childIndex)
|
|
{
|
|
}
|
|
|
|
public virtual TaskStatus OverrideStatus(TaskStatus status)
|
|
{
|
|
return status;
|
|
}
|
|
|
|
public virtual TaskStatus OverrideStatus()
|
|
{
|
|
return TaskStatus.Running;
|
|
}
|
|
|
|
public virtual void OnConditionalAbort(int childIndex)
|
|
{
|
|
}
|
|
|
|
public override void OnDrawGizmos()
|
|
{
|
|
if (children == null)
|
|
{
|
|
return;
|
|
}
|
|
for (int i = 0; i < children.Count; i++)
|
|
{
|
|
if (children[i] != null)
|
|
{
|
|
children[i].OnDrawGizmos();
|
|
}
|
|
}
|
|
}
|
|
|
|
public void AddChild(Task child, int index)
|
|
{
|
|
if (children == null)
|
|
{
|
|
children = new List<Task>();
|
|
}
|
|
children.Insert(index, child);
|
|
}
|
|
|
|
public void ReplaceAddChild(Task child, int index)
|
|
{
|
|
if (children != null && index < children.Count)
|
|
{
|
|
children[index] = child;
|
|
}
|
|
else
|
|
{
|
|
AddChild(child, index);
|
|
}
|
|
}
|
|
}
|
|
}
|