Allow solutions to store extra reagent data (#19323)
This commit is contained in:
@@ -220,14 +220,16 @@ public sealed class MaterialReclaimerSystem : SharedMaterialReclaimerSystem
|
||||
if (!Resolve(reclaimer, ref reclaimerComponent, ref xform))
|
||||
return;
|
||||
|
||||
var overflow = new Solution();
|
||||
var totalChemicals = new Dictionary<string, FixedPoint2>();
|
||||
efficiency *= reclaimerComponent.Efficiency;
|
||||
|
||||
var totalChemicals = new Solution();
|
||||
|
||||
if (Resolve(item, ref composition, false))
|
||||
{
|
||||
foreach (var (key, value) in composition.ChemicalComposition)
|
||||
{
|
||||
totalChemicals[key] = totalChemicals.GetValueOrDefault(key) + value;
|
||||
// TODO use ReagentQuantity
|
||||
totalChemicals.AddReagent(key, value * efficiency, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,27 +240,15 @@ public sealed class MaterialReclaimerSystem : SharedMaterialReclaimerSystem
|
||||
{
|
||||
foreach (var quantity in solution.Contents)
|
||||
{
|
||||
totalChemicals[quantity.ReagentId] =
|
||||
totalChemicals.GetValueOrDefault(quantity.ReagentId) + quantity.Quantity;
|
||||
totalChemicals.AddReagent(quantity.Reagent.Prototype, quantity.Quantity * efficiency, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var (reagent, amount) in totalChemicals)
|
||||
_solutionContainer.TryTransferSolution(reclaimer, reclaimerComponent.OutputSolution, totalChemicals, totalChemicals.Volume);
|
||||
if (totalChemicals.Volume > 0)
|
||||
{
|
||||
var outputAmount = amount * efficiency * reclaimerComponent.Efficiency;
|
||||
_solutionContainer.TryAddReagent(reclaimer, reclaimerComponent.OutputSolution, reagent, outputAmount,
|
||||
out var accepted);
|
||||
var overflowAmount = outputAmount - accepted;
|
||||
if (overflowAmount > 0)
|
||||
{
|
||||
overflow.AddReagent(reagent, overflowAmount);
|
||||
}
|
||||
}
|
||||
|
||||
if (overflow.Volume > 0)
|
||||
{
|
||||
_puddle.TrySpillAt(reclaimer, overflow, out _, transformComponent: xform);
|
||||
_puddle.TrySpillAt(reclaimer, totalChemicals, out _, transformComponent: xform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user