Revert 'Revert 'Solution Entities'' (#23168)

This commit is contained in:
TemporalOroboros
2023-12-29 04:47:43 -08:00
committed by GitHub
parent 93e1af2f8d
commit d23c8d5c19
180 changed files with 3541 additions and 2956 deletions

View File

@@ -1,5 +1,5 @@
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.FixedPoint;
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
@@ -51,7 +51,7 @@ public sealed class SolutionSystemTests
var entityManager = server.ResolveDependency<IEntityManager>();
var protoMan = server.ResolveDependency<IPrototypeManager>();
var containerSystem = entityManager.EntitySysManager.GetEntitySystem<SolutionContainerSystem>();
var containerSystem = entityManager.System<SolutionContainerSystem>();
var testMap = await pair.CreateTestMap();
var coordinates = testMap.GridCoords;
@@ -67,11 +67,11 @@ public sealed class SolutionSystemTests
beaker = entityManager.SpawnEntity("SolutionTarget", coordinates);
Assert.That(containerSystem
.TryGetSolution(beaker, "beaker", out var solution));
.TryGetSolution(beaker, "beaker", out var solutionEnt, out var solution));
solution.AddSolution(originalWater, protoMan);
Assert.That(containerSystem
.TryAddSolution(beaker, solution, oilAdded));
.TryAddSolution(solutionEnt.Value, oilAdded));
var water = solution.GetTotalPrototypeQuantity("Water");
var oil = solution.GetTotalPrototypeQuantity("Oil");
@@ -97,7 +97,7 @@ public sealed class SolutionSystemTests
var entityManager = server.ResolveDependency<IEntityManager>();
var protoMan = server.ResolveDependency<IPrototypeManager>();
var containerSystem = entityManager.EntitySysManager.GetEntitySystem<SolutionContainerSystem>();
var containerSystem = entityManager.System<SolutionContainerSystem>();
var coordinates = testMap.GridCoords;
EntityUid beaker;
@@ -112,11 +112,11 @@ public sealed class SolutionSystemTests
beaker = entityManager.SpawnEntity("SolutionTarget", coordinates);
Assert.That(containerSystem
.TryGetSolution(beaker, "beaker", out var solution));
.TryGetSolution(beaker, "beaker", out var solutionEnt, out var solution));
solution.AddSolution(originalWater, protoMan);
Assert.That(containerSystem
.TryAddSolution(beaker, solution, oilAdded), Is.False);
.TryAddSolution(solutionEnt.Value, oilAdded), Is.False);
var water = solution.GetTotalPrototypeQuantity("Water");
var oil = solution.GetTotalPrototypeQuantity("Oil");
@@ -141,7 +141,7 @@ public sealed class SolutionSystemTests
var entityManager = server.ResolveDependency<IEntityManager>();
var protoMan = server.ResolveDependency<IPrototypeManager>();
var testMap = await pair.CreateTestMap();
var containerSystem = entityManager.EntitySysManager.GetEntitySystem<SolutionContainerSystem>();
var containerSystem = entityManager.System<SolutionContainerSystem>();
var coordinates = testMap.GridCoords;
EntityUid beaker;
@@ -158,11 +158,11 @@ public sealed class SolutionSystemTests
beaker = entityManager.SpawnEntity("SolutionTarget", coordinates);
Assert.That(containerSystem
.TryGetSolution(beaker, "beaker", out var solution));
.TryGetSolution(beaker, "beaker", out var solutionEnt, out var solution));
solution.AddSolution(originalWater, protoMan);
Assert.That(containerSystem
.TryMixAndOverflow(beaker, solution, oilAdded, threshold, out var overflowingSolution));
.TryMixAndOverflow(solutionEnt.Value, oilAdded, threshold, out var overflowingSolution));
Assert.Multiple(() =>
{
@@ -194,7 +194,7 @@ public sealed class SolutionSystemTests
var entityManager = server.ResolveDependency<IEntityManager>();
var protoMan = server.ResolveDependency<IPrototypeManager>();
var containerSystem = entityManager.EntitySysManager.GetEntitySystem<SolutionContainerSystem>();
var containerSystem = entityManager.System<SolutionContainerSystem>();
var testMap = await pair.CreateTestMap();
var coordinates = testMap.GridCoords;
@@ -212,11 +212,11 @@ public sealed class SolutionSystemTests
beaker = entityManager.SpawnEntity("SolutionTarget", coordinates);
Assert.That(containerSystem
.TryGetSolution(beaker, "beaker", out var solution));
.TryGetSolution(beaker, "beaker", out var solutionEnt, out var solution));
solution.AddSolution(originalWater, protoMan);
Assert.That(containerSystem
.TryMixAndOverflow(beaker, solution, oilAdded, threshold, out _),
.TryMixAndOverflow(solutionEnt.Value, oilAdded, threshold, out _),
Is.False);
});

