From 28583452694553c30802405acc5047b0f37b7b80 Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Sun, 8 Jun 2025 19:41:19 -0700 Subject: [PATCH] fix: destroy enemies on entering build mode (#1812) --- dGame/dComponents/PropertyManagementComponent.cpp | 8 ++++++++ dGame/dPropertyBehaviors/Strip.cpp | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/dGame/dComponents/PropertyManagementComponent.cpp b/dGame/dComponents/PropertyManagementComponent.cpp index f20a2886..25a7d036 100644 --- a/dGame/dComponents/PropertyManagementComponent.cpp +++ b/dGame/dComponents/PropertyManagementComponent.cpp @@ -272,6 +272,10 @@ void PropertyManagementComponent::OnStartBuilding() { model->HandleMsg(reset); } } + + for (auto* const entity : Game::entityManager->GetEntitiesInGroup("SpawnedPropertyEnemies")) { + if (entity) entity->Smash(); + } } void PropertyManagementComponent::OnFinishBuilding() { @@ -296,6 +300,10 @@ void PropertyManagementComponent::OnFinishBuilding() { model->HandleMsg(reset); } } + + for (auto* const entity : Game::entityManager->GetEntitiesInGroup("SpawnedPropertyEnemies")) { + if (entity) entity->Smash(); + } } void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const NiPoint3 position, NiQuaternion rotation) { diff --git a/dGame/dPropertyBehaviors/Strip.cpp b/dGame/dPropertyBehaviors/Strip.cpp index b1dd94eb..5e90d2ba 100644 --- a/dGame/dPropertyBehaviors/Strip.cpp +++ b/dGame/dPropertyBehaviors/Strip.cpp @@ -111,7 +111,9 @@ void Strip::Spawn(LOT lot, Entity& entity) { info.pos = entity.GetPosition(); info.rot = NiQuaternionConstant::IDENTITY; info.spawnerID = entity.GetObjectID(); - Game::entityManager->ConstructEntity(Game::entityManager->CreateEntity(info, nullptr, &entity)); + auto* const spawnedEntity = Game::entityManager->CreateEntity(info, nullptr, &entity); + spawnedEntity->AddToGroup("SpawnedPropertyEnemies"); + Game::entityManager->ConstructEntity(spawnedEntity); } // Spawns a specific drop for all