SuperTuxKart
Loading...
Searching...
No Matches
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
27namespace irr
28{
29 namespace scene { class IMesh; }
30}
31
32#include "items/powerup_manager.hpp"
33#include "utils/no_copy.hpp"
34
35class AbstractKart;
36class Flyable;
37class HitEffect;
38class Rewinder;
39class Track;
40class Vec3;
41
46{
47private:
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);
61public:
62 // ----------------------------------------------------------------------------------------
63 static ProjectileManager* get();
64 // ----------------------------------------------------------------------------------------
65 static void create();
66 // ----------------------------------------------------------------------------------------
67 static void destroy();
68 // ----------------------------------------------------------------------------------------
69 static void clear();
70 // ----------------------------------------------------------------------------------------
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
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
Definition: flyable.hpp:50
A small interface for effects to be used when a kart is hit.
Definition: hit_effect.hpp:33
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:26
Definition: projectile_manager.hpp:46
std::shared_ptr< Flyable > newProjectile(AbstractKart *kart, PowerupManager::PowerupType type)
Creates a new projectile of the given type.
Definition: projectile_manager.cpp:173
int getNearbyProjectileCount(const AbstractKart *const kart, float radius, PowerupManager::PowerupType type, bool exclude_owned=false)
Returns an int containing the numbers of a given flyable in a given radius around the kart.
Definition: projectile_manager.cpp:240
void update(int ticks)
General projectile update call.
Definition: projectile_manager.cpp:109
void updateGraphics(float dt)
Called once per rendered frame.
Definition: projectile_manager.cpp:101
std::map< std::string, std::shared_ptr< Flyable > > m_active_projectiles
The list of all active projectiles, i.e.
Definition: projectile_manager.hpp:52
bool projectileIsClose(const AbstractKart *const kart, float radius)
Returns true if a projectile is within the given distance of the specified kart.
Definition: projectile_manager.cpp:218
void addHitEffect(HitEffect *hit_effect)
Adds a special hit effect to be shown.
Definition: projectile_manager.hpp:87
HitEffects m_active_hit_effects
All active hit effects, i.e.
Definition: projectile_manager.hpp:56
void updateServer(int ticks)
Updates all rockets on the server (or no networking).
Definition: projectile_manager.cpp:138
Definition: rewinder.hpp:44
Definition: track.hpp:114
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35