Remove schematic upgrades and module and ship levels
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
|
||||
struct ShipIdentityComponent
|
||||
{
|
||||
int level;
|
||||
std::string schematicId;
|
||||
// Scrap dropped on destruction, derived from the ship's as-built threat cost
|
||||
// at spawn time (REQ-RES-SCRAP-DROP).
|
||||
|
||||
@@ -65,43 +65,31 @@ const ModuleDef* ShipSystem::findModuleDef(const std::string& id) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
entt::entity ShipSystem::spawn(const std::string& schematicId, int level,
|
||||
entt::entity ShipSystem::spawn(const std::string& schematicId,
|
||||
QVector2D position, bool isEnemy,
|
||||
const std::optional<ShipLayoutConfig>& layout,
|
||||
const std::map<std::string, int>& moduleLevelOverrides)
|
||||
const std::optional<ShipLayoutConfig>& layout)
|
||||
{
|
||||
const ShipDef* def = findShipDef(schematicId);
|
||||
assert(def != nullptr);
|
||||
|
||||
const double x = static_cast<double>(level);
|
||||
const float tickRate = static_cast<float>(kTickRateHz);
|
||||
const float tileSize = static_cast<float>(m_config.world.tileSize_m);
|
||||
|
||||
float hp = static_cast<float>(def->health.hpFormula.evaluate(x));
|
||||
float hp = def->health.hp;
|
||||
float maxHp = hp;
|
||||
float maxSpeed_tpt = static_cast<float>(def->movement.speedFormula.evaluate(x))
|
||||
/ tileSize / tickRate;
|
||||
float mainAcceleration_tptt = static_cast<float>(
|
||||
def->movement.mainAccelerationFormula.evaluate(x))
|
||||
/ tileSize / tickRate;
|
||||
float maneuveringAcceleration_tptt = static_cast<float>(
|
||||
def->movement.maneuveringAccelerationFormula.evaluate(x))
|
||||
float maxSpeed_tpt = def->movement.speed_mps / tileSize / tickRate;
|
||||
float mainAcceleration_tptt = def->movement.mainAcceleration_mpss / tileSize / tickRate;
|
||||
float maneuveringAcceleration_tptt = def->movement.maneuveringAcceleration_mpss
|
||||
/ tileSize / tickRate;
|
||||
float maxAngularAcceleration_rptt = static_cast<float>(
|
||||
def->movement.angularAccelerationFormula.evaluate(x))
|
||||
/ tickRate;
|
||||
float maxRotationSpeed_rpt = static_cast<float>(
|
||||
def->movement.maxRotationSpeedFormula.evaluate(x))
|
||||
/ tickRate;
|
||||
float sensorRange_tiles = static_cast<float>(
|
||||
def->sensor.sensorRangeFormula.evaluate(x))
|
||||
/ tileSize;
|
||||
float maxAngularAcceleration_rptt = def->movement.angularAcceleration_radpss / tickRate;
|
||||
float maxRotationSpeed_rpt = def->movement.maxRotationSpeed_radps / tickRate;
|
||||
float sensorRange_tiles = def->sensor.sensorRange_m / tileSize;
|
||||
|
||||
entt::entity entity = m_admin.spawnShip(
|
||||
position, hp, maxHp,
|
||||
maxSpeed_tpt, mainAcceleration_tptt, maneuveringAcceleration_tptt,
|
||||
maxAngularAcceleration_rptt, maxRotationSpeed_rpt, sensorRange_tiles,
|
||||
level, schematicId, isEnemy);
|
||||
schematicId, isEnemy);
|
||||
|
||||
// Determine module list: configured layout takes precedence over default.
|
||||
const std::vector<PlacedModule>& modules =
|
||||
@@ -131,19 +119,12 @@ entt::entity ShipSystem::spawn(const std::string& schematicId, int level,
|
||||
const ModuleDef* modDef = findModuleDef(pm.moduleId);
|
||||
if (!modDef) { throw std::runtime_error("unknown module id '" + pm.moduleId + "'"); }
|
||||
|
||||
const auto overIt = moduleLevelOverrides.find(pm.moduleId);
|
||||
const double mx = static_cast<double>(
|
||||
overIt != moduleLevelOverrides.end() ? overIt->second : modDef->playerProductionLevel);
|
||||
|
||||
if (modDef->weaponCapability)
|
||||
{
|
||||
WeaponComponent w;
|
||||
w.damage = static_cast<float>(
|
||||
modDef->weaponCapability->damageFormula.evaluate(mx));
|
||||
w.range_tiles = static_cast<float>(
|
||||
modDef->weaponCapability->attackRangeFormula.evaluate(mx)) / tileSize;
|
||||
w.fireRateHz = static_cast<float>(
|
||||
modDef->weaponCapability->attackRateFormula.evaluate(mx));
|
||||
w.damage = modDef->weaponCapability->damage;
|
||||
w.range_tiles = modDef->weaponCapability->attackRange_m / tileSize;
|
||||
w.fireRateHz = modDef->weaponCapability->attackRate_hz;
|
||||
w.cooldownTicks = 0.0f;
|
||||
w.currentTarget = std::nullopt;
|
||||
|
||||
@@ -155,12 +136,11 @@ entt::entity ShipSystem::spawn(const std::string& schematicId, int level,
|
||||
|
||||
if (modDef->salvageCapability)
|
||||
{
|
||||
cargoCapacityBase += modDef->salvageCapability->cargoCapacityFormula.evaluate(mx);
|
||||
cargoCapacityBase += modDef->salvageCapability->cargoCapacity;
|
||||
|
||||
SalvagerComponent salvager;
|
||||
salvager.collectionRange_tiles = static_cast<float>(
|
||||
modDef->salvageCapability->collectionRangeFormula.evaluate(mx)) / tileSize;
|
||||
const double rate = modDef->salvageCapability->collectionRateFormula.evaluate(mx);
|
||||
salvager.collectionRange_tiles = modDef->salvageCapability->collectionRange_m / tileSize;
|
||||
const double rate = modDef->salvageCapability->collectionRate_hz;
|
||||
salvager.collectionIntervalTicks = (rate > 0.0)
|
||||
? static_cast<int>(kTickRateHz / rate + 0.5)
|
||||
: 0;
|
||||
@@ -175,16 +155,13 @@ entt::entity ShipSystem::spawn(const std::string& schematicId, int level,
|
||||
if (modDef->repairCapability)
|
||||
{
|
||||
RepairToolComponent rt;
|
||||
const double repairRateHz =
|
||||
modDef->repairCapability->repairRateFormula.evaluate(mx);
|
||||
const double repairRateHz = modDef->repairCapability->repairRate_hz;
|
||||
rt.repairIntervalTicks = (repairRateHz > 0.0)
|
||||
? static_cast<int>(kTickRateHz / repairRateHz + 0.5)
|
||||
: 0;
|
||||
rt.repairAmountHp = static_cast<float>(
|
||||
modDef->repairCapability->repairAmountHpFormula.evaluate(mx));
|
||||
rt.repairAmountHp = modDef->repairCapability->repairAmountHp;
|
||||
rt.cooldownTicksRemaining = 0;
|
||||
rt.range_tiles = static_cast<float>(
|
||||
modDef->repairCapability->repairRangeFormula.evaluate(mx)) / tileSize;
|
||||
rt.range_tiles = modDef->repairCapability->repairRange_m / tileSize;
|
||||
rt.currentTarget = std::nullopt;
|
||||
|
||||
entt::entity child = m_admin.createModuleEntity();
|
||||
@@ -210,13 +187,9 @@ entt::entity ShipSystem::spawn(const std::string& schematicId, int level,
|
||||
const ModuleDef* modDef = findModuleDef(pm.moduleId);
|
||||
if (!modDef) { throw std::runtime_error("unknown module id '" + pm.moduleId + "'"); }
|
||||
|
||||
const auto overIt2 = moduleLevelOverrides.find(pm.moduleId);
|
||||
const double mx = static_cast<double>(
|
||||
overIt2 != moduleLevelOverrides.end() ? overIt2->second : modDef->playerProductionLevel);
|
||||
|
||||
for (const ModuleStatModifier& sm : modDef->statModifiers)
|
||||
{
|
||||
const double val = sm.formula.evaluate(mx);
|
||||
const double val = sm.value;
|
||||
|
||||
// Route modifier to the correct accumulator by stat category.
|
||||
// weapon/salvage/repair stats go to the corresponding child map;
|
||||
|
||||
@@ -18,10 +18,9 @@ class ShipSystem
|
||||
public:
|
||||
ShipSystem(const GameConfig& config, EntityAdmin& admin);
|
||||
|
||||
entt::entity spawn(const std::string& schematicId, int level, QVector2D position,
|
||||
entt::entity spawn(const std::string& schematicId, QVector2D position,
|
||||
bool isEnemy = false,
|
||||
const std::optional<ShipLayoutConfig>& layout = std::nullopt,
|
||||
const std::map<std::string, int>& moduleLevelOverrides = {});
|
||||
const std::optional<ShipLayoutConfig>& layout = std::nullopt);
|
||||
void despawn(entt::entity entity);
|
||||
|
||||
// Reset all movement intents to inactive before behavior systems run.
|
||||
|
||||
Reference in New Issue
Block a user