Revert "Physics (#3452)"

This reverts commit 3e64fd56a1.
This commit is contained in:
Pieter-Jan Briers
2021-02-28 18:49:48 +01:00
parent eddec5fcce
commit 1eb0fbd8d0
211 changed files with 2560 additions and 2600 deletions

View File

@@ -20,10 +20,9 @@ namespace Content.IntegrationTests.Tests.Doors
components:
- type: Physics
anchored: false
fixtures:
- shape:
!type:PhysShapeAabb
bounds: ""-0.49,-0.49,0.49,0.49""
shapes:
- !type:PhysShapeAabb
bounds: ""-0.49,-0.49,0.49,0.49""
layer:
- Impassable
@@ -34,10 +33,9 @@ namespace Content.IntegrationTests.Tests.Doors
- type: Door
- type: Airlock
- type: Physics
fixtures:
- shape:
!type:PhysShapeAabb
bounds: ""-0.49,-0.49,0.49,0.49""
shapes:
- !type:PhysShapeAabb
bounds: ""-0.49,-0.49,0.49,0.49""
mask:
- Impassable
";
@@ -113,9 +111,9 @@ namespace Content.IntegrationTests.Tests.Doors
var mapManager = server.ResolveDependency<IMapManager>();
var entityManager = server.ResolveDependency<IEntityManager>();
IPhysBody physBody = null;
IEntity physicsDummy = null;
IEntity airlock = null;
TestController controller = null;
ServerDoorComponent doorComponent = null;
var physicsDummyStartingX = -1;
@@ -130,7 +128,9 @@ namespace Content.IntegrationTests.Tests.Doors
airlock = entityManager.SpawnEntity("AirlockDummy", new MapCoordinates((0, 0), mapId));
Assert.True(physicsDummy.TryGetComponent(out physBody));
Assert.True(physicsDummy.TryGetComponent(out IPhysicsComponent physics));
controller = physics.EnsureController<TestController>();
Assert.True(airlock.TryGetComponent(out doorComponent));
Assert.That(doorComponent.State, Is.EqualTo(SharedDoorComponent.DoorState.Closed));
@@ -139,13 +139,12 @@ namespace Content.IntegrationTests.Tests.Doors
await server.WaitIdleAsync();
// Push the human towards the airlock
Assert.That(physBody != null);
physBody.LinearVelocity = (0.5f, 0);
controller.LinearVelocity = (0.5f, 0);
for (var i = 0; i < 240; i += 10)
{
// Keep the airlock awake so they collide
airlock.GetComponent<IPhysBody>().WakeBody();
airlock.GetComponent<IPhysicsComponent>().WakeBody();
// Ensure that it is still closed
Assert.That(doorComponent.State, Is.EqualTo(SharedDoorComponent.DoorState.Closed));
@@ -160,5 +159,7 @@ namespace Content.IntegrationTests.Tests.Doors
// Blocked by the airlock
Assert.That(physicsDummy.Transform.MapPosition.X, Is.Negative.Or.Zero);
}
private class TestController : VirtualController { }
}
}

View File

@@ -7,7 +7,6 @@ using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Physics;
namespace Content.IntegrationTests.Tests.GameObjects.Components.Movement
{
@@ -60,12 +59,15 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Movement
// Now let's make the player enter a climbing transitioning state.
climbing.IsClimbing = true;
climbing.TryMoveTo(human.Transform.WorldPosition, table.Transform.WorldPosition);
var body = human.GetComponent<IPhysBody>();
// TODO: Check it's climbing
var body = human.GetComponent<IPhysicsComponent>();
Assert.That(body.HasController<ClimbController>(), "Player has no ClimbController");
// Force the player out of climb state. It should immediately remove the ClimbController.
climbing.IsClimbing = false;
Assert.That(!body.HasController<ClimbController>(), "Player wrongly has a ClimbController");
});
await server.WaitIdleAsync();

