SuperTuxKart
check_manager.hpp
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 
39 class CheckManager : public NoCopy
40 {
41 private:
42  std::vector<CheckStructure*> m_all_checks;
43  static CheckManager *m_check_manager;
46  CheckManager() {m_all_checks.clear();};
47  ~CheckManager();
48 public:
49  void add(CheckStructure* strct) { m_all_checks.push_back(strct); }
50  void addFlyableToCannons(Flyable *flyable);
51  void removeFlyableFromCannons(Flyable *flyable);
52  void load(const XMLNode &node);
53  void update(float dt);
54  void reset(const Track &track);
55  void resetAfterKartMove(AbstractKart *kart);
56  void resetAfterRewind();
57  unsigned int getLapLineIndex() const;
58  int getChecklineTriggering(const Vec3 &from, const Vec3 &to) const;
59  // ------------------------------------------------------------------------
61  static void create()
62  {
63  assert(!m_check_manager);
64  m_check_manager = new CheckManager();
65  } // create
66  // ------------------------------------------------------------------------
68  static CheckManager* get() { return m_check_manager; }
69  // ------------------------------------------------------------------------
71  static void destroy() { delete m_check_manager; m_check_manager = NULL; }
72  // ------------------------------------------------------------------------
74  unsigned int getCheckStructureCount() const { return (unsigned int) m_all_checks.size(); }
75  // ------------------------------------------------------------------------
77  CheckStructure *getCheckStructure(unsigned int n) const
78  {
79  assert(n < m_all_checks.size());
80  return m_all_checks[n];
81  }
82 }; // CheckManager
83 
84 #endif
85 
void removeFlyableFromCannons(Flyable *flyable)
Removes a flyable from all cannons.
Definition: check_manager.cpp:169
CheckStructure * getCheckStructure(unsigned int n) const
Returns the nth.
Definition: check_manager.hpp:77
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:34
void resetAfterKartMove(AbstractKart *kart)
Called after a kart is moved (e.g.
Definition: check_manager.cpp:128
unsigned int getLapLineIndex() const
Returns the index of the first check structures that triggers a new lap to be counted.
Definition: check_manager.cpp:195
~CheckManager()
Private destructor (to make sure it is only called using the static destroy function).
Definition: check_manager.cpp:103
unsigned int getCheckStructureCount() const
Returns the number of check structures defined.
Definition: check_manager.hpp:74
void addFlyableToCannons(Flyable *flyable)
Adds a flyable object to be tested against cannons.
Definition: check_manager.cpp:154
static CheckManager * get()
Returns the instance of the check manager.
Definition: check_manager.hpp:68
Controls all checks structures of a track.
Definition: check_manager.hpp:39
void update(float dt)
Updates all animations.
Definition: check_manager.cpp:184
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:25
void load(const XMLNode &node)
Loads all check structure informaiton from the specified xml file.
Definition: check_manager.cpp:40
void reset(const Track &track)
Resets all checks.
Definition: check_manager.cpp:115
utility class used to parse XML files
Definition: xml_node.hpp:47
CheckManager()
Private constructor, to make sure it is only called via the static create function.
Definition: check_manager.hpp:46
static void destroy()
Destroys the check manager.
Definition: check_manager.hpp:71
Virtual base class for a check structure.
Definition: check_structure.hpp:51
Definition: flyable.hpp:47
static void create()
Creates an instance of the check manager.
Definition: check_manager.hpp:61
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:61
Definition: track.hpp:96
int getChecklineTriggering(const Vec3 &from, const Vec3 &to) const
Returns the check line index that is triggered when going from 'from' to 'to'.
Definition: check_manager.cpp:222