DayZ 1.24
Loading...
Searching...
No Matches
BotStates.c
Go to the documentation of this file.
1
10class BotStateBase
11{
16
17 void BotStateBase(Bot bot = NULL, BotStateBase parent = NULL) { m_Bot = bot; m_Owner = bot.m_Owner; m_ParentState = parent; }
18
20
24 void SetParentState(BotStateBase parent) { m_ParentState = parent; }
29
30 bool HasFSM() { return m_FSM != NULL; }
31 BotFSM GetFSM() { return m_FSM; }
32
34 {
35 if (HasFSM())
36 return m_FSM.ProcessEvent(e);
37 return false;
38 }
39
44 {
45 if (HasFSM())
46 m_FSM.AddTransition(t);
47 else
48 Error("[botfsm] adding transition to state without FSM. Configure FSM first.");
49 }
50
51
58 {
59 if (HasFSM() && !m_FSM.IsRunning())
60 {
61 botDebugPrint("[botfsm] { " + this.Type().ToString() + " Has Sub-FSM! Starting submachine...");
62 m_FSM.Start(e);
63 }
64 else
65 botDebugPrint("[botfsm] { " + this.Type().ToString());
66 }
67
73 void OnUpdate(float dt)
74 {
75 if (HasFSM() && m_FSM.IsRunning())
76 m_FSM.GetCurrentState().OnUpdate(dt);
77 }
78
84 {
85 if (HasFSM() && m_FSM.IsRunning())
86 {
87 botDebugPrint("[botfsm] OnAbort " + this.Type().ToString() + " Has Sub-FSM! Aborting submachine...");
88 m_FSM.Abort(e);
89 }
90 botDebugPrint("[botfsm] } ABORTED " + this.Type().ToString());
91 }
92
98 {
99 botDebugPrint("[botfsm] } " + this.Type().ToString());
100 }
101
106 bool IsWaitingForActionFinish() { return HasFSM() && m_FSM.IsRunning() && m_FSM.GetCurrentState().IsWaitingForActionFinish(); }
107
112 bool IsIdle() { return false; }
113
120
127};
128
130{
132
133 override bool IsIdle() { return true; }
134};
void botDebugPrint(string s)
Definition Bot.c:182
proto string ToString()
string Type
represents event that triggers transition from state to state
Definition BotEvents.c:5
Bot Finite State Machine (Hierarchical)
Definition Bot.c:19
PlayerBase m_Owner
Definition Bot.c:20
represent weapon state base
Definition Bot_Hunt.c:16
void OnStateChanged(BotStateBase src, BotStateBase dst)
called on current state when state machine has changed its state
Definition BotStates.c:126
BotStateBase m_ParentState
bot that this state belongs to
Definition BotStates.c:14
PlayerBase m_Owner
Definition BotStates.c:12
BotFSM GetFSM()
Definition BotStates.c:31
void OnEntry(BotEventBase e)
Definition BotStates.c:57
BotStateBase GetParentState()
Definition BotStates.c:28
void BotStateBase(Bot bot=NULL, BotStateBase parent=NULL)
nested state machine (or null)
Definition BotStates.c:17
void OnUpdate(float dt)
Definition BotStates.c:73
ref BotFSM m_FSM
hierarchical parent state of this state (or null)
Definition BotStates.c:15
void OnAbort(BotEventBase e)
Definition BotStates.c:83
void AddTransition(FSMTransition< BotStateBase, BotEventBase, BotActionBase, BotGuardBase > t)
adds transition into m_FSM transition table
Definition BotStates.c:43
bool HasFSM()
Definition BotStates.c:30
PlayerBase GetPlayerOwner()
Definition BotStates.c:19
void SetParentState(BotStateBase parent)
allows construction of hierarchical state machine
Definition BotStates.c:24
bool IsWaitingForActionFinish()
waiting for active animation action/actionType finish
Definition BotStates.c:106
void OnSubMachineChanged(BotStateBase src, BotStateBase dst)
called when sub-machine has changed its state
Definition BotStates.c:119
bool ProcessEvent(BotEventBase e)
Definition BotStates.c:33
void OnExit(BotEventBase e)
Definition BotStates.c:97
bool IsIdle()
idle state does not expect any animation events
Definition BotStates.c:112
Bot m_Bot
man that this state belongs to
Definition BotStates.c:13
void BotStateIdle(Bot bot=NULL, BotStateBase parent=NULL)
Definition BotStates.c:131
override bool IsIdle()
Definition BotStates.c:133
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90