Files
tianrunCRM/Assets/CoolapeFrame/3rd/Hivemind/Scripts/BehaviorTreeAgent.cs
2020-07-04 14:41:25 +08:00

38 lines
713 B
C#

using UnityEngine;
using System.Collections;
namespace Hivemind {
[AddComponentMenu("Miscellaneous/Behavior Tree Agent")]
public class BehaviorTreeAgent : MonoBehaviour {
public BTAsset btAsset;
[HideInInspector]
public BehaviorTree behaviorTree;
public bool debugMode = true;
public Context context;
public void Awake() {
behaviorTree = btAsset.Deserialize();
context = new Context();
}
public void Start() {
if (btAsset == null) {
return;
}
}
public void Update() {
Tick();
}
public void Tick() {
if (behaviorTree == null) {
throw new MissingReferenceException("Behavior Tree not defined");
}
behaviorTree.Tick (gameObject, context);
}
}
}