Content update for ECS physics (#13291)
This commit is contained in:
@@ -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