ScummVM API documentation
navigation.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 HOLLYWOOD_RUNAWAY_NAVIGATION_H
23#define HOLLYWOOD_RUNAWAY_NAVIGATION_H
24
25#include "common/array.h"
26#include "common/rect.h"
27
28namespace Hollywood {
29
30byte runawayFacingTo(Common::Point position, Common::Point target);
31
33public:
34 RunawayWalkMap(int width, int height, const Common::Array<byte> &mask, const Common::Array<byte> &maps) :
35 _width(width), _height(height), _mask(mask), _maps(maps) {}
36 void findPath(Common::Point start, Common::Point target, Common::Array<Common::Point> &path) const;
37
38private:
39 bool walkable(int x, int y) const;
40 bool clearPath(Common::Point start, Common::Point end) const;
41 int _width, _height;
42 const Common::Array<byte> &_mask, &_maps;
43};
44
46public:
47 explicit RunawayWalkPath(Common::Point position = Common::Point()) : _x(position.x), _y(position.y) {}
48 void reset(Common::Point position);
49 void clear() { _points.clear(); _index = 0; }
50 void findPath(const RunawayWalkMap &map, Common::Point target);
51 void setTarget(Common::Point target);
52 // Returns whether the fractional position changed, for footstep timing.
53 bool advance(float travel, Common::Point &position, byte &facing);
54 bool active() const { return _index < _points.size(); }
55
56private:
57 Common::Point position() const { return Common::Point((int)(_x + 0.5f), (int)(_y + 0.5f)); }
59 uint _index = 0;
60 float _x, _y;
61};
62
63} // End of namespace Hollywood
64
65#endif // HOLLYWOOD_RUNAWAY_NAVIGATION_H
size_type size() const
Definition: array.h:316
void clear()
Definition: array.h:321
Definition: navigation.h:32
Definition: navigation.h:45
Definition: rect.h:144