30 lines
887 B
C#
30 lines
887 B
C#
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;
|
|
}
|
|
}
|
|
}
|