mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-13 10:58:07 +00:00
Enhance hit detection with proximity object checks
Refactor hit handling to include proximity checks for destroyable entities.
This commit is contained in:
@@ -47,8 +47,13 @@ void ExplodingAsset::OnHit(Entity* self, Entity* attacker) {
|
||||
if (!proximityComponent) return;
|
||||
|
||||
if (!self->GetBoolean(u"bIsHit")) {
|
||||
auto* const destroyable = attacker->GetComponent<DestroyableComponent>();
|
||||
if (destroyable) destroyable->Smash(attacker->GetObjectID());
|
||||
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();
|
||||
|
Reference in New Issue
Block a user