HKI Core
AIState.cs
Go to the documentation of this file.
1 using UnityEngine;
2 
3 namespace HKI.Core.AI.StateMachine
4 {
10  //[CreateAssetMenu(fileName = "AI State", menuName = "HKI/AI/State Machine/State", order = 1)]
11  public class AIState : ScriptableObject
12  {
13  // Variables
14  public AIAction[] Actions;
16 
17  // Interface functions
18  public void UpdateState(AIStateController controller)
19  {
20  DoActions(controller);
21  CheckTransitions(controller);
22  }
23 
24  // Helper functions
25  void DoActions(AIStateController controller)
26  {
27  for (int i = 0; i < Actions.Length; i++)
28  Actions[i].Act(controller);
29  }
30 
32  {
33  for (int i = 0; i < Transitions.Length; i++)
34  {
35  bool decisionSucceeded = Transitions[i].Decision.Decide(controller);
36 
37  if (decisionSucceeded)
38  controller.TransitionToState(Transitions[i].TrueState);
39  else
40  controller.TransitionToState(Transitions[i].FalseState);
41  }
42  }
43  }
44 }
This is obsolete code it&#39;ll be removed later. For now it&#39;s still included for exemplary purposes for ...
Definition: AIState.cs:11
void CheckTransitions(AIStateController controller)
Definition: AIState.cs:31
This is obsolete code it&#39;ll be removed later. For now it&#39;s still included for exemplary purposes for ...
abstract bool Decide(AIStateController controller)
This is obsolete code it&#39;ll be removed later. For now it&#39;s still included for exemplary purposes for ...
Definition: AIAction.cs:10
This is obsolete code it&#39;ll be removed later. For now it&#39;s still included for exemplary purposes for ...
Definition: AITransition.cs:11
AITransition [] Transitions
Definition: AIState.cs:15
void UpdateState(AIStateController controller)
Definition: AIState.cs:18
void DoActions(AIStateController controller)
Definition: AIState.cs:25