Puddles & spreader refactor (#15191)
This commit is contained in:
@@ -8,6 +8,7 @@ using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.FixedPoint;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -127,6 +128,17 @@ public sealed partial class SolutionContainerSystem : EntitySystem
|
||||
return splitSol;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Splits a solution without the specified reagent.
|
||||
/// </summary>
|
||||
public Solution SplitSolutionWithout(EntityUid targetUid, Solution solutionHolder, FixedPoint2 quantity,
|
||||
string reagent)
|
||||
{
|
||||
var splitSol = solutionHolder.SplitSolutionWithout(quantity, reagent);
|
||||
UpdateChemicals(targetUid, solutionHolder);
|
||||
return splitSol;
|
||||
}
|
||||
|
||||
public void UpdateChemicals(EntityUid uid, Solution solutionHolder, bool needsReactionsProcessing = false, ReactionMixerComponent? mixerComponent = null)
|
||||
{
|
||||
DebugTools.Assert(solutionHolder.Name != null && TryGetSolution(uid, solutionHolder.Name, out var tmp) && tmp == solutionHolder);
|
||||
@@ -491,6 +503,37 @@ public sealed partial class SolutionContainerSystem : EntitySystem
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the most common reagent across all solutions by volume.
|
||||
/// </summary>
|
||||
/// <param name="component"></param>
|
||||
public ReagentPrototype? GetMaxReagent(SolutionContainerManagerComponent component)
|
||||
{
|
||||
if (component.Solutions.Count == 0)
|
||||
return null;
|
||||
|
||||
var reagentCounts = new Dictionary<string, FixedPoint2>();
|
||||
|
||||
foreach (var solution in component.Solutions.Values)
|
||||
{
|
||||
foreach (var reagent in solution.Contents)
|
||||
{
|
||||
reagentCounts.TryGetValue(reagent.ReagentId, out var existing);
|
||||
existing += reagent.Quantity;
|
||||
reagentCounts[reagent.ReagentId] = existing;
|
||||
}
|
||||
}
|
||||
|
||||
var max = reagentCounts.Max();
|
||||
|
||||
return _prototypeManager.Index<ReagentPrototype>(max.Key);
|
||||
}
|
||||
|
||||
public SoundSpecifier? GetSound(SolutionContainerManagerComponent component)
|
||||
{
|
||||
var max = GetMaxReagent(component);
|
||||
return max?.FootstepSound;
|
||||
}
|
||||
|
||||
// Thermal energy and temperature management.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user