ScummVM API documentation
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_PATH_H
23 #define NUVIE_PATHFINDER_PATH_H
24 
25 #include "ultima/nuvie/core/nuvie_defs.h"
26 #include "ultima/nuvie/pathfinder/path_finder.h"
27 
28 namespace Ultima {
29 namespace Nuvie {
30 
31 class MapCoord;
32 
33 /* Abstract for a class that provides the path-search routines and cost methods
34  * to a PathFinder. This includes useful default methods, and path handling.
35  */
36 class Path {
37 protected:
38  MapCoord *path; // list of tiles in the path, set by create_path()
39  uint32 step_count; // number of locations in the path
40  uint32 path_size; // allocated elements in list
41  PathFinder *pf;
42 
43  void add_step(const MapCoord &loc);
44  bool check_dir(const MapCoord &loc, MapCoord &rel);
45  bool check_loc(const MapCoord &loc);
46  void set_path_size(int alloc_size);
47 
48 public:
49  Path();
50  virtual ~Path();
51  void set_pathfinder(PathFinder *pathfinder) {
52  pf = pathfinder;
53  }
54 
55  /* The pathfinding routine. Can return success or failure of a search. */
56  virtual bool path_search(const MapCoord &start, const MapCoord &goal) = 0;
57  void delete_path();
58  virtual bool have_path();
59 
60  /* Returns the real cost of moving from a node (or location) to a
61  neighboring node. (a single step) */
62  virtual sint32 step_cost(const MapCoord &c1, const MapCoord &c2) = 0;
63 
64  /* Estimate highest possible cost from s to g */
65  virtual uint32 path_cost_est(const MapCoord &s, const MapCoord &g);
66  /* Returns maximum score of any single node in the search of a path with
67  a certain estimated cost.*/
68  virtual uint32 get_max_score(uint32 cost);
69 
70  virtual const MapCoord &get_first_step();
71  virtual const MapCoord &get_last_step();
72  virtual const MapCoord &get_step(uint32 step_index);
73  virtual void get_path(MapCoord **path_start, uint32 &path_size);
74  uint32 get_num_steps() {
75  return step_count;
76  }
77 
78  virtual bool remove_first_step();
79 };
80 
81 } // End of namespace Nuvie
82 } // End of namespace Ultima
83 
84 #endif
Definition: path.h:36
Definition: detection.h:27
Definition: map.h:84
Definition: path_finder.h:32