1 //
2 //  SuperTuxKart - a fun racing game with go-kart
3 //  Copyright (C) 2009-2015  Joerg Henrichs
4 //
5 //  This program is free software; you can redistribute it and/or
6 //  modify it under the terms of the GNU General Public License
7 //  as published by the Free Software Foundation; either version 3
8 //  of the License, or (at your option) any later version.
9 //
10 //  This program is distributed in the hope that it will be useful,
11 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //  GNU General Public License for more details.
14 //
15 //  You should have received a copy of the GNU General Public License
16 //  along with this program; if not, write to the Free Software
17 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 
19 #ifndef HEADER_CHECK_MANAGER_HPP
20 #define HEADER_CHECK_MANAGER_HPP
21 
22 #include "utils/no_copy.hpp"
23 
24 #include <assert.h>
25 #include <string>
26 #include <vector>
27 
28 class AbstractKart;
29 class CheckStructure;
30 class Flyable;
31 class Track;
32 class XMLNode;
33 class Vec3;
34 
35 /**
36   * \brief Controls all checks structures of a track.
37   * \ingroup tracks
38   */
39 class CheckManager : public NoCopy
40 {
41 private:
42     std::vector<CheckStructure*> m_all_checks;
43 public:
44     ~CheckManager();
add(CheckStructure * strct)45     void   add(CheckStructure* strct) { m_all_checks.push_back(strct); }
46     void   addFlyableToCannons(Flyable *flyable);
47     void   removeFlyableFromCannons(Flyable *flyable);
48     void   load(const XMLNode &node);
49     void   update(float dt);
50     void   reset(const Track &track);
51     void   resetAfterKartMove(AbstractKart *kart);
52     void   resetAfterRewind();
53     unsigned int getLapLineIndex() const;
54     int    getChecklineTriggering(const Vec3 &from, const Vec3 &to) const;
55     // ------------------------------------------------------------------------
56     /** Returns the number of check structures defined. */
getCheckStructureCount() const57     unsigned int getCheckStructureCount() const
58                                  { return (unsigned int) m_all_checks.size(); }
59     // ------------------------------------------------------------------------
60     /** Returns the nth. check structure. */
getCheckStructure(unsigned int n) const61     CheckStructure *getCheckStructure(unsigned int n) const
62     {
63         assert(n < m_all_checks.size());
64         return m_all_checks[n];
65     }
66 };   // CheckManager
67 
68 #endif
69 
70