derive threat cost dynamically

This commit is contained in:
2026-06-13 21:50:00 +02:00
parent 3716c2b734
commit 10c5ad678f
28 changed files with 498 additions and 79 deletions

View File

@@ -23,6 +23,7 @@
#include "ShipIdentityComponent.h"
#include "ShipStatsCalculator.h"
#include "ShipStatsPanel.h"
#include "ThreatCostCalculator.h"
#include "StationBodyComponent.h"
#include "TickAdvancedEvent.h"
#include "Building.h"
@@ -784,6 +785,19 @@ void SelectedBuildingPanel::buildEntityShip(entt::entity entity)
const ShipStats stats = buildShipStatsFromEntity(admin, entity);
m_entityStatsPanel->refreshFromLive(stats, health.hp);
m_entityStatsPanel->setDebugDrawEnabled(m_debugDraw);
for (const ShipDef& def : m_config->ships.ships)
{
if (def.id == identity.schematicId)
{
double threat = calculateShipThreatCost(
m_config->threatCosts, *m_config, def.id, def.defaultModules);
m_entityStatsPanel->setThreatCost(threat);
break;
}
}
m_entityStatsPanel->show();
m_stationStatsLabel->hide();
@@ -869,3 +883,9 @@ void SelectedBuildingPanel::handleEvent(std::shared_ptr<const SelectionChangedEv
{
onSelectionChanged(event->ids);
}
void SelectedBuildingPanel::handleEvent(std::shared_ptr<const DebugDrawToggledEvent> event)
{
m_debugDraw = event->active;
m_entityStatsPanel->setDebugDrawEnabled(event->active);
}