Steeriously  0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
Path.hpp
1 #ifndef PATH_HPP
2 #define PATH_HPP
3 
4 #include <list>
5 #include <vector>
6 #include <cassert>
7 
8 #include <steeriously/Vector2.hpp>
9 
10 namespace steer
11 {
16  class Path
17  {
18  public:
19 
24  Path();
25 
32  Path(int NumWaypoints, std::list<steer::Vector2>& waypoints);
33 
44  Path(int NumWaypoints, float MinX, float MinY, float MaxX, float MaxY, bool looped);
45 
47  ~Path();
48 
54  {
55  assert(&(*m_currentWaypoint) != NULL);
56  return *m_currentWaypoint;
57  }
58 
63  bool finished()
64  {
65  return !(m_currentWaypoint != m_wayPoints.end());
66  }
67 
72  void setNextWaypoint();
73 
83  std::list<steer::Vector2> createRandomPath(int NumWaypoints, float MinX, float MinY, float MaxX, float MaxY);
84 
89  void loopOn()
90  {
91  m_looped = true;
92  }
93 
98  void loopOff()
99  {
100  m_looped = false;
101  }
102 
108  void set(std::list<steer::Vector2> newPath)
109  {
110  m_wayPoints = newPath;
111 
112  m_currentWaypoint = m_wayPoints.begin();
113  }
114 
120  void set(const Path& path)
121  {
122  m_wayPoints = path.getPath();
123  m_currentWaypoint = m_wayPoints.begin();
124  }
125 
130  void clear()
131  {
132  m_wayPoints.clear();
133  }
134 
139  std::list<steer::Vector2> getPath() const {return m_wayPoints;}
140 
141  private:
142 
143  std::list<steer::Vector2> m_wayPoints;
144 
145  //points to the current waypoint
146  std::list<steer::Vector2>::iterator m_currentWaypoint;
147 
148  unsigned int m_numWaypoints;
149 
150  bool m_looped;
151  };
152 }
153 
154 #endif // PATH_HPP