fix belts were not drawn
This commit is contained in:
@@ -656,6 +656,21 @@ std::vector<ConstructionSite> BuildingSystem::allSites() const
|
|||||||
m_constructionQueue.end());
|
m_constructionQueue.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<BuildingSystem::BeltTileInfo> BuildingSystem::allBeltTiles() const
|
||||||
|
{
|
||||||
|
std::vector<BeltTileInfo> result;
|
||||||
|
result.reserve(m_beltEntities.size());
|
||||||
|
for (const std::map<EntityId, BeltEntry>::value_type& kv : m_beltEntities)
|
||||||
|
{
|
||||||
|
BeltTileInfo info;
|
||||||
|
info.id = kv.first;
|
||||||
|
info.tile = kv.second.tile;
|
||||||
|
info.type = kv.second.type;
|
||||||
|
result.push_back(info);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
bool BuildingSystem::isTileOccupied(QPoint tile) const
|
bool BuildingSystem::isTileOccupied(QPoint tile) const
|
||||||
{
|
{
|
||||||
return m_tileOccupancy.count({tile.x(), tile.y()}) > 0;
|
return m_tileOccupancy.count({tile.x(), tile.y()}) > 0;
|
||||||
|
|||||||
@@ -55,10 +55,18 @@ public:
|
|||||||
void tickBeltPush();
|
void tickBeltPush();
|
||||||
|
|
||||||
// -- Queries -------------------------------------------------------------
|
// -- Queries -------------------------------------------------------------
|
||||||
|
struct BeltTileInfo
|
||||||
|
{
|
||||||
|
EntityId id;
|
||||||
|
QPoint tile;
|
||||||
|
BuildingType type; // Belt or Splitter
|
||||||
|
};
|
||||||
|
|
||||||
const Building* findBuilding(EntityId id) const;
|
const Building* findBuilding(EntityId id) const;
|
||||||
const ConstructionSite* findSite(EntityId id) const;
|
const ConstructionSite* findSite(EntityId id) const;
|
||||||
std::vector<Building> allBuildings() const;
|
std::vector<Building> allBuildings() const;
|
||||||
std::vector<ConstructionSite> allSites() const;
|
std::vector<ConstructionSite> allSites() const;
|
||||||
|
std::vector<BeltTileInfo> allBeltTiles() const;
|
||||||
bool isTileOccupied(QPoint tile) const;
|
bool isTileOccupied(QPoint tile) const;
|
||||||
|
|
||||||
// Find nearest operational building of the given type; nullptr if none.
|
// Find nearest operational building of the given type; nullptr if none.
|
||||||
|
|||||||
@@ -518,6 +518,21 @@ void GameWorldView::drawBuildings(QPainter& painter)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Belt and splitter tiles (stored separately from regular buildings)
|
||||||
|
for (const BuildingSystem::BeltTileInfo& info : m_sim->buildings().allBeltTiles())
|
||||||
|
{
|
||||||
|
const std::map<BuildingType, BuildingVisuals>::const_iterator it =
|
||||||
|
m_visuals->buildings.find(info.type);
|
||||||
|
if (it == m_visuals->buildings.end()) { continue; }
|
||||||
|
const BuildingVisuals& bv = it->second;
|
||||||
|
|
||||||
|
painter.setPen(Qt::NoPen);
|
||||||
|
painter.fillRect(tileRect(info.tile), bv.fill);
|
||||||
|
painter.setPen(QPen(bv.outline, 1));
|
||||||
|
painter.setBrush(Qt::NoBrush);
|
||||||
|
painter.drawRect(tileRect(info.tile));
|
||||||
|
}
|
||||||
|
|
||||||
painter.setOpacity(0.5);
|
painter.setOpacity(0.5);
|
||||||
for (const ConstructionSite& s : m_sim->buildings().allSites())
|
for (const ConstructionSite& s : m_sim->buildings().allSites())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user