]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Remove AllComponentsOneEntityDeleteTest (#19965)
authorLeon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Sun, 10 Sep 2023 00:35:05 +0000 (12:35 +1200)
committerGitHub <noreply@github.com>
Sun, 10 Sep 2023 00:35:05 +0000 (19:35 -0500)
* Remove AllComponentsOneEntityDeleteTest

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

Content.IntegrationTests/Tests/EntityTest.cs
Content.Server/Chemistry/Components/SolutionManager/RandomFillSolutionComponent.cs
Content.Server/Chemistry/EntitySystems/SolutionRandomFillSystem.cs
Content.Server/Humanoid/Components/RandomHumanoidSpawnerComponent.cs
Content.Server/Humanoid/Systems/RandomHumanoidSystem.cs
Content.Server/Light/EntitySystems/PoweredLightSystem.cs
Content.Server/Power/EntitySystems/ApcSystem.cs
Content.Server/Power/SMES/SmesSystem.cs
Content.Server/Solar/EntitySystems/PowerSolarSystem.cs
Content.Shared/Containers/ContainerFillSystem.cs

index 0966e984bbcaffc9fd39946a4454055f4f0b5477..d1430cbe290b7d6f231c49cdbf98105a9eec7c49 100644 (file)
@@ -208,6 +208,7 @@ namespace Content.IntegrationTests.Tests
                 "GridFillComponent",
                 "Map", // We aren't testing a map entity in this test
                 "MapGrid",
+                "Broadphase",
                 "StationData", // errors when removed mid-round
                 "Actor", // We aren't testing actor components, those need their player session set.
                 "BlobFloorPlanBuilder", // Implodes if unconfigured.
@@ -292,136 +293,5 @@ namespace Content.IntegrationTests.Tests
 
             await pair.CleanReturnAsync();
         }
-
-        [Test]
-        public async Task AllComponentsOneEntityDeleteTest()
-        {
-            var skipComponents = new[]
-            {
-                "DebugExceptionOnAdd", // Debug components that explicitly throw exceptions
-                "DebugExceptionExposeData",
-                "DebugExceptionInitialize",
-                "DebugExceptionStartup",
-                "GridFillComponent",
-                "Map", // We aren't testing a map entity in this test
-                "MapGrid",
-                "StationData", // errors when deleted mid-round
-                "Actor", // We aren't testing actor components, those need their player session set.
-                "BlobFloorPlanBuilder", // Implodes if unconfigured.
-                "DebrisFeaturePlacerController", // Above.
-                "LoadedChunk", // Worldgen chunk loading malding.
-                "BiomeSelection", // Whaddya know, requires config.
-                "DeployableBarrier",
-            };
-
-            await using var pair = await PoolManager.GetServerClient();
-            var server = pair.Server;
-
-            var mapManager = server.ResolveDependency<IMapManager>();
-            var entityManager = server.ResolveDependency<IEntityManager>();
-            var componentFactory = server.ResolveDependency<IComponentFactory>();
-            var tileDefinitionManager = server.ResolveDependency<ITileDefinitionManager>();
-            var logmill = server.ResolveDependency<ILogManager>().GetSawmill("EntityTest");
-
-            MapGridComponent grid = default;
-
-            await server.WaitPost(() =>
-            {
-                // Create a one tile grid to stave off the grid 0 monsters
-                var mapId = mapManager.CreateMap();
-
-                mapManager.AddUninitializedMap(mapId);
-
-                grid = mapManager.CreateGrid(mapId);
-
-                var tileDefinition = tileDefinitionManager["Plating"];
-                var tile = new Tile(tileDefinition.TileId);
-
-                grid.SetTile(Vector2i.Zero, tile);
-                mapManager.DoMapInitialize(mapId);
-            });
-            await server.WaitRunTicks(5);
-
-            var distinctComponents = new List<(List<CompIdx> components, List<CompIdx> references)>
-            {
-                (new List<CompIdx>(), new List<CompIdx>())
-            };
-
-            // Split components into groups, ensuring that their references don't conflict
-            foreach (var type in componentFactory.AllRegisteredTypes)
-            {
-                var registration = componentFactory.GetRegistration(type);
-
-                for (var i = 0; i < distinctComponents.Count; i++)
-                {
-                    var (components, references) = distinctComponents[i];
-
-                    if (references.Intersect(registration.References).Any())
-                    {
-                        // Ensure the next list if this one has conflicting references
-                        if (i + 1 >= distinctComponents.Count)
-                        {
-                            distinctComponents.Add((new List<CompIdx>(), new List<CompIdx>()));
-                        }
-
-                        continue;
-                    }
-
-                    // Add the component and its references if no conflicting references were found
-                    components.Add(registration.Idx);
-                    references.AddRange(registration.References);
-                }
-            }
-
-            // Sanity check
-            Assert.That(distinctComponents, Is.Not.Empty);
-
-            await server.WaitAssertion(() =>
-            {
-                Assert.Multiple(() =>
-                {
-                    foreach (var (components, _) in distinctComponents)
-                    {
-                        var testLocation = grid.ToCoordinates();
-                        var entity = entityManager.SpawnEntity(null, testLocation);
-
-                        Assert.That(entityManager.GetComponent<MetaDataComponent>(entity).EntityInitialized);
-
-                        foreach (var type in components)
-                        {
-                            var component = (Component) componentFactory.GetComponent(type);
-
-                            // If the entity already has this component, if it was ensured or added by another
-                            if (entityManager.HasComponent(entity, component.GetType()))
-                            {
-                                continue;
-                            }
-
-                            var name = componentFactory.GetComponentName(component.GetType());
-
-                            // If this component is ignored
-                            if (skipComponents.Contains(name))
-                                continue;
-
-                            component.Owner = entity;
-                            logmill.Debug($"Adding component: {name}");
-
-                            // Note for the future coder: if an exception occurs where a component reference
-                            // was already occupied it might be because some component is ensuring another // initialize.
-                            // If so, search for cases of EnsureComponent<FailingType>, EnsureComponentWarn<FailingType>
-                            // and all others variations (out parameter)
-                            Assert.DoesNotThrow(() =>
-                                {
-                                    entityManager.AddComponent(entity, component);
-                                }, "Component '{0}' threw an exception.",
-                                name);
-                        }
-                        entityManager.DeleteEntity(entity);
-                    }
-                });
-            });
-
-            await pair.CleanReturnAsync();
-        }
     }
 }
