summary refs log tree commit diff stats
path: root/src/entity.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/entity.cpp')
-rw-r--r--src/entity.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/entity.cpp b/src/entity.cpp new file mode 100644 index 0000000..405de24 --- /dev/null +++ b/src/entity.cpp
@@ -0,0 +1,38 @@
1#include "entity.h"
2
3void Entity::addComponent(std::shared_ptr<Component> c)
4{
5 components.push_back(c);
6}
7
8void Entity::send(message_t msg)
9{
10 for (auto it = components.begin(); it != components.end(); it++)
11 {
12 (*it)->receive(msg);
13 }
14}
15
16void Entity::tick()
17{
18 for (auto it = components.begin(); it != components.end(); it++)
19 {
20 (*it)->tick();
21 }
22}
23
24void Entity::input(int key, int action)
25{
26 for (auto it = components.begin(); it != components.end(); it++)
27 {
28 (*it)->input(key, action);
29 }
30}
31
32void Entity::render(Texture* buffer)
33{
34 for (auto it = components.begin(); it != components.end(); it++)
35 {
36 (*it)->render(buffer);
37 }
38}