draw debug lines to target
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include "AttackBehavior.h"
|
||||||
#include "BeltSystem.h"
|
#include "BeltSystem.h"
|
||||||
#include "Building.h"
|
#include "Building.h"
|
||||||
#include "BuildingSystem.h"
|
#include "BuildingSystem.h"
|
||||||
@@ -248,6 +249,7 @@ void GameWorldView::paintGL()
|
|||||||
if (m_debugDraw)
|
if (m_debugDraw)
|
||||||
{
|
{
|
||||||
drawDebugSensorRanges(painter);
|
drawDebugSensorRanges(painter);
|
||||||
|
drawDebugTargetLines(painter);
|
||||||
drawDebugOverlay(painter);
|
drawDebugOverlay(painter);
|
||||||
}
|
}
|
||||||
drawShips(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)
|
void GameWorldView::drawDebugOverlay(QPainter& painter)
|
||||||
{
|
{
|
||||||
painter.resetTransform();
|
painter.resetTransform();
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ private:
|
|||||||
void drawScrap(QPainter& painter);
|
void drawScrap(QPainter& painter);
|
||||||
void drawShips(QPainter& painter);
|
void drawShips(QPainter& painter);
|
||||||
void drawDebugSensorRanges(QPainter& painter);
|
void drawDebugSensorRanges(QPainter& painter);
|
||||||
|
void drawDebugTargetLines(QPainter& painter);
|
||||||
void drawDebugOverlay(QPainter& painter);
|
void drawDebugOverlay(QPainter& painter);
|
||||||
void drawBeams(QPainter& painter);
|
void drawBeams(QPainter& painter);
|
||||||
void drawOverlays(QPainter& painter);
|
void drawOverlays(QPainter& painter);
|
||||||
|
|||||||
Reference in New Issue
Block a user