SuperTuxKart
check_cannon.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2012-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_CANNON_HPP
20 #define HEADER_CHECK_CANNON_HPP
21 
22 #include "animations/animation_base.hpp"
23 #include "tracks/check_line.hpp"
24 #include "utils/cpp2011.hpp"
25 
26 #include <set>
27 
28 class CheckManager;
29 class Flyable;
30 class Ipo;
31 class ShowCurve;
32 class XMLNode;
33 
34 namespace SP
35 {
36  class SPDynamicDrawCall;
37 }
38 
45 class CheckCannon : public CheckLine
46 {
47 private:
50  Vec3 m_target_right;
51 
54 
55 #ifdef DEBUG
56 
58  ShowCurve* m_show_curve;
59 
61  std::shared_ptr<SP::SPDynamicDrawCall> m_debug_target_dy_dc;
62 #endif
63 
64  std::set<Flyable*> m_all_flyables;
65 public:
66  CheckCannon(const XMLNode &node, unsigned int index);
67  // ------------------------------------------------------------------------
68  virtual ~CheckCannon();
69  // ------------------------------------------------------------------------
70  virtual void trigger(unsigned int kart_index) OVERRIDE {}
71  // ------------------------------------------------------------------------
72  virtual void changeDebugColor(bool is_active) OVERRIDE;
73  // ------------------------------------------------------------------------
74  virtual void update(float dt) OVERRIDE;
75  // ------------------------------------------------------------------------
76  virtual bool triggeringCheckline() const OVERRIDE { return false; }
77  // ------------------------------------------------------------------------
81  void addFlyable(Flyable* flyable) { m_all_flyables.insert(flyable); }
82  // ------------------------------------------------------------------------
86  void removeFlyable(Flyable* flyable) { m_all_flyables.erase(flyable); }
87  // ------------------------------------------------------------------------
88  const Vec3& getTargetLeft() const { return m_target_left; }
89  // ------------------------------------------------------------------------
90  const Vec3& getTargetRight() const { return m_target_right; }
91  // ------------------------------------------------------------------------
92  Ipo* getIpo() const { return m_curve; }
93 }; // CheckCannon
94 
95 #endif
96 
Implements a simple checkline that will cause a kart or flyable to be shot to a specified point.
Definition: check_cannon.hpp:45
virtual void trigger(unsigned int kart_index) OVERRIDE
Is called when this check structure is triggered.
Definition: check_cannon.hpp:70
virtual void update(float dt) OVERRIDE
Overriden to also check all flyables registered with the cannon.
Definition: check_cannon.cpp:130
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:34
Ipo * m_curve
Stores the cannon curve data.
Definition: check_cannon.hpp:53
Vec3 m_target_left
The target point the kart will fly to.
Definition: check_cannon.hpp:49
void removeFlyable(Flyable *flyable)
Removes a flyable from the tests if it crosses a checkline.
Definition: check_cannon.hpp:86
Implements a simple checkline.
Definition: check_line.hpp:50
Controls all checks structures of a track.
Definition: check_manager.hpp:39
This class is used for debugging.
Definition: show_curve.hpp:45
virtual void changeDebugColor(bool is_active) OVERRIDE
Changes the colour of a check cannon depending on state.
Definition: check_cannon.cpp:112
void addFlyable(Flyable *flyable)
Adds a flyable to be tested for crossing a cannon checkline.
Definition: check_cannon.hpp:81
virtual ~CheckCannon()
Destructor, frees the curve data (which the cannon animation objects only have a read-only copy of).
Definition: check_cannon.cpp:98
utility class used to parse XML files
Definition: xml_node.hpp:47
CheckCannon(const XMLNode &node, unsigned int index)
Constructor for a check cannon.
Definition: check_cannon.cpp:40
Definition: flyable.hpp:47
A class to manage a single blender IPO curve.
Definition: ipo.hpp:37