allow to demolish belts and splitters

This commit is contained in:
2026-04-20 21:56:48 +02:00
parent 507b5d1e3a
commit a924877e20

View File

@@ -396,6 +396,10 @@ EntityId GameWorldView::buildingAtTile(QPoint tile) const
if (cell == tile) { return b.id; } if (cell == tile) { return b.id; }
} }
} }
for (const BuildingSystem::BeltTileInfo& info : m_sim->buildings().allBeltTiles())
{
if (info.tile == tile) { return info.id; }
}
return kInvalidEntityId; return kInvalidEntityId;
} }
@@ -778,6 +782,17 @@ void GameWorldView::drawOverlays(QPainter& painter)
painter.fillRect(tileRect(cell), m_visuals->overlays.demolishTint); painter.fillRect(tileRect(cell), m_visuals->overlays.demolishTint);
} }
} }
else
{
for (const BuildingSystem::BeltTileInfo& info : m_sim->buildings().allBeltTiles())
{
if (info.id == m_demolishHoverId)
{
painter.fillRect(tileRect(info.tile), m_visuals->overlays.demolishTint);
break;
}
}
}
} }
// Box-select rectangle // Box-select rectangle
@@ -956,8 +971,9 @@ void GameWorldView::mousePressEvent(QMouseEvent* event)
if (hovered != kInvalidEntityId) if (hovered != kInvalidEntityId)
{ {
const Building* b = m_sim->buildings().findBuilding(hovered); const Building* b = m_sim->buildings().findBuilding(hovered);
if (b && b->type != BuildingType::Hq const bool protected_ = b && (b->type == BuildingType::Hq
&& b->type != BuildingType::PlayerDefenceStation) || b->type == BuildingType::PlayerDefenceStation);
if (!protected_)
{ {
m_sim->buildings().demolish(hovered); m_sim->buildings().demolish(hovered);
m_demolishHoverId = kInvalidEntityId; m_demolishHoverId = kInvalidEntityId;