Files
gpd-925/AI/Assets/Scripts/BehaviorTree/Tree.cs
T

66 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using UnityEngine;
namespace BehaviorTree
{
public class Tree : MonoBehaviour
{
private Node _rootNode;
private void OnEnable()
{
_rootNode = new Selector(new List<Node>{});
Status status = _rootNode.Start();
Debug.Log(status);
switch (status)
{
case Status.Success:
break;
case Status.Failure:
break;
case Status.Running:
break;
default:
throw new ArgumentOutOfRangeException();
}
}
private void OnDisable()
{
Status status = _rootNode?.End() ?? Status.Failure;
switch (status)
{
case Status.Success:
break;
case Status.Failure:
break;
case Status.Running:
break;
default:
throw new ArgumentOutOfRangeException();
}
_rootNode = null;
}
private void Update()
{
Status status = _rootNode?.Update() ?? Status.Failure;
switch (status)
{
case Status.Success:
break;
case Status.Failure:
break;
case Status.Running:
break;
default:
throw new ArgumentOutOfRangeException();
}
}
}
}