Solution rejig (#12428)

This commit is contained in:
Leon Friedrich
2023-01-12 16:41:40 +13:00
committed by GitHub
parent 38504f6412
commit 466384b081
61 changed files with 873 additions and 619 deletions

View File

@@ -1,4 +1,5 @@
using Content.Server.Botany.Components;
using Content.Shared.Chemistry.Components;
using Content.Shared.FixedPoint;
using Robust.Server.GameObjects;
@@ -17,17 +18,17 @@ public sealed partial class BotanySystem
sprite.LayerSetState(0, seed.PlantIconState);
}
var solutionContainer = _solutionContainerSystem.EnsureSolution(uid, produce.SolutionName);
solutionContainer.RemoveAllSolution();
Solution.ReagentQuantity[] reagents = new Solution.ReagentQuantity[seed.Chemicals.Count];
int i = 0;
foreach (var (chem, quantity) in seed.Chemicals)
{
var amount = FixedPoint2.New(quantity.Min);
if (quantity.PotencyDivisor > 0 && seed.Potency > 0)
amount += FixedPoint2.New(seed.Potency / quantity.PotencyDivisor);
amount = FixedPoint2.New((int) MathHelper.Clamp(amount.Float(), quantity.Min, quantity.Max));
solutionContainer.MaxVolume += amount;
solutionContainer.AddReagent(chem, amount);
reagents[i++] = new(chem, amount);
}
_solutionContainerSystem.EnsureSolution(uid, produce.SolutionName, reagents);
}
}

View File

@@ -211,7 +211,7 @@ namespace Content.Server.Botany.Systems
var split =_solutionSystem.Drain(solutionEntity, solution, amount);
if (split.TotalVolume == 0)
if (split.Volume == 0)
{
_popupSystem.PopupCursor(Loc.GetString("plant-holder-component-no-plant-message",
("owner", args.Used)), args.User);
@@ -220,7 +220,7 @@ namespace Content.Server.Botany.Systems
_popupSystem.PopupCursor(Loc.GetString("plant-holder-component-spray-message",
("owner", uid),
("amount", split.TotalVolume)), args.User, PopupType.Medium);
("amount", split.Volume)), args.User, PopupType.Medium);
_solutionSystem.TryAddSolution(targetEntity, targetSolution, split);
@@ -284,7 +284,7 @@ namespace Content.Server.Botany.Systems
{
// This deliberately discards overfill.
_solutionSystem.TryAddSolution(args.Used, solution2,
_solutionSystem.SplitSolution(args.Used, solution2, solution2.TotalVolume));
_solutionSystem.SplitSolution(args.Used, solution2, solution2.Volume));
ForceUpdateByExternalCause(uid, component);
}
@@ -780,7 +780,7 @@ namespace Content.Server.Botany.Systems
if (!_solutionSystem.TryGetSolution(uid, component.SoilSolutionName, out var solution))
return;
if (solution.TotalVolume > 0 && component.MutationLevel < 25)
if (solution.Volume > 0 && component.MutationLevel < 25)
{
var amt = FixedPoint2.New(1);
foreach (var (reagentId, quantity) in _solutionSystem.RemoveEachReagent(uid, solution, amt))