FIFE  be64c707dea6b3250bd4355bf5c825d25920087d
route.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2019 by the FIFE team *
3  * http://www.fifengine.net *
4  * This file is part of FIFE. *
5  * *
6  * FIFE is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20  ***************************************************************************/
21 
22 #ifndef FIFE_ROUTE_H
23 #define FIFE_ROUTE_H
24 
25 // Standard C++ library includes
26 #include <list>
27 
28 // 3rd party library includes
29 
30 // FIFE includes
31 // These includes are split up in two parts, separated by one empty line
32 // First block: files included from the FIFE root src directory
33 // Second block: files included from the same folder
34 #include "util/base/fifeclass.h"
35 
36 namespace FIFE {
37 
38  class Location;
39  class Object;
40 
49  enum RouteStatus {
55  };
57 
59  typedef std::list<Location> Path;
60 
64  class Route : public FifeClass {
65  public:
70  Route(const Location& start, const Location& end);
71 
74  ~Route();
75 
79  void setRouteStatus(RouteStatusInfo status);
80 
84  RouteStatusInfo getRouteStatus();
85 
89  void setStartNode(const Location& node);
90 
94  const Location& getStartNode();
95 
99  void setEndNode(const Location& node);
100 
104  const Location& getEndNode();
105 
109  const Location& getCurrentNode();
110 
114  const Location& getPreviousNode();
115 
119  const Location& getNextNode();
120 
126  bool walkToNextNode(int32_t step = 1);
127 
131  bool reachedEnd();
132 
136  void setPath(const Path& path);
137 
141  Path getPath();
142 
146  void cutPath(uint32_t length = 1);
147 
151  void setReplanned(bool replanned);
152 
156  bool isReplanned();
157 
162 
167 
171  void setSessionId(int32_t id);
172 
176  int32_t getSessionId();
177 
181  void setRotation(int32_t rotation);
182 
186  int32_t getRotation();
187 
191  void setCostId(const std::string& cost);
192 
196  const std::string& getCostId();
197 
201  bool isMultiCell();
202 
206  void setOccupiedArea(const std::vector<ModelCoordinate>& area);
207 
211  const std::vector<ModelCoordinate>& getOccupiedArea();
212 
217  std::vector<ModelCoordinate> getOccupiedCells(int32_t rotation);
218 
222  int32_t getZStepRange();
223 
224  bool isAreaLimited();
225  const std::list<std::string> getLimitedAreas();
226 
230  void setDynamicBlockerIgnored(bool ignore);
231 
236 
242 
246  void setObject(Object* obj);
247 
251  Object* getObject();
252 
253  private:
255  typedef Path::iterator PathIterator;
256 
258  RouteStatusInfo m_status;
259 
262 
265 
267  Path m_path;
268 
270  PathIterator m_current;
271 
274 
276  int32_t m_sessionId;
277 
279  int32_t m_rotation;
280 
283 
286 
288  std::string m_costId;
289 
291  std::vector<ModelCoordinate> m_area;
292 
295  };
296 
297 } // FIFE
298 
299 #endif
void setOccupiedArea(const std::vector< ModelCoordinate > &area)
Sets occupied coordinates for multi cell object.
Definition: route.cpp:254
void cutPath(uint32_t length=1)
Cuts path after the given length.
Definition: route.cpp:181
Object * m_object
pointer to multi object
Definition: route.h:294
Location m_endNode
end location
Definition: route.h:264
void setObject(Object *obj)
Sets the object, needed for multi cell and z-step range.
Definition: route.cpp:315
RouteStatusInfo m_status
search status
Definition: route.h:258
std::list< Location > Path
A path is a list with locations. Each location holds the coordinate for one cell. ...
Definition: ipather.h:38
void setDynamicBlockerIgnored(bool ignore)
Sets the route to ignore dynamic blocker.
Definition: route.cpp:294
int32_t getZStepRange()
Returns z-step range from object.
Definition: route.cpp:270
const Location & getPreviousNode()
Returns previous location.
Definition: route.cpp:108
const Location & getStartNode()
Returns the start location.
Definition: route.cpp:78
Object class.
Definition: object.h:51
bool walkToNextNode(int32_t step=1)
Changes the position on the path.
Definition: route.cpp:137
Object * getObject()
Returns the object, needed for multi cell and z-step range.
Definition: route.cpp:319
void setRouteStatus(RouteStatusInfo status)
Sets route status.
Definition: route.cpp:57
int32_t m_sessionId
session id of the search
Definition: route.h:276
const Location & getNextNode()
Returns next location.
Definition: route.cpp:121
const Location & getEndNode()
Returns the target location.
Definition: route.cpp:94
Base class for all fife classes Used e.g.
Definition: fifeclass.h:42
uint32_t getPathLength()
Returns the length of the path.
Definition: route.cpp:215
bool m_ignoresBlocker
ignores dynamic blocker
Definition: route.h:285
uint32_t m_walked
walked steps on the path
Definition: route.h:273
Path getBlockingPathLocations()
Returns the blocking locations of the path.
Definition: route.cpp:302
PathIterator m_current
current position on the path
Definition: route.h:270
A basic route.
Definition: route.h:64
bool reachedEnd()
Gets if the end of the path was achieved.
Definition: route.cpp:156
int32_t m_rotation
current rotation
Definition: route.h:279
const std::list< std::string > getLimitedAreas()
Definition: route.cpp:286
void setPath(const Path &path)
Sets the path for the route.
Definition: route.cpp:163
unsigned char uint8_t
Definition: core.h:38
void setRotation(int32_t rotation)
Sets the current rotation.
Definition: route.cpp:231
void setStartNode(const Location &node)
Sets the start location.
Definition: route.cpp:67
int32_t getSessionId()
Returns the session identifier.
Definition: route.cpp:227
void setCostId(const std::string &cost)
Sets cost identifier which should be used for pathfinding.
Definition: route.cpp:239
bool isAreaLimited()
Definition: route.cpp:277
bool isDynamicBlockerIgnored()
Gets if the route ignores dynamic blocker.
Definition: route.cpp:298
RouteStatusInfo getRouteStatus()
Returns route status.
Definition: route.cpp:63
Path::iterator PathIterator
path iterator
Definition: route.h:255
RouteStatus
Defines different route status types for the search.
Definition: route.h:49
void setReplanned(bool replanned)
Sets the route to replanned.
Definition: route.cpp:207
Path m_path
path
Definition: route.h:267
std::vector< ModelCoordinate > m_area
occupied cells by multicell object
Definition: route.h:291
~Route()
Destructor.
Definition: route.cpp:54
Path getPath()
Returns the path.
Definition: route.cpp:177
uint32_t getWalkedLength()
Returns the walked steps.
Definition: route.cpp:219
const std::vector< ModelCoordinate > & getOccupiedArea()
Returns occupied coordinates for multi cell object.
Definition: route.cpp:258
std::string m_costId
used cost identifier
Definition: route.h:288
const std::string & getCostId()
Returns cost identifier which is used for pathfinding.
Definition: route.cpp:243
std::vector< ModelCoordinate > getOccupiedCells(int32_t rotation)
Returns relative coordinates for multi cell object based on rotation.
Definition: route.cpp:262
const Location & getCurrentNode()
Returns current location.
Definition: route.cpp:98
bool isMultiCell()
Gets if path is for a multi cell object.
Definition: route.cpp:247
void setEndNode(const Location &node)
Sets the target location.
Definition: route.cpp:82
int32_t getRotation()
Returns the current rotation.
Definition: route.cpp:235
unsigned int uint32_t
Definition: core.h:40
bool m_replanned
is path replanned
Definition: route.h:282
Location m_startNode
start location
Definition: route.h:261
bool isReplanned()
Gets if the route is replanned.
Definition: route.cpp:211
Route(const Location &start, const Location &end)
Constructor.
Definition: route.cpp:41
uint8_t RouteStatusInfo
Definition: route.h:56
void setSessionId(int32_t id)
Sets the session identifier.
Definition: route.cpp:223