1 // 2 // SuperTuxKart - a fun racing game with go-kart 3 // Copyright (C) 2006-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_PROJECTILEMANAGER_HPP 20 #define HEADER_PROJECTILEMANAGER_HPP 21 22 #include <map> 23 #include <memory> 24 #include <unordered_set> 25 #include <vector> 26 27 namespace irr 28 { 29 namespace scene { class IMesh; } 30 } 31 32 #include "items/powerup_manager.hpp" 33 #include "utils/no_copy.hpp" 34 35 class AbstractKart; 36 class Flyable; 37 class HitEffect; 38 class Rewinder; 39 class Track; 40 class Vec3; 41 42 /** 43 * \ingroup items 44 */ 45 class ProjectileManager : public NoCopy 46 { 47 private: 48 typedef std::vector<HitEffect*> HitEffects; 49 50 /** The list of all active projectiles, i.e. projectiles which are 51 * currently moving on the track. */ 52 std::map<std::string, std::shared_ptr<Flyable> > m_active_projectiles; 53 54 /** All active hit effects, i.e. hit effects which are currently 55 * being shown or have a sfx playing. */ 56 HitEffects m_active_hit_effects; 57 58 std::string getUniqueIdentity(AbstractKart* kart, 59 PowerupManager::PowerupType type); 60 void updateServer(int ticks); 61 public: 62 // ---------------------------------------------------------------------------------------- 63 static ProjectileManager* get(); 64 // ---------------------------------------------------------------------------------------- 65 static void create(); 66 // ---------------------------------------------------------------------------------------- 67 static void destroy(); 68 // ---------------------------------------------------------------------------------------- 69 static void clear(); 70 // ---------------------------------------------------------------------------------------- ProjectileManager()71 ProjectileManager() {} ~ProjectileManager()72 ~ProjectileManager() {} 73 void loadData (); 74 void cleanup (); 75 void update (int ticks); 76 void updateGraphics (float dt); 77 void removeTextures (); 78 bool projectileIsClose(const AbstractKart * const kart, 79 float radius); 80 81 int getNearbyProjectileCount(const AbstractKart * const kart, 82 float radius, PowerupManager::PowerupType type, 83 bool exclude_owned=false); 84 // ------------------------------------------------------------------------ 85 /** Adds a special hit effect to be shown. 86 * \param hit_effect The hit effect to be added. */ addHitEffect(HitEffect * hit_effect)87 void addHitEffect(HitEffect *hit_effect) 88 { m_active_hit_effects.push_back(hit_effect); } 89 // ------------------------------------------------------------------------ 90 std::shared_ptr<Rewinder> 91 addRewinderFromNetworkState(const std::string& uid); 92 // ------------------------------------------------------------------------ 93 std::shared_ptr<Flyable> newProjectile(AbstractKart *kart, 94 PowerupManager::PowerupType type); 95 // ------------------------------------------------------------------------ 96 std::vector<Vec3> getBasketballPositions(); 97 // ------------------------------------------------------------------------ addByUID(const std::string & uid,std::shared_ptr<Flyable> f)98 void addByUID(const std::string& uid, std::shared_ptr<Flyable> f) 99 { m_active_projectiles[uid] = f; } 100 // ------------------------------------------------------------------------ removeByUID(const std::string & uid)101 void removeByUID(const std::string& uid) 102 { m_active_projectiles.erase(uid); } 103 }; 104 105 #endif 106 107 /* EOF */ 108 109