Generalize ReagentUnit into FixedPoint2 and use it for damage calculations (#5151)

* Damage units

* sum ext method
This commit is contained in:
mirrorcult
2021-11-03 16:48:03 -07:00
committed by GitHub
parent 8165d8f38c
commit 3ab4a30a0f
100 changed files with 730 additions and 601 deletions

View File

@@ -12,6 +12,7 @@ using Content.Shared.Audio;
using Content.Shared.Botany;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Examine;
using Content.Shared.FixedPoint;
using Content.Shared.Interaction;
using Content.Shared.Popups;
using Content.Shared.Random.Helpers;
@@ -560,7 +561,7 @@ namespace Content.Server.Botany.Components
}
else
{
var one = ReagentUnit.New(1);
var one = FixedPoint2.New(1);
foreach (var reagent in solutionSystem.RemoveEachReagent(solution, one))
{
var reagentProto = _prototypeManager.Index<ReagentPrototype>(reagent);
@@ -727,7 +728,7 @@ namespace Content.Server.Botany.Components
if (solutionSystem.TryGetDrainableSolution(usingItem.Uid, out var solution)
&& solutionSystem.TryGetSolution(Owner.Uid, SoilSolutionName, out var targetSolution))
{
var amount = ReagentUnit.New(5);
var amount = FixedPoint2.New(5);
var sprayed = false;
var targetEntity = Owner.Uid;
var solutionEntity = usingItem.Uid;
@@ -735,7 +736,7 @@ namespace Content.Server.Botany.Components
if (usingItem.TryGetComponent(out SprayComponent? spray))
{
sprayed = true;
amount = ReagentUnit.New(1);
amount = FixedPoint2.New(1);
SoundSystem.Play(Filter.Pvs(usingItem), spray.SpraySound.GetSound(), usingItem,
AudioHelpers.WithVariation(0.125f));

View File

@@ -1,5 +1,6 @@
using Content.Server.Chemistry.EntitySystems;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
@@ -50,10 +51,10 @@ namespace Content.Server.Botany.Components
solutionContainer.RemoveAllSolution();
foreach (var (chem, quantity) in Seed.Chemicals)
{
var amount = ReagentUnit.New(quantity.Min);
var amount = FixedPoint2.New(quantity.Min);
if (quantity.PotencyDivisor > 0 && Potency > 0)
amount += ReagentUnit.New(Potency / quantity.PotencyDivisor);
amount = ReagentUnit.New((int) MathHelper.Clamp(amount.Float(), quantity.Min, quantity.Max));
amount += FixedPoint2.New(Potency / quantity.PotencyDivisor);
amount = FixedPoint2.New((int) MathHelper.Clamp(amount.Float(), quantity.Min, quantity.Max));
solutionContainer.MaxVolume += amount;
solutionContainer.AddReagent(chem, amount);
}