]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Filter prototypes checked by NoStaticPriceAndStackPrice test and skip spawning (...
authorTayrtahn <tayrtahn@gmail.com>
Thu, 13 Feb 2025 20:01:43 +0000 (15:01 -0500)
committerGitHub <noreply@github.com>
Thu, 13 Feb 2025 20:01:43 +0000 (21:01 +0100)
* Filter NoStaticPriceAndStackPrice ents for StaticPriceComponent

* Remove redundant TryComp

* Use dependency shortcuts

* hol' up

* This filter is redundant

* Don't need EntityManager now

Content.IntegrationTests/Tests/CargoTest.cs

index 37fd3a80f9a4f00ec17f99c963137c3f4a686d49..489054c4bd72a2874351a8c243332c79d1592276 100644 (file)
@@ -7,6 +7,7 @@ using Content.Server.Nutrition.Components;
 using Content.Server.Nutrition.EntitySystems;
 using Content.Shared.Cargo.Prototypes;
 using Content.Shared.IdentityManagement;
+using Content.Shared.Prototypes;
 using Content.Shared.Stacks;
 using Content.Shared.Tag;
 using Content.Shared.Whitelist;
@@ -104,51 +105,34 @@ public sealed class CargoTest
         await using var pair = await PoolManager.GetServerClient();
         var server = pair.Server;
 
-        var testMap = await pair.CreateTestMap();
-
-        var entManager = server.ResolveDependency<IEntityManager>();
-        var mapManager = server.ResolveDependency<IMapManager>();
-        var protoManager = server.ResolveDependency<IPrototypeManager>();
+        var protoManager = server.ProtoMan;
+        var compFact = server.ResolveDependency<IComponentFactory>();
 
         await server.WaitAssertion(() =>
         {
-            var mapId = testMap.MapId;
-            var grid = mapManager.CreateGridEntity(mapId);
-            var coord = new EntityCoordinates(grid.Owner, 0, 0);
-
             var protoIds = protoManager.EnumeratePrototypes<EntityPrototype>()
                 .Where(p => !p.Abstract)
                 .Where(p => !pair.IsTestPrototype(p))
-                .Where(p => !p.Components.ContainsKey("MapGrid")) // Grids are not for sale.
-                .Select(p => p.ID)
+                .Where(p => p.Components.ContainsKey("StaticPrice"))
                 .ToList();
 
             foreach (var proto in protoIds)
             {
-                var ent = entManager.SpawnEntity(proto, coord);
+                // Sanity check
+                Assert.That(proto.TryGetComponent<StaticPriceComponent>(out var staticPriceComp, compFact), Is.True);
 
-                if (entManager.TryGetComponent<StackPriceComponent>(ent, out var stackpricecomp)
-                    && stackpricecomp.Price > 0)
+                if (proto.TryGetComponent<StackPriceComponent>(out var stackPriceComp, compFact) && stackPriceComp.Price > 0)
                 {
-                    if (entManager.TryGetComponent<StaticPriceComponent>(ent, out var staticpricecomp))
-                    {
-                        Assert.That(staticpricecomp.Price, Is.EqualTo(0),
-                            $"The prototype {proto} has a StackPriceComponent and StaticPriceComponent whose values are not compatible with each other.");
-                    }
+                    Assert.That(staticPriceComp.Price, Is.EqualTo(0),
+                        $"The prototype {proto} has a StackPriceComponent and StaticPriceComponent whose values are not compatible with each other.");
                 }
 
-                if (entManager.HasComponent<StackComponent>(ent))
+                if (proto.HasComponent<StackComponent>(compFact))
                 {
-                    if (entManager.TryGetComponent<StaticPriceComponent>(ent, out var staticpricecomp))
-                    {
-                        Assert.That(staticpricecomp.Price, Is.EqualTo(0),
-                            $"The prototype {proto} has a StackComponent and StaticPriceComponent whose values are not compatible with each other.");
-                    }
+                    Assert.That(staticPriceComp.Price, Is.EqualTo(0),
+                        $"The prototype {proto} has a StackComponent and StaticPriceComponent whose values are not compatible with each other.");
                 }
-
-                entManager.DeleteEntity(ent);
             }
-            mapManager.DeleteMap(mapId);
         });
 
         await pair.CleanReturnAsync();