ScummVM API documentation
ai_condition.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * Additional copyright for this file:
8  * Copyright (C) 1995-1997 Presto Studios, Inc.
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  *
23  */
24 
25 #ifndef PEGASUS_AI_AICONDITION_H
26 #define PEGASUS_AI_AICONDITION_H
27 
28 #include "pegasus/timers.h"
29 
30 namespace Common {
31  class ReadStream;
32  class WriteStream;
33 }
34 
35 namespace Pegasus {
36 
38 //
39 // AICondition
40 
41 class AICondition {
42 public:
43  AICondition() {}
44  virtual ~AICondition() {}
45 
46  virtual bool fireCondition() = 0;
47 
48  // Only need these for conditions that are dynamic, like timer conditions...
49  // other conditions, like item related conditions, which don't change during
50  // the run of an environment, are completely initted when the environment
51  // is created.
52  virtual void writeAICondition(Common::WriteStream *) {}
53  virtual void readAICondition(Common::ReadStream *) {}
54 };
55 
57 //
58 // AIOneChildCondition
59 
61 public:
63  ~AIOneChildCondition() override;
64 
65  void writeAICondition(Common::WriteStream *) override;
66  void readAICondition(Common::ReadStream *) override;
67 
68 protected:
69  AICondition *_child;
70 };
71 
73 //
74 // AITwoChildrenCondition
75 
77 public:
79  ~AITwoChildrenCondition() override;
80 
81  void writeAICondition(Common::WriteStream *) override;
82  void readAICondition(Common::ReadStream *) override;
83 
84 protected:
85  AICondition *_leftChild, *_rightChild;
86 };
87 
89 //
90 // AINotCondition
91 
93 public:
95 
96  bool fireCondition() override;
97 };
98 
100 //
101 // AIAndCondition
102 
104 public:
106 
107  bool fireCondition() override;
108 };
109 
111 //
112 // AIOrCondition
113 
115 public:
117 
118  bool fireCondition() override;
119 };
120 
122 //
123 // AITimerCondition
124 
126 public:
127  AITimerCondition(const TimeValue, const TimeScale, const bool);
128 
129  void startTimer();
130  void stopTimer();
131 
132  bool fireCondition() override;
133 
134  void writeAICondition(Common::WriteStream *) override;
135  void readAICondition(Common::ReadStream *) override;
136 
137 protected:
138  void fire();
139 
140  FuseFunction _timerFuse;
141  bool _fired;
142 };
143 
145 //
146 // AILocationCondition
147 
149 public:
150  AILocationCondition(uint32);
151  ~AILocationCondition() override;
152 
153  void addLocation(RoomViewID);
154  bool fireCondition() override;
155 
156  void writeAICondition(Common::WriteStream *) override;
157  void readAICondition(Common::ReadStream *) override;
158 
159 protected:
160  uint32 _numLocations, _maxLocations;
161  RoomViewID *_locations;
162 };
163 
165 //
166 // AIDoorOpenedCondition
167 
169 public:
170  AIDoorOpenedCondition(RoomViewID);
171  ~AIDoorOpenedCondition() override {}
172 
173  bool fireCondition() override;
174 
175 protected:
176  RoomViewID _doorLocation;
177 };
178 
180 //
181 // AIHasItemCondition
182 
184 public:
185  AIHasItemCondition(const ItemID);
186 
187  bool fireCondition() override;
188 
189 protected:
190  ItemID _item;
191 };
192 
194 //
195 // AIDoesntHaveItemCondition
196 
198 public:
199  AIDoesntHaveItemCondition(const ItemID);
200 
201  bool fireCondition() override;
202 
203 protected:
204  ItemID _item;
205 };
206 
208 //
209 // AICurrentItemCondition
210 
212 public:
213  AICurrentItemCondition(const ItemID);
214 
215  bool fireCondition() override;
216 
217 protected:
218  ItemID _item;
219 };
220 
222 //
223 // AICurrentBiochipCondition
224 
226 public:
227  AICurrentBiochipCondition(const ItemID);
228 
229  bool fireCondition() override;
230 
231 protected:
232  ItemID _biochip;
233 };
234 
236 //
237 // AIItemStateCondition
238 
240 public:
241  AIItemStateCondition(const ItemID, const ItemState);
242 
243  bool fireCondition() override;
244 
245 protected:
246  ItemID _item;
247  ItemState _state;
248 };
249 
251 //
252 // AIEnergyMonitorCondition
253 
255 public:
256  AIEnergyMonitorCondition(const int32);
257 
258  bool fireCondition() override;
259 
260 protected:
261  int32 _energyThreshold;
262 };
263 
265 //
266 // AILastExtraCondition
267 
269 public:
270  AILastExtraCondition(const ExtraID);
271 
272  bool fireCondition() override;
273 
274 protected:
275  ExtraID _lastExtra;
276 };
277 
279 //
280 // Helper functions
281 
282 AICondition *makeLocationAndDoesntHaveItemCondition(const RoomID room, const DirectionConstant direction, const ItemID item);
283 
284 } // End of namespace Pegasus
285 
286 #endif
Definition: stream.h:77
Definition: ai_condition.h:125
Definition: timers.h:239
Definition: ai_condition.h:60
Definition: ai_condition.h:103
Definition: ai_condition.h:183
Definition: ai_condition.h:114
Definition: ai_condition.h:211
Definition: ai_condition.h:92
Definition: ai_condition.h:254
Definition: ai_condition.h:225
Definition: ai_condition.h:197
Definition: algorithm.h:29
Definition: ai_condition.h:148
Definition: ai_condition.h:239
Definition: ai_condition.h:268
Definition: ai_condition.h:76
Definition: stream.h:385
Definition: ai_condition.h:168
Definition: ai_condition.h:41
Definition: ai_action.h:33