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 39 /** 40 * \brief Implements a simple checkline that will cause a kart or flyable to 41 * be shot to a specified point. 42 * 43 * \ingroup tracks 44 */ 45 class CheckCannon : public CheckLine 46 { 47 private: 48 /** The target point the kart will fly to. */ 49 Vec3 m_target_left; 50 Vec3 m_target_right; 51 52 /** Stores the cannon curve data. */ 53 Ipo *m_curve; 54 55 #if defined(DEBUG) && !defined(SERVER_ONLY) 56 /** If track debugging is enabled, this will show the the curve of 57 * the cannon in the race. */ 58 ShowCurve* m_show_curve; 59 60 /** Used to display debug information about checklines. */ 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 // ------------------------------------------------------------------------ trigger(unsigned int kart_index)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 // ------------------------------------------------------------------------ triggeringCheckline() const76 virtual bool triggeringCheckline() const OVERRIDE { return false; } 77 // ------------------------------------------------------------------------ 78 /** Adds a flyable to be tested for crossing a cannon checkline. 79 * \param flyable The flyable to be tested. 80 */ addFlyable(Flyable * flyable)81 void addFlyable(Flyable* flyable) { m_all_flyables.insert(flyable); } 82 // ------------------------------------------------------------------------ 83 /** Removes a flyable from the tests if it crosses a checkline. Used when 84 * the flyable is removed (e.g. explodes). 85 */ removeFlyable(Flyable * flyable)86 void removeFlyable(Flyable* flyable) { m_all_flyables.erase(flyable); } 87 // ------------------------------------------------------------------------ getTargetLeft() const88 const Vec3& getTargetLeft() const { return m_target_left; } 89 // ------------------------------------------------------------------------ getTargetRight() const90 const Vec3& getTargetRight() const { return m_target_right; } 91 // ------------------------------------------------------------------------ getIpo() const92 Ipo* getIpo() const { return m_curve; } 93 // ------------------------------------------------------------------------ 94 virtual CheckStructure* clone() OVERRIDE; 95 }; // CheckCannon 96 97 #endif 98 99