diff --git a/src/game_logic/damage_infliction_system.cpp b/src/game_logic/damage_infliction_system.cpp index 11e098291..5b0d71fa0 100644 --- a/src/game_logic/damage_infliction_system.cpp +++ b/src/game_logic/damage_infliction_system.cpp @@ -65,22 +65,23 @@ DamageInflictionSystem::DamageInflictionSystem( void DamageInflictionSystem::update(ex::EntityManager& es) { - es.each( + es.each( [this, &es]( - ex::Entity inflictorEntity, - DamageInflicting& damage, - const WorldPosition& inflictorPosition, - const BoundingBox& bbox) { - const auto inflictorBbox = engine::toWorldSpace(bbox, inflictorPosition); - - ex::ComponentHandle shootable; - ex::ComponentHandle shootablePos; - ex::ComponentHandle shootableBboxLocal; - for (auto shootableEntity : es.entities_with_components( - shootable, shootablePos, shootableBboxLocal)) + ex::Entity shootableEntity, + Shootable& shootable, + const WorldPosition& shootablePos, + const BoundingBox& shootableBboxLocal) { + const auto shootableBbox = + engine::toWorldSpace(shootableBboxLocal, shootablePos); + + ex::ComponentHandle damage; + ex::ComponentHandle inflictorPosition; + ex::ComponentHandle inflictorBboxLocal; + for (auto inflictorEntity : es.entities_with_components( + damage, inflictorPosition, inflictorBboxLocal)) { - const auto shootableBbox = - engine::toWorldSpace(*shootableBboxLocal, *shootablePos); + const auto inflictorBbox = + engine::toWorldSpace(*inflictorBboxLocal, *inflictorPosition); const auto shootableOnScreen = shootableEntity.has_component() && @@ -89,17 +90,12 @@ void DamageInflictionSystem::update(ex::EntityManager& es) // clang-format off if ( shootableBbox.intersects(inflictorBbox) && - !shootable->mInvincible && - (shootableOnScreen || shootable->mCanBeHitWhenOffscreen)) + !shootable.mInvincible && + (shootableOnScreen || shootable.mCanBeHitWhenOffscreen)) // clang-format on { - const auto destroyOnContact = - damage.mDestroyOnContact || shootable->mAlwaysConsumeInflictor; - inflictDamage(inflictorEntity, damage, shootableEntity, *shootable); - if (destroyOnContact) - { - break; - } + inflictDamage(inflictorEntity, *damage, shootableEntity, shootable); + break; } } });