Content update for ECS physics (#13291)

This commit is contained in:
metalgearsloth
2023-01-15 15:38:59 +11:00
committed by GitHub
parent 46d24bc36b
commit bf79d76666
61 changed files with 431 additions and 379 deletions

View File

@@ -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();
}