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

@@ -8,6 +8,7 @@ using Content.Server.Hands.Components;
using Content.Server.Items;
using Content.Shared.Body.Components;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers;
using Content.Shared.Popups;
@@ -42,7 +43,7 @@ namespace Content.Server.Nutrition.Components
[ViewVariables]
[DataField("transferAmount")]
private ReagentUnit? TransferAmount { get; set; } = ReagentUnit.New(5);
private FixedPoint2? TransferAmount { get; set; } = FixedPoint2.New(5);
[DataField("utensilsNeeded")]
private UtensilType _utensilsNeeded = UtensilType.None;
@@ -65,7 +66,7 @@ namespace Content.Server.Nutrition.Components
return solution.CurrentVolume == 0
? 0
: Math.Max(1, (int) Math.Ceiling((solution.CurrentVolume / (ReagentUnit)TransferAmount).Float()));
: Math.Max(1, (int) Math.Ceiling((solution.CurrentVolume / (FixedPoint2)TransferAmount).Float()));
}
}
@@ -162,7 +163,7 @@ namespace Content.Server.Nutrition.Components
return false;
}
var transferAmount = TransferAmount != null ? ReagentUnit.Min((ReagentUnit)TransferAmount, solution.CurrentVolume) : solution.CurrentVolume;
var transferAmount = TransferAmount != null ? FixedPoint2.Min((FixedPoint2)TransferAmount, solution.CurrentVolume) : solution.CurrentVolume;
var split = solutionContainerSys.SplitSolution(Owner.Uid, solution, transferAmount);
var firstStomach = stomachs.FirstOrDefault(stomach => stomach.CanTransferSolution(split));