Content update for ECS physics (#13291)
This commit is contained in:
@@ -6,8 +6,10 @@ using Content.Shared.Doors.Components;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Doors
|
||||
{
|
||||
@@ -114,6 +116,7 @@ namespace Content.IntegrationTests.Tests.Doors
|
||||
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
var entityManager = server.ResolveDependency<IEntityManager>();
|
||||
var physicsSystem = entityManager.System<SharedPhysicsSystem>();
|
||||
|
||||
PhysicsComponent physBody = null;
|
||||
EntityUid physicsDummy = default;
|
||||
@@ -140,13 +143,19 @@ namespace Content.IntegrationTests.Tests.Doors
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
// Push the human towards the airlock
|
||||
await server.WaitAssertion(() => Assert.That(physBody != null));
|
||||
await server.WaitPost(() => physBody.LinearVelocity = (0.5f, 0));
|
||||
await server.WaitAssertion(() => Assert.That(physBody, Is.Not.EqualTo(null)));
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
physicsSystem.SetLinearVelocity(physicsDummy, new Vector2(0.5f, 0f), body: physBody);
|
||||
});
|
||||
|
||||
for (var i = 0; i < 240; i += 10)
|
||||
{
|
||||
// Keep the airlock awake so they collide
|
||||
await server.WaitPost(() => entityManager.GetComponent<PhysicsComponent>(airlock).WakeBody());
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
physicsSystem.WakeBody(airlock);
|
||||
});
|
||||
|
||||
await server.WaitRunTicks(10);
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
@@ -6,6 +6,7 @@ using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
|
||||
namespace Content.IntegrationTests.Tests
|
||||
{
|
||||
@@ -20,7 +21,8 @@ namespace Content.IntegrationTests.Tests
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
var mapMan = server.ResolveDependency<IMapManager>();
|
||||
var sEntities = server.ResolveDependency<IEntityManager>();
|
||||
var entManager = server.ResolveDependency<IEntityManager>();
|
||||
var physicsSystem = entManager.System<SharedPhysicsSystem>();
|
||||
|
||||
EntityUid gridEnt = default;
|
||||
|
||||
@@ -30,18 +32,18 @@ namespace Content.IntegrationTests.Tests
|
||||
var grid = mapMan.CreateGrid(mapId);
|
||||
gridEnt = grid.Owner;
|
||||
|
||||
Assert.That(sEntities.HasComponent<ShuttleComponent>(gridEnt));
|
||||
Assert.That(sEntities.TryGetComponent<PhysicsComponent>(gridEnt, out var physicsComponent));
|
||||
Assert.That(entManager.HasComponent<ShuttleComponent>(gridEnt));
|
||||
Assert.That(entManager.TryGetComponent<PhysicsComponent>(gridEnt, out var physicsComponent));
|
||||
Assert.That(physicsComponent!.BodyType, Is.EqualTo(BodyType.Dynamic));
|
||||
Assert.That(sEntities.GetComponent<TransformComponent>(gridEnt).LocalPosition, Is.EqualTo(Vector2.Zero));
|
||||
physicsComponent.ApplyLinearImpulse(Vector2.One);
|
||||
Assert.That(entManager.GetComponent<TransformComponent>(gridEnt).LocalPosition, Is.EqualTo(Vector2.Zero));
|
||||
physicsSystem.ApplyLinearImpulse(gridEnt, Vector2.One, body: physicsComponent);
|
||||
});
|
||||
|
||||
await server.WaitRunTicks(1);
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
Assert.That<Vector2?>(sEntities.GetComponent<TransformComponent>(gridEnt).LocalPosition, Is.Not.EqualTo(Vector2.Zero));
|
||||
Assert.That(entManager.GetComponent<TransformComponent>(gridEnt).LocalPosition, Is.Not.EqualTo(Vector2.Zero));
|
||||
});
|
||||
await pairTracker.CleanReturnAsync();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user