From 5701da5df3e5f0d3a40af0abf7e03302275dcca2 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 4 Dec 2012 21:42:54 +0000 Subject: Introduce Entity::hit() callback, prevent projectiles from doing no damage. --- src/core/entityprojectile.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/core/entityprojectile.cc') diff --git a/src/core/entityprojectile.cc b/src/core/entityprojectile.cc index 8c6c57b..e89c7f7 100644 --- a/src/core/entityprojectile.cc +++ b/src/core/entityprojectile.cc @@ -56,10 +56,12 @@ void EntityProjectile::collision(Entity *other) { if (state() == Entity::Destroyed) { return; + } else { + if ((other->type() == Dynamic) || (other->type() == Controlable)) { + static_cast(other)->hit(this); + } + set_state(Entity::Destroyed); } - - set_state(Entity::Destroyed); - // this method is a bullet callback, we can not reset() here } void EntityProjectile::frame(const unsigned long elapsed) -- cgit v1.2.3