From 033acbfcd666a9c5d0a5ccadd999bb12c41855bc Mon Sep 17 00:00:00 2001 From: deltanedas <39013340+deltanedas@users.noreply.github.com> Date: Mon, 24 Apr 2023 00:02:57 +0000 Subject: [PATCH] regenerate partial amounts (#15573) Co-authored-by: deltanedas <@deltanedas:kde.org> --- .../SolutionRegenerationSystem.cs | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Content.Server/Chemistry/EntitySystems/SolutionRegenerationSystem.cs b/Content.Server/Chemistry/EntitySystems/SolutionRegenerationSystem.cs index d6d74820d1..7e11044dc9 100644 --- a/Content.Server/Chemistry/EntitySystems/SolutionRegenerationSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/SolutionRegenerationSystem.cs @@ -1,5 +1,7 @@ using Content.Server.Chemistry.Components; using Content.Server.Chemistry.Components.SolutionManager; +using Content.Shared.Chemistry.Components; +using Content.Shared.FixedPoint; using Robust.Shared.Timing; namespace Content.Server.Chemistry.EntitySystems; @@ -29,7 +31,24 @@ public sealed class SolutionRegenerationSystem : EntitySystem // timer ignores if its full, it's just a fixed cycle regen.NextRegenTime = _timing.CurTime + regen.Duration; if (_solutionContainer.TryGetSolution(uid, regen.Solution, out var solution, manager)) - _solutionContainer.TryAddSolution(uid, solution, regen.Generated); + { + var amount = FixedPoint2.Min(solution.AvailableVolume, regen.Generated.Volume); + if (amount <= FixedPoint2.Zero) + continue; + + // dont bother cloning and splitting if adding the whole thing + Solution generated; + if (amount == regen.Generated.Volume) + { + generated = regen.Generated; + } + else + { + generated = regen.Generated.Clone().SplitSolution(amount); + } + + _solutionContainer.TryAddSolution(uid, solution, generated); + } } }