1
0

GridJoinTest.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using Content.Server.Atmos.Components;
  2. using Content.Server.Atmos.EntitySystems;
  3. using Content.Server.Atmos.Piping.Components;
  4. using Content.Server.Atmos.Piping.EntitySystems;
  5. using Robust.Shared.GameObjects;
  6. namespace Content.IntegrationTests.Tests.Atmos;
  7. [TestFixture]
  8. public sealed class GridJoinTest
  9. {
  10. private const string CanisterProtoId = "AirCanister";
  11. [Test]
  12. public async Task TestGridJoinAtmosphere()
  13. {
  14. await using var pair = await PoolManager.GetServerClient();
  15. var server = pair.Server;
  16. var entMan = server.EntMan;
  17. var protoMan = server.ProtoMan;
  18. var atmosSystem = entMan.System<AtmosphereSystem>();
  19. var atmosDeviceSystem = entMan.System<AtmosDeviceSystem>();
  20. var transformSystem = entMan.System<SharedTransformSystem>();
  21. var testMap = await pair.CreateTestMap();
  22. await server.WaitPost(() =>
  23. {
  24. // Spawn an atmos device on the grid
  25. var canister = entMan.Spawn(CanisterProtoId);
  26. transformSystem.SetCoordinates(canister, testMap.GridCoords);
  27. var deviceComp = entMan.GetComponent<AtmosDeviceComponent>(canister);
  28. var canisterEnt = (canister, deviceComp);
  29. // Make sure the canister is tracked as an off-grid device
  30. Assert.That(atmosDeviceSystem.IsJoinedOffGrid(canisterEnt));
  31. // Add an atmosphere to the grid
  32. entMan.AddComponent<GridAtmosphereComponent>(testMap.Grid);
  33. // Force AtmosDeviceSystem to update off-grid devices
  34. // This means the canister is now considered on-grid,
  35. // but it's still tracked as off-grid!
  36. Assert.DoesNotThrow(() => atmosDeviceSystem.Update(atmosSystem.AtmosTime));
  37. // Make sure that the canister is now properly tracked as on-grid
  38. Assert.That(atmosDeviceSystem.IsJoinedOffGrid(canisterEnt), Is.False);
  39. });
  40. await pair.CleanReturnAsync();
  41. }
  42. }