using System; using System.Collections.Generic; using UnityEngine; namespace DefaultNamespace.BehaviorTree { public class Tree : MonoBehaviour { private Node _rootNode; // may be you want to run this tree anyways without looking for // the current state, then throw the ifs away private void OnEnable() { // create first node _rootNode = new Sequence(new List()); //if (_rootNode.OnStart() == Status.Failure) enabled = false; Debug.Log($"Root node status at start: {_rootNode.OnStart()}"); } private void OnDisable() { _rootNode.OnEnd(); } private void Update() { // Status status = _rootNode.OnUpdate(); // // switch (status) // { // case Status.Success: // break; // case Status.Failure: // break; // case Status.Running: // break; // default: // throw new ArgumentOutOfRangeException(); // } Debug.Log($"Root node status at update: {_rootNode.OnUpdate()}"); } } }