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
30namespace Common {
31class WriteStream;
32}
33
34namespace QDEngine {
35
38public:
42
43 qdConditionalObject &operator = (const qdConditionalObject &obj);
44
51 };
52
53 typedef Std::vector<qdCondition> conditions_container_t;
54 typedef Std::vector<qdConditionGroup> condition_groups_container_t;
55
57 virtual bool check_conditions();
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
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
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);
118
119 bool is_condition_in_group(int condition_idx) const;
120
129 };
132
134
138 virtual bool trigger_can_start() const;
139
140protected:
141
145 bool save_conditions_script(Common::WriteStream &fh, int indent = 0) const;
146
147private:
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
size_type size() const
Definition: array.h:316
bool empty() const
Definition: array.h:352
iterator begin()
Definition: array.h:375
Definition: stream.h:745
Definition: stream.h:77
Группа условий.
Definition: qd_condition_group.h:32
Условие.
Definition: qd_condition.h:357
Объект с условиями.
Definition: qd_conditional_object.h:37
int conditions_count() const
Возвращает количество условий.
Definition: qd_conditional_object.h:72
bool update_condition(int num, const qdCondition &p)
Обновляет условие условие с порядковым номером num.
bool save_data(Common::WriteStream &fh) const
Запись данных в сэйв.
bool update_condition_group(int num, const qdConditionGroup &p)
Обновляет группу условий с порядковым номером num.
bool load_data(Common::SeekableReadStream &fh, int save_version)
Загрузка данных из сэйва.
int add_condition(const qdCondition *p)
Добавляет условие. Возвращает поярдковый номер,-1 в случае ошибки.
ConditionsMode
Режим проверки условий.
Definition: qd_conditional_object.h:46
@ CONDITIONS_OR
"ИЛИ" - достаточно выполнения одного из условий.
Definition: qd_conditional_object.h:50
@ CONDITIONS_AND
"И" - должны выполниться все условия.
Definition: qd_conditional_object.h:48
void set_conditions_mode(ConditionsMode m)
Устанавливает режим проверки условий.
Definition: qd_conditional_object.h:99
ConditionsMode conditions_mode() const
Возвращает режим проверки условий.
Definition: qd_conditional_object.h:95
bool load_conditions_script(const xml::tag *p)
Загрузка данных из скрипта.
virtual bool init()
Инициализация объекта, вызывается при старте и перезепуске игры.
bool remove_conditon(int idx)
Удаляет условие.
virtual bool trigger_can_start() const
Возвращает true, если триггер может быть активирован при выполнении его внутренних условий.
bool remove_conditon_group(int idx)
Удаляет группу условий.
bool has_conditions() const
Возвращает true, если список условий не пустой.
Definition: qd_conditional_object.h:104
const qdConditionGroup * get_condition_group(int idx=0) const
Возвращает указатель на группу условий.
Definition: qd_conditional_object.h:85
bool save_conditions_script(Common::WriteStream &fh, int indent=0) const
Запись данных в скрипт.
trigger_start_mode
Варианты старта триггера.
Definition: qd_conditional_object.h:122
@ TRIGGER_START_FAILED
запуск не удался
Definition: qd_conditional_object.h:124
@ TRIGGER_START_WAIT
включить ждущий режим у триггера
Definition: qd_conditional_object.h:128
@ TRIGGER_START_ACTIVATE
включить активный режим у триггера
Definition: qd_conditional_object.h:126
int condition_groups_count() const
Возвращает количество групп условий.
Definition: qd_conditional_object.h:90
virtual trigger_start_mode trigger_start()=0
Активация триггера.
int add_condition_group(const qdConditionGroup *p)
Добавляет группу условий. Возвращает поярдковый номер,-1 в случае ошибки.
virtual bool check_conditions()
Возвращает true, если условия выполняются.
void conditions_quant(float dt)
Обсчет логики условий, dt - время в секундах.
const qdCondition * get_condition(int idx=0) const
Возвращает указатель на условие.
Definition: qd_conditional_object.h:67
Поименованный объект.
Definition: qd_named_object.h:70
XML тег.
Definition: xml_tag.h:33
Definition: algorithm.h:29
Базовый класс для игровых ресурсов.
Definition: console.h:28