Updated addon repository URL and improved debug output on download
[supertux.git] / src / object / path.hpp
1 //  SuperTux Path
2 //  Copyright (C) 2005 Philipp <balinor@pnxs.de>
3 //  Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
4 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
5 //
6 //  This program is free software: you can redistribute it and/or modify
7 //  it under the terms of the GNU General Public License as published by
8 //  the Free Software Foundation, either version 3 of the License, or
9 //  (at your option) any later version.
10 //
11 //  This program 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
14 //  GNU General Public License for more details.
15 //
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19 #ifndef HEADER_SUPERTUX_OBJECT_PATH_HPP
20 #define HEADER_SUPERTUX_OBJECT_PATH_HPP
21
22 #include <vector>
23
24 #include "math/vector.hpp"
25 #include "util/reader_fwd.hpp"
26 #include "util/writer_fwd.hpp"
27
28 class Path
29 {
30 public:
31   Path();
32   ~Path();
33
34   void read(const Reader& reader);
35
36   Vector get_base() const;
37
38   /**
39    * Helper class that stores an individual node of a Path
40    */
41   class Node
42   {
43   public:
44     Vector position; /**< the position of this node */
45     float time; /**< time (in seconds) to get from this node to next node */
46
47     Node() :
48       position(),
49       time()
50     {}
51   };
52
53   std::vector<Node> nodes;
54
55   /**
56    * returns Node index nearest to reference_point or -1 if not applicable
57    */
58   int get_nearest_node_no(Vector reference_point) const;
59
60   /**
61    * returns Node index farthest from reference_point or -1 if not applicable
62    */
63   int get_farthest_node_no(Vector reference_point) const;
64
65 private:
66   friend class PathWalker;
67
68   enum WalkMode {
69     // moves from first to last path node and stops
70     ONE_SHOT,
71     // moves from first to last node then in reverse order back to first
72     PING_PONG,
73     // moves from last node back to the first node
74     CIRCULAR
75   };
76
77   WalkMode mode;
78 };
79
80 #endif
81
82 /* EOF */