From 7f0e8c7ef70c62814c274f110367db92f01cbb26 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Tue, 10 Mar 2015 00:41:59 -0400 Subject: C++11'd everything! Also moved location information from physics components into entity. --- src/entity.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'src/entity.cpp') diff --git a/src/entity.cpp b/src/entity.cpp index 405de24..950969e 100644 --- a/src/entity.cpp +++ b/src/entity.cpp @@ -5,34 +5,42 @@ void Entity::addComponent(std::shared_ptr c) components.push_back(c); } -void Entity::send(message_t msg) +void Entity::send(Game& game, Message& msg) { - for (auto it = components.begin(); it != components.end(); it++) + for (auto component : components) { - (*it)->receive(msg); + component->receive(game, *this, msg); } } -void Entity::tick() +void Entity::tick(Game& game) { - for (auto it = components.begin(); it != components.end(); it++) + for (auto component : components) { - (*it)->tick(); + component->tick(game, *this); } } -void Entity::input(int key, int action) +void Entity::input(Game& game, int key, int action) { - for (auto it = components.begin(); it != components.end(); it++) + for (auto component : components) { - (*it)->input(key, action); + component->input(game, *this, key, action); } } -void Entity::render(Texture* buffer) +void Entity::render(Game& game, Texture& buffer) { - for (auto it = components.begin(); it != components.end(); it++) + for (auto component : components) { - (*it)->render(buffer); + component->render(game, *this, buffer); + } +} + +void Entity::detectCollision(Game& game, Entity& collider, std::pair old_position) +{ + for (auto component : components) + { + component->detectCollision(game, *this, collider, old_position); } } -- cgit 1.4.1