mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-25 15:39:50 +00:00
adding on collided callback
This commit is contained in:
@@ -20,7 +20,7 @@ namespace BBM
|
||||
auto &col = entity.getComponent<CollisionComponent>();
|
||||
Vector3f position = posA.position;
|
||||
if (entity.hasComponent(typeid(MovableComponent)))
|
||||
position += entity.getComponent<MovableComponent>()._velocity;
|
||||
position += entity.getComponent<MovableComponent>().getVelocity();
|
||||
Vector3f minA = Vector3f::min(position, position + col.bound);
|
||||
Vector3f maxA = Vector3f::max(position, position + col.bound);
|
||||
for (auto &other : _wal.scene->getEntities()) {
|
||||
@@ -29,14 +29,16 @@ namespace BBM
|
||||
if (!other.hasComponent(typeid(CollisionComponent)) ||
|
||||
!other.hasComponent(typeid(PositionComponent)))
|
||||
continue;
|
||||
auto colB = entity.getComponent<CollisionComponent>().bound;
|
||||
auto colB = entity.getComponent<CollisionComponent>();
|
||||
auto posB = other.getComponent<PositionComponent>().position;
|
||||
Vector3f minB = Vector3f::min(posB, posB + colB);
|
||||
Vector3f maxB = Vector3f::max(posB, posB + colB);
|
||||
Vector3f minB = Vector3f::min(posB, posB + colB.bound);
|
||||
Vector3f maxB = Vector3f::max(posB, posB + colB.bound);
|
||||
if ((minA.x <= maxB.x && maxA.x >= minB.x) &&
|
||||
(minA.y <= maxB.y && maxA.y >= minB.y) &&
|
||||
(minA.z <= maxB.z && maxA.z >= minB.z))
|
||||
col.onCollide(entity, other);
|
||||
(minA.z <= maxB.z && maxA.z >= minB.z)) {
|
||||
col.getOnCollide()(entity, other);
|
||||
colB.getOnCollided()(entity, other);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user