22 #ifndef QDENGINE_QDCORE_QD_GAME_OBJECT_MOVING_H 23 #define QDENGINE_QDCORE_QD_GAME_OBJECT_MOVING_H 25 #include "qdengine/parser/xml_fwd.h" 26 #include "qdengine/qdcore/qd_game_object_animated.h" 30 class qdInterfaceButton;
32 const int QD_MOVING_OBJ_PATH_LENGTH = 200;
44 return QD_NAMED_OBJECT_MOVING_OBJ;
47 enum movement_mode_t {
53 MOVEMENT_MODE_NONE_EARLY
80 CONTROL_ATTACHMENT_TO_ACTIVE_WITH_MOVING = 0x800,
102 if (_control_types & type)
return true;
106 _control_types |= type;
109 _control_types &= ~type;
112 int get_control_types() {
return _control_types; }
113 int get_movement_mode() {
return _movement_mode; }
117 bool is_walkable(
const Vect3f &pos)
const;
118 bool is_walkable(
const Vect2s &pos)
const;
120 const Vect3f &
bound(
bool perspective_correction =
true)
const;
121 Vect3f calc_bound_in_pos(
Vect3f pos,
bool perspective_correction =
true);
122 bool calc_walk_grid(
Vect2s ¢er,
Vect2s &size)
const;
132 float direction_angle()
const {
133 return _direction_angle;
135 float calc_direction_angle(
const Vect3f &target)
const;
136 float animate_rotation(
float dt);
137 float rotation_angle()
const {
138 return _rotation_angle;
141 float rotation_angle_per_quant()
const {
142 return _rotation_angle_per_quant;
144 void set_rotation_angle_per_quant(
float ang) {
145 _rotation_angle_per_quant = ang;
148 bool set_direction(
float angle);
149 int get_direction(
float angle)
const;
151 float default_direction_angle()
const {
152 return _default_direction_angle;
154 void set_default_direction(
float ang) {
155 _default_direction_angle = ang;
158 void set_state(
int st);
162 _last_walk_state = p;
165 return _last_walk_state;
181 bool move(
const Vect3f &target,
bool lock_target =
false);
182 bool move(
const Vect3f &target,
float angle,
bool lock_target =
false);
184 bool move2position(
const Vect3f target);
186 bool skip_movement();
187 bool stop_movement();
189 bool is_moving()
const {
193 bool can_move()
const;
195 bool is_in_position(
const Vect3f pos)
const;
196 bool is_in_position(
const Vect3f pos,
float angle)
const;
198 bool is_moving2position(
const Vect3f pos)
const;
199 bool is_moving2position(
const Vect3f pos,
float angle)
const;
212 return ((_path_length) ? _path[_path_length] : _target_r);
217 void set_scale(
float sc) {
220 float scale()
const {
224 bool load_script(
const xml::tag *p);
232 bool load_resources();
240 Vect3f get_future_r(
float dt,
bool &end_movement,
bool real_moving =
false);
241 void quant(
float dt);
243 void redraw(
int offs_x = 0,
int offs_y = 0)
const;
244 void drawDebugPath()
const;
245 void debug_redraw()
const;
246 void draw_contour(uint32 color)
const;
247 void draw_shadow(
int offs_x,
int offs_y, uint32 color,
int alpha)
const;
253 bool hit(
int x,
int y)
const;
255 bool update_screen_pos();
256 Vect2s screen_size()
const;
258 void disable_control() {
259 _disable_control =
true;
261 void enable_control() {
262 _disable_control =
false;
264 bool is_control_disabled()
const {
265 return _disable_control;
268 bool keyboard_move();
270 bool set_movement_impulse(
float dir_angle);
272 float collision_radius()
const {
273 if (_collision_radius > FLT_EPS)
274 return _collision_radius;
279 void set_collision_radius(
float r) {
280 _collision_radius = r;
283 float collision_delay()
const {
284 return _collision_delay;
286 void set_collision_delay(
float r) {
287 _collision_delay = r;
290 float collision_path()
const {
291 return _collision_path;
293 void set_collision_path(
float path) {
294 _collision_path = path;
297 float follow_min_radius()
const {
298 return _follow_min_radius;
300 void set_follow_min_radius(
float fmr) {
301 _follow_min_radius = fmr;
304 float follow_max_radius()
const {
305 return _follow_max_radius;
307 void set_follow_max_radius(
float fmr) {
308 _follow_max_radius = fmr;
311 int follow_condition()
const {
312 return _follow_condition;
314 void set_follow_condition(
int cond) {
315 _follow_condition = cond;
319 return _circuit_objs;
322 return _circuit_objs;
331 return _attacher_ref;
333 Vect2s attach_shift()
const {
334 return _attach_shift;
336 void set_attach_shift(
Vect2s shift) {
337 _attach_shift = shift;
340 Vect3f last_move_order()
const {
341 return _last_move_order;
343 void set_last_move_order(
const Vect3f &pnt) {
344 _last_move_order = pnt;
348 bool move_from_personage_path();
350 bool toggle_grid_zone(
bool make_walkable =
false);
351 void toggle_selection(
bool state) {
352 _is_selected = state;
355 void set_path_attributes(
int attr)
const;
356 void clear_path_attributes(
int attr)
const;
358 static Common::String control2str(
int control,
bool truncate =
false);
359 static Common::String movement2str(
int movement,
bool truncate =
false);
363 bool load_script_body(
const xml::tag *p);
372 float _collision_radius;
374 float _collision_delay;
376 float _collision_path;
379 float _follow_min_radius;
380 float _follow_max_radius;
383 int _follow_condition;
395 bool _disable_control;
397 bool _impulse_movement_mode;
398 float _impulse_timer;
399 float _impulse_start_timer;
400 float _impulse_direction;
402 movement_mode_t _movement_mode;
403 float _movement_mode_time;
404 float _movement_mode_time_current;
407 float _direction_angle;
408 float _rotation_angle;
409 float _rotation_angle_per_quant;
411 float _default_direction_angle;
421 Vect3f _path[QD_MOVING_OBJ_PATH_LENGTH];
426 bool _ignore_personages;
431 Vect2s get_nearest_walkable_point(
const Vect2s &target)
const;
433 Vect2s get_pre_last_walkable_point(
const Vect2s &target)
const;
434 bool is_path_walkable(
int x1,
int y1,
int x2,
int y2)
const;
435 bool is_path_walkable(
const Vect2i &src,
const Vect2i &trg)
const {
436 return is_path_walkable(src.x, src.y, trg.x, trg.y);
438 bool is_path_walkable(
const Vect3f &src,
const Vect3f &trg)
const;
439 bool enough_far_target(
const Vect3f &dest)
const;
441 void toggle_ignore_personages(
bool state) {
442 _ignore_personages = state;
445 bool find_path(
const Vect3f target,
bool lock_target =
false);
459 bool adjust_position(
Vect3f &pos)
const;
460 bool adjust_direction_angle(
float &angle);
462 void change_direction_angle(
float angle);
464 bool is_direction_allowed(
float angle)
const;
465 int allowed_directions_count()
const;
467 float calc_scale()
const {
468 return calc_scale(R());
470 float calc_scale(
const Vect3f &r)
const;
472 bool set_walk_animation();
473 bool movement_impulse();
476 bool get_speed_parameters(
float &speed,
float &speed_max,
float &acceleration);
480 bool adjust_position(
Vect3f &pos,
float dir_angle)
const;
484 Vect2s walk_grid_size()
const {
485 return walk_grid_size(R());
488 bool start_auto_move();
491 bool future_pos_correct(
float dt);
494 bool is_movement_finished()
const;
499 #endif // QDENGINE_QDCORE_QD_GAME_OBJECT_MOVING_H Definition: qd_game_object_moving.h:78
можно толкать другим персонажем
Definition: qd_game_object_moving.h:63
автоматически двигаться
Definition: qd_game_object_moving.h:67
float radius() const
Возвращает радиус объекта.
сгонять с пути других персонажей, если блокируют дорогу
Definition: qd_game_object_moving.h:69
Vect3f target_position() const
Точка, к которой движется персонаж.
Definition: qd_game_object_moving.h:210
Все ок
Definition: qd_game_object_moving.h:92
control_type_t
режимы управления персонажем
Definition: qd_game_object_moving.h:57
bool save_data(Common::WriteStream &fh) const
Запись данных в сэйв.
Vect3f local_target_position() const
Текущая точка, к которой движется персонаж.
Definition: qd_game_object_moving.h:202
можно указывать мышью точки куда идти
Definition: qd_game_object_moving.h:59
Dynamic object.
Definition: qd_game_object_animated.h:37
Режим с анимацией поворота
Definition: qd_game_object_moving.h:84
follow_condition_t
флаги следования
Definition: qd_game_object_moving.h:88
Состояние динамического объекта - базовый класс.
Definition: qd_game_object_state.h:91
автоматически избегать столкновений с другими персонажами
Definition: qd_game_object_moving.h:65
bool check_flag(int fl) const
Возвращает true, если установлен флаг fl.
Definition: qd_named_object.h:99
Definition: qd_named_object_reference.h:35
XML тег.
Definition: xml_tag.h:33
bool can_change_state(const qdGameObjectState *state=NULL) const
Возвращает true, если объект в данный момент может менять состояние.
Базовый класс для игровых ресурсов.
Definition: console.h:28
bool get_debug_info(Common::String &buf) const
Копирует в буфер отладочную информацию для вывода на экран в отладочном режиме.
bool calc_cur_and_future_walk_grid(float dt, Vect2s &cen_cur, Vect2s &size_cur, Vect2s &cen_next, Vect2s &size_next)
Возвращает текущее положение сетки движения, и положение сетки через dt.
int named_object_type() const
Возвращает тип объекта.
Definition: qd_game_object_moving.h:43
Режим реагирования на клик активному персонажу (персонаж бежит туда же)
Definition: qd_game_object_moving.h:82
Персонаж следует
Definition: qd_game_object_moving.h:98
Персонаж.
Definition: qd_game_object_moving.h:35
movement_type_t
режимы передвижения для персонажа
Definition: qd_game_object_state.h:725
Персонаж ждет остановки всех следующих персонажей, чтобы продолжить следование
Definition: qd_game_object_moving.h:96
Жесткая привязка персонажа к заданному персонажу
Definition: qd_game_object_moving.h:75
Состояние динамического объекта - походка.
Definition: qd_game_object_state.h:715
bool init()
Инициализация объекта, вызывается при старте и перезапуске игры.
Персонаж стремится не отходить от активного персонажа более чем на некоторый радиус ...
Definition: qd_game_object_moving.h:71
mouseEvent
События.
Definition: mouse_input.h:41
Прямоугольная область на экране.
Definition: gr_screen_region.h:31
Для персонажа нужно просчитать путь следования
Definition: qd_game_object_moving.h:90
const Vect3f & bound(bool perspective_correction=true) const
Возвращает баунд объекта.
bool load_data(Common::SeekableReadStream &fh, int save_version)
Загрузка данных из сэйва.
можно рулить с клавиатуры
Definition: qd_game_object_moving.h:61
Персонаж пытается двигаться в ту же сторону, что и активный
Definition: qd_game_object_moving.h:73
Персонаж ждет, когда можно будет возобновить попытку следования
Definition: qd_game_object_moving.h:94