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

@@ -39,8 +39,10 @@ public static class ProductionCatalogReader
var kind = ClassifyBuilding(prefab);
if (category == ProductionRecipeCategory.None && kind == ProductionBuildingKind.Ordinary) continue;
var speed = prefab.isLab ? prefab.labAssembleSpeed : prefab.assemblerSpeed;
// Charging power nodes draw idle power except while charging a mecha, which production power excludes.
var workEnergyPerTick = prefab.isPowerCharger ? prefab.idleEnergyPerTick : prefab.workEnergyPerTick;
buildings.Add(new ProductionBuilding(item.ID, category, speed / 10000.0,
prefab.workEnergyPerTick * 60.0, prefab.idleEnergyPerTick * 60.0, kind,
workEnergyPerTick * 60.0, prefab.idleEnergyPerTick * 60.0, kind,
prefab.genEnergyPerTick * 60.0, prefab.exchangeEnergyPerTick * 60.0,
prefab.maxExcEnergy, prefab.emptyId, prefab.fullId,
prefab.windForcedPower ? RenewablePowerSource.Wind :
@@ -68,9 +70,12 @@ public static class ProductionCatalogReader
recipes.Add(new ProductionRecipe(recipe.ID, MapCategory(recipe.Type), recipe.TimeSpend, recipe.productive,
PairFlows(recipe.Items, recipe.ItemCounts), PairFlows(recipe.Results, recipe.ResultCounts)));
// Follow native maincraft selection (lowest result index, then recipe order), but skip recipes such as
// Reforming Refine that consume their own product and so cannot start its production chain.
for (var resultIndex = 0; resultIndex < recipe.Results.Length; resultIndex++)
{
var productId = recipe.Results[resultIndex];
if (Array.IndexOf(recipe.Items, productId) >= 0) continue;
if (!defaultRecipes.TryGetValue(productId, out var old) || resultIndex < old.resultIndex)
defaultRecipes[productId] = (recipe.ID, resultIndex);
}
@@ -82,8 +87,8 @@ public static class ProductionCatalogReader
foreach (var item in itemProtos)
{
if (item == null) continue;
var defaultRecipeId = item.maincraft?.ID ??
(defaultRecipes.TryGetValue(item.ID, out var fallback) ? fallback.recipeId : 0);
var defaultRecipeId = defaultRecipes.TryGetValue(item.ID, out var defaultRecipe)
? defaultRecipe.recipeId : 0;
var isProliferator = proliferators.Contains(item.ID);
items.Add(new ProductionItem(item.ID, defaultRecipeId,
naturalItems.Contains(item.ID) || !string.IsNullOrEmpty(item.MiningFrom),
@@ -192,7 +197,7 @@ public static class ProductionCatalogReader
? ProductionBuildingKind.RenewableGenerator : ProductionBuildingKind.FuelGenerator;
if (prefab.isStation || prefab.isDispenser || prefab.isBattleBase)
return ProductionBuildingKind.Logistics;
if (prefab.isPowerConsumer && !prefab.isStation && !prefab.isDispenser)
if (prefab.isPowerConsumer || prefab.isPowerCharger)
return ProductionBuildingKind.Auxiliary;
return ProductionBuildingKind.Ordinary;
}