-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEntity.cpp
112 lines (97 loc) · 1.74 KB
/
Entity.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include "Entity.h"
#include "Component.h"
class BoxCollider;
Entity::~Entity()
{
for (const auto& iter : components)
{
delete iter.second;
}
}
void Entity::Update()
{
for (const auto& c : components)
{
if (c.second->GetState())
{
c.second->Update(*this);
}
}
}
void Entity::Render(tmpl8::Surface& screen)
{
for (const auto& c : components)
{
c.second->Render(*this, screen);
}
}
void Entity::KeyUp(SDL_Scancode key)
{
for (const auto& c : components)
{
c.second->KeyUp(*this, key);
}
}
void Entity::KeyDown(SDL_Scancode key)
{
for (const auto& c : components)
{
c.second->KeyDown(*this, key);
}
}
void Entity::MouseMove(int x, int y)
{
for (const auto& c : components)
{
c.second->MouseMove(*this, x, y);
}
}
void Entity::MouseUp(int key)
{
for (const auto& c : components)
{
c.second->MouseUp(*this, key);
}
}
void Entity::MouseDown(int key)
{
for (const auto& c : components)
{
c.second->MouseDown(*this, key);
}
}
void Entity::Hurt()
{
for (const auto& c : components)
{
c.second->Hurt(*this);
}
}
void Entity::SetActive(bool state)
{
for (const auto& component : components)
{
component.second->SetActive(*this, state);
}
}
void Entity::JoystickMove(Uint8 axis, Sint16 value)
{
for (const auto & component : components)
{
component.second->JoystickMove(axis, value);
}
}
void Entity::ButtonDown(Uint8 button)
{
for (auto && component : components)
{
component.second->ButtonDown(button);
}
}
void Entity::ButtonUp(Uint8 button)
{
for (auto && component : components)
{
component.second->ButtonUp(button);
}
}