draw debug lines to target

This commit is contained in:
2026-06-16 21:25:59 +02:00
parent ac97652c60
commit bd2391876c
2 changed files with 26 additions and 0 deletions

View File

@@ -18,6 +18,7 @@
#include <QStringList>
#include <QTimer>
#include "AttackBehavior.h"
#include "BeltSystem.h"
#include "Building.h"
#include "BuildingSystem.h"
@@ -248,6 +249,7 @@ void GameWorldView::paintGL()
if (m_debugDraw)
{
drawDebugSensorRanges(painter);
drawDebugTargetLines(painter);
drawDebugOverlay(painter);
}
drawShips(painter);
@@ -921,6 +923,29 @@ void GameWorldView::drawDebugSensorRanges(QPainter& painter)
});
}
void GameWorldView::drawDebugTargetLines(QPainter& painter)
{
m_sim->admin().forEach<ShipIdentityComponent, PositionComponent, AttackBehavior>(
[&](entt::entity /*e*/, const ShipIdentityComponent& si,
const PositionComponent& pos, const AttackBehavior& attack)
{
if (!attack.currentTarget.has_value()) { return; }
const std::optional<QVector2D> targetPos =
entityPosition(*attack.currentTarget);
if (!targetPos.has_value()) { return; }
const std::map<std::string, ShipVisuals>::const_iterator it =
m_visuals->ships.find(si.schematicId);
if (it == m_visuals->ships.end()) { return; }
QColor lineColor = it->second.fill;
lineColor.setAlpha(128);
painter.setPen(QPen(lineColor, 1));
painter.drawLine(worldToWidget(pos.value), worldToWidget(*targetPos));
});
}
void GameWorldView::drawDebugOverlay(QPainter& painter)
{
painter.resetTransform();

View File

@@ -99,6 +99,7 @@ private:
void drawScrap(QPainter& painter);
void drawShips(QPainter& painter);
void drawDebugSensorRanges(QPainter& painter);
void drawDebugTargetLines(QPainter& painter);
void drawDebugOverlay(QPainter& painter);
void drawBeams(QPainter& painter);
void drawOverlays(QPainter& painter);