ScummVM API documentation
path_finder.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_PATH_FINDER_H
23 #define NUVIE_PATHFINDER_PATH_FINDER_H
24 
25 #include "ultima/nuvie/core/map.h"
26 
27 namespace Ultima {
28 namespace Nuvie {
29 
30 class Path;
31 
32 class PathFinder {
33 protected:
34  MapCoord start, goal, loc; /* source, destination, current location */
35 
36  Path *search; /* contains path-search algorithms, and
37  game-specific step costs */
38 
39  void new_search(Path *new_path);
40 // bool is_hazardous(MapCoord &loc); will have to check objects and tiles
41 
42 public:
43  PathFinder();
44  PathFinder(const MapCoord &s, const MapCoord &g);
45  virtual ~PathFinder();
46  void set_search(Path *new_path) {
47  new_search(new_path);
48  }
49 
50  virtual void set_start(const MapCoord &s);
51  virtual void set_goal(const MapCoord &g);
52  virtual void set_location(const MapCoord &l) {
53  loc = l;
54  }
55 
56  virtual MapCoord get_location() {
57  return loc;
58  }
59  virtual MapCoord get_goal() {
60  return goal;
61  }
62  virtual bool reached_goal() {
63  return (loc.x == goal.x && loc.y == goal.y
64  && loc.z == goal.z);
65  }
66 
67  virtual bool check_dir(const MapCoord &from, MapCoord &rel, sint8 unused = 0);
68  virtual bool check_loc(const MapCoord &loc) = 0;
69  bool check_loc(uint16 x, uint16 y, uint8 z);
70 
71  virtual bool find_path(); /* get path to goal if one doesn't already exist */
72  virtual bool have_path(); /* a working path exists */
73  virtual bool is_path_clear(); /* recheck each location in path */
74  virtual bool get_next_move(MapCoord &step) = 0;
75 };
76 
77 } // End of namespace Nuvie
78 } // End of namespace Ultima
79 
80 #endif
Definition: path.h:36
Definition: detection.h:27
Path
Definition: game.h:75
Definition: map.h:84
Definition: path_finder.h:32