-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpw_behavior_sequence.cpp
More file actions
41 lines (35 loc) · 889 Bytes
/
Copy pathpw_behavior_sequence.cpp
File metadata and controls
41 lines (35 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "pw_behavior_sequence.h"
namespace pwngs
{
EBehaviorResult BehaviorSequence::ExecutionBegan( BehaviorEnvriment& env )
{
m_nCurrentNode = 0;
return BehaviorNode::ExecutionBegan(env);
}
EBehaviorResult BehaviorSequence::Execute(BehaviorEnvriment& env)
{
if(m_nCurrentNode >= m_vtNodes.size())
return BEHAVIOR_RESULT_FINISHED;
BehaviorNode* node = m_vtNodes[m_nCurrentNode];
assert(node);
EBehaviorResult result = node->Evaluation(env);
switch(result)
{
case BEHAVIOR_RESULT_FINISHED:
{
m_nCurrentNode += 1;
if(m_nCurrentNode >= m_vtNodes.size())
result = BEHAVIOR_RESULT_FINISHED;
else
result = BEHAVIOR_RESULT_RUNNING;
}
break;
}
return result;
}
EBehaviorResult BehaviorSequence::ExecutionEnded( BehaviorEnvriment& env )
{
m_nCurrentNode = std::string::npos;
return BehaviorNode::ExecutionEnded(env);
}
}