CatStation/Content.IntegrationTests/Tests/Materials/ReclaimerLoopTest.cs
SlamBamActionman 0cd76c7bac
Add industrial smelters (admin only) (#43651)
* Initial commit with shredder base functionality

* Fix items being deleted and make items continue moving after a grid tile gets deleted

* Make a bunch of previously unpullable/unrecyclable things work

* temp commit

* Fix the recycling hitbox to actually be good code

* Fix material spawning via tiles

* Finish up the prototype visuals for the shredder

* SHRED EVERYTHING

* Add reduced efficiency for recycling with shreder

* Fix miss in conflict merge

* Make more things pullable

* Update shredder textures to look different to recyclers

* Remove unused

* "fix" repairability and sprites

* Update sprites, set up TODO-s

* Fix switches, description

* Fix up some comments

* Add "Do Not Map" to the smelter

* Add to meta.json

* Review fixes

* Review changes

* Review changes

* Remove readonly in new system

* Aaaand partial class

* Fix the final test issues

* Update and resolve merge conflicts

* Update the impulse strength to match new mass values

* Fix issues after merge conflict

* Update size, fix physics resolve errors, prevent computers/circuitboards from being deleted

* Review comments

* Fix tiles giving steel

* Add a todo about tilestacking
2026-09-22 09:04:21 +00:00

89 lines
3.6 KiB
C#

using Content.IntegrationTests.Fixtures.Attributes;
using Content.IntegrationTests.Tests.Interaction;
using Content.IntegrationTests.Utility;
using Content.Server.Materials;
using Content.Shared.Materials;
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
namespace Content.IntegrationTests.Tests.Materials;
/// <summary>
/// Tests to prevent Recycler loops, where the product of one recycling can be recycled again.
/// </summary>
[TestOf(typeof(MaterialReclaimerSystem))]
[TestOf(typeof(MaterialReclaimerComponent))]
public sealed class ReclaimerLoopTest : InteractionTest
{
// ProtoIDs we need
private static readonly EntProtoId ApcId = "APCBasic";
private static readonly EntProtoId FloorTileId = "FloorTileItemSteel";
private static readonly string[] Reclaimers = GameDataScrounger.EntitiesWithComponent("MaterialReclaimer");
[SidedDependency(Side.Server)] private readonly SharedMaterialReclaimerSystem _materialReclaimerSystem = null!;
[Test]
[TestCaseSource(nameof(Reclaimers))]
[TestOf(typeof(MaterialReclaimerSystem))]
[TestOf(typeof(MaterialReclaimerComponent))]
[Description("For every material that a reclaimer can spawn, make sure that it cannot get stuck in a loop of spawning then recycling.")]
[TrackingIssue("https://github.com/space-wizards/space-station-14/issues/39691")]
public async Task MaterialSpawnLoopTest(string reclaimerId)
{
// Spawn the reclaimer
await SpawnTarget(reclaimerId, PlayerCoords);
Assume.That(STarget, Is.Not.Null, "STarget was null, did the reclaimer spawn correctly?");
var reclaimComp = Comp<MaterialReclaimerComponent>(Target);
// Put a floor tile down
await InteractUsing(FloorTileId);
// Power the reclaimer
await SpawnEntity(ApcId, SEntMan.GetCoordinates(TargetCoords));
await RunTicks(1);
// Set reclaimer to enabled
await Server.WaitPost(() =>
{
_materialReclaimerSystem.SetReclaimerEnabled((EntityUid)STarget, true);
});
// Check that reclaimer enabled
Assume.That(reclaimComp.Enabled, "The reclaimer did not get or stay enabled");
// Reclaimer can't reclaim materials? Job's done.
if (!reclaimComp.ReclaimMaterials)
Assert.Ignore("Cannot reclaim materials");
using (Assert.EnterMultipleScope())
{
// For each material, assert that it is not recyclable (and would thus cause a recycling loop)
foreach (var material in ProtoMan.EnumeratePrototypes<MaterialPrototype>())
{
var matStack = material.StackEntity;
Assert.That(
matStack,
Is.Not.Null,
$"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.That(
HandSys.GetActiveItem((SPlayer, Hands)),
Is.EqualTo(matInHandsUid),
$"The material, {matStack}, never got put in our hands.");
await Interact();
// Assert Hands not empty
Assert.That(
HandSys.GetActiveItem((SPlayer, Hands)),
Is.Not.Null,
$"The material that should not have been reclaimed, {matStack}, is no longer in our hands. The reclaimer was {reclaimerId}");
}
}
}
}