1
0

BuckleDragTest.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using Content.IntegrationTests.Tests.Interaction;
  2. using Content.Shared.Buckle;
  3. using Content.Shared.Buckle.Components;
  4. using Content.Shared.Input;
  5. using Content.Shared.Movement.Pulling.Components;
  6. namespace Content.IntegrationTests.Tests.Buckle;
  7. public sealed class BuckleDragTest : InteractionTest
  8. {
  9. // Check that dragging a buckled player unbuckles them.
  10. [Test]
  11. public async Task BucklePullTest()
  12. {
  13. var urist = await SpawnTarget("MobHuman");
  14. var sUrist = ToServer(urist);
  15. await SpawnTarget("Chair");
  16. var buckle = Comp<BuckleComponent>(urist);
  17. var strap = Comp<StrapComponent>(Target);
  18. var puller = Comp<PullerComponent>(Player);
  19. var pullable = Comp<PullableComponent>(urist);
  20. #pragma warning disable RA0002
  21. buckle.Delay = TimeSpan.Zero;
  22. #pragma warning restore RA0002
  23. // Initially not buckled to the chair and not pulling anything
  24. Assert.That(buckle.Buckled, Is.False);
  25. Assert.That(buckle.BuckledTo, Is.Null);
  26. Assert.That(strap.BuckledEntities, Is.Empty);
  27. Assert.That(puller.Pulling, Is.Null);
  28. Assert.That(pullable.Puller, Is.Null);
  29. Assert.That(pullable.BeingPulled, Is.False);
  30. // Strap the human to the chair
  31. await Server.WaitAssertion(() =>
  32. {
  33. Assert.That(Server.System<SharedBuckleSystem>().TryBuckle(sUrist, SPlayer, STarget.Value));
  34. });
  35. await RunTicks(5);
  36. Assert.That(buckle.Buckled, Is.True);
  37. Assert.That(buckle.BuckledTo, Is.EqualTo(STarget));
  38. Assert.That(strap.BuckledEntities, Is.EquivalentTo(new[] { sUrist }));
  39. Assert.That(puller.Pulling, Is.Null);
  40. Assert.That(pullable.Puller, Is.Null);
  41. Assert.That(pullable.BeingPulled, Is.False);
  42. // Start pulling, and thus unbuckle them
  43. await PressKey(ContentKeyFunctions.TryPullObject, cursorEntity: urist);
  44. await RunTicks(5);
  45. Assert.That(buckle.Buckled, Is.False);
  46. Assert.That(buckle.BuckledTo, Is.Null);
  47. Assert.That(strap.BuckledEntities, Is.Empty);
  48. Assert.That(puller.Pulling, Is.EqualTo(sUrist));
  49. Assert.That(pullable.Puller, Is.EqualTo(SPlayer));
  50. Assert.That(pullable.BeingPulled, Is.True);
  51. }
  52. }