2019-08-03 17:36:17 +02:00
|
|
|
using System;
|
2019-08-14 16:17:48 +02:00
|
|
|
using Saltosion.OneWeapon.Enemies;
|
2019-08-03 17:36:17 +02:00
|
|
|
|
|
|
|
namespace Saltosion.OneWeapon.AI {
|
|
|
|
[Serializable]
|
2019-08-14 16:48:42 +02:00
|
|
|
[Obsolete]
|
2019-08-03 17:36:17 +02:00
|
|
|
public class BehaviourBranch : BehaviourNode {
|
|
|
|
public Trigger Trigger;
|
2019-08-04 17:35:24 +02:00
|
|
|
// FIXME: Change these from arrays to just single ones
|
|
|
|
// BehaviourLeaf already has the capability to have multiple behaviours
|
2019-08-03 17:36:17 +02:00
|
|
|
public BehaviourNode[] TriggeredNodes;
|
|
|
|
public BehaviourNode[] NotTriggeredNodes;
|
|
|
|
|
2019-08-04 15:44:44 +02:00
|
|
|
private String MostRecentExecution;
|
|
|
|
|
2019-08-03 17:36:17 +02:00
|
|
|
/* Returns true if any action was taken. */
|
|
|
|
public override bool Execute(Enemy subject) {
|
2019-08-04 15:44:44 +02:00
|
|
|
if (Trigger != null && Trigger.IsTriggered(subject)) {
|
2019-08-03 17:36:17 +02:00
|
|
|
foreach (BehaviourNode Node in TriggeredNodes) {
|
|
|
|
if (Node.Execute(subject)) {
|
2019-08-04 15:44:44 +02:00
|
|
|
MostRecentExecution = Node.GetExecutedName();
|
2019-08-03 17:36:17 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
foreach (BehaviourNode Node in NotTriggeredNodes) {
|
|
|
|
if (Node.Execute(subject)) {
|
2019-08-04 15:44:44 +02:00
|
|
|
MostRecentExecution = Node.GetExecutedName();
|
2019-08-03 17:36:17 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2019-08-04 15:44:44 +02:00
|
|
|
|
|
|
|
public override string GetExecutedName() {
|
|
|
|
return MostRecentExecution;
|
|
|
|
}
|
2019-08-03 17:36:17 +02:00
|
|
|
}
|
|
|
|
}
|