fix(production): correct blueprint power and planner edge cases

Read the Advanced Mining Machine speed stored with station settings in prebuild
and blueprint captures, and count charging power nodes such as Satellite
Substations at their idle draw. Skip recipes that consume their own product when
choosing an item's default recipe, so Refined Oil uses Plasma Refining instead
of Reforming Refine.

Run each planner recipe in one proliferation mode and report conflicting
explicit modes, keep material flows for recipe types the catalog does not know,
and attribute receiver warnings to their recipe. Compare simplex ratio ties
relatively and drive out near-zero artificials without amplifying residuals.
Bound the steady-state reduction so lossless cycles cannot stall blueprint
descriptions, and choose power units after rounding.

Remove redundant code: share the numeric and flow helpers, and drop the unused
IsExcessIntermediate threshold, legacy constructor and Capture overloads, the
multi-field updater, and the unused proliferator source table.
This commit is contained in:
soarqin committed 2026-10-25 22:01:05 +08:00
1 parent 6345562c66
commit f0773ffb9b
24 files changed
+463 -404

No files matched your search

+23 -14
View File
@@ -35,13 +35,11 @@ public sealed class BlueprintSelectionCapture
public static class BlueprintSelectionReader
{
public static BlueprintSelectionCapture Capture(PlanetFactory factory, IEnumerable<int> selectedObjectIds)
{
return Capture(factory, selectedObjectIds, null);
}
// Native station parameters store charging power at this index, followed by other station settings.
private const int StationSettingsIndex = 320;
public static BlueprintSelectionCapture Capture(PlanetFactory factory, IEnumerable<int> selectedObjectIds,
BlueprintSelectionContext context)
BlueprintSelectionContext context = null)
{
var catalog = ProductionCatalogService.Current;
if (factory == null || catalog == null)
@@ -81,21 +79,18 @@ public static class BlueprintSelectionReader
var operation = new Dictionary<string, double>();
var speedFactor = GetLiveSpeed(factory, objectId, parameters.type, operation);
AddSettings(parameters, operation);
var storedParameters = objectId < 0 ? factory.prebuildPool[-objectId].parameters : null;
if (building.Kind == ProductionBuildingKind.Logistics)
{
if (objectId > 0)
CaptureLiveChargePower(factory, objectId, operation);
else
{
ref var prebuild = ref factory.prebuildPool[-objectId];
CaptureStoredChargePower(building, parameters, prebuild.parameters, operation);
}
if (objectId > 0) CaptureLiveChargePower(factory, objectId, operation);
else CaptureStoredChargePower(building, parameters, storedParameters, operation);
}
if (operation.ContainsKey("ResearchMode")) CaptureResearchSettings(factory, operation);
switch (building.Kind)
{
case ProductionBuildingKind.Miner:
CaptureMiningSettings(factory, objectId, building, operation);
if (objectId < 0) CaptureStoredMinerSpeed(parameters, storedParameters, operation);
break;
case ProductionBuildingKind.Collector:
CaptureCollectionSettings(factory, operation);
@@ -177,6 +172,8 @@ public static class BlueprintSelectionReader
operation["ResearchMatrixSink"] = 1;
if (building.Kind == ProductionBuildingKind.Logistics)
CaptureStoredChargePower(building, parameters, blueprint.parameters, operation);
else if (building.Kind == ProductionBuildingKind.Miner)
CaptureStoredMinerSpeed(parameters, blueprint.parameters, operation);
ApplySupplied(context?.OperatingParametersByIndex, blueprint.index, operation);
snapshots.Add(CreateSnapshot(catalog, building, 0, parameters, parameters.recipeId, null, operation,
diagnostics));
@@ -231,8 +228,9 @@ public static class BlueprintSelectionReader
{
case BuildingType.Station:
if (storedParameters != null &&
storedParameters.Length >= BuildingParameters.kStationParamsLength && storedParameters[320] > 0)
watts = storedParameters[320] * ProductionUnits.TicksPerSecond;
storedParameters.Length >= BuildingParameters.kStationParamsLength &&
storedParameters[StationSettingsIndex] > 0)
watts = storedParameters[StationSettingsIndex] * ProductionUnits.TicksPerSecond;
break;
case BuildingType.Dispenser:
if (storedParameters != null && storedParameters.Length >= BuildingParameters.kAddonParamsLength)
@@ -250,6 +248,17 @@ public static class BlueprintSelectionReader
operation["ChargePowerWatts"] = watts;
}
// Advanced Mining Machines store their speed with the station settings; native construction restores it.
private static void CaptureStoredMinerSpeed(BuildingParameters parameters, int[] storedParameters,
IDictionary<string, double> operation)
{
if (parameters.type == BuildingType.Station && storedParameters != null &&
storedParameters.Length >= BuildingParameters.kStationParamsLength &&
storedParameters[StationSettingsIndex] > 0 && storedParameters[StationSettingsIndex + 9] > 0)
operation["MachineSpeedFactor"] =
storedParameters[StationSettingsIndex + 9] / ProductionUnits.FixedPointScale;
}
private static ProductionBuildingSnapshot CreateSnapshot(ProductionCatalog catalog, ProductionBuilding building,
int objectId, BuildingParameters parameters, int recipeId, double? speedFactor,
Dictionary<string, double> operation, ICollection<ProductionDiagnostic> diagnostics)