define ship roles via added modules and allow multiple weapons

This commit is contained in:
2026-06-01 22:57:53 +02:00
parent f363f7a67c
commit 9d0a60a93b
31 changed files with 873 additions and 407 deletions

View File

@@ -14,23 +14,12 @@
#include "FactionComponent.h"
#include "HealthComponent.h"
#include "PositionComponent.h"
#include "RepairToolComponent.h"
#include "SalvageCargoComponent.h"
#include "ScrapSystem.h"
#include "ShipIdentityComponent.h"
#include "StationBodyComponent.h"
namespace
{
ShipRole shipRoleFromComponents(bool isEnemy, bool hasCargo, bool hasRepairTool)
{
if (isEnemy) { return ShipRole::Enemy; }
if (hasCargo) { return ShipRole::Salvage; }
if (hasRepairTool) { return ShipRole::Repair; }
return ShipRole::PlayerCombat;
}
} // namespace
@@ -322,15 +311,12 @@ void ArenaView::drawShips(QPainter& painter)
{
m_sim->admin().forEach<ShipIdentityComponent, PositionComponent, FacingComponent,
FactionComponent>(
[&](entt::entity e, const ShipIdentityComponent& /*si*/,
[&](entt::entity /*e*/, const ShipIdentityComponent& si,
const PositionComponent& pos, const FacingComponent& facing,
const FactionComponent& fac)
const FactionComponent& /*fac*/)
{
const bool hasCargo = m_sim->admin().hasAll<SalvageCargoComponent>(e);
const bool hasRepair = m_sim->admin().hasAll<RepairToolComponent>(e);
const ShipRole role = shipRoleFromComponents(fac.isEnemy, hasCargo, hasRepair);
const std::map<ShipRole, ShipVisuals>::const_iterator it =
m_visuals->ships.find(role);
const std::map<std::string, ShipVisuals>::const_iterator it =
m_visuals->ships.find(si.schematicId);
if (it == m_visuals->ships.end()) { return; }
const QPointF center = worldToWidget(pos.value);