Animate items entering building input ports

This commit is contained in:
2026-07-14 20:21:25 +02:00
parent 6a8c456aa1
commit c9f14970a1
7 changed files with 264 additions and 37 deletions

View File

@@ -402,10 +402,11 @@ 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);
// Port items are drawn before the buildings so the building body occludes the
// portion still inside the footprint: items appear to slide out of the output
// port (REQ-MAT-OUTPUT-EMERGE) and into the input port (REQ-MAT-INPUT-INTAKE)
// rather than popping in or out of existence.
drawPortItems(painter);
drawBuildings(painter);
drawCopyConfigFeedback(painter);
drawStations(painter);
@@ -1157,11 +1158,14 @@ void GameWorldView::drawCopyConfigFeedback(QPainter& painter)
}
}
void GameWorldView::drawEmergingItems(QPainter& painter)
void GameWorldView::drawPortItems(QPainter& painter)
{
const float halfPx = tilePx() * 0.5f * 0.5f;
m_sim->buildings().forEachEmergingItem(
// Shared with belt items (REQ-GW-TILE-SIZE): a half-tile filled square with an
// outline, occluded by the building drawn afterwards so the item slides out of
// (REQ-MAT-OUTPUT-EMERGE) or into (REQ-MAT-INPUT-INTAKE) the port.
const std::function<void(const ItemType&, QPointF)> drawItem =
[&](const ItemType& type, QPointF worldPos)
{
const std::map<std::string, ItemVisuals>::const_iterator it =
@@ -1177,7 +1181,10 @@ void GameWorldView::drawEmergingItems(QPainter& painter)
painter.setPen(QPen(it->second.outline, 1));
painter.setBrush(Qt::NoBrush);
painter.drawRect(rect);
});
};
m_sim->buildings().forEachEmergingItem(drawItem);
m_sim->buildings().forEachIncomingItem(drawItem);
}
void GameWorldView::drawBeltItems(QPainter& painter)

View File

@@ -115,7 +115,7 @@ private:
bool canAfford(BuildingType type) const;
void drawTiles(QPainter& painter);
void drawEmergingItems(QPainter& painter);
void drawPortItems(QPainter& painter);
void drawBuildings(QPainter& painter);
void drawSelectionHighlights(QPainter& painter);
void drawCopyConfigFeedback(QPainter& painter);