View File

@@ -0,0 +1,79 @@
using System.Threading.Tasks;
using Content.Server.GameObjects.Components.Pulling;
using Content.Shared.GameObjects.Components.Pulling;
using Content.Shared.Physics.Pull;
using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
namespace Content.IntegrationTests.Tests.Pulling
{
[TestFixture]
[TestOf(typeof(SharedPullableComponent))]
[TestOf(typeof(SharedPullerComponent))]
[TestOf(typeof(PullController))]
public class PullTest : ContentIntegrationTest
{
private const string Prototypes = @"
- type: entity
name: PullTestPullerDummy
id: PullTestPullerDummy
components:
- type: Puller
- type: Physics
- type: entity
name: PullTestPullableDummy
id: PullTestPullableDummy
components:
- type: Pullable
- type: Physics
";
[Test]
public async Task AnchoredNoPullTest()
{
var options = new ServerContentIntegrationOption {ExtraPrototypes = Prototypes};
var server = StartServerDummyTicker(options);
await server.WaitIdleAsync();
var mapManager = server.ResolveDependency<IMapManager>();
var entityManager = server.ResolveDependency<IEntityManager>();
await server.WaitAssertion(() =>
{
mapManager.CreateNewMapEntity(MapId.Nullspace);
var pullerEntity = entityManager.SpawnEntity("PullTestPullerDummy", MapCoordinates.Nullspace);
var pullableEntity = entityManager.SpawnEntity("PullTestPullableDummy", MapCoordinates.Nullspace);
var puller = pullerEntity.GetComponent<SharedPullerComponent>();
var pullable = pullableEntity.GetComponent<PullableComponent>();
var pullablePhysics = pullableEntity.GetComponent<PhysicsComponent>();
pullablePhysics.Anchored = false;
Assert.That(pullable.TryStartPull(puller.Owner));
Assert.That(pullable.Puller, Is.EqualTo(puller.Owner));
Assert.That(pullable.BeingPulled);
Assert.That(puller.Pulling, Is.EqualTo(pullable.Owner));
Assert.That(pullable.TryStopPull);
Assert.That(pullable.Puller, Is.Null);
Assert.That(pullable.BeingPulled, Is.False);
Assert.That(puller.Pulling, Is.Null);
pullablePhysics.Anchored = true;
Assert.That(pullable.TryStartPull(puller.Owner), Is.False);
Assert.That(pullable.Puller, Is.Null);
Assert.That(pullable.BeingPulled, Is.False);
Assert.That(puller.Pulling, Is.Null);
});
}
}
}

View File

@@ -5,7 +5,6 @@ using Content.Shared.Utility;
using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Physics.Broadphase;
namespace Content.IntegrationTests.Tests.Utility
{
@@ -21,10 +20,9 @@ namespace Content.IntegrationTests.Tests.Utility
name: {BlockerDummyId}
components:
- type: Physics
fixtures:
- shape:
!type:PhysShapeAabb
bounds: ""-0.49,-0.49,0.49,0.49""
shapes:
- !type:PhysShapeAabb
bounds: ""-0.49,-0.49,0.49,0.49""
mask:
- Impassable
";
@@ -39,7 +37,6 @@ namespace Content.IntegrationTests.Tests.Utility
var sMapManager = server.ResolveDependency<IMapManager>();
var sEntityManager = server.ResolveDependency<IEntityManager>();
var broady = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<SharedBroadPhaseSystem>();
await server.WaitAssertion(() =>
{
@@ -61,7 +58,6 @@ namespace Content.IntegrationTests.Tests.Utility
// Spawn a blocker with an Impassable mask
sEntityManager.SpawnEntity(BlockerDummyId, entityCoordinates);
broady.Update(0.016f);
// Cannot spawn something with an Impassable layer
Assert.Null(sEntityManager.SpawnIfUnobstructed(null, entityCoordinates, CollisionGroup.Impassable));