Ships/Modules/RecipesConfig now carry lookup helpers mirroring BuildingsConfig::findBuildingDef. The hand-rolled linear scans in BuildingSystem, ShipSystem, ShipStatsCalculator, ThreatCostCalculator, ShipLayoutDialog, SelectedBuildingPanel and SchematicChoiceDialog now call them instead. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GH8ZMRY3vhxxXcaUxBqxkk
67 lines
1.6 KiB
C++
67 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "RecipesConfig.h" // for RecipeIngredient
|
|
#include "ShipLayout.h" // for PlacedModule
|
|
|
|
// Build materials and base production time (REQ-BLD-SHIPYARD, REQ-DEF-SCHEMATIC-DROP).
|
|
struct ShipSchematic
|
|
{
|
|
std::vector<RecipeIngredient> materials;
|
|
double productionTimeSeconds;
|
|
};
|
|
|
|
struct ShipHealth
|
|
{
|
|
float hp; // REQ-SHP-STATS
|
|
};
|
|
|
|
struct ShipMovement
|
|
{
|
|
float speed_mps; // max linear speed cap, m/s (REQ-SHP-STATS, REQ-SHP-MOVEMENT)
|
|
float mainAcceleration_mpss; // forward acceleration, m/s²
|
|
float maneuveringAcceleration_mpss;// omnidirectional acceleration, m/s²
|
|
float angularAcceleration_radpss; // angular acceleration, rad/s²
|
|
float maxRotationSpeed_radps; // angular velocity cap, rad/s
|
|
};
|
|
|
|
struct ShipSensor
|
|
{
|
|
float sensorRange_m; // REQ-SHP-SENSOR, REQ-SHP-STATS
|
|
};
|
|
|
|
struct ShipDef
|
|
{
|
|
std::string id;
|
|
std::vector<std::string> layout;
|
|
|
|
ShipSchematic schematic;
|
|
ShipHealth health;
|
|
ShipMovement movement;
|
|
ShipSensor sensor;
|
|
|
|
// Module layout used for enemy wave ships (REQ-WAV-DEFAULT-MODULES).
|
|
std::vector<PlacedModule> defaultModules;
|
|
};
|
|
|
|
struct ShipsConfig
|
|
{
|
|
std::vector<ShipDef> ships;
|
|
|
|
// Returns the definition for the given ship schematic id, or nullptr if the
|
|
// id has no entry in ships.toml.
|
|
const ShipDef* findShipDef(const std::string& id) const
|
|
{
|
|
for (const ShipDef& def : ships)
|
|
{
|
|
if (def.id == id)
|
|
{
|
|
return &def;
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
};
|