summary refs log tree commit diff stats
path: root/src/entity.cpp
blob: 405de24e732407211c40b292a757b0feb8ed9145 (plain) (blame)
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
#include "entity.h"

void Entity::addComponent(std::shared_ptr<Component> c)
{
  components.push_back(c);
}

void Entity::send(message_t msg)
{
  for (auto it = components.begin(); it != components.end(); it++)
  {
    (*it)->receive(msg);
  }
}

void Entity::tick()
{
  for (auto it = components.begin(); it != components.end(); it++)
  {
    (*it)->tick();
  }
}

void Entity::input(int key, int action)
{
  for (auto it = components.begin(); it != components.end(); it++)
  {
    (*it)->input(key, action);
  }
}

void Entity::render(Texture* buffer)
{
  for (auto it = components.begin(); it != components.end(); it++)
  {
    (*it)->render(buffer);
  }
}