forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for anchored prototypes (space-wizards#30526)
Nothing fails at least but at some point will let us remove some hacky engine code.
- Loading branch information
1 parent
f264da8
commit 778bfe3
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
Content.IntegrationTests/Tests/Physics/AnchorPrototypeTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
{ | ||
/// <summary> | ||
/// Asserts that entityprototypes marked as anchored are also static physics bodies. | ||
/// </summary> | ||
[Test] | ||
public async Task TestStaticAnchorPrototypes() | ||
{ | ||
await using var pair = await PoolManager.GetServerClient(); | ||
|
||
var protoManager = pair.Server.ResolveDependency<IPrototypeManager>(); | ||
|
||
await pair.Server.WaitAssertion(() => | ||
{ | ||
foreach (var ent in protoManager.EnumeratePrototypes<EntityPrototype>()) | ||
{ | ||
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(); | ||
} | ||
} |