Enhance hit detection with proximity object checks

Refactor hit handling to include proximity checks for destroyable entities.
This commit is contained in:
David Markowitz
2025-10-04 20:59:00 -07:00
committed by GitHub
parent f8a82fbf79
commit a4f3362fd3

View File

@@ -47,9 +47,14 @@ void ExplodingAsset::OnHit(Entity* self, Entity* attacker) {
if (!proximityComponent) return;
if (!self->GetBoolean(u"bIsHit")) {
auto* const destroyable = attacker->GetComponent<DestroyableComponent>();
for (const auto objID : proximityComponent->GetProximityObjects("crateHitters")) {
auto* const entity = Game::entityManager->GetEntity(objID);
if (!entity || entity->GetObjectID() != attacker->GetObjectID()) continue;
auto* const destroyable = entity->GetComponent<DestroyableComponent>();
if (destroyable) destroyable->Smash(attacker->GetObjectID());
}
}
attacker = attacker->GetOwner();
self->SetBoolean(u"bIsHit", true);