refactor(backend): align station module production semantics

This commit is contained in:
2026-03-27 16:44:50 -04:00
parent 3237735b08
commit 04d182e93f
10 changed files with 125 additions and 82 deletions

View File

@@ -34,17 +34,16 @@ internal sealed class StationLifecycleService
private void UpdateStationPopulation(SimulationWorld world, StationRuntime station, float deltaSeconds, ICollection<SimulationEventRecord> events)
{
station.WorkforceRequired = MathF.Max(12f, station.Modules.Count * 14f);
station.WorkforceRequired = GetStationRequiredWorkforce(world.ModuleDefinitions, station);
var requiredWater = station.Population * WaterConsumptionPerWorkerPerSecond * deltaSeconds;
var consumedWater = RemoveInventory(station.Inventory, "water", requiredWater);
var waterSatisfied = requiredWater <= 0.01f || consumedWater + 0.001f >= requiredWater;
var habitatModules = CountStationModules(station, ModuleType.Habitation);
station.PopulationCapacity = 40f + (habitatModules * 220f);
station.PopulationCapacity = GetStationSupportedPopulation(world.ModuleDefinitions, station);
if (waterSatisfied)
{
if (habitatModules > 0 && station.Population < station.PopulationCapacity)
if (station.PopulationCapacity > 40f && station.Population < station.PopulationCapacity)
{
station.Population = MathF.Min(station.PopulationCapacity, station.Population + (PopulationGrowthPerSecond * deltaSeconds));
}