Animate items emerging from building output ports

This commit is contained in:
2026-07-14 20:18:47 +02:00
parent af8a2224c0
commit 6a8c456aa1
13 changed files with 282 additions and 122 deletions

View File

@@ -402,6 +402,10 @@ void GameWorldView::paintGL()
painter.setRenderHint(QPainter::Antialiasing, false);
drawTiles(painter);
// Emerging items are drawn before the buildings so the building body occludes
// the portion still inside the footprint, making items appear to slide out of
// the output port rather than pop into existence (REQ-MAT-OUTPUT-EMERGE).
drawEmergingItems(painter);
drawBuildings(painter);
drawCopyConfigFeedback(painter);
drawStations(painter);
@@ -1153,6 +1157,29 @@ void GameWorldView::drawCopyConfigFeedback(QPainter& painter)
}
}
void GameWorldView::drawEmergingItems(QPainter& painter)
{
const float halfPx = tilePx() * 0.5f * 0.5f;
m_sim->buildings().forEachEmergingItem(
[&](const ItemType& type, QPointF worldPos)
{
const std::map<std::string, ItemVisuals>::const_iterator it =
m_visuals->items.find(type.id);
if (it == m_visuals->items.end()) { return; }
const QPointF center = worldToWidget(
QVector2D(static_cast<float>(worldPos.x()),
static_cast<float>(worldPos.y())));
const QRectF rect(center.x() - halfPx, center.y() - halfPx,
halfPx * 2, halfPx * 2);
painter.fillRect(rect, it->second.fill);
painter.setPen(QPen(it->second.outline, 1));
painter.setBrush(Qt::NoBrush);
painter.drawRect(rect);
});
}
void GameWorldView::drawBeltItems(QPainter& painter)
{
const float halfPx = tilePx() * 0.5f * 0.5f;