1
0

BuckleMovementTest.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using Content.Shared.Alert;
  2. using Content.Shared.Buckle.Components;
  3. using Robust.Shared.Maths;
  4. namespace Content.IntegrationTests.Tests.Movement;
  5. public sealed class BuckleMovementTest : MovementTest
  6. {
  7. // Check that interacting with a chair straps you to it and prevents movement.
  8. [Test]
  9. public async Task ChairTest()
  10. {
  11. await SpawnTarget("Chair");
  12. var cAlert = Client.System<AlertsSystem>();
  13. var sAlert = Server.System<AlertsSystem>();
  14. var buckle = Comp<BuckleComponent>(Player);
  15. var strap = Comp<StrapComponent>(Target);
  16. #pragma warning disable RA0002
  17. buckle.Delay = TimeSpan.Zero;
  18. #pragma warning restore RA0002
  19. // Initially not buckled to the chair, and standing off to the side
  20. Assert.That(Delta(), Is.InRange(0.9f, 1.1f));
  21. Assert.That(buckle.Buckled, Is.False);
  22. Assert.That(buckle.BuckledTo, Is.Null);
  23. Assert.That(strap.BuckledEntities, Is.Empty);
  24. Assert.That(cAlert.IsShowingAlert(CPlayer, strap.BuckledAlertType), Is.False);
  25. Assert.That(sAlert.IsShowingAlert(SPlayer, strap.BuckledAlertType), Is.False);
  26. // Interact results in being buckled to the chair
  27. await Interact();
  28. Assert.That(Delta(), Is.InRange(-0.01f, 0.01f));
  29. Assert.That(buckle.Buckled, Is.True);
  30. Assert.That(buckle.BuckledTo, Is.EqualTo(STarget));
  31. Assert.That(strap.BuckledEntities, Is.EquivalentTo(new[] { SPlayer }));
  32. Assert.That(cAlert.IsShowingAlert(CPlayer, strap.BuckledAlertType), Is.True);
  33. Assert.That(sAlert.IsShowingAlert(SPlayer, strap.BuckledAlertType), Is.True);
  34. // Attempting to walk away does nothing
  35. await Move(DirectionFlag.East, 1);
  36. Assert.That(Delta(), Is.InRange(-0.01f, 0.01f));
  37. Assert.That(buckle.Buckled, Is.True);
  38. Assert.That(buckle.BuckledTo, Is.EqualTo(STarget));
  39. Assert.That(strap.BuckledEntities, Is.EquivalentTo(new[] { SPlayer }));
  40. Assert.That(cAlert.IsShowingAlert(CPlayer, strap.BuckledAlertType), Is.True);
  41. Assert.That(sAlert.IsShowingAlert(SPlayer, strap.BuckledAlertType), Is.True);
  42. // Interacting again will unbuckle the player
  43. await Interact();
  44. Assert.That(Delta(), Is.InRange(-0.5f, 0.5f));
  45. Assert.That(buckle.Buckled, Is.False);
  46. Assert.That(buckle.BuckledTo, Is.Null);
  47. Assert.That(strap.BuckledEntities, Is.Empty);
  48. Assert.That(cAlert.IsShowingAlert(CPlayer, strap.BuckledAlertType), Is.False);
  49. Assert.That(sAlert.IsShowingAlert(SPlayer, strap.BuckledAlertType), Is.False);
  50. // And now they can move away
  51. await Move(DirectionFlag.SouthEast, 1);
  52. Assert.That(Delta(), Is.LessThan(-1));
  53. }
  54. }