diff --git a/Content.IntegrationTests/Tests/Materials/ReclaimerLoopTest.cs b/Content.IntegrationTests/Tests/Materials/ReclaimerLoopTest.cs index 6e2a4ea229..310401ed59 100644 --- a/Content.IntegrationTests/Tests/Materials/ReclaimerLoopTest.cs +++ b/Content.IntegrationTests/Tests/Materials/ReclaimerLoopTest.cs @@ -2,13 +2,9 @@ using Content.IntegrationTests.Fixtures.Attributes; using Content.IntegrationTests.Tests.Interaction; using Content.IntegrationTests.Utility; using Content.Server.Materials; -using Content.Server.Spawners.Components; using Content.Shared.Materials; -using Content.Shared.Sprite; -using Content.Shared.Whitelist; using Robust.Shared.GameObjects; using Robust.Shared.Prototypes; -using System.Collections.Generic; namespace Content.IntegrationTests.Tests.Materials; @@ -19,15 +15,13 @@ namespace Content.IntegrationTests.Tests.Materials; [TestOf(typeof(MaterialReclaimerComponent))] public sealed class ReclaimerLoopTest : InteractionTest { - //ProtoIDs we need + // ProtoIDs we need private static readonly EntProtoId ApcId = "APCBasic"; - private static readonly EntProtoId FloorTileId = "FloorTileItemSteelCheckerDark"; + private static readonly EntProtoId FloorTileId = "FloorTileItemSteel"; private static readonly string[] Reclaimers = GameDataScrounger.EntitiesWithComponent("MaterialReclaimer"); [SidedDependency(Side.Server)] private readonly SharedMaterialReclaimerSystem _materialReclaimerSystem = null!; - [SidedDependency(Side.Server)] private readonly EntityWhitelistSystem _entityWhitelistSystem = null!; - [SidedDependency(Side.Server)] private readonly IComponentFactory _compFactory = null!; [Test] [TestCaseSource(nameof(Reclaimers))] @@ -37,78 +31,46 @@ public sealed class ReclaimerLoopTest : InteractionTest [TrackingIssue("https://github.com/space-wizards/space-station-14/issues/39691")] public async Task MaterialSpawnLoopTest(string reclaimerId) { - //Spawn the reclaimer + // Spawn the reclaimer await SpawnTarget(reclaimerId, PlayerCoords); - Assert.That(STarget, Is.Not.Null, "STarget was null, did the reclaimer spawn correctly?"); + Assume.That(STarget, Is.Not.Null, "STarget was null, did the reclaimer spawn correctly?"); var reclaimComp = Comp(Target); - //If the reclaimer can produce materials - var reclaimsMaterials = reclaimComp.ReclaimMaterials; - - //if the reclaimer has reclaimsMaterials and is able to produce materials - //go through all recyclable items, compile a HashSet of producible materials - HashSet> producibleMaterials = []; //If reclaimMaterials is false, this will stay empty - if (reclaimsMaterials) - { - foreach (var proto in ProtoMan.EnumeratePrototypes()) - { - //we don't care about items that don't recycle into anything physical - if (!proto.HasComp(_compFactory)) - continue; - - //spawners and random items mess things up quickly, avoid them too - if (proto.HasComp(_compFactory) || proto.HasComp(_compFactory)) - continue; - - var currentScrap = await Spawn(proto.ID); - var currentScrapUid = ToServer(currentScrap); - var currentScrapCompositionComp = Comp(currentScrap); - - //If it's on the whitelist for the reclaimer, and not on its blacklist. - if (_entityWhitelistSystem.CheckBoth(currentScrapUid, reclaimComp.Blacklist, reclaimComp.Whitelist)) - { - //for each material it produces, add it to the HashSet - foreach (var (mat, _) in currentScrapCompositionComp.MaterialComposition) - { - ProtoId matAsProto = ProtoMan.Index(mat); - producibleMaterials.Add(matAsProto); - } - } - - await Delete(currentScrapUid); - } - } // Power the reclaimer await SpawnEntity(ApcId, SEntMan.GetCoordinates(TargetCoords)); await RunTicks(1); - //Set reclaimer to enabled + // Set reclaimer to enabled await Server.WaitPost(() => { _materialReclaimerSystem.SetReclaimerEnabled((EntityUid)STarget, true); }); - //Assert that reclaimer enabled - Assert.That(reclaimComp.Enabled, "The reclaimer did not get or stay enabled"); + // Check that reclaimer enabled + Assume.That(reclaimComp.Enabled, "The reclaimer did not get or stay enabled"); - //put a floor tile down + // Put a floor tile down await InteractUsing(FloorTileId); + // Reclaimer can't reclaim materials? Job's done. + if (!reclaimComp.ReclaimMaterials) + Assert.Ignore("Cannot reclaim materials"); + using (Assert.EnterMultipleScope()) { - //For each producible Material, assert that it is not recyclable (and would thus cause a recycling loop) - foreach (ProtoId material in producibleMaterials) + // For each material, assert that it is not recyclable (and would thus cause a recycling loop) + foreach (var material in ProtoMan.EnumeratePrototypes()) { - var matStack = ProtoMan.Index(material).StackEntity; + var matStack = material.StackEntity; Assert.That( matStack, Is.Not.Null, - $"The material, {material}, did not have a stackentity associated with it. You may need to add a stackEntity to its Reagents/Materials yml file."); + $"The material, {material.ID}, did not have a stackentity associated with it. You may need to add a stackEntity to its Reagents/Materials yml file."); var matInHands = await PlaceInHands(matStack); var matInHandsUid = ToServer(matInHands); - //Assert we're holding material + // Assert we're holding material Assert.That( HandSys.GetActiveItem((SPlayer, Hands)), Is.EqualTo(matInHandsUid), @@ -116,7 +78,7 @@ public sealed class ReclaimerLoopTest : InteractionTest await Interact(); - //Assert Hands not empty + // Assert Hands not empty Assert.That( HandSys.GetActiveItem((SPlayer, Hands)), Is.Not.Null, diff --git a/Resources/Prototypes/Reagents/Materials/materials.yml b/Resources/Prototypes/Reagents/Materials/materials.yml index 3455026913..e139c8152b 100644 --- a/Resources/Prototypes/Reagents/Materials/materials.yml +++ b/Resources/Prototypes/Reagents/Materials/materials.yml @@ -113,6 +113,7 @@ - type: material id: Bones + stackEntity: MaterialBones1 name: materials-bones unit: materials-unit-piece icon: { sprite: Objects/Materials/materials.rsi, state: bones }