ScummVM API documentation
qd_coords_animation.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_QD_COORDS_ANIMATION_H
23#define QDENGINE_QDCORE_QD_COORDS_ANIMATION_H
24
25#include "qdengine/parser/xml_fwd.h"
26#include "qdengine/qdcore/qd_named_object.h"
27#include "qdengine/qdcore/qd_coords_animation_point.h"
28#include "qdengine/qdcore/qd_named_object_reference.h"
29
30
31namespace QDEngine {
32
33const int QD_COORDS_ANM_OBJECT_START_FLAG = 0x01;
34const int QD_COORDS_ANM_LOOP_FLAG = 0x02;
35const int QD_COORDS_ANM_RELATIVE_FLAG = 0x04; // Флаг перемещения траектории в текущую точку нахождения объекта
36
38public:
39 enum qdCoordsAnimationType {
40 CA_INTERPOLATE_COORDS,
41 CA_WALK
42 };
43
47
48 qdCoordsAnimation &operator = (const qdCoordsAnimation &anm);
49
50 int named_object_type() const {
51 return QD_NAMED_OBJECT_COORDS_ANIMATION;
52 }
53
54 float speed() const {
55 return _speed;
56 }
57 void set_speed(float sp) {
58 _speed = sp;
59 }
60
61 const qdGameObject *start_object() const {
62 return _start_object;
63 }
64 void set_start_object(const qdGameObject *p_obj);
65 const qdNamedObjectReference &start_object_ref() const {
66 return _start_object_ref;
67 }
68
69 bool is_playing() const {
70 return _status;
71 }
72 bool is_finished() const {
73 return _is_finished;
74 }
75
76 qdCoordsAnimationType type() const {
77 return _type;
78 }
79 void set_type(qdCoordsAnimationType tp) {
80 _type = tp;
81 }
82
83 float animation_phase() const {
84 return _animation_phase;
85 }
86 void set_animation_phase(float p) {
87 _animation_phase = p;
88 }
89
90 void start() const;
91 void stop() const;
92 void quant(float dt) const;
93
94 bool reset_cur_point() const;
95 bool set_cur_point(int point_num) const;
96 int get_cur_point() const {
97 return _cur_point;
98 }
99
100 void set_time_rel(float tm);
101
102 void add_point(const qdCoordsAnimationPoint *p);
103 void insert_point(const qdCoordsAnimationPoint *p, int insert_pos);
104
105 void remove_point(int num);
106 void clear();
107
108 qdCoordsAnimationPoint *get_point(int index = 0) {
109 return &_points[index];
110 };
111 const qdCoordsAnimationPoint *get_point(int index = 0) const {
112 return &_points[index];
113 };
114
115 int size() const {
116 return _points.size();
117 }
118
119 void load_script(const xml::tag *p);
120 bool save_script(Common::WriteStream &fh, int indent = 0) const;
121
122 bool is_empty() const {
123 if (_points.empty()) return true;
124 return false;
125 }
126
128 bool load_data(Common::SeekableReadStream &fh, int save_version);
131
132 Common::String flag2str(int flags) const;
133
134private:
135
136 qdCoordsAnimationType _type;
138 float _animation_phase;
139 float _speed;
140
141 // Для относительного перемещения персонажа (QD_COORDS_ANM_RELATIVE_FLAG):
142 // объект, относительно коориднат которого будет работать траектория движения (если не задано, то работаем
143 // относительно координат объекта-владельца координатной анимации)
144 const qdGameObject *_start_object;
145 qdNamedObjectReference _start_object_ref;
146
147 mutable bool _status;
148 mutable bool _is_finished;
149 mutable qdCoordsAnimationPoint _start_point;
150 mutable int _cur_point;
151
152 Vect3f cur_pos() const;
153 class qdGameObjectAnimated *object() const;
154
155 void calc_paths() const;
156
157 // Дельта (вектор) смещения координат анимации
158 mutable Vect3f _del;
159};
160
161//typedef Std::list<qdCoordsAnimation*> qdCoordsAnimationList;
162
163} // namespace QDEngine
164
165#endif // QDENGINE_QDCORE_QD_COORDS_ANIMATION_H
size_type size() const
Definition: array.h:316
bool empty() const
Definition: array.h:352
Definition: stream.h:745
Definition: str.h:59
Definition: stream.h:77
Definition: xmath.h:533
Definition: qd_coords_animation.h:37
int named_object_type() const
Возвращает тип объекта.
Definition: qd_coords_animation.h:50
bool load_data(Common::SeekableReadStream &fh, int save_version)
Загрузка данных из сэйва.
bool save_data(Common::WriteStream &fh) const
Запись данных в сэйв.
Definition: qd_coords_animation_point.h:30
Dynamic object.
Definition: qd_game_object_animated.h:37
Базовый класс для игровых объектов.
Definition: qd_game_object.h:53
Поименованный объект.
Definition: qd_named_object.h:70
int flags() const
Возвращает значение флагов объекта.
Definition: qd_named_object.h:108
Definition: qd_named_object_reference.h:35
Базовый класс для игровых ресурсов.
Definition: console.h:28