fix stations were not drawn
This commit is contained in:
@@ -145,6 +145,7 @@ void ArenaView::paintGL()
|
|||||||
|
|
||||||
drawTiles(painter);
|
drawTiles(painter);
|
||||||
drawBuildings(painter);
|
drawBuildings(painter);
|
||||||
|
//drawStations(painter);
|
||||||
drawScrap(painter);
|
drawScrap(painter);
|
||||||
drawShips(painter);
|
drawShips(painter);
|
||||||
drawBeams(painter);
|
drawBeams(painter);
|
||||||
@@ -264,6 +265,48 @@ void ArenaView::drawScrap(QPainter& painter)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ArenaView::drawStations(QPainter& painter)
|
||||||
|
{
|
||||||
|
m_sim->admin().forEach<StationBody, Faction, Health>(
|
||||||
|
[&](entt::entity /*e*/, const StationBody& sb, const Faction& f, const Health& h)
|
||||||
|
{
|
||||||
|
const BuildingType visType = f.isEnemy
|
||||||
|
? BuildingType::EnemyDefenceStation
|
||||||
|
: BuildingType::PlayerDefenceStation;
|
||||||
|
const std::map<BuildingType, BuildingVisuals>::const_iterator it =
|
||||||
|
m_visuals->buildings.find(visType);
|
||||||
|
if (it == m_visuals->buildings.end()) { return; }
|
||||||
|
const BuildingVisuals& bv = it->second;
|
||||||
|
|
||||||
|
painter.setPen(Qt::NoPen);
|
||||||
|
for (const QPoint& cell : sb.bodyCells)
|
||||||
|
{
|
||||||
|
painter.fillRect(tileRect(cell), bv.fill);
|
||||||
|
}
|
||||||
|
|
||||||
|
const QPointF tl = tileToWidget(sb.anchor);
|
||||||
|
const QRectF bboxRect(tl.x(), tl.y(),
|
||||||
|
sb.footprint.width() * static_cast<qreal>(tilePx()),
|
||||||
|
sb.footprint.height() * static_cast<qreal>(tilePx()));
|
||||||
|
|
||||||
|
painter.setPen(QPen(bv.outline, 1));
|
||||||
|
painter.setBrush(Qt::NoBrush);
|
||||||
|
painter.drawRect(bboxRect);
|
||||||
|
|
||||||
|
if (h.maxHp > 0.0f)
|
||||||
|
{
|
||||||
|
const float fraction = std::max(0.0f, h.hp / h.maxHp);
|
||||||
|
const qreal barH = static_cast<qreal>(tilePx()) * 0.12;
|
||||||
|
const qreal barY = bboxRect.bottom() + 1.0;
|
||||||
|
const qreal barW = bboxRect.width();
|
||||||
|
painter.fillRect(QRectF(bboxRect.left(), barY, barW, barH),
|
||||||
|
QColor(60, 60, 60));
|
||||||
|
painter.fillRect(QRectF(bboxRect.left(), barY, barW * static_cast<qreal>(fraction), barH),
|
||||||
|
f.isEnemy ? QColor(200, 60, 60) : QColor(60, 200, 60));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void ArenaView::drawShips(QPainter& painter)
|
void ArenaView::drawShips(QPainter& painter)
|
||||||
{
|
{
|
||||||
m_sim->admin().forEach<ShipIdentity, Position, Velocity, Faction>(
|
m_sim->admin().forEach<ShipIdentity, Position, Velocity, Faction>(
|
||||||
@@ -312,3 +355,4 @@ void ArenaView::drawBeams(QPainter& painter)
|
|||||||
worldToWidget(*targetPos + beam.targetOffset));
|
worldToWidget(*targetPos + beam.targetOffset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
void drawTiles(QPainter& painter);
|
void drawTiles(QPainter& painter);
|
||||||
void drawBuildings(QPainter& painter);
|
void drawBuildings(QPainter& painter);
|
||||||
|
void drawStations(QPainter& painter);
|
||||||
void drawScrap(QPainter& painter);
|
void drawScrap(QPainter& painter);
|
||||||
void drawShips(QPainter& painter);
|
void drawShips(QPainter& painter);
|
||||||
void drawBeams(QPainter& painter);
|
void drawBeams(QPainter& painter);
|
||||||
|
|||||||
@@ -600,9 +600,7 @@ void BuildingSystem::tickProduction(Tick currentTick)
|
|||||||
building.type == BuildingType::Splitter ||
|
building.type == BuildingType::Splitter ||
|
||||||
building.type == BuildingType::Shipyard ||
|
building.type == BuildingType::Shipyard ||
|
||||||
building.type == BuildingType::SalvageBay ||
|
building.type == BuildingType::SalvageBay ||
|
||||||
building.type == BuildingType::Hq ||
|
building.type == BuildingType::Hq)
|
||||||
building.type == BuildingType::PlayerDefenceStation ||
|
|
||||||
building.type == BuildingType::EnemyDefenceStation)
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -262,6 +262,7 @@ void GameWorldView::paintGL()
|
|||||||
|
|
||||||
drawTiles(painter);
|
drawTiles(painter);
|
||||||
drawBuildings(painter);
|
drawBuildings(painter);
|
||||||
|
drawStations(painter);
|
||||||
drawBeltItems(painter);
|
drawBeltItems(painter);
|
||||||
drawScrap(painter);
|
drawScrap(painter);
|
||||||
if (m_debugDraw) { drawDebugSensorRanges(painter); }
|
if (m_debugDraw) { drawDebugSensorRanges(painter); }
|
||||||
@@ -342,17 +343,16 @@ float GameWorldView::enemyStationRightEdge() const
|
|||||||
{
|
{
|
||||||
float rightX = static_cast<float>(m_config->world.regions.playerBufferWidth
|
float rightX = static_cast<float>(m_config->world.regions.playerBufferWidth
|
||||||
+ m_config->world.regions.contestZoneWidth);
|
+ m_config->world.regions.contestZoneWidth);
|
||||||
for (const Building& b : m_sim->buildings().allBuildings())
|
m_sim->admin().forEach<StationBody, Faction>(
|
||||||
|
[&rightX](entt::entity /*e*/, const StationBody& sb, const Faction& f)
|
||||||
{
|
{
|
||||||
if (b.type == BuildingType::EnemyDefenceStation)
|
if (!f.isEnemy) { return; }
|
||||||
{
|
for (const QPoint& cell : sb.bodyCells)
|
||||||
for (const QPoint& cell : b.bodyCells)
|
|
||||||
{
|
{
|
||||||
const float cx = static_cast<float>(cell.x() + 1);
|
const float cx = static_cast<float>(cell.x() + 1);
|
||||||
if (cx > rightX) { rightX = cx; }
|
if (cx > rightX) { rightX = cx; }
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
|
||||||
return rightX;
|
return rightX;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -792,6 +792,49 @@ void GameWorldView::drawScrap(QPainter& painter)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameWorldView::drawStations(QPainter& painter)
|
||||||
|
{
|
||||||
|
m_sim->admin().forEach<StationBody, Faction, Health>(
|
||||||
|
[&](entt::entity /*e*/, const StationBody& sb, const Faction& f, const Health& h)
|
||||||
|
{
|
||||||
|
const BuildingType visType = f.isEnemy
|
||||||
|
? BuildingType::EnemyDefenceStation
|
||||||
|
: BuildingType::PlayerDefenceStation;
|
||||||
|
const std::map<BuildingType, BuildingVisuals>::const_iterator it =
|
||||||
|
m_visuals->buildings.find(visType);
|
||||||
|
if (it == m_visuals->buildings.end()) { return; }
|
||||||
|
const BuildingVisuals& bv = it->second;
|
||||||
|
|
||||||
|
painter.setPen(Qt::NoPen);
|
||||||
|
for (const QPoint& cell : sb.bodyCells)
|
||||||
|
{
|
||||||
|
painter.fillRect(tileRect(cell), bv.fill);
|
||||||
|
}
|
||||||
|
|
||||||
|
const QPointF tl = tileToWidget(QPoint(sb.anchor.x(), sb.anchor.y()));
|
||||||
|
const QRectF bboxRect(tl.x(), tl.y(),
|
||||||
|
sb.footprint.width() * static_cast<qreal>(tilePx()),
|
||||||
|
sb.footprint.height() * static_cast<qreal>(tilePx()));
|
||||||
|
|
||||||
|
painter.setPen(QPen(bv.outline, 1));
|
||||||
|
painter.setBrush(Qt::NoBrush);
|
||||||
|
painter.drawRect(bboxRect);
|
||||||
|
|
||||||
|
// HP bar below footprint.
|
||||||
|
if (h.maxHp > 0.0f)
|
||||||
|
{
|
||||||
|
const float fraction = std::max(0.0f, h.hp / h.maxHp);
|
||||||
|
const qreal barH = static_cast<qreal>(tilePx()) * 0.12;
|
||||||
|
const qreal barY = bboxRect.bottom() + 1.0;
|
||||||
|
const qreal barW = bboxRect.width();
|
||||||
|
painter.fillRect(QRectF(bboxRect.left(), barY, barW, barH),
|
||||||
|
QColor(60, 60, 60));
|
||||||
|
painter.fillRect(QRectF(bboxRect.left(), barY, barW * static_cast<qreal>(fraction), barH),
|
||||||
|
f.isEnemy ? QColor(200, 60, 60) : QColor(60, 200, 60));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void GameWorldView::drawShips(QPainter& painter)
|
void GameWorldView::drawShips(QPainter& painter)
|
||||||
{
|
{
|
||||||
m_sim->admin().forEach<ShipIdentity, Position, Facing, Faction>(
|
m_sim->admin().forEach<ShipIdentity, Position, Facing, Faction>(
|
||||||
@@ -1133,8 +1176,7 @@ 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);
|
||||||
const bool isProtected = b && (b->type == BuildingType::Hq
|
const bool isProtected = b && b->type == BuildingType::Hq;
|
||||||
|| b->type == BuildingType::PlayerDefenceStation);
|
|
||||||
if (!isProtected)
|
if (!isProtected)
|
||||||
{
|
{
|
||||||
m_sim->demolish(hovered);
|
m_sim->demolish(hovered);
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
void drawTiles(QPainter& painter);
|
void drawTiles(QPainter& painter);
|
||||||
void drawBuildings(QPainter& painter);
|
void drawBuildings(QPainter& painter);
|
||||||
|
void drawStations(QPainter& painter);
|
||||||
void drawBeltItems(QPainter& painter);
|
void drawBeltItems(QPainter& painter);
|
||||||
void drawScrap(QPainter& painter);
|
void drawScrap(QPainter& painter);
|
||||||
void drawShips(QPainter& painter);
|
void drawShips(QPainter& painter);
|
||||||
|
|||||||
Reference in New Issue
Block a user