-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComponent.cpp
More file actions
48 lines (40 loc) · 834 Bytes
/
Component.cpp
File metadata and controls
48 lines (40 loc) · 834 Bytes
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
#include "Component.h"
#include "Services.h"
Component::Component(ComponentType type)
: type(type)
{
parentObjectID = -1;
state = ComponentState::ALIVE;
}
Component::~Component()
{
std::cout << "Component deleted!" << std::endl;
}
// A given Component can simply access other Components
// from the same Game Object
Component* Component::getComponent(ComponentType type)
{
return Services::componentManager()->
gameObjGetComponentOfType(parentObjectID, type);
}
ComponentType Component::getType()
{
return type;
}
void Component::setParentObjectID(int newID)
{
parentObjectID = newID;
}
// Methods which deal with the Component's state
ComponentState Component::getState()
{
return state;
}
void Component::deactivate()
{
state = ComponentState::INACTIVE;
}
void Component::kill()
{
state = ComponentState::DEAD;
}