-
Notifications
You must be signed in to change notification settings - Fork 0
/
BaseParticleSystemManager.cpp
61 lines (35 loc) · 1.62 KB
/
BaseParticleSystemManager.cpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "stdafx.h"
#include "ParticleSystemManager.hpp"
class BaseParticleSystem;
class BaseParticleSystemManager : public ParticleSystemManager {
DynamicArray<BaseParticleSystem*> particlesSystems;
public:
ParticleSystem* createParticleSystem(const AssetName&);
ParticleSystem* createParticleSystem();
void destroyParticleSystem(ParticleSystem*);
};
class BaseParticleSystem : public ParticleSystem {
SharedPtr<BaseParticleSystemManager> manager;
public:
BaseParticleSystem(BaseParticleSystemManager* manager_) : manager(manager_) {}
BaseParticleSystem(ParticleSystemAsset* asset_, BaseParticleSystemManager* manager_) : manager(manager_), ParticleSystem(asset_) {}
~BaseParticleSystem() { manager->destroyParticleSystem(this); }
};
ParticleSystem* BaseParticleSystemManager::createParticleSystem(const AssetName& assetName) {
BaseParticleSystem* ps = NULL;
ParticleSystemAsset* particleSystemAsset = new ParticleSystemAsset(assetName);
particleSystemAsset->addStream(new ParticleStream);
particleSystemAsset->addStream(new ParticleStream);
particleSystemAsset->addStream(new ParticleStream);
ps = new BaseParticleSystem(particleSystemAsset, this);
return ps;
}
ParticleSystem* BaseParticleSystemManager::createParticleSystem() {
BaseParticleSystem* ps = new BaseParticleSystem(this);
particlesSystems.add(ps);
return ps;
}
void BaseParticleSystemManager::destroyParticleSystem(ParticleSystem* ps) {
particlesSystems.remove((BaseParticleSystem*)ps);
}
ParticleSystemManager* CreateParticleSystemManager() { return new BaseParticleSystemManager; }