-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathParticleManager.h
39 lines (33 loc) · 1.12 KB
/
ParticleManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef PARTICLEMANAGER_H
#define PARTICLEMANAGER_H
#include "Singleton.h"
#include <entityx.h>
#include "MessageManager.h"
#include "Messages.h"
struct Particle{
Particle(Ogre::String name, Ogre::String templateName)
{
partSys = RenderManager::getPtr()->getSceneManager()->createParticleSystem(name, templateName);
partSys->getEmitter(0)->setEnabled(false);
originalQuota = partSys->getParticleQuota();
RenderManager::getPtr()->getSceneManager()->getRootSceneNode()->attachObject(partSys);
}
Ogre::ParticleSystem *partSys;
size_t originalQuota;
};
class ParticleManager : public Singleton<ParticleManager>, public entityx::Receiver<ParticleManager>
{
public:
ParticleManager();
void init();
void receive(const ShootEvent &);
void receive(const ObjectDestroyed &);
void update(double dt);
private:
void createEmitter(std::string name, entityx::Entity ent);
const double deleteInterval = 5;
double timeSinceLastDelete;
std::map<std::string, Particle*> particleSystems;
std::vector<Ogre::ParticleEmitter*> emitters;
};
#endif // PARTICLEMANAGER_H