*
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class AiSelector : AiComposite {
|
||||
|
||||
private int _currentId = 0;
|
||||
|
||||
protected override void OnBegin(AiBlackboard blackboard) {
|
||||
_currentId = 0;
|
||||
}
|
||||
|
||||
protected override void OnEnd(AiBlackboard blackboard) {
|
||||
|
||||
}
|
||||
|
||||
protected override BehaviorStatus OnExecute(AiBlackboard blackboard) {
|
||||
if (children == null || children.Length == 0) {
|
||||
Debug.LogError("Broken behavior! No children!");
|
||||
return BehaviorStatus.Invalid;
|
||||
}
|
||||
|
||||
while(_currentId < children.Length) {
|
||||
var current = children[_currentId];
|
||||
var result = current.Tick(blackboard);
|
||||
if (result != BehaviorStatus.Fail) {
|
||||
return result;
|
||||
}
|
||||
_currentId++;
|
||||
}
|
||||
return BehaviorStatus.Fail;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user