Behaviour Tree
This commit is contained in:
39
Runtime/Engine/Code/AI/BehaviourNode.cs
Normal file
39
Runtime/Engine/Code/AI/BehaviourNode.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace RebootKit.Engine.AI {
|
||||
public class BehaviourNode {
|
||||
public enum Status {
|
||||
Success,
|
||||
Failure,
|
||||
Running
|
||||
}
|
||||
|
||||
public readonly string Name;
|
||||
|
||||
public readonly List<BehaviourNode> Children = new List<BehaviourNode>();
|
||||
|
||||
protected int m_CurrentChild;
|
||||
|
||||
public BehaviourNode(string name) {
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public void AddChild(BehaviourNode child) {
|
||||
Children.Add(child);
|
||||
}
|
||||
|
||||
public virtual Status Process(float dt) {
|
||||
return Children[m_CurrentChild].Process(dt);
|
||||
}
|
||||
|
||||
public virtual void Reset() {
|
||||
m_CurrentChild = 0;
|
||||
|
||||
for (int i = 0; i < Children.Count; i++) {
|
||||
Children[i].Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user