BloodAndGore/Assets/Scripts/AI/BehaviourBranch.cs

30 lines
887 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 BehaviourBranch : BehaviourNode {
public Trigger Trigger;
public BehaviourNode[] TriggeredNodes;
public BehaviourNode[] NotTriggeredNodes;
/* Returns true if any action was taken. */
public override bool Execute(Enemy subject) {
if (Trigger.IsTriggered(subject)) {
foreach (BehaviourNode Node in TriggeredNodes) {
if (Node.Execute(subject)) {
return true;
}
}
} else {
foreach (BehaviourNode Node in NotTriggeredNodes) {
if (Node.Execute(subject)) {
return true;
}
}
}
return false;
}
}
}