26 lines
750 B
C#
26 lines
750 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace Saltosion.OneWeapon.AI {
|
|
[Serializable]
|
|
public class BehaviourLeaf : BehaviourNode {
|
|
public Behaviour[] Behaviours;
|
|
public bool IsLeaf { get { return Behaviours.Length > 0; } }
|
|
|
|
/* Returns true if any action was taken. */
|
|
public override bool Execute(Enemy subject) {
|
|
bool Acted = false;
|
|
foreach (Behaviour Behaviour in Behaviours) {
|
|
if (Behaviour.CanBehave(subject)) {
|
|
if (Behaviour.Execute(subject)) {
|
|
return true;
|
|
} else {
|
|
Acted = true;
|
|
}
|
|
}
|
|
}
|
|
return Acted;
|
|
}
|
|
}
|
|
}
|