Dragonfly  4.3
A text-based game engine
Path.h
1 //
2 // An path class.
3 //
4 
5 #ifndef __PATH_H__
6 #define __PATH_H__
7 
8 // System includes.
9 #include <vector>
10 
11 // Engine includes.
12 #include "Vector.h"
13 
14 namespace df {
15 
16 class Path {
17 
18  private:
19  std::vector<Vector> m_path; ///< Nodes in path.
20  int m_index; ///< Index of next target node.
21 
22  public:
23  Path();
24 
25  /// Return next node in path.
26  /// Return (-1,-1) if none.
27  Vector nextNode() const;
28 
29  /// Return previous node in path.
30  /// Return (-1,-1) if none.
31  Vector previousNode() const;
32 
33  /// Set path.
34  void setPath(std::vector<Vector> new_path);
35 
36  /// Return path.
37  std::vector<Vector> getPath() const;
38 
39  /// Return true when at end of path.
40  bool endOfPath() const;
41 
42  /// Return last node of path.
43  Vector getEnd() const;
44 
45  /// Set index of path.
46  /// Return 0 if ok, else -1;
47  int setIndex(int new_index);
48 
49  /// Return index of path.
50  int getIndex() const;
51 
52  /// Increment path target node.
53  /// If at last node, index stays at end.
54  Path operator++(int);
55 };
56 
57 } // end of namespace df
58 #endif //__PATH_H__
Definition: Path.h:16
Vector nextNode() const
Return next node in path.
int getIndex() const
Return index of path.
A 2-d bounding box.
Definition: Box.h:10
Path operator++(int)
Increment path target node.
int m_index
Index of next target node.
Definition: Path.h:20
int setIndex(int new_index)
Set index of path.
void setPath(std::vector< Vector > new_path)
Set path.
std::vector< Vector > getPath() const
Return path.
std::vector< Vector > m_path
Nodes in path.
Definition: Path.h:19
bool endOfPath() const
Return true when at end of path.
Vector previousNode() const
Return previous node in path.
Definition: Vector.h:10
Vector getEnd() const
Return last node of path.