mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-11-19 17:05:20 +08:00
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:
1 parent
4839f868e1
commit
d941de2810
24 files changed
+463
-404
No files matched your search
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using static UXAssist.Production.ProductionMath;
|
||||
|
||||
namespace UXAssist.Production;
|
||||
|
||||
@@ -28,7 +29,7 @@ public sealed class RayReceiverAdapter : IProductionProcessAdapter
|
||||
return false;
|
||||
}
|
||||
|
||||
if (building.RatedGenerationWatts <= 0 || !Finite(building.RatedGenerationWatts) ||
|
||||
if (!FinitePositive(building.RatedGenerationWatts) ||
|
||||
(recipe != null && (recipe.Category != ProductionRecipeCategory.PhotonStore ||
|
||||
recipe.Inputs.Count != 0 || recipe.Outputs.Count != 1 ||
|
||||
!recipe.Outputs.ContainsKey(building.PowerProductItemId))))
|
||||
@@ -60,8 +61,7 @@ public sealed class RayReceiverAdapter : IProductionProcessAdapter
|
||||
|
||||
if (recipe == null && selectedMode > 0) photonMode = true;
|
||||
if (photonMode && (building.PowerProductItemId <= 0 ||
|
||||
building.PowerProductEnergyJoules <= 0 ||
|
||||
!Finite(building.PowerProductEnergyJoules) ||
|
||||
!FinitePositive(building.PowerProductEnergyJoules) ||
|
||||
!catalog.Items.ContainsKey(building.PowerProductItemId)))
|
||||
{
|
||||
diagnostic = new ProductionDiagnostic(ProductionDiagnosticCode.MissingOperatingParameter,
|
||||
@@ -71,7 +71,7 @@ public sealed class RayReceiverAdapter : IProductionProcessAdapter
|
||||
}
|
||||
|
||||
if (!operatingParameters.TryGetValue("LensItemId", out var lensId) ||
|
||||
lensId < 0 || lensId > int.MaxValue || lensId != Math.Truncate(lensId))
|
||||
lensId != 0 && !PositiveId(lensId))
|
||||
{
|
||||
diagnostic = new ProductionDiagnostic(ProductionDiagnosticCode.MissingOperatingParameter,
|
||||
"Provide the receiver's lens item ID, or zero for no lens.", buildingItemId: building.ItemId);
|
||||
@@ -81,7 +81,7 @@ public sealed class RayReceiverAdapter : IProductionProcessAdapter
|
||||
ProductionItem lens = null;
|
||||
if (lensId > 0 && (!catalog.Items.TryGetValue((int)lensId, out lens) ||
|
||||
(lens.CatalystTypeMask & building.CatalystMask) == 0 ||
|
||||
lens.CatalystAbilityMultiplier <= 0 || !Finite(lens.CatalystAbilityMultiplier)))
|
||||
!FinitePositive(lens.CatalystAbilityMultiplier)))
|
||||
{
|
||||
diagnostic = new ProductionDiagnostic(ProductionDiagnosticCode.InvalidRequest,
|
||||
"The selected item is not a compatible ray-receiver lens.",
|
||||
@@ -111,7 +111,7 @@ public sealed class RayReceiverAdapter : IProductionProcessAdapter
|
||||
(1 + speedBonus) * (photonMode ? 8 : 1);
|
||||
var cyclesPerMinute = photonMode
|
||||
? energyWatts * 60 / building.PowerProductEnergyJoules : 1;
|
||||
if (cyclesPerMinute <= 0 || !Finite(cyclesPerMinute) || !Finite(energyWatts))
|
||||
if (!FinitePositive(cyclesPerMinute) || !Finite(energyWatts))
|
||||
{
|
||||
diagnostic = new ProductionDiagnostic(ProductionDiagnosticCode.InvalidRequest,
|
||||
"The receiver's native output is outside the supported range.", buildingItemId: building.ItemId);
|
||||
@@ -129,7 +129,7 @@ public sealed class RayReceiverAdapter : IProductionProcessAdapter
|
||||
if (!lossKnown)
|
||||
diagnostic = new ProductionDiagnostic(ProductionDiagnosticCode.MissingOperatingParameter,
|
||||
"The Dyson-sphere power requirement needs the current solar energy loss technology setting.",
|
||||
buildingItemId: building.ItemId);
|
||||
recipeId: recipe?.Id ?? 0, buildingItemId: building.ItemId);
|
||||
|
||||
var lensFlow = lens == null ? Array.Empty<KeyValuePair<int, double>>() :
|
||||
new[] { new KeyValuePair<int, double>(lens.Id, 0.1 / cyclesPerMinute) };
|
||||
@@ -172,9 +172,4 @@ public sealed class RayReceiverAdapter : IProductionProcessAdapter
|
||||
Array.Empty<KeyValuePair<int, double>>(), recipe.Outputs, 0, 0, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool Finite(double value)
|
||||
{
|
||||
return !double.IsNaN(value) && !double.IsInfinity(value);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user