From 778bfe3355044835e7ee993c00a26cc456673522 Mon Sep 17 00:00:00 2001
From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Date: Wed, 31 Jul 2024 21:31:41 +1000
Subject: [PATCH] Add test for anchored prototypes (#30526)
Nothing fails at least but at some point will let us remove some hacky engine code.
---
.../Tests/Physics/AnchorPrototypeTest.cs | 43 +++++++++++++++++++
1 file changed, 43 insertions(+)
create mode 100644 Content.IntegrationTests/Tests/Physics/AnchorPrototypeTest.cs
diff --git a/Content.IntegrationTests/Tests/Physics/AnchorPrototypeTest.cs b/Content.IntegrationTests/Tests/Physics/AnchorPrototypeTest.cs
new file mode 100644
index 0000000000..a65e7d1fd6
--- /dev/null
+++ b/Content.IntegrationTests/Tests/Physics/AnchorPrototypeTest.cs
@@ -0,0 +1,43 @@
+using Robust.Shared.GameObjects;
+using Robust.Shared.Physics;
+using Robust.Shared.Physics.Components;
+using Robust.Shared.Prototypes;
+
+namespace Content.IntegrationTests.Tests.Physics;
+
+[TestFixture]
+public sealed class AnchorPrototypeTest
+{
+ ///
+ /// Asserts that entityprototypes marked as anchored are also static physics bodies.
+ ///
+ [Test]
+ public async Task TestStaticAnchorPrototypes()
+ {
+ await using var pair = await PoolManager.GetServerClient();
+
+ var protoManager = pair.Server.ResolveDependency();
+
+ await pair.Server.WaitAssertion(() =>
+ {
+ foreach (var ent in protoManager.EnumeratePrototypes())
+ {
+ if (!ent.Components.TryGetComponent("Transform", out var xformComp) ||
+ !ent.Components.TryGetComponent("Physics", out var physicsComp))
+ {
+ continue;
+ }
+
+ var xform = (TransformComponent)xformComp;
+ var physics = (PhysicsComponent)physicsComp;
+
+ if (!xform.Anchored)
+ continue;
+
+ Assert.That(physics.BodyType, Is.EqualTo(BodyType.Static), $"Found entity prototype {ent} marked as anchored but not static for physics.");
+ }
+ });
+
+ await pair.CleanReturnAsync();
+ }
+}