Prefix all getters with "get"
This commit is contained in:
@@ -211,7 +211,7 @@ void GameWorldView::onFrame()
|
||||
if (m_replayPlayer->isFinished()
|
||||
|| m_sim->isWon() || m_sim->isGameOver()) { break; }
|
||||
m_sim->tick();
|
||||
m_replayPlayer->advanceTo(m_sim->currentTick());
|
||||
m_replayPlayer->advanceTo(m_sim->getCurrentTick());
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -263,7 +263,7 @@ void GameWorldView::onFrame()
|
||||
// Expire old beams. Lifetime is measured in game ticks so beams stay
|
||||
// visible while the simulation is paused or slowed (REQ-SHP-FIRING-BEAM).
|
||||
{
|
||||
const Tick now = m_sim->currentTick();
|
||||
const Tick now = m_sim->getCurrentTick();
|
||||
std::vector<ActiveBeam> live;
|
||||
for (const ActiveBeam& b : m_activeBeams)
|
||||
{
|
||||
@@ -314,11 +314,11 @@ void GameWorldView::onFrame()
|
||||
|
||||
// Fire events for any state that changed since the last frame
|
||||
{
|
||||
const Tick newTick = m_sim->currentTick();
|
||||
const int newBlocks = m_sim->buildingBlocksStock();
|
||||
const int newExpCost = m_sim->currentExpansionCost();
|
||||
const int newBoss = m_sim->bossWaveCounter();
|
||||
const Tick newCountdown = m_sim->bossCountdownTicks();
|
||||
const Tick newTick = m_sim->getCurrentTick();
|
||||
const int newBlocks = m_sim->getBuildingBlocksStock();
|
||||
const int newExpCost = m_sim->getCurrentExpansionCost();
|
||||
const int newBoss = m_sim->getBossWaveCounter();
|
||||
const Tick newCountdown = m_sim->getBossCountdownTicks();
|
||||
|
||||
if (newTick != m_lastTick)
|
||||
{
|
||||
@@ -384,16 +384,16 @@ void GameWorldView::onFrame()
|
||||
|
||||
// Artifact count is a passive reflection of sim state (not a live-input source
|
||||
// like the schematic/game-over polls above), so it updates during replay too —
|
||||
// the recorded ApplySchematicChoice drives m_sim->artifactCount() forward and
|
||||
// the recorded ApplySchematicChoice drives m_sim->getArtifactCount() forward and
|
||||
// the header bar must track it. Fires on the first frame (count 0 vs the -1
|
||||
// sentinel), which also populates the win-count max (replacing the "0/?" label).
|
||||
const int currentArtifactCount = m_sim->artifactCount();
|
||||
const int currentArtifactCount = m_sim->getArtifactCount();
|
||||
if (currentArtifactCount != m_lastArtifactCount)
|
||||
{
|
||||
m_lastArtifactCount = currentArtifactCount;
|
||||
EventManager::getInstance()->sendEventImmediately(
|
||||
std::make_shared<ArtifactCountChangedEvent>(
|
||||
currentArtifactCount, m_sim->config().world.artifacts.artifactWinCount));
|
||||
currentArtifactCount, m_sim->getConfig().world.artifacts.artifactWinCount));
|
||||
}
|
||||
|
||||
update();
|
||||
@@ -432,27 +432,27 @@ void GameWorldView::paintGL()
|
||||
// Coordinate helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
float GameWorldView::tilePx() const
|
||||
float GameWorldView::getTilePx() const
|
||||
{
|
||||
if (m_config->world.heightTiles <= 0) { return 1.0f; }
|
||||
return static_cast<float>(height()) / static_cast<float>(m_config->world.heightTiles);
|
||||
}
|
||||
|
||||
float GameWorldView::viewportWidthTiles() const
|
||||
float GameWorldView::getViewportWidthTiles() const
|
||||
{
|
||||
return static_cast<float>(width()) / tilePx();
|
||||
return static_cast<float>(width()) / getTilePx();
|
||||
}
|
||||
|
||||
float GameWorldView::viewLeftTiles() const
|
||||
float GameWorldView::getViewLeftTiles() const
|
||||
{
|
||||
return m_scrollXTiles - viewportWidthTiles() / 2.0f;
|
||||
return m_scrollXTiles - getViewportWidthTiles() / 2.0f;
|
||||
}
|
||||
|
||||
QPointF GameWorldView::worldToWidget(QVector2D worldPos) const
|
||||
{
|
||||
return QPointF(
|
||||
static_cast<qreal>((worldPos.x() - viewLeftTiles()) * tilePx()),
|
||||
static_cast<qreal>(worldPos.y() * tilePx()));
|
||||
static_cast<qreal>((worldPos.x() - getViewLeftTiles()) * getTilePx()),
|
||||
static_cast<qreal>(worldPos.y() * getTilePx()));
|
||||
}
|
||||
|
||||
QPointF GameWorldView::tileToWidget(QPoint tile) const
|
||||
@@ -463,15 +463,15 @@ QPointF GameWorldView::tileToWidget(QPoint tile) const
|
||||
|
||||
QPoint GameWorldView::widgetToTile(QPoint widgetPt) const
|
||||
{
|
||||
const float wx = static_cast<float>(widgetPt.x()) / tilePx() + viewLeftTiles();
|
||||
const float wy = static_cast<float>(widgetPt.y()) / tilePx();
|
||||
const float wx = static_cast<float>(widgetPt.x()) / getTilePx() + getViewLeftTiles();
|
||||
const float wy = static_cast<float>(widgetPt.y()) / getTilePx();
|
||||
return QPoint(static_cast<int>(std::floor(wx)), static_cast<int>(std::floor(wy)));
|
||||
}
|
||||
|
||||
QVector2D GameWorldView::widgetToWorld(QPoint widgetPt) const
|
||||
{
|
||||
const float wx = static_cast<float>(widgetPt.x()) / tilePx() + viewLeftTiles();
|
||||
const float wy = static_cast<float>(widgetPt.y()) / tilePx();
|
||||
const float wx = static_cast<float>(widgetPt.x()) / getTilePx() + getViewLeftTiles();
|
||||
const float wy = static_cast<float>(widgetPt.y()) / getTilePx();
|
||||
return QVector2D(wx, wy);
|
||||
}
|
||||
|
||||
@@ -479,22 +479,22 @@ QRectF GameWorldView::tileRect(QPoint tile) const
|
||||
{
|
||||
const QPointF tl = tileToWidget(tile);
|
||||
return QRectF(tl.x(), tl.y(),
|
||||
static_cast<qreal>(tilePx()), static_cast<qreal>(tilePx()));
|
||||
static_cast<qreal>(getTilePx()), static_cast<qreal>(getTilePx()));
|
||||
}
|
||||
|
||||
QRect GameWorldView::viewportRect() const
|
||||
QRect GameWorldView::getViewportRect() const
|
||||
{
|
||||
const int left = static_cast<int>(std::floor(viewLeftTiles())) - 1;
|
||||
const int left = static_cast<int>(std::floor(getViewLeftTiles())) - 1;
|
||||
const int top = 0;
|
||||
const int right = static_cast<int>(std::ceil(viewLeftTiles() + viewportWidthTiles())) + 1;
|
||||
const int right = static_cast<int>(std::ceil(getViewLeftTiles() + getViewportWidthTiles())) + 1;
|
||||
const int bottom = m_config->world.heightTiles;
|
||||
return QRect(left, top, right - left, bottom - top);
|
||||
}
|
||||
|
||||
float GameWorldView::asteroidLeftEdge() const
|
||||
float GameWorldView::getAsteroidLeftEdge() const
|
||||
{
|
||||
float leftX = -static_cast<float>(m_sim->currentAsteroidWidth_tiles());
|
||||
for (const Building& b : m_sim->buildings().allBuildings())
|
||||
float leftX = -static_cast<float>(m_sim->getCurrentAsteroidWidth_tiles());
|
||||
for (const Building& b : m_sim->getBuildings().getAllBuildings())
|
||||
{
|
||||
for (const QPoint& cell : b.bodyCells)
|
||||
{
|
||||
@@ -507,11 +507,11 @@ float GameWorldView::asteroidLeftEdge() const
|
||||
return leftX;
|
||||
}
|
||||
|
||||
float GameWorldView::enemyStationRightEdge() const
|
||||
float GameWorldView::getEnemyStationRightEdge() const
|
||||
{
|
||||
float rightX = static_cast<float>(m_config->world.regions.playerBufferWidth_tiles
|
||||
+ m_config->world.regions.contestZoneWidth_tiles);
|
||||
m_sim->admin().forEach<StationBodyComponent, FactionComponent>(
|
||||
m_sim->getAdmin().forEach<StationBodyComponent, FactionComponent>(
|
||||
[&rightX](entt::entity /*e*/, const StationBodyComponent& sb, const FactionComponent& f)
|
||||
{
|
||||
if (!f.isEnemy) { return; }
|
||||
@@ -546,7 +546,7 @@ float GameWorldView::panSpeedTilesPerSecondAt(float viewCenterXTiles) const
|
||||
const float fast = static_cast<float>(m_config->world.scroll.panSpeedFast_tps);
|
||||
const float half = static_cast<float>(m_config->world.scroll.panRampBandWidth_tiles) / 2.0f;
|
||||
const float leftEdge = static_cast<float>(m_config->world.regions.playerBufferWidth_tiles);
|
||||
const float rightEdge = enemyStationRightEdge();
|
||||
const float rightEdge = getEnemyStationRightEdge();
|
||||
|
||||
// Rising ramp at the left boundary (slow -> fast) and falling ramp at the right
|
||||
// boundary (fast -> slow); their minimum yields flat-slow outside, flat-fast in
|
||||
@@ -562,8 +562,8 @@ void GameWorldView::clampScroll()
|
||||
// m_scrollXTiles is the view center, so the pan limits are the edges themselves:
|
||||
// the view can pan left until the buildable/asteroid edge is centered, and right
|
||||
// until the enemy stations are centered (revealing a little space beyond them).
|
||||
const float leftBound = asteroidLeftEdge();
|
||||
const float rightBound = enemyStationRightEdge();
|
||||
const float leftBound = getAsteroidLeftEdge();
|
||||
const float rightBound = getEnemyStationRightEdge();
|
||||
m_scrollXTiles = std::max(leftBound, std::min(m_scrollXTiles, rightBound));
|
||||
}
|
||||
|
||||
@@ -586,7 +586,7 @@ bool GameWorldView::isValidPlacement(BuildingType type, QPoint anchor,
|
||||
// Terrain and world-bounds validity are owned by the simulation
|
||||
// (REQ-BLD-PLACE-VALID); the presentation layer only adds the occupancy /
|
||||
// rotate-in-place check.
|
||||
if (!m_sim->buildings().isPlacementValid(type, anchor, rot))
|
||||
if (!m_sim->getBuildings().isPlacementValid(type, anchor, rot))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -598,7 +598,7 @@ bool GameWorldView::isValidPlacement(BuildingType type, QPoint anchor,
|
||||
bool anyOccupied = false;
|
||||
for (const QPoint& relCell : parsed.bodyCells)
|
||||
{
|
||||
if (m_sim->buildings().isTileOccupied(anchor + relCell))
|
||||
if (m_sim->getBuildings().isTileOccupied(anchor + relCell))
|
||||
{
|
||||
anyOccupied = true;
|
||||
break;
|
||||
@@ -607,14 +607,14 @@ bool GameWorldView::isValidPlacement(BuildingType type, QPoint anchor,
|
||||
|
||||
if (anyOccupied)
|
||||
{
|
||||
return m_sim->buildings().findRotateInPlaceTarget(type, anchor, rot).has_value();
|
||||
return m_sim->getBuildings().findRotateInPlaceTarget(type, anchor, rot).has_value();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
BuildingId GameWorldView::buildingAtTile(QPoint tile) const
|
||||
{
|
||||
for (const Building& b : m_sim->buildings().allBuildings())
|
||||
for (const Building& b : m_sim->getBuildings().getAllBuildings())
|
||||
{
|
||||
for (const QPoint& cell : b.bodyCells)
|
||||
{
|
||||
@@ -629,7 +629,7 @@ BuildingId GameWorldView::buildingAtTile(QPoint tile) const
|
||||
|
||||
BuildingId GameWorldView::siteAtTile(QPoint tile) const
|
||||
{
|
||||
for (const ConstructionSite& s : m_sim->buildings().allSites())
|
||||
for (const ConstructionSite& s : m_sim->getBuildings().getAllSites())
|
||||
{
|
||||
for (const QPoint& cell : s.bodyCells)
|
||||
{
|
||||
@@ -651,7 +651,7 @@ std::vector<BuildingId> GameWorldView::buildingsInBox(QPoint cornerA, QPoint cor
|
||||
const int y1 = std::max(cornerA.y(), cornerB.y());
|
||||
|
||||
std::vector<BuildingId> ids;
|
||||
for (const Building& b : m_sim->buildings().allBuildings())
|
||||
for (const Building& b : m_sim->getBuildings().getAllBuildings())
|
||||
{
|
||||
for (const QPoint& cell : b.bodyCells)
|
||||
{
|
||||
@@ -663,7 +663,7 @@ std::vector<BuildingId> GameWorldView::buildingsInBox(QPoint cornerA, QPoint cor
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const ConstructionSite& s : m_sim->buildings().allSites())
|
||||
for (const ConstructionSite& s : m_sim->getBuildings().getAllSites())
|
||||
{
|
||||
for (const QPoint& cell : s.bodyCells)
|
||||
{
|
||||
@@ -680,11 +680,11 @@ std::vector<BuildingId> GameWorldView::buildingsInBox(QPoint cornerA, QPoint cor
|
||||
|
||||
std::optional<QVector2D> GameWorldView::entityPosition(entt::entity entity) const
|
||||
{
|
||||
if (!m_sim->admin().isValid(entity) || !m_sim->admin().hasAll<PositionComponent>(entity))
|
||||
if (!m_sim->getAdmin().isValid(entity) || !m_sim->getAdmin().hasAll<PositionComponent>(entity))
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
return m_sim->admin().get<PositionComponent>(entity).value;
|
||||
return m_sim->getAdmin().get<PositionComponent>(entity).value;
|
||||
}
|
||||
|
||||
void GameWorldView::clearScrapSelection()
|
||||
@@ -700,7 +700,7 @@ void GameWorldView::pruneDespawnedScrap()
|
||||
if (m_selectedScrap.empty()) { return; }
|
||||
|
||||
std::vector<entt::entity> live;
|
||||
for (const ScrapInfo& info : m_sim->scraps().allScrapInfo())
|
||||
for (const ScrapInfo& info : m_sim->getScraps().getAllScrapInfo())
|
||||
{
|
||||
if (std::find(m_selectedScrap.begin(), m_selectedScrap.end(), info.entity)
|
||||
!= m_selectedScrap.end())
|
||||
@@ -747,7 +747,7 @@ void GameWorldView::placeBlueprintAtTile(QPoint center)
|
||||
int totalCost = 0;
|
||||
for (const BlueprintBuilding& bb : bp.buildings)
|
||||
{
|
||||
if (m_sim->buildings().findRotateInPlaceTarget(
|
||||
if (m_sim->getBuildings().findRotateInPlaceTarget(
|
||||
bb.type, center + bb.offset, bb.rotation).has_value())
|
||||
{
|
||||
continue;
|
||||
@@ -755,13 +755,13 @@ void GameWorldView::placeBlueprintAtTile(QPoint center)
|
||||
const BuildingDef* def = findBuildingDef(bb.type);
|
||||
if (def) { totalCost += def->cost; }
|
||||
}
|
||||
if (m_sim->buildingBlocksStock() < totalCost) { return; }
|
||||
if (m_sim->getBuildingBlocksStock() < totalCost) { return; }
|
||||
|
||||
for (const BlueprintBuilding& bb : bp.buildings)
|
||||
{
|
||||
const QPoint anchor = center + bb.offset;
|
||||
const std::optional<BuildingId> rotateTarget =
|
||||
m_sim->buildings().findRotateInPlaceTarget(bb.type, anchor, bb.rotation);
|
||||
m_sim->getBuildings().findRotateInPlaceTarget(bb.type, anchor, bb.rotation);
|
||||
if (rotateTarget.has_value())
|
||||
{
|
||||
std::shared_ptr<RotateInPlaceCommand> rotateCommand =
|
||||
@@ -832,7 +832,7 @@ void GameWorldView::placeAtTile(QPoint tile)
|
||||
}
|
||||
|
||||
const std::optional<BuildingId> rotateTarget =
|
||||
m_sim->buildings().findRotateInPlaceTarget(type, tile, m_ghostRotation);
|
||||
m_sim->getBuildings().findRotateInPlaceTarget(type, tile, m_ghostRotation);
|
||||
if (rotateTarget.has_value())
|
||||
{
|
||||
std::shared_ptr<RotateInPlaceCommand> command =
|
||||
@@ -853,7 +853,7 @@ void GameWorldView::placeAtTile(QPoint tile)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!m_sim->buildings().isTileOccupied(tile) && canAfford(type))
|
||||
if (!m_sim->getBuildings().isTileOccupied(tile) && canAfford(type))
|
||||
{
|
||||
enqueuePlaceBuilding(type, tile, m_ghostRotation);
|
||||
m_beltDragTiles.insert(tile);
|
||||
@@ -863,7 +863,7 @@ void GameWorldView::placeAtTile(QPoint tile)
|
||||
|| type == BuildingType::TunnelEntry
|
||||
|| type == BuildingType::TunnelExit)
|
||||
{
|
||||
if (!m_sim->buildings().isTileOccupied(tile) && canAfford(type))
|
||||
if (!m_sim->getBuildings().isTileOccupied(tile) && canAfford(type))
|
||||
{
|
||||
enqueuePlaceBuilding(type, tile, m_ghostRotation);
|
||||
if (type == BuildingType::TunnelEntry)
|
||||
@@ -889,7 +889,7 @@ void GameWorldView::placeAtTile(QPoint tile)
|
||||
void GameWorldView::drawPortGlyph(QPainter& painter, QPoint bodyTile,
|
||||
Rotation direction, const QColor& color)
|
||||
{
|
||||
const float px = tilePx();
|
||||
const float px = getTilePx();
|
||||
const QRectF tr = tileRect(bodyTile);
|
||||
const QPointF center(tr.x() + static_cast<qreal>(px) * 0.5,
|
||||
tr.y() + static_cast<qreal>(px) * 0.5);
|
||||
@@ -922,13 +922,13 @@ void GameWorldView::drawPortGlyph(QPainter& painter, QPoint bodyTile,
|
||||
|
||||
void GameWorldView::drawTiles(QPainter& painter)
|
||||
{
|
||||
const int leftTile = static_cast<int>(std::floor(viewLeftTiles())) - 1;
|
||||
const int rightTile = leftTile + static_cast<int>(std::ceil(viewportWidthTiles())) + 2;
|
||||
const int leftTile = static_cast<int>(std::floor(getViewLeftTiles())) - 1;
|
||||
const int rightTile = leftTile + static_cast<int>(std::ceil(getViewportWidthTiles())) + 2;
|
||||
const int bottomTile = m_config->world.heightTiles;
|
||||
|
||||
// Asteroid columns left of the buildable edge are not yet unlocked by
|
||||
// expansion; tint them so the player sees the reachable-but-locked area.
|
||||
const int buildableLeftX = -m_sim->currentAsteroidWidth_tiles();
|
||||
const int buildableLeftX = -m_sim->getCurrentAsteroidWidth_tiles();
|
||||
|
||||
painter.setPen(Qt::NoPen);
|
||||
for (int x = leftTile; x <= rightTile; ++x)
|
||||
@@ -951,7 +951,7 @@ void GameWorldView::drawTiles(QPainter& painter)
|
||||
|
||||
void GameWorldView::drawBuildings(QPainter& painter)
|
||||
{
|
||||
for (const Building& b : m_sim->buildings().allBuildings())
|
||||
for (const Building& b : m_sim->getBuildings().getAllBuildings())
|
||||
{
|
||||
const std::map<BuildingType, BuildingVisuals>::const_iterator it =
|
||||
m_visuals->buildings.find(b.type);
|
||||
@@ -966,8 +966,8 @@ void GameWorldView::drawBuildings(QPainter& painter)
|
||||
|
||||
const QPointF tl = tileToWidget(b.anchor);
|
||||
const QRectF bboxRect(tl.x(), tl.y(),
|
||||
b.footprint.width() * static_cast<qreal>(tilePx()),
|
||||
b.footprint.height() * static_cast<qreal>(tilePx()));
|
||||
b.footprint.width() * static_cast<qreal>(getTilePx()),
|
||||
b.footprint.height() * static_cast<qreal>(getTilePx()));
|
||||
|
||||
painter.setPen(QPen(bv.outline, 1));
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
@@ -988,7 +988,7 @@ void GameWorldView::drawBuildings(QPainter& painter)
|
||||
// HP bar below the HQ footprint; the HQ's HP lives on its proxy entity.
|
||||
if (b.type == BuildingType::Hq)
|
||||
{
|
||||
m_sim->admin().forEach<HqProxyComponent, FactionComponent, HealthComponent>(
|
||||
m_sim->getAdmin().forEach<HqProxyComponent, FactionComponent, HealthComponent>(
|
||||
[&](entt::entity /*e*/, const HqProxyComponent& /*hq*/,
|
||||
const FactionComponent& f, const HealthComponent& h)
|
||||
{
|
||||
@@ -1002,7 +1002,7 @@ void GameWorldView::drawBuildings(QPainter& painter)
|
||||
}
|
||||
|
||||
painter.setOpacity(0.5);
|
||||
for (const ConstructionSite& s : m_sim->buildings().allSites())
|
||||
for (const ConstructionSite& s : m_sim->getBuildings().getAllSites())
|
||||
{
|
||||
const std::map<BuildingType, BuildingVisuals>::const_iterator it =
|
||||
m_visuals->buildings.find(s.type);
|
||||
@@ -1016,8 +1016,8 @@ void GameWorldView::drawBuildings(QPainter& painter)
|
||||
|
||||
const QPointF tl = tileToWidget(s.anchor);
|
||||
const QRectF bboxRect(tl.x(), tl.y(),
|
||||
s.footprint.width() * static_cast<qreal>(tilePx()),
|
||||
s.footprint.height() * static_cast<qreal>(tilePx()));
|
||||
s.footprint.width() * static_cast<qreal>(getTilePx()),
|
||||
s.footprint.height() * static_cast<qreal>(getTilePx()));
|
||||
painter.setPen(QPen(bv.outline, 1, Qt::DashLine));
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
painter.drawRect(bboxRect);
|
||||
@@ -1030,7 +1030,7 @@ void GameWorldView::drawBuildings(QPainter& painter)
|
||||
int pct = 0;
|
||||
if (s.completesAt > 0 && durationTicks > 0)
|
||||
{
|
||||
const Tick elapsed = m_sim->currentTick()
|
||||
const Tick elapsed = m_sim->getCurrentTick()
|
||||
- (s.completesAt - durationTicks);
|
||||
pct = static_cast<int>(
|
||||
std::max(Tick(0), std::min(durationTicks, elapsed))
|
||||
@@ -1079,12 +1079,12 @@ std::optional<QRectF> GameWorldView::footprintWidgetRect(BuildingId id) const
|
||||
std::optional<QPoint> anchor;
|
||||
std::optional<QSize> footprint;
|
||||
|
||||
if (const Building* b = m_sim->buildings().findBuilding(id))
|
||||
if (const Building* b = m_sim->getBuildings().findBuilding(id))
|
||||
{
|
||||
anchor = b->anchor;
|
||||
footprint = b->footprint;
|
||||
}
|
||||
else if (const ConstructionSite* s = m_sim->buildings().findSite(id))
|
||||
else if (const ConstructionSite* s = m_sim->getBuildings().findSite(id))
|
||||
{
|
||||
anchor = s->anchor;
|
||||
footprint = s->footprint;
|
||||
@@ -1093,8 +1093,8 @@ std::optional<QRectF> GameWorldView::footprintWidgetRect(BuildingId id) const
|
||||
|
||||
const QPointF tl = tileToWidget(*anchor);
|
||||
return QRectF(tl.x(), tl.y(),
|
||||
footprint->width() * static_cast<qreal>(tilePx()),
|
||||
footprint->height() * static_cast<qreal>(tilePx()));
|
||||
footprint->width() * static_cast<qreal>(getTilePx()),
|
||||
footprint->height() * static_cast<qreal>(getTilePx()));
|
||||
}
|
||||
|
||||
void GameWorldView::drawSelectionHighlights(QPainter& painter)
|
||||
@@ -1111,11 +1111,11 @@ void GameWorldView::drawSelectionHighlights(QPainter& painter)
|
||||
}
|
||||
|
||||
// A ring around each selected scrap pile, sitting just outside the pile's
|
||||
// rendered circle (radius tilePx()*0.2, matching drawScrap) (REQ-UI-SCRAP-CLICK-SELECT).
|
||||
// rendered circle (radius getTilePx()*0.2, matching drawScrap) (REQ-UI-SCRAP-CLICK-SELECT).
|
||||
if (!m_selectedScrap.empty())
|
||||
{
|
||||
const qreal outlineRadius = static_cast<qreal>(tilePx() * 0.2f) + 3.0;
|
||||
for (const ScrapInfo& scrap : m_sim->scraps().allScrapInfo())
|
||||
const qreal outlineRadius = static_cast<qreal>(getTilePx() * 0.2f) + 3.0;
|
||||
for (const ScrapInfo& scrap : m_sim->getScraps().getAllScrapInfo())
|
||||
{
|
||||
if (std::find(m_selectedScrap.begin(), m_selectedScrap.end(), scrap.entity)
|
||||
== m_selectedScrap.end()) { continue; }
|
||||
@@ -1136,13 +1136,13 @@ void GameWorldView::drawCopyConfigFeedback(QPainter& painter)
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.setBrush(color);
|
||||
const BuildingType type = m_copiedConfig->type;
|
||||
for (const Building& b : m_sim->buildings().allBuildings())
|
||||
for (const Building& b : m_sim->getBuildings().getAllBuildings())
|
||||
{
|
||||
if (b.type != type) { continue; }
|
||||
const std::optional<QRectF> rect = footprintWidgetRect(b.id);
|
||||
if (rect.has_value()) { painter.drawRect(*rect); }
|
||||
}
|
||||
for (const ConstructionSite& s : m_sim->buildings().allSites())
|
||||
for (const ConstructionSite& s : m_sim->getBuildings().getAllSites())
|
||||
{
|
||||
if (s.type != type) { continue; }
|
||||
const std::optional<QRectF> rect = footprintWidgetRect(s.id);
|
||||
@@ -1163,7 +1163,7 @@ void GameWorldView::drawCopyConfigFeedback(QPainter& painter)
|
||||
|
||||
void GameWorldView::drawPortItems(QPainter& painter)
|
||||
{
|
||||
const float halfPx = tilePx() * 0.5f * 0.5f;
|
||||
const float halfPx = getTilePx() * 0.5f * 0.5f;
|
||||
|
||||
// Port items are drawn over the buildings (drawBuildings runs first) but clipped
|
||||
// to a thin margin at each machine's edges: the clip region is the whole view
|
||||
@@ -1174,10 +1174,10 @@ void GameWorldView::drawPortItems(QPainter& painter)
|
||||
// (REQ-MAT-DIRECT-COUPLE). Transport tiles are not machines and never occlude, so
|
||||
// items on belts stay fully visible.
|
||||
constexpr double kPortMarginTiles = 0.2;
|
||||
const double margin = kPortMarginTiles * static_cast<double>(tilePx());
|
||||
const double margin = kPortMarginTiles * static_cast<double>(getTilePx());
|
||||
|
||||
QRegion clip(rect());
|
||||
for (const Building& b : m_sim->buildings().allBuildings())
|
||||
for (const Building& b : m_sim->getBuildings().getAllBuildings())
|
||||
{
|
||||
if (b.type == BuildingType::Belt || b.type == BuildingType::Splitter
|
||||
|| b.type == BuildingType::TunnelEntry || b.type == BuildingType::TunnelExit)
|
||||
@@ -1218,17 +1218,17 @@ void GameWorldView::drawPortItems(QPainter& painter)
|
||||
|
||||
painter.save();
|
||||
painter.setClipRegion(clip);
|
||||
m_sim->buildings().forEachEmergingItem(drawItem);
|
||||
m_sim->buildings().forEachIncomingItem(drawItem);
|
||||
m_sim->getBuildings().forEachEmergingItem(drawItem);
|
||||
m_sim->getBuildings().forEachIncomingItem(drawItem);
|
||||
painter.restore();
|
||||
}
|
||||
|
||||
void GameWorldView::drawBeltItems(QPainter& painter)
|
||||
{
|
||||
const float halfPx = tilePx() * 0.5f * 0.5f;
|
||||
const QRect vr = viewportRect();
|
||||
const float halfPx = getTilePx() * 0.5f * 0.5f;
|
||||
const QRect vr = getViewportRect();
|
||||
|
||||
m_sim->belts().forEachVisualItem(vr, [&](const VisualItem& vi)
|
||||
m_sim->getBelts().forEachVisualItem(vr, [&](const VisualItem& vi)
|
||||
{
|
||||
const std::map<std::string, ItemVisuals>::const_iterator it =
|
||||
m_visuals->items.find(vi.type.id);
|
||||
@@ -1248,8 +1248,8 @@ void GameWorldView::drawBeltItems(QPainter& painter)
|
||||
|
||||
void GameWorldView::drawScrap(QPainter& painter)
|
||||
{
|
||||
const float r = tilePx() * 0.2f;
|
||||
for (const ScrapInfo& scrap : m_sim->scraps().allScrapInfo())
|
||||
const float r = getTilePx() * 0.2f;
|
||||
for (const ScrapInfo& scrap : m_sim->getScraps().getAllScrapInfo())
|
||||
{
|
||||
const QPointF center = worldToWidget(scrap.position);
|
||||
painter.setBrush(QColor(128, 110, 90));
|
||||
@@ -1261,7 +1261,7 @@ void GameWorldView::drawScrap(QPainter& painter)
|
||||
|
||||
void GameWorldView::drawStations(QPainter& painter)
|
||||
{
|
||||
m_sim->admin().forEach<StationBodyComponent, FactionComponent, HealthComponent>(
|
||||
m_sim->getAdmin().forEach<StationBodyComponent, FactionComponent, HealthComponent>(
|
||||
[&](entt::entity e, const StationBodyComponent& sb, const FactionComponent& f,
|
||||
const HealthComponent& h)
|
||||
{
|
||||
@@ -1281,8 +1281,8 @@ void GameWorldView::drawStations(QPainter& painter)
|
||||
|
||||
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()));
|
||||
sb.footprint.width() * static_cast<qreal>(getTilePx()),
|
||||
sb.footprint.height() * static_cast<qreal>(getTilePx()));
|
||||
|
||||
painter.setPen(QPen(bv.outline, 1));
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
@@ -1306,7 +1306,7 @@ void GameWorldView::drawStations(QPainter& painter)
|
||||
|
||||
void GameWorldView::drawShips(QPainter& painter)
|
||||
{
|
||||
m_sim->admin().forEach<ShipIdentityComponent, PositionComponent, FacingComponent,
|
||||
m_sim->getAdmin().forEach<ShipIdentityComponent, PositionComponent, FacingComponent,
|
||||
FactionComponent, HealthComponent>(
|
||||
[&](entt::entity e, const ShipIdentityComponent& si,
|
||||
const PositionComponent& pos, const FacingComponent& facing,
|
||||
@@ -1320,8 +1320,8 @@ void GameWorldView::drawShips(QPainter& painter)
|
||||
const QVector2D dir(std::cos(facing.radians), std::sin(facing.radians));
|
||||
const QVector2D perp(-dir.y(), dir.x());
|
||||
|
||||
const float fwd = tilePx() * 0.45f;
|
||||
const float side = tilePx() * 0.25f;
|
||||
const float fwd = getTilePx() * 0.45f;
|
||||
const float side = getTilePx() * 0.25f;
|
||||
|
||||
QPolygonF tri;
|
||||
tri << QPointF(center.x() + static_cast<qreal>(dir.x() * fwd),
|
||||
@@ -1356,7 +1356,7 @@ void GameWorldView::drawShips(QPainter& painter)
|
||||
void GameWorldView::drawHpBar(QPainter& painter, qreal left, qreal top, qreal width,
|
||||
float fraction, bool isEnemy)
|
||||
{
|
||||
const qreal barH = static_cast<qreal>(tilePx()) * 0.12;
|
||||
const qreal barH = static_cast<qreal>(getTilePx()) * 0.12;
|
||||
const float clamped = std::max(0.0f, fraction);
|
||||
painter.fillRect(QRectF(left, top, width, barH), QColor(60, 60, 60));
|
||||
painter.fillRect(QRectF(left, top, width * static_cast<qreal>(clamped), barH),
|
||||
@@ -1366,7 +1366,7 @@ void GameWorldView::drawHpBar(QPainter& painter, qreal left, qreal top, qreal wi
|
||||
void GameWorldView::drawDebugSensorRanges(QPainter& painter)
|
||||
{
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
m_sim->admin().forEach<ShipIdentityComponent, PositionComponent, FacingComponent,
|
||||
m_sim->getAdmin().forEach<ShipIdentityComponent, PositionComponent, FacingComponent,
|
||||
FactionComponent, SensorRangeComponent>(
|
||||
[&](entt::entity /*e*/, const ShipIdentityComponent& si,
|
||||
const PositionComponent& pos, const FacingComponent& /*facing*/,
|
||||
@@ -1378,7 +1378,7 @@ void GameWorldView::drawDebugSensorRanges(QPainter& painter)
|
||||
|
||||
const QPointF center = worldToWidget(pos.value);
|
||||
const qreal radiusPx = static_cast<qreal>(sensor.value_tiles)
|
||||
* static_cast<qreal>(tilePx());
|
||||
* static_cast<qreal>(getTilePx());
|
||||
QColor circleColor = it->second.outline;
|
||||
circleColor.setAlpha(77);
|
||||
painter.setPen(QPen(circleColor, 1));
|
||||
@@ -1404,7 +1404,7 @@ void GameWorldView::drawDebugTargetLines(QPainter& painter)
|
||||
painter.drawLine(worldToWidget(from), worldToWidget(to));
|
||||
};
|
||||
|
||||
m_sim->admin().forEach<ShipIdentityComponent, PositionComponent, AttackBehavior>(
|
||||
m_sim->getAdmin().forEach<ShipIdentityComponent, PositionComponent, AttackBehavior>(
|
||||
[&](entt::entity /*e*/, const ShipIdentityComponent& si,
|
||||
const PositionComponent& pos, const AttackBehavior& attack)
|
||||
{
|
||||
@@ -1417,7 +1417,7 @@ void GameWorldView::drawDebugTargetLines(QPainter& painter)
|
||||
drawTargetLine(si.schematicId, pos.value, *targetPos);
|
||||
});
|
||||
|
||||
m_sim->admin().forEach<ShipIdentityComponent, PositionComponent, RepairBehavior>(
|
||||
m_sim->getAdmin().forEach<ShipIdentityComponent, PositionComponent, RepairBehavior>(
|
||||
[&](entt::entity /*e*/, const ShipIdentityComponent& si,
|
||||
const PositionComponent& pos, const RepairBehavior& repair)
|
||||
{
|
||||
@@ -1430,7 +1430,7 @@ void GameWorldView::drawDebugTargetLines(QPainter& painter)
|
||||
drawTargetLine(si.schematicId, pos.value, *targetPos);
|
||||
});
|
||||
|
||||
m_sim->admin().forEach<ShipIdentityComponent, PositionComponent, SalvageScrapBehavior>(
|
||||
m_sim->getAdmin().forEach<ShipIdentityComponent, PositionComponent, SalvageScrapBehavior>(
|
||||
[&](entt::entity /*e*/, const ShipIdentityComponent& si,
|
||||
const PositionComponent& pos, const SalvageScrapBehavior& salvage)
|
||||
{
|
||||
@@ -1446,15 +1446,15 @@ void GameWorldView::drawDebugOverlay(QPainter& painter)
|
||||
|
||||
const QStringList lines = {
|
||||
tr("Accumulated Threat Level: %1")
|
||||
.arg(m_sim->threatLevel(), 0, 'f', 1),
|
||||
.arg(m_sim->getThreatLevel(), 0, 'f', 1),
|
||||
tr("Time until Wave: %1s")
|
||||
.arg(ticksToSeconds(m_sim->normalGapRemainingTicks()), 0, 'f', 1),
|
||||
.arg(ticksToSeconds(m_sim->getNormalGapRemainingTicks()), 0, 'f', 1),
|
||||
tr("Threat Accumulation Rate: %1 threat/s")
|
||||
.arg(m_sim->threatAccumulationRate(), 0, 'f', 1),
|
||||
.arg(m_sim->getThreatAccumulationRate(), 0, 'f', 1),
|
||||
tr("Max Factory Production: %1 threat/s")
|
||||
.arg(m_sim->maxFactoryProductionThreatRate(), 0, 'f', 1),
|
||||
.arg(m_sim->getMaxFactoryProductionThreatRate(), 0, 'f', 1),
|
||||
tr("Current Factory Production: %1 threat/s")
|
||||
.arg(m_sim->currentFactoryProductionThreatRate(), 0, 'f', 1),
|
||||
.arg(m_sim->getCurrentFactoryProductionThreatRate(), 0, 'f', 1),
|
||||
};
|
||||
|
||||
QFont font = painter.font();
|
||||
@@ -1582,12 +1582,12 @@ void GameWorldView::drawOverlays(QPainter& painter)
|
||||
{
|
||||
for (BuildingId id : buildingsInBox(m_boxStartTile, m_boxCurrentTile))
|
||||
{
|
||||
const Building* b = m_sim->buildings().findBuilding(id);
|
||||
const Building* b = m_sim->getBuildings().findBuilding(id);
|
||||
if (b && b->type == BuildingType::Hq) { continue; }
|
||||
const std::vector<QPoint>* cells = nullptr;
|
||||
const ConstructionSite* s = nullptr;
|
||||
if (b) { cells = &b->bodyCells; }
|
||||
else if ((s = m_sim->buildings().findSite(id))) { cells = &s->bodyCells; }
|
||||
else if ((s = m_sim->getBuildings().findSite(id))) { cells = &s->bodyCells; }
|
||||
if (cells)
|
||||
{
|
||||
for (const QPoint& cell : *cells)
|
||||
@@ -1599,7 +1599,7 @@ void GameWorldView::drawOverlays(QPainter& painter)
|
||||
}
|
||||
else if (m_demolishMode && m_demolishHoverBuildingId != kInvalidBuildingId)
|
||||
{
|
||||
const Building* b = m_sim->buildings().findBuilding(m_demolishHoverBuildingId);
|
||||
const Building* b = m_sim->getBuildings().findBuilding(m_demolishHoverBuildingId);
|
||||
if (b)
|
||||
{
|
||||
for (const QPoint& cell : b->bodyCells)
|
||||
@@ -1663,8 +1663,8 @@ void GameWorldView::drawBuildingGhost(QPainter& painter, BuildingType type,
|
||||
|
||||
const QPointF tl = tileToWidget(anchorTile + minCell);
|
||||
const QRectF bboxRect(tl.x(), tl.y(),
|
||||
(maxCell.x() - minCell.x() + 1) * static_cast<qreal>(tilePx()),
|
||||
(maxCell.y() - minCell.y() + 1) * static_cast<qreal>(tilePx()));
|
||||
(maxCell.x() - minCell.x() + 1) * static_cast<qreal>(getTilePx()),
|
||||
(maxCell.y() - minCell.y() + 1) * static_cast<qreal>(getTilePx()));
|
||||
|
||||
painter.setPen(QPen(lineColor, 1));
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
@@ -1932,7 +1932,7 @@ void GameWorldView::mousePressEvent(QMouseEvent* event)
|
||||
}
|
||||
|
||||
const QVector2D worldPos = widgetToWorld(event->pos());
|
||||
const entt::entity hitEntity = entityAtWorldPos(m_sim->admin(), worldPos);
|
||||
const entt::entity hitEntity = entityAtWorldPos(m_sim->getAdmin(), worldPos);
|
||||
|
||||
if (hitEntity != entt::null)
|
||||
{
|
||||
@@ -1983,7 +1983,7 @@ void GameWorldView::mousePressEvent(QMouseEvent* event)
|
||||
std::make_shared<SelectionChangedEvent>(m_selectedBuildingIds));
|
||||
}
|
||||
else if (const entt::entity scrapHit =
|
||||
scrapAtWorldPos(m_sim->admin(), worldPos); scrapHit != entt::null)
|
||||
scrapAtWorldPos(m_sim->getAdmin(), worldPos); scrapHit != entt::null)
|
||||
{
|
||||
// Scrap forms its own selection category; picking it clears any
|
||||
// building selection (REQ-UI-SCRAP-CLICK-SELECT, REQ-UI-SCRAP-MULTI-SELECT).
|
||||
@@ -2081,7 +2081,7 @@ void GameWorldView::mouseReleaseEvent(QMouseEvent* event)
|
||||
// (REQ-BLD-DEMOLISH, REQ-BLD-DEMOLISH-BOX).
|
||||
for (BuildingId id : boxIds)
|
||||
{
|
||||
const Building* b = m_sim->buildings().findBuilding(id);
|
||||
const Building* b = m_sim->getBuildings().findBuilding(id);
|
||||
if (b && b->type == BuildingType::Hq) { continue; }
|
||||
std::shared_ptr<DemolishCommand> command =
|
||||
std::make_shared<DemolishCommand>();
|
||||
@@ -2123,7 +2123,7 @@ void GameWorldView::mouseReleaseEvent(QMouseEvent* event)
|
||||
// No buildings in the box: a scrap-only box selects the scrap it covers
|
||||
// (REQ-UI-SCRAP-MULTI-SELECT).
|
||||
const std::vector<entt::entity> boxScrap =
|
||||
scrapInBox(m_sim->admin(), m_boxStartTile, m_boxCurrentTile);
|
||||
scrapInBox(m_sim->getAdmin(), m_boxStartTile, m_boxCurrentTile);
|
||||
if (!boxScrap.empty())
|
||||
{
|
||||
if (!m_selectedBuildingIds.empty())
|
||||
@@ -2260,7 +2260,7 @@ void GameWorldView::pasteConfigTo(BuildingId id)
|
||||
{
|
||||
// Operational splitters are configured by tile; sites by BuildingId
|
||||
// (mirrors SelectedBuildingPanel::onSplitterFilterChanged).
|
||||
if (const Building* building = m_sim->buildings().findBuilding(id))
|
||||
if (const Building* building = m_sim->getBuildings().findBuilding(id))
|
||||
{
|
||||
std::shared_ptr<SetSplitterFiltersCommand> command =
|
||||
std::make_shared<SetSplitterFiltersCommand>();
|
||||
@@ -2338,7 +2338,7 @@ void GameWorldView::exitBuilderMode()
|
||||
std::make_shared<BuilderModeExitedEvent>());
|
||||
}
|
||||
|
||||
double GameWorldView::gameSpeed() const
|
||||
double GameWorldView::getGameSpeed() const
|
||||
{
|
||||
return m_gameSpeedMultiplier;
|
||||
}
|
||||
@@ -2402,17 +2402,17 @@ void GameWorldView::handleEvent(std::shared_ptr<const BeamFiredEvent> event)
|
||||
{
|
||||
// Endpoint offset is a fraction of the target's visual size (REQ-SHP-FIRING-BEAM):
|
||||
// half a ship's rendered radius, half a station's shorter footprint side, or
|
||||
// half a scrap pile's rendered radius (scrap is drawn at tilePx()*0.2).
|
||||
// half a scrap pile's rendered radius (scrap is drawn at getTilePx()*0.2).
|
||||
float maxRadius = 0.125f;
|
||||
if (m_sim->admin().isValid(event->target)
|
||||
&& m_sim->admin().hasAll<StationBodyComponent>(event->target))
|
||||
if (m_sim->getAdmin().isValid(event->target)
|
||||
&& m_sim->getAdmin().hasAll<StationBodyComponent>(event->target))
|
||||
{
|
||||
const StationBodyComponent& sb = m_sim->admin().get<StationBodyComponent>(event->target);
|
||||
const StationBodyComponent& sb = m_sim->getAdmin().get<StationBodyComponent>(event->target);
|
||||
const int shorter = std::min(sb.footprint.width(), sb.footprint.height());
|
||||
maxRadius = shorter / 2.0f;
|
||||
}
|
||||
else if (m_sim->admin().isValid(event->target)
|
||||
&& m_sim->admin().hasAll<ScrapDataComponent>(event->target))
|
||||
else if (m_sim->getAdmin().isValid(event->target)
|
||||
&& m_sim->getAdmin().hasAll<ScrapDataComponent>(event->target))
|
||||
{
|
||||
maxRadius = 0.1f;
|
||||
}
|
||||
@@ -2488,5 +2488,5 @@ bool GameWorldView::canAfford(BuildingType type) const
|
||||
{
|
||||
const BuildingDef* def = findBuildingDef(type);
|
||||
if (!def) { return false; }
|
||||
return m_sim->buildingBlocksStock() >= def->cost;
|
||||
return m_sim->getBuildingBlocksStock() >= def->cost;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user