diff options
author | Stijn Buys <ingar@osirion.org> | 2012-12-04 21:42:54 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2012-12-04 21:42:54 +0000 |
commit | 5701da5df3e5f0d3a40af0abf7e03302275dcca2 (patch) | |
tree | 6135b87fc0573183a02688b0415a1ed70a40c751 /src/core/entityprojectile.cc | |
parent | a3450f23b09e8d5c66f710fbaf085d6d3b6d8122 (diff) |
Introduce Entity::hit() callback, prevent projectiles from doing no damage.
Diffstat (limited to 'src/core/entityprojectile.cc')
-rw-r--r-- | src/core/entityprojectile.cc | 8 |
1 files changed, 5 insertions, 3 deletions
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<EntityDynamic *>(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) |