ScummVM API documentation
ai_rule.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_AIRULE_H
26 #define PEGASUS_AI_AIRULE_H
27 
28 #include "common/list.h"
29 
30 #include "pegasus/ai/ai_action.h"
31 #include "pegasus/ai/ai_condition.h"
32 
33 namespace Common {
34  class ReadStream;
35  class WriteStream;
36 }
37 
38 namespace Pegasus {
39 
40 class AICondition;
41 class AIAction;
42 
43 class AIRule {
44 public:
45  AIRule(AICondition *condition, AIAction *rule) {
46  _ruleCondition = condition;
47  _ruleAction = rule;
48  _ruleActive = true;
49  }
50 
51  ~AIRule() {
52  if (_ruleCondition)
53  delete _ruleCondition;
54 
55  if (_ruleAction)
56  delete _ruleAction;
57  }
58 
59  bool fireRule();
60 
61  void activateRule() { _ruleActive = true; }
62  void deactivateRule() { _ruleActive = false; }
63  bool isRuleActive() { return _ruleActive; }
64 
65  void writeAIRule(Common::WriteStream *);
66  void readAIRule(Common::ReadStream *);
67 
68 protected:
69  AICondition *_ruleCondition;
70  AIAction *_ruleAction;
71  bool _ruleActive;
72 };
73 
74 class AIRuleList : public Common::List<AIRule *> {
75 public:
76  AIRuleList() {}
77  ~AIRuleList() {}
78 
79  void writeAIRules(Common::WriteStream *);
80  void readAIRules(Common::ReadStream *);
81 };
82 
83 } // End of namespace Pegasus
84 
85 #endif
Definition: stream.h:77
Definition: list.h:44
Definition: algorithm.h:29
Definition: ai_rule.h:43
Definition: stream.h:385
Definition: ai_rule.h:74
Definition: ai_condition.h:41
Definition: ai_action.h:42
Definition: ai_action.h:33