View File

@@ -1,11 +1,11 @@
using System.Linq;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.EntitySystems;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Shared.Chemistry.Reaction;
using Content.Shared.Chemistry.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using System.Linq;
namespace Content.IntegrationTests.Tests.Chemistry
{
@@ -34,8 +34,7 @@ namespace Content.IntegrationTests.Tests.Chemistry
var prototypeManager = server.ResolveDependency<IPrototypeManager>();
var testMap = await pair.CreateTestMap();
var coordinates = testMap.GridCoords;
var solutionSystem = server.ResolveDependency<IEntitySystemManager>()
.GetEntitySystem<SolutionContainerSystem>();
var solutionContainerSystem = entityManager.System<SolutionContainerSystem>();
foreach (var reactionPrototype in prototypeManager.EnumeratePrototypes<ReactionPrototype>())
{
@@ -43,30 +42,31 @@ namespace Content.IntegrationTests.Tests.Chemistry
Console.WriteLine($"Testing {reactionPrototype.ID}");
EntityUid beaker = default;
Solution component = null;
Entity<SolutionComponent>? solutionEnt = default!;
Solution solution = null;
await server.WaitAssertion(() =>
{
beaker = entityManager.SpawnEntity("TestSolutionContainer", coordinates);
Assert.That(solutionSystem
.TryGetSolution(beaker, "beaker", out component));
Assert.That(solutionContainerSystem
.TryGetSolution(beaker, "beaker", out solutionEnt, out solution));
foreach (var (id, reactant) in reactionPrototype.Reactants)
{
#pragma warning disable NUnit2045
Assert.That(solutionSystem
.TryAddReagent(beaker, component, id, reactant.Amount, out var quantity));
Assert.That(solutionContainerSystem
.TryAddReagent(solutionEnt.Value, id, reactant.Amount, out var quantity));
Assert.That(reactant.Amount, Is.EqualTo(quantity));
#pragma warning restore NUnit2045
}
solutionSystem.SetTemperature(beaker, component, reactionPrototype.MinimumTemperature);
solutionContainerSystem.SetTemperature(solutionEnt.Value, reactionPrototype.MinimumTemperature);
if (reactionPrototype.MixingCategories != null)
{
var dummyEntity = entityManager.SpawnEntity(null, MapCoordinates.Nullspace);
var mixerComponent = entityManager.AddComponent<ReactionMixerComponent>(dummyEntity);
mixerComponent.ReactionTypes = reactionPrototype.MixingCategories;
solutionSystem.UpdateChemicals(beaker, component, true, mixerComponent);
solutionContainerSystem.UpdateChemicals(solutionEnt.Value, true, mixerComponent);
}
});
@@ -79,7 +79,7 @@ namespace Content.IntegrationTests.Tests.Chemistry
var foundProductsMap = reactionPrototype.Products
.Concat(reactionPrototype.Reactants.Where(x => x.Value.Catalyst).ToDictionary(x => x.Key, x => x.Value.Amount))
.ToDictionary(x => x, _ => false);
foreach (var (reagent, quantity) in component.Contents)
foreach (var (reagent, quantity) in solution.Contents)
{
Assert.That(foundProductsMap.TryFirstOrNull(x => x.Key.Key == reagent.Prototype && x.Key.Value == quantity, out var foundProduct));
foundProductsMap[foundProduct.Value.Key] = true;

View File

@@ -80,7 +80,7 @@ public sealed class AbsorbentTest
var entityManager = server.ResolveDependency<IEntityManager>();
var absorbentSystem = entityManager.System<AbsorbentSystem>();
var solutionContainerSystem = entityManager.System<SolutionContainerSystem>();
var solutionContainerSystem = entityManager.System<SharedSolutionContainerSystem>();
var prototypeManager = server.ResolveDependency<IPrototypeManager>();
EntityUid user = default;
@@ -94,19 +94,19 @@ public sealed class AbsorbentTest
refillable = entityManager.SpawnEntity(RefillableDummyId, coordinates);
entityManager.TryGetComponent(absorbent, out component);
solutionContainerSystem.TryGetSolution(absorbent, AbsorbentComponent.SolutionName, out var absorbentSolution);
solutionContainerSystem.TryGetRefillableSolution(refillable, out var refillableSolution);
solutionContainerSystem.TryGetSolution(absorbent, AbsorbentComponent.SolutionName, out var absorbentSoln, out var absorbentSolution);
solutionContainerSystem.TryGetRefillableSolution(refillable, out var refillableSoln, out var refillableSolution);
// Arrange
if (testCase.InitialAbsorbentSolution.VolumeOfEvaporable > FixedPoint2.Zero)
solutionContainerSystem.AddSolution(absorbent, absorbentSolution, new Solution(EvaporablePrototypeId, testCase.InitialAbsorbentSolution.VolumeOfEvaporable));
solutionContainerSystem.AddSolution(absorbentSoln.Value, new Solution(EvaporablePrototypeId, testCase.InitialAbsorbentSolution.VolumeOfEvaporable));
if (testCase.InitialAbsorbentSolution.VolumeOfNonEvaporable > FixedPoint2.Zero)
solutionContainerSystem.AddSolution(absorbent, absorbentSolution, new Solution(NonEvaporablePrototypeId, testCase.InitialAbsorbentSolution.VolumeOfNonEvaporable));
solutionContainerSystem.AddSolution(absorbentSoln.Value, new Solution(NonEvaporablePrototypeId, testCase.InitialAbsorbentSolution.VolumeOfNonEvaporable));
if (testCase.InitialRefillableSolution.VolumeOfEvaporable > FixedPoint2.Zero)
solutionContainerSystem.AddSolution(refillable, refillableSolution, new Solution(EvaporablePrototypeId, testCase.InitialRefillableSolution.VolumeOfEvaporable));
solutionContainerSystem.AddSolution(refillableSoln.Value, new Solution(EvaporablePrototypeId, testCase.InitialRefillableSolution.VolumeOfEvaporable));
if (testCase.InitialRefillableSolution.VolumeOfNonEvaporable > FixedPoint2.Zero)
solutionContainerSystem.AddSolution(refillable, refillableSolution, new Solution(NonEvaporablePrototypeId, testCase.InitialRefillableSolution.VolumeOfNonEvaporable));
solutionContainerSystem.AddSolution(refillableSoln.Value, new Solution(NonEvaporablePrototypeId, testCase.InitialRefillableSolution.VolumeOfNonEvaporable));
// Act
absorbentSystem.Mop(user, refillable, absorbent, component);
@@ -138,7 +138,7 @@ public sealed class AbsorbentTest
var entityManager = server.ResolveDependency<IEntityManager>();
var absorbentSystem = entityManager.System<AbsorbentSystem>();
var solutionContainerSystem = entityManager.System<SolutionContainerSystem>();
var solutionContainerSystem = entityManager.System<SharedSolutionContainerSystem>();
var prototypeManager = server.ResolveDependency<IPrototypeManager>();
EntityUid user = default;
@@ -152,18 +152,18 @@ public sealed class AbsorbentTest
refillable = entityManager.SpawnEntity(SmallRefillableDummyId, coordinates);
entityManager.TryGetComponent(absorbent, out component);
solutionContainerSystem.TryGetSolution(absorbent, AbsorbentComponent.SolutionName, out var absorbentSolution);
solutionContainerSystem.TryGetRefillableSolution(refillable, out var refillableSolution);
solutionContainerSystem.TryGetSolution(absorbent, AbsorbentComponent.SolutionName, out var absorbentSoln, out var absorbentSolution);
solutionContainerSystem.TryGetRefillableSolution(refillable, out var refillableSoln, out var refillableSolution);
// Arrange
solutionContainerSystem.AddSolution(absorbent, absorbentSolution, new Solution(EvaporablePrototypeId, testCase.InitialAbsorbentSolution.VolumeOfEvaporable));
solutionContainerSystem.AddSolution(absorbentSoln.Value, new Solution(EvaporablePrototypeId, testCase.InitialAbsorbentSolution.VolumeOfEvaporable));
if (testCase.InitialAbsorbentSolution.VolumeOfNonEvaporable > FixedPoint2.Zero)
solutionContainerSystem.AddSolution(absorbent, absorbentSolution, new Solution(NonEvaporablePrototypeId, testCase.InitialAbsorbentSolution.VolumeOfNonEvaporable));
solutionContainerSystem.AddSolution(absorbentSoln.Value, new Solution(NonEvaporablePrototypeId, testCase.InitialAbsorbentSolution.VolumeOfNonEvaporable));
if (testCase.InitialRefillableSolution.VolumeOfEvaporable > FixedPoint2.Zero)
solutionContainerSystem.AddSolution(refillable, refillableSolution, new Solution(EvaporablePrototypeId, testCase.InitialRefillableSolution.VolumeOfEvaporable));
solutionContainerSystem.AddSolution(refillableSoln.Value, new Solution(EvaporablePrototypeId, testCase.InitialRefillableSolution.VolumeOfEvaporable));
if (testCase.InitialRefillableSolution.VolumeOfNonEvaporable > FixedPoint2.Zero)
solutionContainerSystem.AddSolution(refillable, refillableSolution, new Solution(NonEvaporablePrototypeId, testCase.InitialRefillableSolution.VolumeOfNonEvaporable));
solutionContainerSystem.AddSolution(refillableSoln.Value, new Solution(NonEvaporablePrototypeId, testCase.InitialRefillableSolution.VolumeOfNonEvaporable));
// Act
absorbentSystem.Mop(user, refillable, absorbent, component);