#include "collider.hpp"
#include "entity/entity.hpp"

using game::entity::Entity;

namespace game {

void ColliderListener::BeginContact(b2Contact *contact)
{
    Entity *a = (Entity*)contact->GetFixtureA()->GetUserData();
    Entity *b = (Entity*)contact->GetFixtureB()->GetUserData();

    if (a && b) {
        a->OnCollide(b);
        b->OnCollide(a);
    } else if (a) {
        a->OnCollide();
    } else if (b) {
        b->OnCollide();
    }
}

}
