ScummVM API documentation
seek_path.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 NUVIE_PATHFINDER_SEEK_PATH_H
23 #define NUVIE_PATHFINDER_SEEK_PATH_H
24 
25 #include "ultima/nuvie/pathfinder/path.h"
26 
27 namespace Ultima {
28 namespace Nuvie {
29 
30 /* Provides routines for building short paths around obstacles and seeking a
31  * target. Much of the work doesn't involve finding a path at all, but instead
32  * finding the direction closest to the target.
33  */
34 class SeekPath: public Path {
35 protected:
36  Common::Array<MapCoord> A_scan, B_scan; // nodes of a line scanned by trace_obstacle()
37 
38  void create_path(const MapCoord &start, const MapCoord &goal);
39  Common::Array<MapCoord> *get_best_scan(const MapCoord &start, const MapCoord &goal);
40  void delete_nodes();
41  bool trace_check_obstacle(bool &turned, MapCoord &line, sint32 &deltax, sint32 &deltay, sint32 &xdir, sint32 &ydir, Common::Array<MapCoord> *scan);
42  void trace_around_corner(MapCoord &line, sint32 &deltax, sint32 &deltay, sint32 &xdir, sint32 &ydir, Common::Array<MapCoord> *scan);
43 
44 public:
45  SeekPath();
46  ~SeekPath() override;
47  sint32 step_cost(const MapCoord &c1, const MapCoord &c2) override {
48  return -1;
49  }
50  bool path_search(const MapCoord &start, const MapCoord &goal) override;
51  void delete_path() {
52  Path::delete_path();
53  delete_nodes();
54  }
55 
56  /* Trace obstacle towards xdir,ydir for a possible opening. */
57  bool trace_obstacle(MapCoord line, sint32 deltax, sint32 deltay, sint32 xdir, sint32 ydir, Common::Array<MapCoord> *scan);
58  /* Get two relative directions that a line can travel to trace around an
59  obstacle towards `xdir',`ydir'. */
60  bool get_obstacle_tracer(const MapCoord &start, sint32 xdir, sint32 ydir,
61  sint32 &Axdir, sint32 &Aydir,
62  sint32 &Bxdir, sint32 &Bydir);
63 };
64 
65 } // End of namespace Nuvie
66 } // End of namespace Ultima
67 
68 #endif
Definition: array.h:52
Definition: path.h:36
Definition: detection.h:27
Definition: map.h:84
Definition: seek_path.h:34