2023-07-08 14:08:32 +10:00
|
|
|
|
using System.Numerics;
|
|
|
|
|
|
using Content.Server.Body.Systems;
|
2021-06-09 22:19:39 +02:00
|
|
|
|
using Content.Shared.Body.Components;
|
|
|
|
|
|
using Content.Shared.Body.Part;
|
|
|
|
|
|
using Content.Shared.Rotation;
|
2021-02-11 01:13:03 -08:00
|
|
|
|
using Robust.Shared.GameObjects;
|
2020-10-10 15:25:13 +02:00
|
|
|
|
using Robust.Shared.Map;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Content.IntegrationTests.Tests.Body
|
|
|
|
|
|
{
|
|
|
|
|
|
[TestFixture]
|
2022-10-23 00:46:28 +02:00
|
|
|
|
[TestOf(typeof(BodyPartComponent))]
|
2020-10-10 15:25:13 +02:00
|
|
|
|
[TestOf(typeof(BodyComponent))]
|
2022-06-19 20:22:28 -07:00
|
|
|
|
public sealed class LegTest
|
2020-10-10 15:25:13 +02:00
|
|
|
|
{
|
2023-08-05 16:16:48 +12:00
|
|
|
|
[TestPrototypes]
|
2021-02-09 22:04:47 +01:00
|
|
|
|
private const string Prototypes = @"
|
2020-11-18 15:30:36 +01:00
|
|
|
|
- type: entity
|
|
|
|
|
|
name: HumanBodyAndAppearanceDummy
|
|
|
|
|
|
id: HumanBodyAndAppearanceDummy
|
|
|
|
|
|
components:
|
|
|
|
|
|
- type: Appearance
|
|
|
|
|
|
- type: Body
|
2022-10-23 00:46:28 +02:00
|
|
|
|
prototype: Human
|
2021-06-27 19:02:46 +10:00
|
|
|
|
- type: StandingState
|
2020-11-18 15:30:36 +01:00
|
|
|
|
";
|
|
|
|
|
|
|
2020-10-10 15:25:13 +02:00
|
|
|
|
[Test]
|
|
|
|
|
|
public async Task RemoveLegsFallTest()
|
|
|
|
|
|
{
|
2023-08-25 02:56:51 +02:00
|
|
|
|
await using var pair = await PoolManager.GetServerClient();
|
|
|
|
|
|
var server = pair.Server;
|
2020-10-10 15:25:13 +02:00
|
|
|
|
|
2023-07-05 21:54:25 -07:00
|
|
|
|
EntityUid human = default!;
|
2020-10-10 15:25:13 +02:00
|
|
|
|
AppearanceComponent appearance = null;
|
2023-07-05 21:54:25 -07:00
|
|
|
|
|
2023-06-07 21:08:52 +10:00
|
|
|
|
var entityManager = server.ResolveDependency<IEntityManager>();
|
|
|
|
|
|
var mapManager = server.ResolveDependency<IMapManager>();
|
2023-07-05 21:54:25 -07:00
|
|
|
|
var appearanceSystem = entityManager.System<SharedAppearanceSystem>();
|
2023-09-21 00:23:02 -07:00
|
|
|
|
var xformSystem = entityManager.System<SharedTransformSystem>();
|
2020-10-10 15:25:13 +02:00
|
|
|
|
|
2024-07-02 20:01:37 -04:00
|
|
|
|
var map = await pair.CreateTestMap();
|
|
|
|
|
|
|
2020-10-10 15:25:13 +02:00
|
|
|
|
await server.WaitAssertion(() =>
|
|
|
|
|
|
{
|
2023-07-05 21:54:25 -07:00
|
|
|
|
BodyComponent body = null;
|
2020-10-10 15:25:13 +02:00
|
|
|
|
|
2023-07-05 21:54:25 -07:00
|
|
|
|
human = entityManager.SpawnEntity("HumanBodyAndAppearanceDummy",
|
2024-07-02 20:01:37 -04:00
|
|
|
|
new MapCoordinates(Vector2.Zero, map.MapId));
|
2020-10-10 15:25:13 +02:00
|
|
|
|
|
2023-07-05 21:54:25 -07:00
|
|
|
|
Assert.Multiple(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
Assert.That(entityManager.TryGetComponent(human, out body));
|
|
|
|
|
|
Assert.That(entityManager.TryGetComponent(human, out appearance));
|
|
|
|
|
|
});
|
2020-10-10 15:25:13 +02:00
|
|
|
|
|
2023-07-05 21:54:25 -07:00
|
|
|
|
Assert.That(!appearanceSystem.TryGetData(human, RotationVisuals.RotationState, out RotationState _, appearance));
|
2020-10-10 15:25:13 +02:00
|
|
|
|
|
2022-10-23 00:46:28 +02:00
|
|
|
|
var bodySystem = entityManager.System<BodySystem>();
|
2023-06-07 21:08:52 +10:00
|
|
|
|
var legs = bodySystem.GetBodyChildrenOfType(human, BodyPartType.Leg, body);
|
2020-10-10 15:25:13 +02:00
|
|
|
|
|
|
|
|
|
|
foreach (var leg in legs)
|
|
|
|
|
|
{
|
2024-07-02 20:01:37 -04:00
|
|
|
|
xformSystem.DetachEntity(leg.Id, entityManager.GetComponent<TransformComponent>(leg.Id));
|
2020-10-10 15:25:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
await server.WaitAssertion(() =>
|
|
|
|
|
|
{
|
2023-07-05 21:54:25 -07:00
|
|
|
|
#pragma warning disable NUnit2045
|
|
|
|
|
|
// Interdependent assertions.
|
|
|
|
|
|
Assert.That(appearanceSystem.TryGetData(human, RotationVisuals.RotationState, out RotationState state, appearance));
|
2020-10-10 15:25:13 +02:00
|
|
|
|
Assert.That(state, Is.EqualTo(RotationState.Horizontal));
|
2023-07-05 21:54:25 -07:00
|
|
|
|
#pragma warning restore NUnit2045
|
2020-10-10 15:25:13 +02:00
|
|
|
|
});
|
2023-08-25 02:56:51 +02:00
|
|
|
|
await pair.CleanReturnAsync();
|
2020-10-10 15:25:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|