TileConstructionTests.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using Content.IntegrationTests.Tests.Interaction;
  2. using Robust.Shared.Map;
  3. namespace Content.IntegrationTests.Tests.Tiles;
  4. public sealed class TileConstructionTests : InteractionTest
  5. {
  6. /// <summary>
  7. /// Test placing and cutting a single lattice.
  8. /// </summary>
  9. [Test]
  10. public async Task PlaceThenCutLattice()
  11. {
  12. await AssertTile(Plating);
  13. await AssertTile(Plating, PlayerCoords);
  14. AssertGridCount(1);
  15. await SetTile(null);
  16. await InteractUsing(Rod);
  17. await AssertTile(Lattice);
  18. Assert.That(Hands.ActiveHandEntity, Is.Null);
  19. await InteractUsing(Cut);
  20. await AssertTile(null);
  21. await AssertEntityLookup((Rod, 1));
  22. AssertGridCount(1);
  23. }
  24. /// <summary>
  25. /// Test placing and cutting a single lattice in space (not adjacent to any existing grid.
  26. /// </summary>
  27. [Test]
  28. public async Task CutThenPlaceLatticeNewGrid()
  29. {
  30. await AssertTile(Plating);
  31. await AssertTile(Plating, PlayerCoords);
  32. AssertGridCount(1);
  33. // Remove grid
  34. await SetTile(null);
  35. await SetTile(null, PlayerCoords);
  36. Assert.That(MapData.Grid.Comp.Deleted);
  37. AssertGridCount(0);
  38. // Place Lattice
  39. var oldPos = TargetCoords;
  40. TargetCoords = SEntMan.GetNetCoordinates(new EntityCoordinates(MapData.MapUid, 1, 0));
  41. await InteractUsing(Rod);
  42. TargetCoords = oldPos;
  43. await AssertTile(Lattice);
  44. AssertGridCount(1);
  45. // Cut lattice
  46. Assert.That(Hands.ActiveHandEntity, Is.Null);
  47. await InteractUsing(Cut);
  48. await AssertTile(null);
  49. AssertGridCount(0);
  50. await AssertEntityLookup((Rod, 1));
  51. }
  52. /// <summary>
  53. /// Test space -> floor -> plating
  54. /// </summary>
  55. [Test]
  56. public async Task FloorConstructDeconstruct()
  57. {
  58. await AssertTile(Plating);
  59. await AssertTile(Plating, PlayerCoords);
  60. AssertGridCount(1);
  61. // Remove grid
  62. await SetTile(null);
  63. await SetTile(null, PlayerCoords);
  64. Assert.That(MapData.Grid.Comp.Deleted);
  65. AssertGridCount(0);
  66. // Space -> Lattice
  67. var oldPos = TargetCoords;
  68. TargetCoords = SEntMan.GetNetCoordinates(new EntityCoordinates(MapData.MapUid, 1, 0));
  69. await InteractUsing(Rod);
  70. TargetCoords = oldPos;
  71. await AssertTile(Lattice);
  72. AssertGridCount(1);
  73. // Lattice -> Plating
  74. await InteractUsing(Steel);
  75. Assert.That(Hands.ActiveHandEntity, Is.Null);
  76. await AssertTile(Plating);
  77. AssertGridCount(1);
  78. // Plating -> Tile
  79. await InteractUsing(FloorItem);
  80. Assert.That(Hands.ActiveHandEntity, Is.Null);
  81. await AssertTile(Floor);
  82. AssertGridCount(1);
  83. // Tile -> Plating
  84. await InteractUsing(Pry);
  85. await AssertTile(Plating);
  86. AssertGridCount(1);
  87. await AssertEntityLookup((FloorItem, 1));
  88. }
  89. }