Fix reagent spill errors (#1180)

Co-authored-by: ComicIronic <comicironic@gmail.com>
This commit is contained in:
DrSmugleaf
2020-07-02 20:31:40 +02:00
committed by GitHub
parent ebebb3603a
commit dbd9ee1671
10 changed files with 128 additions and 59 deletions

View File

@@ -175,6 +175,21 @@ namespace Content.Shared.Chemistry
return a < b ? a : b;
}
public static ReagentUnit Max(ReagentUnit a, ReagentUnit b)
{
return a > b ? a : b;
}
public static ReagentUnit Clamp(ReagentUnit reagent, ReagentUnit min, ReagentUnit max)
{
if (min > max)
{
throw new ArgumentException($"{nameof(min)} {min} cannot be larger than {nameof(max)} {max}");
}
return reagent < min ? min : reagent > max ? max : reagent;
}
public override bool Equals(object obj)
{
return obj is ReagentUnit unit &&