Mark ReagentUnit instance methods are readonly.
This commit is contained in:
@@ -19,7 +19,7 @@ namespace Content.Shared.Chemistry
|
|||||||
public static ReagentUnit Epsilon { get; } = new(1);
|
public static ReagentUnit Epsilon { get; } = new(1);
|
||||||
public static ReagentUnit Zero { get; } = new(0);
|
public static ReagentUnit Zero { get; } = new(0);
|
||||||
|
|
||||||
private double ShiftDown()
|
private readonly double ShiftDown()
|
||||||
{
|
{
|
||||||
return _value / Math.Pow(10, Shift);
|
return _value / Math.Pow(10, Shift);
|
||||||
}
|
}
|
||||||
@@ -164,17 +164,17 @@ namespace Content.Shared.Chemistry
|
|||||||
return a._value > b._value;
|
return a._value > b._value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float Float()
|
public readonly float Float()
|
||||||
{
|
{
|
||||||
return (float) ShiftDown();
|
return (float) ShiftDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double Double()
|
public readonly double Double()
|
||||||
{
|
{
|
||||||
return ShiftDown();
|
return ShiftDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Int()
|
public readonly int Int()
|
||||||
{
|
{
|
||||||
return (int) ShiftDown();
|
return (int) ShiftDown();
|
||||||
}
|
}
|
||||||
@@ -204,14 +204,15 @@ namespace Content.Shared.Chemistry
|
|||||||
return reagent < min ? min : reagent > max ? max : reagent;
|
return reagent < min ? min : reagent > max ? max : reagent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
public override readonly bool Equals(object obj)
|
||||||
{
|
{
|
||||||
return obj is ReagentUnit unit &&
|
return obj is ReagentUnit unit &&
|
||||||
_value == unit._value;
|
_value == unit._value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override readonly int GetHashCode()
|
||||||
{
|
{
|
||||||
|
// ReSharper disable once NonReadonlyMemberInGetHashCode
|
||||||
return HashCode.Combine(_value);
|
return HashCode.Combine(_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,19 +221,19 @@ namespace Content.Shared.Chemistry
|
|||||||
_value = FromFloat(FloatFromString(value));
|
_value = FromFloat(FloatFromString(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() => $"{ShiftDown().ToString(CultureInfo.InvariantCulture)}";
|
public override readonly string ToString() => $"{ShiftDown().ToString(CultureInfo.InvariantCulture)}";
|
||||||
|
|
||||||
public string Serialize()
|
public readonly string Serialize()
|
||||||
{
|
{
|
||||||
return ToString();
|
return ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(ReagentUnit other)
|
public readonly bool Equals(ReagentUnit other)
|
||||||
{
|
{
|
||||||
return _value == other._value;
|
return _value == other._value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int CompareTo(ReagentUnit other)
|
public readonly int CompareTo(ReagentUnit other)
|
||||||
{
|
{
|
||||||
if(other._value > _value)
|
if(other._value > _value)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user