Generalize ReagentUnit into FixedPoint2 and use it for damage calculations (#5151)
* Damage units * sum ext method
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Reflection;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.Serialization.Manager;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
@@ -9,18 +10,18 @@ using Robust.UnitTesting.Shared.Serialization;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Chemistry
|
||||
{
|
||||
public class ReagentUnitSerializationTest : SerializationTest
|
||||
public class FixedPoint2SerializationTest : SerializationTest
|
||||
{
|
||||
protected override Assembly[] Assemblies => new[]
|
||||
{
|
||||
typeof(ReagentUnitSerializationTest).Assembly
|
||||
typeof(FixedPoint2SerializationTest).Assembly
|
||||
};
|
||||
|
||||
[Test]
|
||||
public void DeserializeNullTest()
|
||||
{
|
||||
var node = new ValueDataNode("null");
|
||||
var unit = Serialization.ReadValue<ReagentUnit?>(node);
|
||||
var unit = Serialization.ReadValue<FixedPoint2?>(node);
|
||||
|
||||
Assert.That(unit, Is.Null);
|
||||
}
|
||||
@@ -29,15 +30,15 @@ namespace Content.IntegrationTests.Tests.Chemistry
|
||||
public void DeserializeNullDefinitionTest()
|
||||
{
|
||||
var node = new MappingDataNode().Add("unit", "null");
|
||||
var definition = Serialization.ReadValueOrThrow<ReagentUnitTestDefinition>(node);
|
||||
var definition = Serialization.ReadValueOrThrow<FixedPoint2TestDefinition>(node);
|
||||
|
||||
Assert.That(definition.Unit, Is.Null);
|
||||
}
|
||||
}
|
||||
|
||||
[DataDefinition]
|
||||
public class ReagentUnitTestDefinition
|
||||
public class FixedPoint2TestDefinition
|
||||
{
|
||||
[DataField("unit")] public ReagentUnit? Unit { get; set; } = ReagentUnit.New(5);
|
||||
[DataField("unit")] public FixedPoint2? Unit { get; set; } = FixedPoint2.New(5);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user