OdinAI

- Main Page
- Namespaces
- Classes
- Files
- Examples

- File List

All Classes Namespaces Functions Variables
Goals.h
1 /*******************************************************************************
2 * ________ .___.__ _____ .___
3 * \_____ \ __| _/|__| ____ / _ \ | |
4 * / | \ / __ | | |/ \ / /_\ \| |
5 * / | \/ /_/ | | | | \/ | \ |
6 * \_______ /\____ | |__|___| /\____|__ /___|
7 * \/ \/ \/ \/
8 *
9 * Copyright (c) Emil Sandstø 2012
10 *******************************************************************************/
11 #ifndef ODINAI_GOALS_H_
12 #define ODINAI_GOALS_H_
13
14 #ifdef _WINDOWS
15 #pragma once
16 #endif
17
18 #include <stack>
19
20 namespace OdinAI
21 {
22 enum Goal_Status
23 {
24 GOAL_FAILED,
25 GOAL_COMPLETE,
26 GOAL_ACTIVE,
27 GOAL_INACTIVE,
28 };
29
33 class BaseGoal
34 {
35 public:
36 BaseGoal() {}
37
38 virtual ~BaseGoal() {}
39
44 virtual void AddGoal(BaseGoal *goal) {}
45
49 virtual void Activate() {m_status = GOAL_ACTIVE;}
50
54 virtual int Process() {return GOAL_FAILED;}
55
59 virtual void End() {}
60
64 bool IsActive() const {return m_status == GOAL_ACTIVE;}
65
70 void ActivateIfInactive() {if(m_status != GOAL_ACTIVE)Activate();}
71
75 bool IsComplete() const {return m_status == GOAL_COMPLETE;}
76
80 bool HasFailed() const {return m_status == GOAL_FAILED;}
81
85 int GetStatus() const {return m_status;}
86 protected:
87 int m_status;
88 };
89
93 class AtomicGoal : public BaseGoal
94 {
95 public:
96 virtual ~AtomicGoal() {}
97
101 void AddGoal(BaseGoal *goal);
102
106 virtual void Activate() {}
107
111 virtual int Process() {return GOAL_FAILED;}
112
116 virtual void End() {}
117 };
118
122 class CompositeGoal : public BaseGoal
123 {
124 public:
125 CompositeGoal() {}
126
127 virtual ~CompositeGoal();
128
132 virtual void AddGoal(BaseGoal *goal);
133
137 virtual void Activate() {}
138
142 virtual int Process() {return GOAL_FAILED;}
143
147 virtual int ProcessSubgoals();
148
152 virtual void End() {}
153
154 void Clear();
155 protected:
156 std::stack<BaseGoal*> m_stackOfGoals;
157 };
158
159 }
160
161 #endif
OdinAI::BaseGoal::Activate
virtual void Activate()
Definition: Goals.h:49
OdinAI::CompositeGoal::Process
virtual int Process()
Definition: Goals.h:142
OdinAI::AtomicGoal::End
virtual void End()
Definition: Goals.h:116
OdinAI::BaseGoal::m_status
int m_status
The status of the goal.
Definition: Goals.h:87
OdinAI::CompositeGoal::Activate
virtual void Activate()
Definition: Goals.h:137
OdinAI::BaseGoal
Definition: Goals.h:33
OdinAI::AtomicGoal::AddGoal
void AddGoal(BaseGoal *goal)
OdinAI::BaseGoal::GetStatus
int GetStatus() const
Definition: Goals.h:85
OdinAI::BaseGoal::AddGoal
virtual void AddGoal(BaseGoal *goal)
Definition: Goals.h:44
OdinAI::BaseGoal::Process
virtual int Process()
Definition: Goals.h:54
OdinAI::AtomicGoal
Definition: Goals.h:93
OdinAI::CompositeGoal::AddGoal
virtual void AddGoal(BaseGoal *goal)
OdinAI::AtomicGoal::Activate
virtual void Activate()
Definition: Goals.h:106
OdinAI::BaseGoal::IsComplete
bool IsComplete() const
Definition: Goals.h:75
OdinAI::BaseGoal::End
virtual void End()
Definition: Goals.h:59
OdinAI::BaseGoal::IsActive
bool IsActive() const
Definition: Goals.h:64
OdinAI::CompositeGoal::ProcessSubgoals
virtual int ProcessSubgoals()
OdinAI::CompositeGoal
Definition: Goals.h:122
OdinAI::AtomicGoal::Process
virtual int Process()
Definition: Goals.h:111
OdinAI::CompositeGoal::End
virtual void End()
Definition: Goals.h:152
OdinAI::BaseGoal::ActivateIfInactive
void ActivateIfInactive()
Definition: Goals.h:70
OdinAI::BaseGoal::HasFailed
bool HasFailed() const
Definition: Goals.h:80