mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-11-19 17:05:20 +08:00
fix(uxassist): preserve blueprint layout and add production bases
This commit is contained in:
1 parent
8fbb244ba2
commit
d728e8b4ae
10 files changed
+577
-57
No files matched your search
@@ -8,7 +8,8 @@
|
||||
* Add a Factory-tab button to arrange ordinary Mining Machines densely around the nearest solid vein group. Each miner covers at least 3 nodes from that group, without including nearby groups. Layouts are not limited by stock; missing miners remain as ghosts awaiting materials. Placement respects construction range and does not include belts or power facilities. Click again to cancel a search.
|
||||
* `Allow restoring/burying veins` is off by default, using only visible nodes without restoring or burying any. Enable it to restore unobstructed nodes away from Dark Fog Planetary Bases and allow unused nodes to be buried for better coverage. Nodes used by existing miners or miner ghosts are protected.
|
||||
* `Blueprint descriptions`:
|
||||
* Add `Auto-fill description` to the blueprint browser, copy, and paste panels. It replaces the main description with full-load material flows per minute, separating shortages, surpluses, inputs, outputs, and research use, and adds factory and logistics power demand to a `Power` custom field.
|
||||
* Add an `Auto-fill` entry to the native description header in the blueprint browser, copy, and paste inspectors. It opens generation options without moving native fields or covering the file list. Generation replaces the main description with material flows per minute, separating shortages, surpluses, inputs, outputs, and research use, and adds factory and logistics power demand to a `Power` custom field.
|
||||
* Choose `Final-product output` (the default on opening the inspector) to retain rated final outputs and show intermediate shortages and excess, or `Lowest intermediate throughput` to scale the final-product mix to the bottleneck using recipe ratios. Complete, balanceable chains have no internal shortages in the latter mode; unused intermediate capacity appears as excess. External inputs use the selected basis; power still covers every selected building at full load. If a balanced basis cannot be determined, the original description is kept.
|
||||
* A `Proliferation` checkbox controls whether calculations include proliferation, defaulting to on when the blueprint contains a Spray Coater. Large rates use K/M/G where display precision is preserved, and numbers with four or more integer digits use comma thousands separators, including before suffixes; unknown values are marked separately. Other custom fields are preserved, and the blueprint still needs to be saved manually.
|
||||
* `Sunlight at night`: Lighting now follows the camera, including planet view, and stays consistent across buildings, terrain, solar panels, and belts. Restore lighting correctly after switching planets, and return to native lighting when sailing, disabling the feature, or using white rendering mode.
|
||||
* `Protect veins from exhaustion`: Fix the option failing to take effect in 1.6.2, restoring protection of configured vein reserves and minimum oil rates, along with the corresponding mining statistics.
|
||||
@@ -448,7 +449,8 @@
|
||||
* 在「工厂」页增加按钮,自动在最近的固体矿脉周围密集铺设普通采矿机。每台至少覆盖选中矿脉的 3 个矿点,不混入附近其他矿脉。布局数量不受库存限制,采矿机不足的位置保留待建造虚影。遵守建造范围,不自动铺设传送带和电力设施。计算期间再次点击可取消。
|
||||
* 「允许恢复/掩埋矿物」默认关闭,仅使用可见矿点,不恢复或掩埋矿点。开启后可恢复未被建筑阻挡、且远离黑雾行星基地的矿点,并允许掩埋未使用的矿点来提高覆盖数;已有矿机和待建造矿机使用的矿点会受到保护。
|
||||
* `蓝图说明`:
|
||||
* 在蓝图浏览、复制和粘贴界面增加「自动填写说明」按钮,用满负荷运行时每分钟的物料流量替换原说明,分别列出「缺少」「多余」「输入」「输出」「研究」,并将工厂与物流耗电写入「耗电」自定义字段。
|
||||
* 在蓝图浏览、复制和粘贴检查面板的说明标题行增加「自动填写」入口,点击展开生成选项,不移动原生字段或遮挡文件列表。生成时用每分钟的物料流量替换原说明,分别列出「缺少」「多余」「输入」「输出」「研究」,并将工厂与物流耗电写入「耗电」自定义字段。
|
||||
* 可选择「最终产物产量」(每次打开检查面板时的默认值),保留最终产物的额定产量并显示中间产物的缺口和余量;也可选择「最低产量中间产物」,按配方比例换算瓶颈,等比例缩放各最终产物。后一种模式下,数据完整且可平衡的生产链没有内部缺口,未使用的中间产能列为「多余」。外部输入采用所选基准,耗电仍按所选全部建筑满载估算。无法确定平衡基准时保留原说明。
|
||||
* 可用「增产」复选框选择是否计入增产效果,蓝图含喷涂机时默认勾选。较大的流量在保留显示精度的前提下使用 K/M/G 单位;整数部分达到四位的数字用逗号每三位分隔,带单位时也适用。无法计算的数值单独标注。保留其他自定义字段,填写后仍需手动保存蓝图。
|
||||
* `夜间日光灯`:光照改为随镜头变化,行星视图也适用;建筑、地表、太阳能板和传送带的光照方向保持一致。切换行星后正确恢复光照,航行、关闭功能或进入白模渲染时恢复原版光照。
|
||||
* `保护矿脉不会枯竭`:修复 1.6.2 中开启后仍不生效的问题,恢复设定的矿脉剩余量、油井最低流速保护及相应开采统计。
|
||||
|
||||
@@ -6,7 +6,14 @@ public static class I18NKeys
|
||||
{
|
||||
public const string Unknown = "Unknown";
|
||||
public const string BlueprintAutoFillDescription = "UXAssist Blueprint Auto-fill description";
|
||||
public const string BlueprintDescriptionOptions = "UXAssist Blueprint Description Options";
|
||||
public const string BlueprintDescriptionOptionsTip = "UXAssist Blueprint Description Options Tip";
|
||||
public const string BlueprintProliferation = "UXAssist Blueprint Proliferation";
|
||||
public const string BlueprintProductionBasis = "UXAssist Blueprint Production Basis";
|
||||
public const string BlueprintFinalProducts = "UXAssist Blueprint Final Products";
|
||||
public const string BlueprintBottleneckIntermediate = "UXAssist Blueprint Bottleneck Intermediate";
|
||||
public const string BlueprintProductionBasisTip = "UXAssist Blueprint Production Basis Tip";
|
||||
public const string BlueprintBasisUnavailable = "Cannot determine a balanced intermediate throughput. Check building settings and production-chain outputs, or use final-product output.";
|
||||
public const string BlueprintPower = "UXAssist Blueprint Power";
|
||||
public const string BlueprintPowerEnglish = "Power";
|
||||
public const string BlueprintPowerChinese = "耗电";
|
||||
@@ -237,7 +244,19 @@ public static class I18NKeys
|
||||
{
|
||||
I18N.Add(Unknown, "Unknown", "未知");
|
||||
I18N.Add(BlueprintAutoFillDescription, "Auto-fill description", "自动填写说明");
|
||||
I18N.Add(BlueprintDescriptionOptions, "Auto-fill…", "自动填写…");
|
||||
I18N.Add(BlueprintDescriptionOptionsTip,
|
||||
"Choose production basis and proliferation, then fill the blueprint description.",
|
||||
"选择产量基准和增产后,自动填写蓝图说明。");
|
||||
I18N.Add(BlueprintProliferation, "Proliferation", "增产");
|
||||
I18N.Add(BlueprintProductionBasis, "Production basis", "产量基准");
|
||||
I18N.Add(BlueprintFinalProducts, "Final-product output", "最终产物产量");
|
||||
I18N.Add(BlueprintBottleneckIntermediate, "Lowest intermediate throughput", "最低产量中间产物");
|
||||
I18N.Add(BlueprintProductionBasisTip,
|
||||
"Final-product output (default): keep rated final outputs and show intermediate shortages and excess.\nLowest intermediate throughput: convert capacities through recipe ratios and scale all final outputs together to the bottleneck; complete, balanceable chains have no internal shortages. Excess shows unused intermediate capacity. Power still sizes all selected buildings at full load.\nUnknown settings or an unresolved output prevent balanced generation; the existing description is kept.",
|
||||
"最终产物产量(默认):保留最终产物的额定产量,显示中间产物的缺口和余量。\n最低产量中间产物:按配方比例换算产能,以瓶颈等比例缩放各最终产物;数据完整且可平衡时没有内部缺口,「多余」表示未使用的中间产能。耗电仍按所选全部建筑满载估算。\n缺少参数或无法确定输出时,不生成平衡说明,保留原说明。");
|
||||
I18N.Add(BlueprintBasisUnavailable, BlueprintBasisUnavailable,
|
||||
"无法确定可平衡的中间产物产量,原说明已保留。请检查建筑参数和生产链输出,或改用最终产物产量基准。");
|
||||
I18N.Add(BlueprintPower, BlueprintPowerEnglish, BlueprintPowerChinese);
|
||||
I18N.Add(BlueprintInputLine, "Input: ", "输入:");
|
||||
I18N.Add(BlueprintOutputLine, "Output: ", "输出:");
|
||||
|
||||
@@ -102,38 +102,81 @@ public class BlueprintDescriptionPatch : PatchImpl<BlueprintDescriptionPatch>
|
||||
|
||||
private sealed class InspectorControls
|
||||
{
|
||||
private const float Left = 22f;
|
||||
private const float Left = 12f;
|
||||
private const float ControlsGap = 12f;
|
||||
|
||||
private readonly UIBlueprintInspector _inspector;
|
||||
private readonly float _controlsHeight;
|
||||
private RectTransform _panel;
|
||||
private UIButton _entry;
|
||||
private Text _entryText;
|
||||
private UIButton _button;
|
||||
private Text _buttonText;
|
||||
private UIButton _cancelButton;
|
||||
private Text _cancelText;
|
||||
private MyCheckBox _checkbox;
|
||||
private MyCornerComboBox _basisCombo;
|
||||
private Text _basisLabel;
|
||||
private UIButton _basisHelp;
|
||||
private BlueprintData _currentBlueprint;
|
||||
private bool _manualProliferation;
|
||||
private bool _layoutApplied;
|
||||
|
||||
public InspectorControls(UIBlueprintInspector inspector)
|
||||
{
|
||||
_inspector = inspector;
|
||||
try
|
||||
{
|
||||
_button = LayoutHelper.AddButton(Left, 0, inspector.group1,
|
||||
// The native description has a 22px title row above its editable text.
|
||||
_entry = LayoutHelper.AddButton(0, 0, inspector.descGroupTrans,
|
||||
I18NKeys.BlueprintDescriptionOptions, 13, "blueprint-description-options", ToggleOptions);
|
||||
_entryText = _entry.transform.Find("button-text").GetComponent<Text>();
|
||||
_entry.tips = inspector.tipButton2.tips;
|
||||
_entry.tips.topLevel = true;
|
||||
Util.NormalizeRectWithTopRight(_entry, 0, 0, inspector.descGroupTrans);
|
||||
|
||||
// Reuse the native background, including its blur material, only while options are open.
|
||||
var source = UIRoot.instance.uiGame.inserterWindow.transform.Find("panel-bg").GetComponent<Image>();
|
||||
_panel = UnityEngine.Object.Instantiate(source, inspector.rectTrans).rectTransform;
|
||||
_panel.gameObject.name = "uxassist-blueprint-description-options";
|
||||
for (var i = _panel.childCount - 1; i >= 0; i--)
|
||||
{
|
||||
var child = _panel.GetChild(i).gameObject;
|
||||
child.SetActive(false);
|
||||
UnityEngine.Object.Destroy(child);
|
||||
}
|
||||
_panel.anchorMin = new Vector2(0, 1);
|
||||
_panel.anchorMax = Vector2.one;
|
||||
_panel.pivot = new Vector2(0, 1);
|
||||
_panel.anchoredPosition = new Vector2(Left, -Left);
|
||||
_panel.sizeDelta = new Vector2(-Left * 2, 152);
|
||||
_button = LayoutHelper.AddButton(Left, 12, _panel,
|
||||
I18NKeys.BlueprintAutoFillDescription, 15, "blueprint-auto-fill-description", Generate);
|
||||
_buttonText = _button.transform.Find("button-text").GetComponent<Text>();
|
||||
_checkbox = MyCheckBox.CreateCheckBox(Left, 0, inspector.group1, false,
|
||||
_cancelButton = LayoutHelper.AddButton(0, 0, _panel,
|
||||
I18NKeys.Cancel, 14, "blueprint-description-cancel", CloseOptions);
|
||||
_cancelText = _cancelButton.transform.Find("button-text").GetComponent<Text>();
|
||||
Util.NormalizeRectWithTopRight(_cancelButton, Left, 14, _panel);
|
||||
_checkbox = MyCheckBox.CreateCheckBox(Left, 52, _panel, false,
|
||||
I18NKeys.BlueprintProliferation.Translate(), 15).WithSmallerBox(22f);
|
||||
_checkbox.gameObject.name = "blueprint-proliferation";
|
||||
_checkbox.OnChecked += OnProliferationChecked;
|
||||
_basisLabel = LayoutHelper.AddText(Left, 80, _panel, I18NKeys.BlueprintProductionBasis, 14);
|
||||
_basisCombo = MyCornerComboBox.CreateComboBox(Left, 108, _panel).WithFontSize(14)
|
||||
.WithItems(I18NKeys.BlueprintFinalProducts, I18NKeys.BlueprintBottleneckIntermediate)
|
||||
.WithIndex(0);
|
||||
var combo = _basisCombo.GetComponent<UIComboBox>();
|
||||
combo.CanInput = false;
|
||||
combo.autoWidth = false;
|
||||
var comboRect = (RectTransform)_basisCombo.transform;
|
||||
comboRect.anchorMax = Vector2.one;
|
||||
comboRect.sizeDelta = new Vector2(-Left * 2, 28);
|
||||
_basisHelp = LayoutHelper.AddTipsButton(Left, 80, _panel,
|
||||
I18NKeys.BlueprintProductionBasis.Translate(), I18NKeys.BlueprintProductionBasisTip.Translate(), "");
|
||||
UpdateLabels();
|
||||
_controlsHeight = Math.Max(_button.transform.GetComponent<RectTransform>().rect.height,
|
||||
_checkbox.rectTrans.rect.height) + 10f;
|
||||
_panel.gameObject.SetActive(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (_button) UnityEngine.Object.Destroy(_button.gameObject);
|
||||
if (_checkbox) UnityEngine.Object.Destroy(_checkbox.gameObject);
|
||||
Destroy();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@@ -142,65 +185,72 @@ public class BlueprintDescriptionPatch : PatchImpl<BlueprintDescriptionPatch>
|
||||
{
|
||||
_currentBlueprint = null;
|
||||
_manualProliferation = false;
|
||||
_basisCombo.SetIndex(0);
|
||||
if (_inspector.blueprint != null) SyncDefault();
|
||||
else _checkbox.Checked = false;
|
||||
CloseOptions();
|
||||
_entry.gameObject.SetActive(_inspector.blueprint != null);
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
SyncDefault();
|
||||
if (!_layoutApplied)
|
||||
_inspector.group1.anchoredPosition += new Vector2(0, -_controlsHeight);
|
||||
PositionControls();
|
||||
_inspector.group2.anchoredPosition += new Vector2(0, -_controlsHeight);
|
||||
_inspector.group3.anchoredPosition += new Vector2(0, -_controlsHeight);
|
||||
_inspector.group4.anchoredPosition += new Vector2(0, -_controlsHeight);
|
||||
_inspector.contentTrans.sizeDelta += new Vector2(0, _controlsHeight);
|
||||
_layoutApplied = true;
|
||||
_entry.gameObject.SetActive(_inspector.blueprint != null);
|
||||
}
|
||||
|
||||
private void ToggleOptions()
|
||||
{
|
||||
_panel.SetAsLastSibling();
|
||||
_panel.gameObject.SetActive(!_panel.gameObject.activeSelf);
|
||||
}
|
||||
|
||||
private void CloseOptions() => _panel.gameObject.SetActive(false);
|
||||
|
||||
public void UpdateLabels()
|
||||
{
|
||||
_entryText.text = I18NKeys.BlueprintDescriptionOptions.Translate();
|
||||
((RectTransform)_entry.transform).sizeDelta =
|
||||
new Vector2(Util.GetPreferredWidth(_entryText) + 16, 20);
|
||||
_entry.tips.tipTitle = I18NKeys.BlueprintAutoFillDescription.Translate();
|
||||
_entry.tips.tipText = I18NKeys.BlueprintDescriptionOptionsTip.Translate();
|
||||
_entry.UpdateTip();
|
||||
_buttonText.text = I18NKeys.BlueprintAutoFillDescription.Translate();
|
||||
_cancelText.text = I18NKeys.Cancel.Translate();
|
||||
((RectTransform)_cancelButton.transform).sizeDelta =
|
||||
new Vector2(Util.GetPreferredWidth(_cancelText) + 20, 24);
|
||||
_checkbox.SetLabelText(I18NKeys.BlueprintProliferation.Translate());
|
||||
_basisLabel.text = I18NKeys.BlueprintProductionBasis.Translate();
|
||||
var combo = _basisCombo.GetComponent<UIComboBox>();
|
||||
var index = combo.itemIndex;
|
||||
_basisCombo.SetItems(I18NKeys.BlueprintFinalProducts, I18NKeys.BlueprintBottleneckIntermediate);
|
||||
_basisCombo.SetIndex(index);
|
||||
_basisHelp.tips.tipTitle = I18NKeys.BlueprintProductionBasis.Translate();
|
||||
_basisHelp.tips.tipText = I18NKeys.BlueprintProductionBasisTip.Translate();
|
||||
_basisHelp.UpdateTip();
|
||||
var width = Math.Max(160f, Util.GetPreferredWidth(_buttonText) + 26f);
|
||||
_button.transform.GetComponent<RectTransform>().sizeDelta =
|
||||
new Vector2(width, _button.transform.GetComponent<RectTransform>().sizeDelta.y);
|
||||
if (_layoutApplied) PositionControls();
|
||||
var labelWidth = Util.GetPreferredWidth(_basisLabel);
|
||||
_basisLabel.rectTransform.sizeDelta = new Vector2(labelWidth, _basisLabel.rectTransform.sizeDelta.y);
|
||||
Util.NormalizeRectWithTopLeft(_basisHelp, Left + labelWidth + ControlsGap, 80, _panel);
|
||||
}
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
if (_layoutApplied && _inspector)
|
||||
if (_entry)
|
||||
{
|
||||
_inspector.group1.anchoredPosition += new Vector2(0, _controlsHeight);
|
||||
_inspector.group2.anchoredPosition += new Vector2(0, _controlsHeight);
|
||||
_inspector.group3.anchoredPosition += new Vector2(0, _controlsHeight);
|
||||
_inspector.group4.anchoredPosition += new Vector2(0, _controlsHeight);
|
||||
_inspector.contentTrans.sizeDelta += new Vector2(0, -_controlsHeight);
|
||||
_layoutApplied = false;
|
||||
_entry.button.onClick.RemoveListener(ToggleOptions);
|
||||
UnityEngine.Object.Destroy(_entry.gameObject);
|
||||
}
|
||||
|
||||
if (_button)
|
||||
{
|
||||
_button.button.onClick.RemoveListener(Generate);
|
||||
UnityEngine.Object.Destroy(_button.gameObject);
|
||||
}
|
||||
|
||||
if (_cancelButton)
|
||||
_cancelButton.button.onClick.RemoveListener(CloseOptions);
|
||||
if (_checkbox)
|
||||
{
|
||||
_checkbox.OnChecked -= OnProliferationChecked;
|
||||
UnityEngine.Object.Destroy(_checkbox.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
private void PositionControls()
|
||||
{
|
||||
var buttonRect = _button.transform.GetComponent<RectTransform>();
|
||||
var top = 4f - _controlsHeight;
|
||||
Util.NormalizeRectWithTopLeft(_button, Left, top, _inspector.group1);
|
||||
Util.NormalizeRectWithTopLeft(_checkbox, Left + buttonRect.rect.width + ControlsGap,
|
||||
top + (buttonRect.rect.height - _checkbox.rectTrans.rect.height) / 2f, _inspector.group1);
|
||||
if (!_panel) return;
|
||||
_panel.gameObject.SetActive(false);
|
||||
UnityEngine.Object.Destroy(_panel.gameObject);
|
||||
}
|
||||
|
||||
private void SyncDefault()
|
||||
@@ -208,6 +258,7 @@ public class BlueprintDescriptionPatch : PatchImpl<BlueprintDescriptionPatch>
|
||||
var blueprint = _inspector.blueprint;
|
||||
if (!ReferenceEquals(blueprint, _currentBlueprint))
|
||||
{
|
||||
CloseOptions();
|
||||
_currentBlueprint = blueprint;
|
||||
_manualProliferation = false;
|
||||
}
|
||||
@@ -266,7 +317,14 @@ public class BlueprintDescriptionPatch : PatchImpl<BlueprintDescriptionPatch>
|
||||
return;
|
||||
}
|
||||
|
||||
var report = new FactoryBlackBoxAnalyzer(catalog).Analyze(capture.CreateRequest(_checkbox.Checked));
|
||||
var request = capture.CreateRequest(_checkbox.Checked);
|
||||
request.ProductionBasis = (BlueprintProductionBasis)_basisCombo.GetComponent<UIComboBox>().itemIndex;
|
||||
var report = new FactoryBlackBoxAnalyzer(catalog).Analyze(request);
|
||||
if (report.Diagnostics.Any(diagnostic => diagnostic.Code == ProductionDiagnosticCode.BlueprintBasisUnavailable))
|
||||
{
|
||||
UIRealtimeTip.Popup(I18NKeys.BlueprintBasisUnavailable.Translate());
|
||||
return;
|
||||
}
|
||||
if (report.Status == ProductionStatus.Failed || report.Status == ProductionStatus.DataNotReady)
|
||||
{
|
||||
UIRealtimeTip.Popup((report.Status == ProductionStatus.DataNotReady
|
||||
@@ -320,6 +378,7 @@ public class BlueprintDescriptionPatch : PatchImpl<BlueprintDescriptionPatch>
|
||||
throw;
|
||||
}
|
||||
|
||||
CloseOptions();
|
||||
if (!report.MaterialComplete || !report.PowerBreakdown.FactoryComplete ||
|
||||
!report.PowerBreakdown.LogisticsComplete)
|
||||
UIRealtimeTip.Popup(I18NKeys.BlueprintPartial.Translate());
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using static UXAssist.Production.ProductionMath;
|
||||
|
||||
namespace UXAssist.Production;
|
||||
|
||||
internal static class BlueprintBottleneckBalance
|
||||
{
|
||||
private const double Tolerance = 1e-7;
|
||||
|
||||
internal static bool TryCalculate(IReadOnlyList<BlackBoxProcessGroup> processes,
|
||||
IReadOnlyDictionary<int, double> production, IReadOnlyDictionary<int, double> consumption,
|
||||
ISet<int> researchMatrixSinks,
|
||||
out SortedDictionary<int, double> balancedProduction, out SortedDictionary<int, double> balancedConsumption,
|
||||
out IReadOnlyDictionary<int, BlackBoxItemClassification> balancedClassifications,
|
||||
out IReadOnlyDictionary<int, double> balancedNet)
|
||||
{
|
||||
balancedProduction = null;
|
||||
balancedConsumption = null;
|
||||
balancedClassifications = null;
|
||||
balancedNet = null;
|
||||
if (production.Count == 0 && consumption.Count == 0)
|
||||
{
|
||||
balancedProduction = new SortedDictionary<int, double>();
|
||||
balancedConsumption = new SortedDictionary<int, double>();
|
||||
balancedClassifications = new Dictionary<int, BlackBoxItemClassification>();
|
||||
balancedNet = new Dictionary<int, double>();
|
||||
return true;
|
||||
}
|
||||
|
||||
var groups = processes.GroupBy(process => process.StableKey, StringComparer.Ordinal)
|
||||
.OrderBy(group => group.Key, StringComparer.Ordinal)
|
||||
.Select(group => (source: group.First(), count: group.Sum(process => process.Count))).ToArray();
|
||||
var produced = new HashSet<int>(groups.SelectMany(group => group.source.NetPerBuilding)
|
||||
.Where(flow => flow.Value > BlackBoxMaterialClassifier.Tolerance).Select(flow => flow.Key));
|
||||
var consumed = new HashSet<int>(groups.SelectMany(group => group.source.NetPerBuilding)
|
||||
.Where(flow => flow.Value < -BlackBoxMaterialClassifier.Tolerance).Select(flow => flow.Key));
|
||||
var items = produced.OrderBy(itemId => itemId).ToArray();
|
||||
// Normalize only the scale variable; the solver still resolves shared demand, recipe ratios, and cycles together.
|
||||
var commonScale = items.Where(consumed.Contains).Select(itemId => production[itemId] / consumption[itemId])
|
||||
.Aggregate(1.0, Math.Min);
|
||||
var targets = items.Where(itemId => !consumed.Contains(itemId) || researchMatrixSinks.Contains(itemId))
|
||||
.ToDictionary(itemId => itemId, itemId => Math.Max(0, production[itemId] -
|
||||
(consumption.TryGetValue(itemId, out var amount) ? amount : 0)));
|
||||
// Launchers, generators, and precise research can terminate a chain without an item output.
|
||||
var sinks = Enumerable.Range(0, groups.Length).Where(index =>
|
||||
groups[index].source.NetPerBuilding.Values.Any(value => value < -BlackBoxMaterialClassifier.Tolerance) &&
|
||||
!groups[index].source.NetPerBuilding.Values.Any(value => value > BlackBoxMaterialClassifier.Tolerance))
|
||||
.ToArray();
|
||||
if (!targets.Values.Any(FinitePositive) && sinks.Length == 0) return false;
|
||||
|
||||
var scaleColumn = groups.Length;
|
||||
var surplusStart = scaleColumn + 1;
|
||||
var capacitySlackStart = surplusStart + items.Length;
|
||||
var columnCount = capacitySlackStart + groups.Length + 1;
|
||||
var matrix = new double[items.Length + groups.Length + 1 + sinks.Length, columnCount];
|
||||
var rhs = new double[matrix.GetLength(0)];
|
||||
var maximizeOutput = new double[columnCount];
|
||||
var minimizeUse = new double[columnCount];
|
||||
var minimizeSurplus = new double[columnCount];
|
||||
maximizeOutput[scaleColumn] = -1;
|
||||
for (var row = 0; row < items.Length; row++)
|
||||
{
|
||||
var itemId = items[row];
|
||||
var rowScale = Math.Max(production[itemId], consumption.TryGetValue(itemId, out var amount) ? amount : 0);
|
||||
for (var index = 0; index < groups.Length; index++)
|
||||
if (groups[index].source.NetPerBuilding.TryGetValue(itemId, out var net))
|
||||
matrix[row, index] = net * groups[index].count / rowScale;
|
||||
if (targets.TryGetValue(itemId, out var target)) matrix[row, scaleColumn] = -target / rowScale * commonScale;
|
||||
matrix[row, surplusStart + row] = -1;
|
||||
minimizeSurplus[surplusStart + row] = 1;
|
||||
}
|
||||
|
||||
for (var index = 0; index <= groups.Length; index++)
|
||||
{
|
||||
var row = items.Length + index;
|
||||
matrix[row, index] = index < groups.Length ? 1 : commonScale;
|
||||
matrix[row, capacitySlackStart + index] = 1;
|
||||
rhs[row] = 1;
|
||||
if (index < groups.Length) minimizeUse[index] = groups[index].count;
|
||||
}
|
||||
|
||||
for (var index = 0; index < sinks.Length; index++)
|
||||
{
|
||||
var row = items.Length + groups.Length + 1 + index;
|
||||
matrix[row, sinks[index]] = 1;
|
||||
matrix[row, scaleColumn] = -commonScale;
|
||||
}
|
||||
|
||||
var solution = TwoPhaseSimplex.Solve(matrix, rhs,
|
||||
new[] { maximizeOutput, minimizeUse, minimizeSurplus }, 20000, CancellationToken.None);
|
||||
if (solution.Status != LinearSolveStatus.Optimal || !FinitePositive(solution.Values[scaleColumn])) return false;
|
||||
for (var row = 0; row < rhs.Length; row++)
|
||||
{
|
||||
var residual = -rhs[row];
|
||||
for (var column = 0; column < columnCount; column++) residual += matrix[row, column] * solution.Values[column];
|
||||
if (Math.Abs(residual) > Tolerance) return false;
|
||||
}
|
||||
|
||||
balancedProduction = new SortedDictionary<int, double>(production.ToDictionary(flow => flow.Key, _ => 0.0));
|
||||
balancedConsumption = new SortedDictionary<int, double>(consumption.ToDictionary(flow => flow.Key, _ => 0.0));
|
||||
var unusedProduction = new Dictionary<int, double>();
|
||||
for (var index = 0; index < groups.Length; index++)
|
||||
{
|
||||
var group = groups[index];
|
||||
var utilized = Math.Min(1, solution.Values[index]) * group.count;
|
||||
var executions = group.source.Process.CyclesPerBuildingPerMinute * utilized;
|
||||
foreach (var flow in group.source.Process.OutputsPerCycle)
|
||||
AddFlow(balancedProduction, flow.Key, flow.Value * executions);
|
||||
foreach (var flow in group.source.Process.InputsPerCycle)
|
||||
AddFlow(balancedConsumption, flow.Key, flow.Value * executions);
|
||||
foreach (var flow in group.source.NetPerBuilding)
|
||||
if (flow.Value > 0) AddFlow(unusedProduction, flow.Key, flow.Value * (group.count - utilized));
|
||||
}
|
||||
|
||||
var netFlows = new Dictionary<int, double>();
|
||||
var result = new Dictionary<int, BlackBoxItemClassification>();
|
||||
var allItems = new SortedSet<int>(production.Keys);
|
||||
allItems.UnionWith(consumption.Keys);
|
||||
foreach (var itemId in allItems)
|
||||
{
|
||||
var grossProduced = balancedProduction.TryGetValue(itemId, out var p) ? p : 0;
|
||||
var grossConsumed = balancedConsumption.TryGetValue(itemId, out var c) ? c : 0;
|
||||
var net = grossProduced - grossConsumed;
|
||||
if (targets.TryGetValue(itemId, out var target))
|
||||
{
|
||||
var required = target * solution.Values[scaleColumn] * commonScale;
|
||||
if (net < required - Tolerance * Math.Max(1, required)) return false;
|
||||
}
|
||||
if (Math.Abs(net) <= Tolerance * Math.Max(1, Math.Max(grossProduced, grossConsumed))) net = 0;
|
||||
netFlows[itemId] = net;
|
||||
var intermediate = produced.Contains(itemId) && consumed.Contains(itemId);
|
||||
if (intermediate && net < 0) return false;
|
||||
var research = researchMatrixSinks.Contains(itemId);
|
||||
var researchProduct = research && net > 0;
|
||||
result[itemId] = new BlackBoxItemClassification(produced.Contains(itemId) && !consumed.Contains(itemId) || researchProduct,
|
||||
researchProduct, 0,
|
||||
intermediate && !research && unusedProduction.TryGetValue(itemId, out var unused) ? unused : 0,
|
||||
intermediate && !research ? Math.Max(0, net) : 0);
|
||||
}
|
||||
|
||||
balancedClassifications = result;
|
||||
balancedNet = netFlows;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -31,11 +31,18 @@ public sealed class ProductionBuildingSnapshot
|
||||
}
|
||||
}
|
||||
|
||||
public enum BlueprintProductionBasis
|
||||
{
|
||||
FinalProducts,
|
||||
BottleneckIntermediate
|
||||
}
|
||||
|
||||
public sealed class FactoryBlackBoxRequest
|
||||
{
|
||||
public List<ProductionBuildingSnapshot> Buildings { get; } = new List<ProductionBuildingSnapshot>();
|
||||
public List<ProductionDiagnostic> CaptureDiagnostics { get; } = new List<ProductionDiagnostic>();
|
||||
public bool ProliferationEnabled { get; set; }
|
||||
public BlueprintProductionBasis ProductionBasis { get; set; }
|
||||
}
|
||||
|
||||
public sealed class FactoryBlackBoxAnalyzer
|
||||
@@ -250,8 +257,27 @@ public sealed class FactoryBlackBoxAnalyzer
|
||||
|
||||
var matrixSinkItems = hasResearchMatrixSink
|
||||
? new HashSet<int>(_catalog.ResearchMatrixItemIds) : new HashSet<int>();
|
||||
var classifications = BlackBoxMaterialClassifier.Classify(processGroups, grossProduction, grossConsumption,
|
||||
materialComplete, uncertainDemandItems, unknownDemand, matrixSinkItems, out var steadyStateBalance);
|
||||
IReadOnlyDictionary<int, BlackBoxItemClassification> classifications = null;
|
||||
IReadOnlyDictionary<int, double> steadyStateBalance = null;
|
||||
if (request.ProductionBasis == BlueprintProductionBasis.BottleneckIntermediate)
|
||||
{
|
||||
if (!materialComplete || !BlueprintBottleneckBalance.TryCalculate(processGroups,
|
||||
grossProduction, grossConsumption, matrixSinkItems,
|
||||
out var balancedProduction, out var balancedConsumption, out var balancedClassifications,
|
||||
out var balancedNet))
|
||||
diagnostics.Add(new ProductionDiagnostic(ProductionDiagnosticCode.BlueprintBasisUnavailable,
|
||||
"A complete material selection with a feasible final output is required for the bottleneck basis."));
|
||||
else
|
||||
{
|
||||
grossProduction = balancedProduction;
|
||||
grossConsumption = balancedConsumption;
|
||||
classifications = balancedClassifications;
|
||||
steadyStateBalance = balancedNet;
|
||||
}
|
||||
}
|
||||
if (classifications == null)
|
||||
classifications = BlackBoxMaterialClassifier.Classify(processGroups, grossProduction, grossConsumption,
|
||||
materialComplete, uncertainDemandItems, unknownDemand, matrixSinkItems, out steadyStateBalance);
|
||||
var flows = new List<ProductionItemFlow>();
|
||||
var allItems = new SortedSet<int>(grossProduction.Keys);
|
||||
allItems.UnionWith(grossConsumption.Keys);
|
||||
|
||||
@@ -116,7 +116,8 @@ public enum ProductionDiagnosticCode
|
||||
Unbounded,
|
||||
IterationLimit,
|
||||
Cancelled,
|
||||
ConservationFailure
|
||||
ConservationFailure,
|
||||
BlueprintBasisUnavailable
|
||||
}
|
||||
|
||||
public sealed class ProductionDiagnostic
|
||||
|
||||
+8
-4
@@ -17,8 +17,10 @@
|
||||
* Strict hotkey dectection for build menu, thus building hotkeys(0~9, F1~F10, X, U) are not triggered while holding Ctrl/Alt/Shift.
|
||||
* Fix a bug that warning popup on `Veins Utilization` upgraded to level 8000+
|
||||
* Sort blueprint structures before saving, to reduce generated blueprint data size a little
|
||||
* Add an `Auto-fill description` button and a `Proliferation` checkbox to the blueprint browser, copy, and paste panels, to fill the description with the blueprint's material flows per minute and its power demand
|
||||
* Replaces the main description with full-load material flows and writes power demand to a `Power` custom field, preserving other custom fields. Proliferation defaults to on when the blueprint contains a Spray Coater. Save the blueprint manually to keep the changes.
|
||||
* Add an `Auto-fill` entry to the description header in the blueprint browser, copy, and paste inspectors. Click it to open generation options without moving or resizing native fields or covering the file list
|
||||
* `Production basis` defaults to `Final-product output` each time the inspector opens, retaining rated final outputs and showing intermediate shortages and excess. Choose `Lowest intermediate throughput` to scale the final-product mix together to the bottleneck, using recipe ratios and shared intermediate demand. Complete, balanceable chains then have no internal shortages; unused intermediate capacity appears as excess. External inputs and final outputs use the same basis.
|
||||
* `Proliferation` defaults to on when the blueprint contains a Spray Coater; it can be changed manually. Power demand still estimates all selected buildings at full load in either production basis.
|
||||
* Replaces the main description with material flows per minute and writes power demand to a `Power` custom field, preserving other custom fields. If the bottleneck basis cannot be determined, the existing description is kept; check missing building settings and chain outputs, or select `Final-product output`. Save the blueprint manually to keep generated changes.
|
||||
* Large material rates use the largest exact `K`/`M`/`G` suffix with at most one decimal place; rates that cannot be shortened without losing display precision keep their ordinary format. Numbers with four or more integer digits use comma thousands separators, including before suffixes (for example, `12,345` and `1,234.5K`).
|
||||
* Increase maximum count of Metadata Instantiations to 20000 (from 2000)
|
||||
* Increase capacity of player order queue to 128 (from 16)
|
||||
@@ -222,8 +224,10 @@
|
||||
* 更严格的建造菜单热键检测,因此在按住Ctrl/Alt/Shift时不再会触发建造热键(0~9, F1~F10, X, U)
|
||||
* 修复了`矿物利用`升级到8000级以上时弹出警告的bug
|
||||
* 保存蓝图前对建筑进行排序,以减少生成的蓝图数据大小
|
||||
* 在蓝图浏览、复制和粘贴界面增加「自动填写说明」按钮和「增产」复选框,用蓝图每分钟的物料流量和耗电自动填写说明
|
||||
* 用满负荷运行时的物料流量替换原说明,将耗电写入「耗电」自定义字段,保留其他自定义字段。蓝图含喷涂机时默认勾选增产。填写后需手动保存蓝图。
|
||||
* 在蓝图浏览、复制和粘贴检查面板的说明标题行增加「自动填写」入口,点击展开生成选项,不移动或缩放原生字段,也不遮挡文件列表
|
||||
* 每次打开检查面板时,「产量基准」默认为「最终产物产量」,保留最终产物的额定产量,并显示中间产物的缺口和余量。选择「最低产量中间产物」后,按配方比例和共享中间物料的需求换算瓶颈,等比例缩放各最终产物。数据完整且可平衡的生产链没有内部缺口,未使用的中间产能列为「多余」;外部输入和最终输出采用同一基准。
|
||||
* 蓝图含喷涂机时默认勾选「增产」,也可手动修改。两种产量基准均按所选全部建筑满载估算耗电。
|
||||
* 用每分钟的物料流量替换原说明,将耗电写入「耗电」自定义字段,保留其他自定义字段。无法确定瓶颈基准时保留原说明;可检查缺失的建筑参数和生产链输出,或改选「最终产物产量」。填写后需手动保存蓝图。
|
||||
* 较大的物料流量使用能精确表示的最大 `K`/`M`/`G` 单位,小数最多一位;无法在保留显示精度的前提下缩写时,保留普通数字格式。整数部分达到四位的数字用逗号每三位分隔,带单位时也适用,例如 `12,345` 和 `1,234.5K`。
|
||||
* 将元数据提取的最大数量增加到20000(原来为2000)
|
||||
* 将玩家指令队列的容量增加到128(原来为16)
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
# Blueprint Description Validation
|
||||
|
||||
This document records the native layout evidence for the UXAssist description-header entry and the checks needed for in-game acceptance. Compilation and managed production checks do not establish compatibility with other blueprint mods.
|
||||
|
||||
## Native evidence
|
||||
|
||||
Inspected on 2026-11-01 after discovering Steam through `HKCU`'s Steam path and `steamapps/libraryfolders.vdf`:
|
||||
|
||||
- Original assembly: `D:/Steam/steamapps/common/Dyson Sphere Program/DSPGAME_Data/Managed/Assembly-CSharp.dll`, SHA-256 `EF314425DADE51F529F184F07BE136CD3C2660A6A81515603C7226FBE7AB1D8C`.
|
||||
- Native UI assets: `DSPGAME_Data/level0`, SHA-256 `04655A46BBEB113113688BCDC0E0EA8EC5F128B348E32194FC9743ADB48C8E91`.
|
||||
- The installed version history ends at `0.10.35.29151`; the Steam manifest reports build ID `25955035`. Assembly file version `0.0.0.0` alone does not identify this game build.
|
||||
|
||||
The original `UIBlueprintInspector.Refresh` sizes the description and native groups, places groups 2 through 4, and updates the scroll content height. It does not restore group 1's position. The previous UXAssist layout shifted group 1 and repeatedly offset the later groups and content height, making both the native refresh and other layout patches share ownership of those transforms.
|
||||
|
||||
The relevant original methods can be reproduced by decompiling the following types from the original assembly:
|
||||
|
||||
| Native method | Observed behavior |
|
||||
| --- | --- |
|
||||
| `UIBlueprintInspector.Refresh(bool forModify, bool refreshComponent, bool refreshCode, bool loadExistHead = false)` | Controls native group sizes, later group positions, and content height; reloads the main description input only when `forModify` is false. |
|
||||
| `UIBlueprintInspector._OnOpen()` and `_OnClose()` | Refresh and open native settings for the relevant mode; clear the blueprint on close. |
|
||||
| `ManualBehaviour._Close()` | Deactivates the inspector GameObject, hiding children. |
|
||||
| `UIBlueprintInspector.OnCustomFieldEndEdit(string str)` and `CollectExternalFields(int excludeTargetId = -1)` | Collect, escape, and validate pending custom-field edits through the native path. |
|
||||
| `UIBlueprintInspector.OnCopyClick()`, `OnSaveChangesClick()`, and `OnSaveClick()` | Serialize or save the current blueprint with the game's native workflow. |
|
||||
|
||||
The native `descGroupTrans` in all three inspectors contains a description label at the top and an input beginning 22 pixels below it. The compact UXAssist entry occupies the right side of this existing title row; it does not move the title, input, groups, or scroll content. Options appear only on request inside the inspector and close after successful generation or inspector closure. The browser's file grid remains outside the UXAssist controls. Following the separate native settings panel is unnecessary, and no per-frame positioning patch is used.
|
||||
|
||||
`UIBlueprintInspector.Refresh(forModify: true)` does not reload `descTextInput`. Successful generation must assign both the blueprint description and its input before using the native modification refresh. Pending custom fields must first pass through the native field collection and escaping rules. Native copy and save handlers serialize the current blueprint, so they remain the actions used to share or persist a generated description.
|
||||
|
||||
Decompiled methods and extracted rectangle data are development artifacts under `UXAssist/obj/native-inspector/`. Reinspect the installed original assembly and assets after a game update; the publicized compile-time references omit method bodies.
|
||||
|
||||
## Managed production checks
|
||||
|
||||
Run the production checks and normal UXAssist build from the repository root:
|
||||
|
||||
```powershell
|
||||
dotnet run --project UXAssist/tools/ProductionCheck/ProductionCheck.csproj -c Release
|
||||
dotnet build UXAssist/UXAssist.csproj -c Release --no-restore
|
||||
git diff --check
|
||||
```
|
||||
|
||||
The production-basis cases check an undersupplied chain, recipe-ratio conversion, shared intermediate demand, joint products, a cycle with an output, research-matrix outlets, no internal intermediate, power-only selections, very different capacity scales, and unavailable material settings or final output. A successful bottleneck report must conserve material, normalize inputs and outputs to the same throughput, preserve rated group capacity and power, and avoid internal shortages. Existing default-mode expectations must continue to pass.
|
||||
|
||||
## Manual acceptance
|
||||
|
||||
No in-game, Unity event-loop, or third-party mod integration test has been performed for this change. Repeat these checks at the target profile's resolutions and UI scales, with each installed blueprint UI mod. The header entry avoids native layout writes but another mod may use the same extension space.
|
||||
|
||||
1. Open all three inspectors in English and Simplified Chinese. Confirm the header entry is readable without covering the title or editable description. Open and close its options, generate, and close the inspector. The options must not remain over the file grid or survive an inspector close.
|
||||
2. Scroll the native description and custom fields and expand native foundation, fill-only, and reform settings. All native fields must retain their positions and sizes, and scrolling must reach every field.
|
||||
3. Reopen each inspector and repeatedly refresh or change the blueprint selection. Confirm there is one entry, options are initially closed, the production basis resets to final-product output on opening, Spray Coaters set the automatic proliferation default, and a manual checkbox choice survives content refreshes in the current session.
|
||||
4. Generate both production bases for an unbalanced chain. Final-product output should retain rated final capacity and show the missing intermediate; lowest intermediate throughput should reduce the common final-output mix, use correspondingly reduced external inputs, and show no internal shortage when the chain is complete and balanceable. Power should remain the same full-load estimate. Check necessary coproduct output separately from unused intermediate capacity.
|
||||
5. Edit the description and unrelated custom fields before generating. Generate twice, including with 20 custom fields and with existing English or Chinese power fields. Confirm unrelated edits survive, duplicate power fields are consolidated, and failed generation leaves the prior description and fields intact. Include missing building settings, an unavailable bottleneck basis, and the native description length limit.
|
||||
6. Save, copy the share code, and reopen or paste the blueprint through the native buttons. Confirm the generated main description, power field, and unrelated fields persist correctly. With a research-mode lab, confirm net produced matrices appear under Research without fabricated matrix imports or research speed.
|
||||
7. Restart the test profile without UXAssist, then restore it and restart again. Confirm the entry and options are absent without UXAssist, native fields keep their normal layout in both cases, and repeated opening and generation work with the installed blueprint mods. `OnDisable` and inspector-destruction cleanup are code-review checks unless a development harness exercises them; a supported user-facing hot-disable workflow is not assumed.
|
||||
@@ -40,12 +40,16 @@ When proliferation is enabled, ordinary recipes default to their native extra-pr
|
||||
|
||||
## Fixed-building analysis
|
||||
|
||||
The black box evaluates each selected building at full load, even if another selected building cannot provide all its inputs. It does not simulate belt layouts, startup storage, or logistics throughput. Missing inputs appear as `RequiredExternalSupply`; byproducts and internal deficits retain producer and consumer group attribution. `GrossProduction` and `GrossConsumption` remain separate even when a recipe returns some of its own input. Material classification uses each process's net per-item flow, so that return cannot become a false external requirement or coproduct.
|
||||
By default, the black box evaluates each selected building at full load, even if another selected building cannot provide all its inputs. It does not simulate belt layouts, startup storage, or logistics throughput. Missing inputs appear as `RequiredExternalSupply`; byproducts and internal deficits retain producer and consumer group attribution. `GrossProduction` and `GrossConsumption` remain separate even when a recipe returns some of its own input. Material classification uses each process's net per-item flow, so that return cannot become a false external requirement or coproduct. The optional blueprint production basis below changes material ledgers only when explicitly requested.
|
||||
|
||||
`IntermediateShortage` records the missing externally supplied portion of an item produced and consumed within the selection. `OverbuildSurplus` and `CoproductSurplus` are independent nullable amounts; both can be positive for the same item. Equivalent buildings are grouped by recipe, building, proliferation mode, speed, and operating settings in stable order. Whole-building reductions are tested against every item's shared balance: no final-product capacity may decrease and no internal shortage may increase. The reduction identifies redundancy only; gross flows, original full-load inputs, outputs, and power never change. Coproduct supply counts only retained whole buildings required by a process's other products, and internal net consumption is credited before exposing the remainder. Headroom from a single-output producer or a joint process's limiting product remains ordinary balance, not a coproduct. When materials are incomplete, overbuild and coproduct amounts are unknown rather than fabricated from a partial layout.
|
||||
|
||||
`SteadyStateExternalSupply` is a separate input estimate from the known processes. After whole-building classification for complete selections, a fractional reduction of surplus intermediate producers propagates downstream limits through upstream processes. The reduction stops after a bounded number of passes, because a lossless cycle such as charging and discharging accumulators can otherwise pass a tiny leftover around indefinitely; stopping early only keeps the input estimate conservative. Every reduction applies to the entire process, keeps rated final-product capacity, and never worsens an existing intermediate shortage; deterministic grouping and ordering keep results independent of blueprint building order. For partial selections, skip whole-building classification but still cap independently known upstream inputs against known demand. Protect any known inputs of an unresolved downstream process, or all known products if its possible inputs are unknown, instead of treating its demand as zero. Only the blueprint description uses this estimate, marked as a known portion when incomplete. Gross ledgers, `RequiredExternalSupply`, uncertain overbuild and coproduct classification, independently known rated outputs, and power retain their original meaning.
|
||||
|
||||
`FactoryBlackBoxRequest.ProductionBasis` defaults to `BlueprintProductionBasis.FinalProducts`, preserving these existing full-load semantics for all callers. The blueprint inspector can explicitly select `BottleneckIntermediate`. This mode reuses `TwoPhaseSimplex` to maximize one common fraction, no greater than 1, of the selected final-product mix, bounded by each selected process's capacity. Terminal consumers without item outputs, such as launchers, fuel generators, or precisely configured research, operate at that same fraction. Every internally produced material must balance without external imports; only materials with no selected producer can enter from outside. Capacities are converted through recipe ratios and shared consumption, rather than comparing different items' absolute per-minute rates. Joint products and selected cycles participate in the same balance; no unselected recipe is introduced. After maximizing the common fraction, the solver minimizes used building capacity, then remaining normalized surplus.
|
||||
|
||||
On a successful bottleneck calculation, all material ledgers, external inputs, final outputs, and research-matrix outlets use the normalized process rates. Unused positive intermediate capacity, including fractional building capacity, is reported as excess. This measures spare rated capacity rather than actual surplus stock or extra throughput; that capacity may not be simultaneously attainable from the normalized upstream flow. Surplus necessarily produced alongside required joint products remains coproduct output. A complete, balanceable chain therefore has no internal shortage within numerical tolerance. `Groups` and power retain the full selected building capacities, so normalized material rates must not be used to infer reduced power demand. Unknown material data, an unidentified final outlet, zero feasible throughput, or a failed or limited solve produces `BlueprintBasisUnavailable`; the inspector then preserves the existing description and fields. A pure cycle without a final outlet cannot establish this basis. A selection with no internal intermediate can retain its rated final output; a known selection with no material flows can still generate its power field without a material solve. Independently unknown power does not become known through balancing.
|
||||
|
||||
```csharp
|
||||
var capture = BlueprintSelectionReader.Capture(factory, selectedObjectIds);
|
||||
var selection = capture.CreateRequest(proliferationEnabled: true);
|
||||
@@ -66,11 +70,13 @@ Native research uses the current lab technology's matrix point requirements, wit
|
||||
|
||||
## Blueprint descriptions
|
||||
|
||||
The shared `UIBlueprintInspector` in browser, copy, and paste modes hosts `Auto-fill description` with `Proliferation` immediately to its right in one row above every description box. Move the first native inspector group down once, and offset later groups and the scroll height after each native refresh so the controls do not split the smaller fields from the main description. The checkbox initially reflects the blueprint's Spray Coater prefab capability and tracks content changes until manually changed in the current editing session; changing it does not modify the blueprint. Clicking the button captures only `blueprint.buildings` with `BlueprintSelectionReader.FromBlueprint` on the game thread, then runs `FactoryBlackBoxAnalyzer` against the captured catalog. The maximum supported proliferation level applies while each building keeps its acceleration or extra-products mode. Input coating is assumed to be supplied externally; no spray routing or spray consumption is inferred from the Spray Coater.
|
||||
The shared `UIBlueprintInspector` in browser, copy, and paste modes adds a compact `Auto-fill` entry to the existing description header. Its options open on demand within the inspector, rather than occupying the browser file grid. Only UXAssist-owned transforms are positioned: native fields, groups, anchors, and scroll height remain owned by the game. No per-frame layout patch or native-settings tracking is needed. Disable and destruction remove only the UXAssist controls.
|
||||
|
||||
`BlueprintDescriptionFormatter` builds replacement multiline `blueprint.desc` text in this order: optional `Missing:` and `Excess:` lines for intermediate shortages and true overbuild; `Input:` for external inputs capped by downstream demand; `Output:` for ordinary final products and necessary coproduct surplus; and `Research:` for positive net matrix production accepted by a selected research-mode lab. Each warning category has one label followed by comma-separated items; warnings do not repeat in Input, and a matrix on Research does not repeat in Output. It uses `SteadyStateExternalSupply` for complete and independently known partial inputs, labeling partial values as known portions. The assumed lab adds no numerical matrix consumption or external input; other buildings' known matrix demand is subtracted from the Research rate. Omit each empty line, including Research when no produced matrix remains. A single optional `Power` custom field separates factory and configured logistics consumption, omitting categories with no demand and removing the field altogether if neither consumes power; a present but unknown category displays `Unknown` rather than zero. Material rates remain items per minute even though the description labels omit the unit. Rates are rounded only for display. Large displayed rates use the largest exact K/M/G suffix with at most one decimal place (for example, 1,234,000 becomes 1,234K); if no suffix preserves that display precision, keep the ordinary number. Numbers with four or more integer digits use comma thousands separators, including coefficients before material or power units. Rates are ordered by item ID within each category, and use native item icon/name tags with comma-separated entries inside each description line. Uncertain final-product, overbuild, or coproduct conclusions are omitted. Veins and other scene objects are not blueprint entries or requested parameters.
|
||||
The options contain `Auto-fill description`, `Proliferation`, and a `Production basis` selector with a localized help tip. Each inspector open resets the basis to `Final-product output`, retaining existing calculation behavior; selecting `Lowest intermediate throughput` opts into `BottleneckIntermediate` for generation. The checkbox initially reflects the blueprint's Spray Coater prefab capability and tracks content changes until manually changed in the current editing session; changing it does not modify the blueprint. Generation captures only `blueprint.buildings` with `BlueprintSelectionReader.FromBlueprint` on the game thread, then runs `FactoryBlackBoxAnalyzer` against the captured catalog. A successful bottleneck solve supplies classification and steady-state balances directly; the original classifier runs only in final-product mode or after an unavailable bottleneck result. The maximum supported proliferation level applies while each building keeps its acceleration or extra-products mode. Input coating is assumed to be supplied externally; no spray routing or spray consumption is inferred from the Spray Coater.
|
||||
|
||||
`BlueprintDescriptionFields` matches only exact English or Simplified Chinese power field titles, updates or removes matching power fields, and collapses duplicate matches; all other fields, including input/output custom fields, stay intact. The inspector first collects pending custom-field edits, checks the native 2,000-character description limit and `kMaxFieldCount`, and applies native `ExternalFieldEscape` and `ExternalFieldUnescape` rules to the remaining power field. An invalid blueprint, unavailable catalog, failed calculation, malformed fields, overlong description, or insufficient capacity does not overwrite the description or generated fields. A successful update replaces the original description, synchronizes its native input control, and refreshes the inspector and share-code preview through the native modification path, leaving save and copy actions to the native buttons. Native `Refresh` recalculates the later groups' positions and the scroll height but not the first group's position, and `Refresh(forModify: true)` does not reload `descTextInput`, so assign it explicitly. `BlueprintData.Validate` strips newlines from custom fields, so multiline text belongs only in the main description. Recheck these inspector behaviors against the original DLL after game updates. The formatting and field updater remain pure-managed so `ProductionCheck` can verify them without loading Unity.
|
||||
`BlueprintDescriptionFormatter` builds replacement multiline `blueprint.desc` text in this order: optional `Missing:` and `Excess:` lines for intermediate shortages and excess classified by the selected production basis; `Input:` for external inputs capped by downstream demand; `Output:` for ordinary final products and necessary coproduct surplus; and `Research:` for positive net matrix production accepted by a selected research-mode lab. Each warning category has one label followed by comma-separated items; warnings do not repeat in Input, and a matrix on Research does not repeat in Output. It uses `SteadyStateExternalSupply` for complete and independently known partial inputs, labeling partial values as known portions. The assumed lab adds no numerical matrix consumption or external input; other buildings' known matrix demand is subtracted from the Research rate. Omit each empty line, including Research when no produced matrix remains. A single optional `Power` custom field separates factory and configured logistics consumption, omitting categories with no demand and removing the field altogether if neither consumes power; a present but unknown category displays `Unknown` rather than zero. Material rates remain items per minute even though the description labels omit the unit. Rates are rounded only for display. Large displayed rates use the largest exact K/M/G suffix with at most one decimal place (for example, 1,234,000 becomes 1,234K); if no suffix preserves that display precision, keep the ordinary number. Numbers with four or more integer digits use comma thousands separators, including coefficients before material or power units. Rates are ordered by item ID within each category, and use native item icon/name tags with comma-separated entries inside each description line. Uncertain final-product, overbuild, or coproduct conclusions are omitted. Veins and other scene objects are not blueprint entries or requested parameters.
|
||||
|
||||
`BlueprintDescriptionFields` matches only exact English or Simplified Chinese power field titles, updates or removes matching power fields, and collapses duplicate matches; all other fields, including input/output custom fields, stay intact. The inspector first collects pending custom-field edits, checks the native 2,000-character description limit and `kMaxFieldCount`, and applies native `ExternalFieldEscape` and `ExternalFieldUnescape` rules to the remaining power field. An invalid blueprint, unavailable catalog, failed calculation or bottleneck basis, malformed fields, overlong description, or insufficient capacity does not overwrite the description or generated fields. A successful update replaces the original description, synchronizes its native input control, and refreshes the inspector and share-code preview through the native modification path, leaving save and copy actions to the native buttons. Native `Refresh` owns the groups' positions and scroll height. `Refresh(forModify: true)` does not reload `descTextInput`, so assign it explicitly. `BlueprintData.Validate` strips newlines from custom fields, so multiline text belongs only in the main description. Recheck these inspector behaviors against the original DLL after game updates. The formatting and field updater remain pure-managed so `ProductionCheck` can verify them without loading Unity. See [blueprint description validation](BlueprintDescriptionValidation.md) for native layout evidence and manual compatibility checks.
|
||||
|
||||
## Special-process settings
|
||||
|
||||
@@ -123,7 +129,8 @@ Use a test game for the following manual checks. Compare full-load rates only wi
|
||||
- Select miners at different machine speeds, including one with a backed-up output, a gas collector, and renewable generators. Check native miner power scaling, full-load miner output regardless of the output backlog, per-minute gas output without added grid demand, and ideal rated renewable power rather than local conditions.
|
||||
- Select ray receivers in both modes, fuel generators, ejectors, and silos. Toggle proliferation and compare working power, generation, accumulator exchange, and Dyson demand as separate quantities. In a sandbox game, capture boosted artificial stars and launchers, and confirm that blueprint analysis of boosted buildings requires `BoostEnabled`.
|
||||
- Remove an upstream producer from a mixed production selection. Confirm that downstream capacity is unchanged and the missing material appears as required external supply. Add one producer more than downstream demand needs, and confirm that only that whole building's output is reported as excess.
|
||||
- In browser, copy, and paste inspectors, check localized control placement, Spray Coater defaults and manual overrides, and native item tags in the generated description and `Power` field. Generate twice and at the 20-field limit; verify that pending manual edits, unrelated fields, save/copy behavior, and ordinary blueprint sharing remain intact. Compare joint-production overbuild with necessary coproduct output without replacing original full-load rates or power.
|
||||
- In browser, copy, and paste inspectors, check the localized description-header entry and options, Spray Coater defaults and manual overrides, and native item tags in the generated description and `Power` field. Confirm options close after successful generation or inspector closure, the file grid stays usable, and native settings and description fields retain their positions. Generate twice and at the 20-field limit; verify that pending manual edits, unrelated fields, save/copy behavior, and ordinary blueprint sharing remain intact.
|
||||
- Compare both production bases on an undersupplied chain, uneven recipe ratios, shared intermediate branches, and a joint-product chain. Final-product mode must retain rated final outputs and expose intermediate shortages. Bottleneck mode must scale final outputs together, update raw inputs to the same throughput, and leave no internal shortage for a complete, balanceable chain. Confirm unused intermediate capacity and necessary coproduct output remain distinct, and that power stays at the same full-load estimate. Test a chain without internal intermediates, missing building settings, and a cycle without a final outlet; an unavailable bottleneck basis must preserve existing description and fields.
|
||||
- Place one research-mode lab alongside one or all six matrix production chains. Confirm the matrices' positive net production appears only in the Research line, other final products stay in Output, and known in-blueprint matrix consumption reduces the Research rate. Do not fabricate lab matrix imports, excess, or an estimated lab consumption rate; change current technology, add more labs, and toggle proliferation to check matrix routing stays independent while full working power updates. Without the lab, normal matrix output and overbuild rules resume.
|
||||
- Combine planner targets with shared coproducts, explicit raw-material boundaries, and alternate selected recipes. Confirm material conservation, shared surplus reuse, and no introduction of unselected recipes.
|
||||
- Toggle belt-signal proliferation and reload a game. Confirm that existing belts use the new catalog, item generation continues, and fractional production and consumption statistics remain independent.
|
||||
@@ -31,6 +31,7 @@ internal static class Program
|
||||
BlueprintMixedProducersAndCycles();
|
||||
SteadyStateLosslessCycle();
|
||||
BlueprintProliferationAndCompleteness();
|
||||
BlueprintProductionBases();
|
||||
BlueprintDescriptionFormattingAndFields();
|
||||
LogisticsChargingPower();
|
||||
FractionationFlow();
|
||||
@@ -2020,6 +2021,206 @@ internal static class Program
|
||||
"an unresolved but known downstream input prevents underestimating its upstream supply");
|
||||
}
|
||||
|
||||
private static void BlueprintProductionBases()
|
||||
{
|
||||
var analyzer = new FactoryBlackBoxAnalyzer(BlueprintCatalog());
|
||||
var request = BlueprintRequest(1);
|
||||
var rated = analyzer.Analyze(request);
|
||||
Equal(60, rated.ItemFlows[2].IntermediateShortage,
|
||||
"default final-product basis retains the selected downstream shortage");
|
||||
request.ProductionBasis = BlueprintProductionBasis.BottleneckIntermediate;
|
||||
var balanced = analyzer.Analyze(request);
|
||||
Check(balanced.MaterialComplete && !balanced.Diagnostics.Any(), "bottleneck coproduct chain is complete");
|
||||
Equal(0.5, balanced.ItemFlows[4].NetFlow, "limiting A capacity halves final output");
|
||||
Equal(1, balanced.ItemFlows[1].SteadyStateExternalSupply.Value, "raw input uses the same feasible basis");
|
||||
Equal(45, balanced.ItemFlows[3].CoproductSurplus.Value, "joint output retains its unavoidable B45 surplus");
|
||||
Equal(0, balanced.ItemFlows[2].IntermediateShortage, "bottleneck mode solves rather than hides missing A");
|
||||
Equal(60, balanced.ItemFlows[2].GrossConsumption, "downstream consumption is actually reduced");
|
||||
Equal(rated.Power.ConsumptionWatts, balanced.Power.ConsumptionWatts,
|
||||
"power still sizes all selected facilities at rated load");
|
||||
Equal(rated.Groups[1].ExecutionsPerMinute, balanced.Groups[1].ExecutionsPerMinute,
|
||||
"selected group capacities stay available separately from basis material flows");
|
||||
var labels = new BlueprintDescriptionLabels("Factory power", "Logistics power", "Missing: ",
|
||||
"Excess: ", "Unknown", "(known portion)", "Input: ", "Output: ", "Research: ");
|
||||
var balancedText = BlueprintDescriptionFormatter.Format(balanced, TestItemTag, labels);
|
||||
Check(!balancedText.Warnings.Contains("Missing:"), "a solved bottleneck does not format an internal shortage");
|
||||
Check(balancedText.Input == TestItemTag(1) + " x1", "formatted input uses normalized raw demand");
|
||||
Check(balancedText.Output == TestItemTag(3) + " x45, " + TestItemTag(4) + " x0.5",
|
||||
"formatted output uses the same normalized final and coproduct rates");
|
||||
|
||||
var ratioCatalog = BasisCatalog(new[]
|
||||
{
|
||||
Recipe(801, new[] { (1, 1.0) }, new[] { (2, 0.5) }),
|
||||
Recipe(802, new[] { (1, 1.0) }, new[] { (3, 100.0) }),
|
||||
Recipe(803, new[] { (2, 1.0), (3, 100.0) }, new[] { (4, 10.0) })
|
||||
});
|
||||
var ratioRequest = BasisRequest(801, 802, 803);
|
||||
var ratio = new FactoryBlackBoxAnalyzer(ratioCatalog).Analyze(ratioRequest);
|
||||
Equal(5, ratio.ItemFlows[4].NetFlow, "different intermediate units are converted through recipe ratios");
|
||||
Equal(50, ratio.ItemFlows[3].GrossConsumption, "large-count ingredient uses normalized demand");
|
||||
Equal(50, ratio.ItemFlows[3].OverbuildSurplus.Value, "unused intermediate capacity is excess");
|
||||
Equal(1.5, ratio.ItemFlows[1].SteadyStateExternalSupply.Value, "external inputs share the selected basis");
|
||||
Check(ratio.ItemFlows.Values.All(flow => flow.IntermediateShortage == 0),
|
||||
"ratio-scaled complete chain has no internal missing material");
|
||||
var ratioReverse = BasisRequest(803, 802, 801);
|
||||
var reversed = new FactoryBlackBoxAnalyzer(ratioCatalog).Analyze(ratioReverse);
|
||||
foreach (var flow in ratio.ItemFlows.Values)
|
||||
{
|
||||
Equal(flow.GrossProduction, reversed.ItemFlows[flow.ItemId].GrossProduction,
|
||||
"bottleneck production is independent of selection order");
|
||||
Equal(flow.GrossConsumption, reversed.ItemFlows[flow.ItemId].GrossConsumption,
|
||||
"bottleneck consumption is independent of selection order");
|
||||
}
|
||||
var unevenCatalog = BasisCatalog(new[]
|
||||
{
|
||||
Recipe(804, new[] { (1, 1.0) }, new[] { (2, 0.5) }),
|
||||
Recipe(805, new[] { (2, 1e8) }, new[] { (4, 1e8) })
|
||||
});
|
||||
var uneven = new FactoryBlackBoxAnalyzer(unevenCatalog).Analyze(BasisRequest(804, 805));
|
||||
Check(!uneven.Diagnostics.Any(), "a small common fraction can still represent meaningful known throughput");
|
||||
Equal(0.5, uneven.ItemFlows[4].NetFlow, "large capacity ratios do not become a false zero-throughput failure");
|
||||
|
||||
var sharedCatalog = BasisCatalog(new[]
|
||||
{
|
||||
Recipe(811, new[] { (1, 1.0) }, new[] { (2, 3.0) }),
|
||||
Recipe(812, new[] { (2, 2.0) }, new[] { (3, 3.0) }),
|
||||
Recipe(813, new[] { (2, 3.0) }, new[] { (4, 4.0) })
|
||||
});
|
||||
var shared = new FactoryBlackBoxAnalyzer(sharedCatalog).Analyze(BasisRequest(811, 812, 813));
|
||||
Equal(1.8, shared.ItemFlows[3].NetFlow, "shared material scales the first final branch by 3/5");
|
||||
Equal(2.4, shared.ItemFlows[4].NetFlow, "shared material scales the second final branch by 3/5");
|
||||
Equal(3, shared.ItemFlows[2].GrossConsumption, "shared demand sums both branches");
|
||||
Equal(1, shared.ItemFlows[1].RequiredExternalSupply, "shared branches use one common raw-input ledger");
|
||||
Equal(1, shared.ItemFlows[1].SteadyStateExternalSupply.Value,
|
||||
"steady-state supply matches the normalized shared-branch ledger");
|
||||
foreach (var report in new[] { balanced, ratio, shared })
|
||||
foreach (var flow in report.ItemFlows.Values.Where(flow => flow.ProducerGroups.Count > 0 &&
|
||||
flow.ConsumerGroups.Count > 0))
|
||||
Check(flow.NetFlow >= -1e-7 * Math.Max(1, Math.Max(flow.GrossProduction, flow.GrossConsumption)),
|
||||
"normalized gross ledgers conserve internal material within relative tolerance");
|
||||
|
||||
var knownMaterialsRequest = BlueprintRequest(1);
|
||||
knownMaterialsRequest.ProductionBasis = BlueprintProductionBasis.BottleneckIntermediate;
|
||||
knownMaterialsRequest.Buildings.Add(new ProductionBuildingSnapshot(3, 30, 0, 1, ProliferationMode.None));
|
||||
var unknownPower = analyzer.Analyze(knownMaterialsRequest);
|
||||
Check(unknownPower.MaterialComplete && !unknownPower.PowerComplete && !unknownPower.Diagnostics.Any(
|
||||
diagnostic => diagnostic.Code == ProductionDiagnosticCode.BlueprintBasisUnavailable),
|
||||
"unknown logistics power does not discard independently known bottleneck materials");
|
||||
Equal(0.5, unknownPower.ItemFlows[4].NetFlow, "known material throughput survives unknown power");
|
||||
var powerOnlyRequest = new FactoryBlackBoxRequest
|
||||
{ ProductionBasis = BlueprintProductionBasis.BottleneckIntermediate };
|
||||
powerOnlyRequest.Buildings.Add(new ProductionBuildingSnapshot(1, 31, 0, 1, ProliferationMode.None));
|
||||
powerOnlyRequest.Buildings.Add(new ProductionBuildingSnapshot(2, 30, 0, 1, ProliferationMode.None,
|
||||
operatingParameters: new Dictionary<string, double> { ["ChargePowerWatts"] = 500 }));
|
||||
var powerOnly = analyzer.Analyze(powerOnlyRequest);
|
||||
Check(powerOnly.MaterialComplete && powerOnly.PowerComplete && !powerOnly.Diagnostics.Any(),
|
||||
"known power-only blueprints have an empty material ledger that needs no basis reduction");
|
||||
Check(powerOnly.ItemFlows.Count == 0, "power-only blueprints do not fabricate material rates");
|
||||
var powerOnlyText = BlueprintDescriptionFormatter.Format(powerOnly, TestItemTag, labels);
|
||||
Check(powerOnlyText.Description.Length == 0 && powerOnlyText.Power == "Factory power 900W | Logistics power 500W",
|
||||
"power-only generation keeps its useful power field under the bottleneck option");
|
||||
powerOnlyRequest.ProductionBasis = BlueprintProductionBasis.FinalProducts;
|
||||
Equal(analyzer.Analyze(powerOnlyRequest).Power.ConsumptionWatts, powerOnly.Power.ConsumptionWatts,
|
||||
"power-only layouts have the same selected capacity under either material basis");
|
||||
|
||||
var cycleCatalog = BasisCatalog(new[]
|
||||
{
|
||||
Recipe(821, new[] { (1, 1.0) }, new[] { (2, 0.5) }),
|
||||
Recipe(822, new[] { (2, 2.0) }, new[] { (3, 1.0) }),
|
||||
Recipe(823, new[] { (3, 1.0) }, new[] { (2, 1.0), (4, 1.0) })
|
||||
});
|
||||
var cycle = new FactoryBlackBoxAnalyzer(cycleCatalog).Analyze(BasisRequest(821, 822, 823));
|
||||
Equal(0.5, cycle.ItemFlows[4].NetFlow, "returned intermediate participates in the bottleneck solve");
|
||||
Equal(0, cycle.ItemFlows[2].NetFlow, "cyclic first material conserves at normalized throughput");
|
||||
Equal(0, cycle.ItemFlows[3].NetFlow, "cyclic second material conserves at normalized throughput");
|
||||
Check(cycle.ItemFlows.Values.All(flow => flow.IntermediateShortage == 0),
|
||||
"a feasible cycle has no internal missing material");
|
||||
|
||||
var single = new FactoryBlackBoxAnalyzer(ratioCatalog).Analyze(BasisRequest(801));
|
||||
Equal(0.5, single.ItemFlows[2].NetFlow, "no-intermediate selection keeps final capacity");
|
||||
Equal(1, single.ItemFlows[1].SteadyStateExternalSupply.Value, "no-intermediate raw input remains known");
|
||||
var subset = new FactoryBlackBoxAnalyzer(ratioCatalog).Analyze(BasisRequest(803));
|
||||
Equal(10, subset.ItemFlows[4].NetFlow, "a blueprint subset treats absent upstream stages as external");
|
||||
Equal(100, subset.ItemFlows[3].SteadyStateExternalSupply.Value,
|
||||
"an absent producer remains a real external input");
|
||||
var unknownRequest = BasisRequest(801, 803, 9999);
|
||||
var unknown = new FactoryBlackBoxAnalyzer(ratioCatalog).Analyze(unknownRequest);
|
||||
Check(!unknown.MaterialComplete && unknown.Diagnostics.Any(diagnostic =>
|
||||
diagnostic.Code == ProductionDiagnosticCode.BlueprintBasisUnavailable),
|
||||
"unknown production prevents claiming a complete bottleneck balance");
|
||||
Equal(0.5, unknown.ItemFlows[2].IntermediateShortage,
|
||||
"unavailable basis preserves the original known shortage");
|
||||
var closed = new FactoryBlackBoxAnalyzer(BlueprintCatalog()).Analyze(BasisRequest(621, 622));
|
||||
Check(closed.Diagnostics.Any(diagnostic => diagnostic.Code == ProductionDiagnosticCode.BlueprintBasisUnavailable),
|
||||
"a pure closed loop has no final output from which to choose a common basis");
|
||||
var infeasibleCatalog = BasisCatalog(new[]
|
||||
{
|
||||
Recipe(831, new[] { (2, 1.0) }, new[] { (3, 1.0), (4, 1.0) }),
|
||||
Recipe(832, new[] { (3, 1.0) }, new[] { (2, 0.5) })
|
||||
});
|
||||
var infeasible = new FactoryBlackBoxAnalyzer(infeasibleCatalog).Analyze(BasisRequest(831, 832));
|
||||
Check(infeasible.Diagnostics.Any(diagnostic =>
|
||||
diagnostic.Code == ProductionDiagnosticCode.BlueprintBasisUnavailable),
|
||||
"zero feasible final throughput cannot masquerade as a balanced zero-output description");
|
||||
Equal(1, infeasible.ItemFlows[4].NetFlow, "infeasible basis keeps the original known final rate");
|
||||
|
||||
var sinkCatalog = BasisCatalog(new[]
|
||||
{
|
||||
Recipe(841, new[] { (1, 1.0) }, new[] { (2, 0.5) }),
|
||||
Recipe(842, new[] { (2, 1.0) }, Array.Empty<(int, double)>())
|
||||
});
|
||||
var sink = new FactoryBlackBoxAnalyzer(sinkCatalog).Analyze(BasisRequest(841, 842));
|
||||
Check(!sink.Diagnostics.Any(), "a consuming terminal process supplies a non-item final target");
|
||||
Equal(0.5, sink.ItemFlows[2].GrossConsumption,
|
||||
"a non-item terminal consumer follows the bottleneck instead of silently idling");
|
||||
|
||||
var researchCatalog = new ProductionCatalog(ratioCatalog.Items.Values, ratioCatalog.Recipes.Values,
|
||||
ratioCatalog.Buildings.Values, new[] { 0.0 }, new[] { 0.0 }, new[] { 1.0 },
|
||||
researchMatrixItemIds: new[] { 2 });
|
||||
var researchRequest = BasisRequest(801, 803);
|
||||
researchRequest.Buildings.Add(new ProductionBuildingSnapshot(9, 11, 0, 1, ProliferationMode.None,
|
||||
operatingParameters: new Dictionary<string, double>
|
||||
{ ["ResearchMode"] = 1, ["ResearchMatrixSink"] = 1 }));
|
||||
var research = new FactoryBlackBoxAnalyzer(researchCatalog).Analyze(researchRequest);
|
||||
Equal(5, research.ItemFlows[4].NetFlow, "known matrix consumption still constrains the final product");
|
||||
Equal(0, research.ItemFlows[2].NetFlow, "matrix outlet does not fabricate extra matrix consumption");
|
||||
Check(!research.ItemFlows[2].IsResearchProduct, "no positive matrix net means no research output");
|
||||
var matrixOnlyRequest = BasisRequest(801);
|
||||
matrixOnlyRequest.Buildings.Add(researchRequest.Buildings.Last());
|
||||
var matrixOnly = new FactoryBlackBoxAnalyzer(researchCatalog).Analyze(matrixOnlyRequest);
|
||||
Equal(0.5, matrixOnly.ItemFlows[2].NetFlow, "research outlet preserves produced matrices as a final target");
|
||||
Check(matrixOnly.ItemFlows[2].IsResearchProduct, "positive matrix net remains a research product");
|
||||
var researchConsumedRequest = BasisRequest(801, 803);
|
||||
researchConsumedRequest.Buildings[0] = new ProductionBuildingSnapshot(1, 10, 801, 3,
|
||||
ProliferationMode.None);
|
||||
researchConsumedRequest.Buildings.Add(researchRequest.Buildings.Last());
|
||||
var researchConsumed = new FactoryBlackBoxAnalyzer(researchCatalog).Analyze(researchConsumedRequest);
|
||||
Equal(0.5, researchConsumed.ItemFlows[2].NetFlow,
|
||||
"positive research matrix output subtracts real downstream matrix use");
|
||||
Check(researchConsumed.ItemFlows[2].IsResearchProduct,
|
||||
"matrix outlets preserve the positive net target alongside an ordinary final product");
|
||||
}
|
||||
|
||||
private static ProductionCatalog BasisCatalog(IEnumerable<ProductionRecipe> recipes)
|
||||
{
|
||||
return new ProductionCatalog(Enumerable.Range(1, 4)
|
||||
.Select(id => new ProductionItem(id, 0, id == 1, false, 0, 0)), recipes,
|
||||
new[]
|
||||
{
|
||||
new ProductionBuilding(10, ProductionRecipeCategory.Assemble, 1, 1000, 100),
|
||||
new ProductionBuilding(11, ProductionRecipeCategory.Research, 1, 2000, 200)
|
||||
}, new[] { 0.0 }, new[] { 0.0 }, new[] { 1.0 });
|
||||
}
|
||||
|
||||
private static FactoryBlackBoxRequest BasisRequest(params int[] recipes)
|
||||
{
|
||||
var request = new FactoryBlackBoxRequest { ProductionBasis = BlueprintProductionBasis.BottleneckIntermediate };
|
||||
for (var index = 0; index < recipes.Length; index++)
|
||||
request.Buildings.Add(new ProductionBuildingSnapshot(index + 1, 10, recipes[index], 1,
|
||||
ProliferationMode.None));
|
||||
return request;
|
||||
}
|
||||
|
||||
private static void BlueprintDescriptionFormattingAndFields()
|
||||
{
|
||||
var labels = new BlueprintDescriptionLabels("工厂耗电", "物流耗电", "缺少:", "多余:", "未知",
|
||||
|
||||
Reference in new issue
Block a user