-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBehaviourController.cs
46 lines (37 loc) · 1.01 KB
/
BehaviourController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Controls the behaviour tree.
/// </summary>
namespace BeeTree {
public class BehaviourController : MonoBehaviour
{
public BehaviourTree behaviourTree;
private BehaviourTree _runtimeBehaviourTree;
private Blackboard _blackboard;
public BehaviourTree RuntimeBehaviourTree => _runtimeBehaviourTree;
private void Start ()
{
if (behaviourTree == null)
{
Debug.LogWarning("No Behaviour Tree set in Behaviour Controller", gameObject);
return;
}
_runtimeBehaviourTree = behaviourTree.Clone();
_blackboard = new Blackboard(this);
_runtimeBehaviourTree.Initialize(_blackboard);
}
private void Update ()
{
if (_runtimeBehaviourTree != null)
{
_runtimeBehaviourTree.Tick();
}
}
public void ReturnState(Node.NodeState state)
{
Debug.Log("Tree completed with state: " + state);
}
}
}