ScummVM API documentation
qd_conditional_object.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  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef QDENGINE_QDCORE_CONDITIONAL_OBJECT_H
23 #define QDENGINE_QDCORE_CONDITIONAL_OBJECT_H
24 
25 #include "qdengine/parser/xml_fwd.h"
26 #include "qdengine/qdcore/qd_condition.h"
27 #include "qdengine/qdcore/qd_condition_group.h"
28 #include "qdengine/qdcore/qd_named_object.h"
29 
30 namespace Common {
31 class WriteStream;
32 }
33 
34 namespace QDEngine {
35 
38 public:
42 
43  qdConditionalObject &operator = (const qdConditionalObject &obj);
44 
50  CONDITIONS_OR
51  };
52 
55 
57  virtual bool check_conditions();
59  int add_condition(const qdCondition *p);
61  bool update_condition(int num, const qdCondition &p);
62 
64  bool remove_conditon(int idx);
65 
67  const qdCondition *get_condition(int idx = 0) const {
68  return &*(_conditions.begin() + idx);
69  }
70 
72  int conditions_count() const {
73  return _conditions.size();
74  }
75 
77  int add_condition_group(const qdConditionGroup *p);
79  bool update_condition_group(int num, const qdConditionGroup &p);
80 
82  bool remove_conditon_group(int idx);
83 
85  const qdConditionGroup *get_condition_group(int idx = 0) const {
86  return &*(_condition_groups.begin() + idx);
87  }
88 
90  int condition_groups_count() const {
91  return _condition_groups.size();
92  }
93 
96  return _conditions_mode;
97  }
100  _conditions_mode = m;
101  }
102 
104  bool has_conditions() const {
105  return !_conditions.empty();
106  }
107 
109  void conditions_quant(float dt);
110 
112  virtual bool init();
113 
115  bool load_data(Common::SeekableReadStream &fh, int save_version);
117  bool save_data(Common::WriteStream &fh) const;
118 
119  bool is_condition_in_group(int condition_idx) const;
120 
128  TRIGGER_START_WAIT
129  };
131  virtual trigger_start_mode trigger_start() = 0;
132 
134 
138  virtual bool trigger_can_start() const;
139 
140 protected:
141 
143  bool load_conditions_script(const xml::tag *p);
145  bool save_conditions_script(Common::WriteStream &fh, int indent = 0) const;
146 
147 private:
148 
150  ConditionsMode _conditions_mode;
151 
153  conditions_container_t _conditions;
154 
156  condition_groups_container_t _condition_groups;
157 
158  bool check_group_conditions(const qdConditionGroup &gr);
159 };
160 
161 } // namespace QDEngine
162 
163 #endif // QDENGINE_QDCORE_CONDITIONAL_OBJECT_H
ConditionsMode
Режим проверки условий.
Definition: qd_conditional_object.h:46
Условие.
Definition: qd_condition.h:357
Definition: stream.h:77
Поименованный объект.
Definition: qd_named_object.h:70
Группа условий.
Definition: qd_condition_group.h:32
bool has_conditions() const
Возвращает true, если список условий не пустой.
Definition: qd_conditional_object.h:104
ConditionsMode conditions_mode() const
Возвращает режим проверки условий.
Definition: qd_conditional_object.h:95
включить активный режим у триггера
Definition: qd_conditional_object.h:126
Definition: stream.h:745
Объект с условиями.
Definition: qd_conditional_object.h:37
запуск не удался
Definition: qd_conditional_object.h:124
XML тег.
Definition: xml_tag.h:33
int conditions_count() const
Возвращает количество условий.
Definition: qd_conditional_object.h:72
Базовый класс для игровых ресурсов.
Definition: console.h:28
Definition: algorithm.h:29
trigger_start_mode
Варианты старта триггера.
Definition: qd_conditional_object.h:122
"И" - должны выполниться все условия.
Definition: qd_conditional_object.h:48
void set_conditions_mode(ConditionsMode m)
Устанавливает режим проверки условий.
Definition: qd_conditional_object.h:99
const qdCondition * get_condition(int idx=0) const
Возвращает указатель на условие.
Definition: qd_conditional_object.h:67
const qdConditionGroup * get_condition_group(int idx=0) const
Возвращает указатель на группу условий.
Definition: qd_conditional_object.h:85
int condition_groups_count() const
Возвращает количество групп условий.
Definition: qd_conditional_object.h:90