BloodAndGore/Assets/Scripts/AI/BehaviourLeaf.cs

26 lines
750 B
C#
Raw Normal View History

2019-08-03 17:36:17 +02:00
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;
}
}
}