SuperTuxKart
projectile_manager.hpp
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 
45 class ProjectileManager : public NoCopy
46 {
47 private:
48  typedef std::vector<HitEffect*> HitEffects;
49 
52  std::map<std::string, std::shared_ptr<Flyable> > m_active_projectiles;
53 
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  // ----------------------------------------------------------------------------------------
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  // ------------------------------------------------------------------------
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  // ------------------------------------------------------------------------
98  void addByUID(const std::string& uid, std::shared_ptr<Flyable> f)
99  { m_active_projectiles[uid] = f; }
100  // ------------------------------------------------------------------------
101  void removeByUID(const std::string& uid)
102  { m_active_projectiles.erase(uid); }
103 };
104 
105 #endif
106 
107 /* EOF */
108 
void addHitEffect(HitEffect *hit_effect)
Adds a special hit effect to be shown.
Definition: projectile_manager.hpp:87
Definition: projectile_manager.hpp:45
A wrapper around bullets btVector3 to include conventient conversion functions (e.g.
Definition: vec3.hpp:34
Definition: rewinder.hpp:43
A small interface for effects to be used when a kart is hit.
Definition: hit_effect.hpp:32
Definition: three_d_animation.hpp:32
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:25
Definition: script_track.cpp:52
HitEffects m_active_hit_effects
All active hit effects, i.e.
Definition: projectile_manager.hpp:56
Definition: flyable.hpp:48
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:61
std::map< std::string, std::shared_ptr< Flyable > > m_active_projectiles
The list of all active projectiles, i.e.
Definition: projectile_manager.hpp:52