change repair_tool application and add beams for salvager and repair_tool
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "SensorRangeComponent.h"
|
||||
#include "ShipIdentityComponent.h"
|
||||
#include "StationBodyComponent.h"
|
||||
#include "ScrapDataComponent.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -111,11 +112,11 @@ void ArenaView::onFrame()
|
||||
|
||||
// Emit fire events via EventManager
|
||||
{
|
||||
const std::vector<WeaponFiredEvent> fires = m_sim->drainWeaponFiredEvents();
|
||||
for (const WeaponFiredEvent& fe : fires)
|
||||
const std::vector<BeamFiredEvent> fires = m_sim->drainBeamFiredEvents();
|
||||
for (const BeamFiredEvent& fe : fires)
|
||||
{
|
||||
EventManager::getInstance()->sendEventImmediately(
|
||||
std::make_shared<WeaponFiredEvent>(fe));
|
||||
std::make_shared<BeamFiredEvent>(fe));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +141,7 @@ void ArenaView::onFrame()
|
||||
update();
|
||||
}
|
||||
|
||||
void ArenaView::handleEvent(std::shared_ptr<const WeaponFiredEvent> event)
|
||||
void ArenaView::handleEvent(std::shared_ptr<const BeamFiredEvent> event)
|
||||
{
|
||||
float maxRadius = 0.125f;
|
||||
if (m_sim->admin().isValid(event->target)
|
||||
@@ -151,6 +152,11 @@ void ArenaView::handleEvent(std::shared_ptr<const WeaponFiredEvent> event)
|
||||
sb.footprint.height());
|
||||
maxRadius = shorter / 2.0f;
|
||||
}
|
||||
else if (m_sim->admin().isValid(event->target)
|
||||
&& m_sim->admin().hasAll<ScrapDataComponent>(event->target))
|
||||
{
|
||||
maxRadius = 0.1f;
|
||||
}
|
||||
|
||||
std::uniform_real_distribution<float> angleDist(0.0f, 6.28318530f);
|
||||
std::uniform_real_distribution<float> radiusDist(0.0f, maxRadius);
|
||||
@@ -526,12 +532,20 @@ void ArenaView::drawDebugTargetLines(QPainter& painter)
|
||||
|
||||
void ArenaView::drawBeams(QPainter& painter)
|
||||
{
|
||||
painter.setPen(QPen(m_visuals->beams.color, m_visuals->beams.widthPx));
|
||||
for (const ActiveBeam& beam : m_activeBeams)
|
||||
{
|
||||
const std::optional<QVector2D> shooterPos = entityPosition(beam.event.shooter);
|
||||
const std::optional<QVector2D> targetPos = entityPosition(beam.event.target);
|
||||
if (!shooterPos.has_value() || !targetPos.has_value()) { continue; }
|
||||
|
||||
QColor color = m_visuals->beams.weaponColor;
|
||||
switch (beam.event.kind)
|
||||
{
|
||||
case BeamKind::Weapon: color = m_visuals->beams.weaponColor; break;
|
||||
case BeamKind::Repair: color = m_visuals->beams.repairColor; break;
|
||||
case BeamKind::Salvage: color = m_visuals->beams.salvageColor; break;
|
||||
}
|
||||
painter.setPen(QPen(color, m_visuals->beams.widthPx));
|
||||
painter.drawLine(worldToWidget(*shooterPos),
|
||||
worldToWidget(*targetPos + beam.targetOffset));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user