// Try to transfer as much solution as possible to the drain
- var transferSolution = _solutionContainerSystem.SplitSolution(containerSoln.Value,
- FixedPoint2.Min(containerSolution.Volume, drainSolution.AvailableVolume));
+ var amountToPutInDrain = drainSolution.AvailableVolume;
+ var amountToSpillOnGround = containerSolution.Volume - drainSolution.AvailableVolume;
- _solutionContainerSystem.TryAddSolution(drain.Solution.Value, transferSolution);
+ if (amountToPutInDrain > 0)
+ {
+ var solutionToPutInDrain = _solutionContainerSystem.SplitSolution(containerSoln.Value, amountToPutInDrain);
+ _solutionContainerSystem.TryAddSolution(drain.Solution.Value, solutionToPutInDrain);
+
+ _audioSystem.PlayPvs(drain.ManualDrainSound, target);
+ _ambientSoundSystem.SetAmbience(target, true);
+ }
- _audioSystem.PlayPvs(drain.ManualDrainSound, target);
- _ambientSoundSystem.SetAmbience(target, true);
- // If drain is full, spill
+ // Spill the remainder.
- if (drainSolution.MaxVolume == drainSolution.Volume)
+ if (amountToSpillOnGround > 0)
{
- _puddleSystem.TrySpillAt(Transform(target).Coordinates, containerSolution, out _);
+ var solutionToSpill = _solutionContainerSystem.SplitSolution(containerSoln.Value, amountToSpillOnGround);
+ _puddleSystem.TrySpillAt(Transform(target).Coordinates, solutionToSpill, out _);
_popupSystem.PopupEntity(
Loc.GetString("drain-component-empty-verb-target-is-full-message", ("object", target)),
container);