index bbc06a056e2e8776ce15c064d08493cfdfc3a5b5..e4ee6bfc0b1c5b26009a10f4e38d39ebefb6bee3 100644 (file)
@@ -20,5 +20,5 @@ public sealed partial class RandomFillSolutionComponent : Component
     ///     Weighted random fill prototype Id. Used to pick reagent and quantity.
     /// </summary>
     [DataField("weightedRandomId", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<WeightedRandomFillSolutionPrototype>))]
-    public string WeightedRandomId { get; set; } = "default";
+    public string? WeightedRandomId;
 }
index 78afda99108a10c09e0e23e5f3f95699e131ff4a..efd7857147de8a7ddd3e575a219ae7aac9a1eeac 100644 (file)
@@ -22,6 +22,9 @@ public sealed class SolutionRandomFillSystem : EntitySystem
 
     private void OnRandomSolutionFillMapInit(EntityUid uid, RandomFillSolutionComponent component, MapInitEvent args)
     {
+        if (component.WeightedRandomId == null)
+            return;
+
         var target = _solutionsSystem.EnsureSolution(uid, component.Solution);
         var pick = _proto.Index<WeightedRandomFillSolutionPrototype>(component.WeightedRandomId).Pick(_random);
 
index f3b064c132359128a6dbbc686e963e7e9988fdcd..b56664fe19e398933170e3790d2936290b410335 100644 (file)
@@ -12,5 +12,5 @@ namespace Content.Server.Humanoid.Components;
 public sealed partial class RandomHumanoidSpawnerComponent : Component
 {
     [DataField("settings", customTypeSerializer: typeof(PrototypeIdSerializer<RandomHumanoidSettingsPrototype>))]
-    public string SettingsPrototypeId = default!;
+    public string? SettingsPrototypeId;
 }
index 6ec1770ccd2b938000abcf73b262aea0db755c58..6a17a52c3dc54bd45562f0f76e629de224dbb981 100644 (file)
@@ -29,7 +29,8 @@ public sealed class RandomHumanoidSystem : EntitySystem
     private void OnMapInit(EntityUid uid, RandomHumanoidSpawnerComponent component, MapInitEvent args)
     {
         QueueDel(uid);
-        SpawnRandomHumanoid(component.SettingsPrototypeId, Transform(uid).Coordinates, MetaData(uid).EntityName);
+        if (component.SettingsPrototypeId != null)
+            SpawnRandomHumanoid(component.SettingsPrototypeId, Transform(uid).Coordinates, MetaData(uid).EntityName);
     }
 
     public EntityUid SpawnRandomHumanoid(string prototypeId, EntityCoordinates coordinates, string name)
index acb354082a7d7cde666efc25698821d0fbfd4706..144190cf8e0bae00fb303a07851e96a83890f865 100644 (file)
@@ -246,7 +246,7 @@ namespace Content.Server.Light.EntitySystems
             ApcPowerReceiverComponent? powerReceiver = null,
             AppearanceComponent? appearance = null)
         {
-            if (!Resolve(uid, ref light, ref powerReceiver))
+            if (!Resolve(uid, ref light, ref powerReceiver, false))
                 return;
 
             // Optional component.
index d477fa4360f011168b392e91a1a1bb80ff19b26d..5356318aaa3fc84c505b99e9ee187038112b07bf 100644 (file)
@@ -120,7 +120,7 @@ public sealed class ApcSystem : EntitySystem
         ApcComponent? apc=null,
         PowerNetworkBatteryComponent? battery = null)
     {
-        if (!Resolve(uid, ref apc, ref battery))
+        if (!Resolve(uid, ref apc, ref battery, false))
             return;
 
         var newState = CalcChargeState(uid, battery.NetworkBattery);
index 7da8eb068811590d045523e9fb58083c4b5491d1..ebd56ee3e1b5308ecc0ad0cd3d154b2557f243ab 100644 (file)
@@ -57,7 +57,7 @@ internal sealed class SmesSystem : EntitySystem
 
     private int CalcChargeLevel(EntityUid uid, BatteryComponent? battery = null)
     {
-        if (!Resolve(uid, ref battery))
+        if (!Resolve(uid, ref battery, false))
             return 0;
 
         return ContentHelpers.RoundToLevels(battery.CurrentCharge, battery.MaxCharge, 6);
@@ -65,7 +65,7 @@ internal sealed class SmesSystem : EntitySystem
 
     private ChargeState CalcChargeState(EntityUid uid, PowerNetworkBatteryComponent? netBattery = null)
     {
-        if (!Resolve(uid, ref netBattery))
+        if (!Resolve(uid, ref netBattery, false))
             return ChargeState.Still;
 
         return (netBattery.CurrentSupply - netBattery.CurrentReceiving) switch
index 74f88bc0d1a7eb7dddee51e42fd5bb2909267db2..cead16b76d326e7dbc8eafbff1ab3d44fc5424f1 100644 (file)
@@ -172,10 +172,8 @@ namespace Content.Server.Solar.EntitySystems
             SolarPanelComponent? solar = null,
             PowerSupplierComponent? supplier = null)
         {
-            if (!Resolve(uid, ref solar, ref supplier))
-            {
+            if (!Resolve(uid, ref solar, ref supplier, false))
                 return;
-            }
 
             supplier.MaxSupply = (int) (solar.MaxSupply * solar.Coverage);
         }
index 81b9782dcde445c09492733919d6872a5f7268dd..88aa1def350f0af939ec992993fa974e5728013a 100644 (file)
@@ -17,10 +17,7 @@ public sealed class ContainerFillSystem : EntitySystem
     private void OnMapInit(EntityUid uid, ContainerFillComponent component, MapInitEvent args)
     {
         if (!TryComp(uid, out ContainerManagerComponent? containerComp))
-        {
-            Log.Error($"Entity {ToPrettyString(uid)} with a {nameof(ContainerFillComponent)} has no {nameof(ContainerManagerComponent)}.");
             return;
-        }
 
         var xform = Transform(uid);
         var coords = new EntityCoordinates(uid, Vector2.Zero);