-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComponentFactory.cpp
More file actions
51 lines (32 loc) · 1.08 KB
/
ComponentFactory.cpp
File metadata and controls
51 lines (32 loc) · 1.08 KB
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
#include "ComponentFactory.h"
#include "LogManager.h"
#include "Component.h"
ComponentFactory ComponentFactory::s_xInstance;
ComponentFactory::ComponentFactory() {
m_xComponents = new ComponentList[Component::TYPE_N];
}
ComponentFactory::~ComponentFactory() {
delete [] m_xComponents;
}
ComponentFactory* ComponentFactory::instance() {
return &s_xInstance;
}
void ComponentFactory::destroy(Component* component) {
Component::Type type = component->getType();
for (unsigned int i = 0; i < m_xComponents[type].size(); ++i) {
if (m_xComponents[type][i] == component) {
delete component;
m_xComponents[type].erase(m_xComponents[type].begin() + i);
return;
}
}
Log::Warn("ComponentFactory: Trying to destroy unmanaged Component");
}
/*void ComponentFactory::update(Component::Type type, float delta, float elapsedTime) {
for (unsigned int i = 0; i < m_xComponents[type].size(); ++i) {
m_xComponents[type][i]->update(delta, elapsedTime);
}
}*/
const ComponentFactory::ComponentList* ComponentFactory::getList(unsigned int type) {
return &m_xComponents[type];
}