2021-03-31 12:41:23 -07:00
|
|
|
#nullable enable
|
2020-08-19 18:13:22 -04:00
|
|
|
|
|
|
|
|
using System.Threading.Tasks;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Server.Climbing.Components;
|
2020-08-19 18:13:22 -04:00
|
|
|
using NUnit.Framework;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Shared.GameObjects;
|
2020-08-19 18:13:22 -04:00
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
using Robust.Shared.Map;
|
2021-03-08 04:09:59 +11:00
|
|
|
using Robust.Shared.Physics;
|
2020-08-19 18:13:22 -04:00
|
|
|
|
|
|
|
|
namespace Content.IntegrationTests.Tests.GameObjects.Components.Movement
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
[TestOf(typeof(ClimbableComponent))]
|
|
|
|
|
[TestOf(typeof(ClimbingComponent))]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class ClimbUnitTest : ContentIntegrationTest
|
2020-08-19 18:13:22 -04:00
|
|
|
{
|
2021-02-09 22:04:47 +01:00
|
|
|
private const string Prototypes = @"
|
2020-11-18 15:30:36 +01:00
|
|
|
- type: entity
|
|
|
|
|
name: HumanDummy
|
|
|
|
|
id: HumanDummy
|
|
|
|
|
components:
|
|
|
|
|
- type: Climbing
|
|
|
|
|
- type: Physics
|
|
|
|
|
|
|
|
|
|
- type: entity
|
|
|
|
|
name: TableDummy
|
|
|
|
|
id: TableDummy
|
|
|
|
|
components:
|
|
|
|
|
- type: Climbable
|
2021-03-26 01:51:26 +00:00
|
|
|
- type: Physics
|
2020-11-18 15:30:36 +01:00
|
|
|
";
|
|
|
|
|
|
2020-08-19 18:13:22 -04:00
|
|
|
[Test]
|
|
|
|
|
public async Task Test()
|
|
|
|
|
{
|
2021-02-09 22:04:47 +01:00
|
|
|
var options = new ServerIntegrationOptions{ExtraPrototypes = Prototypes};
|
2021-11-06 11:49:59 +01:00
|
|
|
var server = StartServer(options);
|
2020-08-19 18:13:22 -04:00
|
|
|
|
2021-12-05 18:09:01 +01:00
|
|
|
EntityUid human;
|
|
|
|
|
EntityUid table;
|
2020-08-19 18:13:22 -04:00
|
|
|
ClimbingComponent climbing;
|
|
|
|
|
|
|
|
|
|
server.Assert(() =>
|
|
|
|
|
{
|
|
|
|
|
var mapManager = IoCManager.Resolve<IMapManager>();
|
|
|
|
|
mapManager.CreateNewMapEntity(MapId.Nullspace);
|
|
|
|
|
|
|
|
|
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
|
|
|
|
|
|
|
|
|
// Spawn the entities
|
2020-11-18 15:30:36 +01:00
|
|
|
human = entityManager.SpawnEntity("HumanDummy", MapCoordinates.Nullspace);
|
|
|
|
|
table = entityManager.SpawnEntity("TableDummy", MapCoordinates.Nullspace);
|
2020-08-19 18:13:22 -04:00
|
|
|
|
|
|
|
|
// Test for climb components existing
|
|
|
|
|
// Players and tables should have these in their prototypes.
|
2021-12-05 18:09:01 +01:00
|
|
|
Assert.That(entityManager.TryGetComponent(human, out climbing), "Human has no climbing");
|
|
|
|
|
Assert.That(entityManager.TryGetComponent(table, out ClimbableComponent? _), "Table has no climbable");
|
2020-08-19 18:13:22 -04:00
|
|
|
|
|
|
|
|
// Now let's make the player enter a climbing transitioning state.
|
|
|
|
|
climbing.IsClimbing = true;
|
2021-12-08 12:43:38 +01:00
|
|
|
climbing.TryMoveTo(entityManager.GetComponent<TransformComponent>(human).WorldPosition, entityManager.GetComponent<TransformComponent>(table).WorldPosition);
|
2021-12-05 18:09:01 +01:00
|
|
|
var body = entityManager.GetComponent<IPhysBody>(human);
|
2021-03-08 04:09:59 +11:00
|
|
|
// TODO: Check it's climbing
|
2020-08-19 18:13:22 -04:00
|
|
|
|
|
|
|
|
// Force the player out of climb state. It should immediately remove the ClimbController.
|
|
|
|
|
climbing.IsClimbing = false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await server.WaitIdleAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|