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