From e9fd16f8f6040fde2841ad2a6a2e5c066840eec8 Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Wed, 1 Mar 2023 15:57:48 +1300 Subject: [PATCH] Fix lung test (#14325) --- .../Tests/Body/LungTest.cs | 18 ++++++++++++++---- .../EntitySystems/AtmosphereSystem.API.cs | 12 ++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Content.IntegrationTests/Tests/Body/LungTest.cs b/Content.IntegrationTests/Tests/Body/LungTest.cs index 18e2d7f5f8..7cb54d3937 100644 --- a/Content.IntegrationTests/Tests/Body/LungTest.cs +++ b/Content.IntegrationTests/Tests/Body/LungTest.cs @@ -1,11 +1,13 @@ -using System.Threading.Tasks; +using System.Threading.Tasks; using Content.Server.Atmos.Components; +using Content.Server.Atmos.EntitySystems; using Content.Server.Body.Components; using Content.Server.Body.Systems; using Content.Shared.Body.Components; using NUnit.Framework; using Robust.Server.GameObjects; -using Robust.Server.Maps; +using Robust.Shared; +using Robust.Shared.Configuration; using Robust.Shared.GameObjects; using Robust.Shared.Map; using Robust.Shared.Maths; @@ -134,6 +136,7 @@ namespace Content.IntegrationTests.Tests.Body var mapManager = server.ResolveDependency(); var entityManager = server.ResolveDependency(); + var cfg = server.ResolveDependency(); var mapLoader = entityManager.System(); MapId mapId; @@ -153,10 +156,14 @@ namespace Content.IntegrationTests.Tests.Body await server.WaitAssertion(() => { - var center = new Vector2(0.5f, -1.5f); + var center = new Vector2(0.5f, 0.5f); + var coordinates = new EntityCoordinates(grid.Value, center); human = entityManager.SpawnEntity("HumanBodyDummy", coordinates); + var mixture = entityManager.System().GetContainingMixture(human); + Assert.That(mixture.TotalMoles, Is.GreaterThan(0)); + Assert.True(entityManager.HasComponent(human)); Assert.True(entityManager.TryGetComponent(human, out respirator)); Assert.False(respirator.SuffocationCycles > respirator.SuffocationCycleThreshold); @@ -164,7 +171,10 @@ namespace Content.IntegrationTests.Tests.Body var increment = 10; - for (var tick = 0; tick < 600; tick += increment) + // 20 seconds + var total = 20 * cfg.GetCVar(CVars.NetTickrate); + + for (var tick = 0; tick < total; tick += increment) { await server.WaitRunTicks(increment); await server.WaitAssertion(() => diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.API.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.API.cs index 03a07a2e5f..00ed05449c 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.API.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.API.cs @@ -97,7 +97,10 @@ public partial class AtmosphereSystem // If we've been passed a grid, try to let it handle it. if (gridUid.HasValue) + { + DebugTools.Assert(_mapManager.IsGrid(gridUid.Value)); RaiseLocalEvent(gridUid.Value, ref ev, false); + } if (ev.Handled) return ev.Mixtures; @@ -105,7 +108,10 @@ public partial class AtmosphereSystem // We either don't have a grid, or the event wasn't handled. // Let the map handle it instead, and also broadcast the event. if (mapUid.HasValue) + { + DebugTools.Assert(_mapManager.IsMap(mapUid.Value)); RaiseLocalEvent(mapUid.Value, ref ev, true); + } else RaiseLocalEvent(ref ev); @@ -127,7 +133,10 @@ public partial class AtmosphereSystem // If we've been passed a grid, try to let it handle it. if(gridUid.HasValue) + { + DebugTools.Assert(_mapManager.IsGrid(gridUid.Value)); RaiseLocalEvent(gridUid.Value, ref ev, false); + } if (ev.Handled) return ev.Mixture; @@ -135,7 +144,10 @@ public partial class AtmosphereSystem // We either don't have a grid, or the event wasn't handled. // Let the map handle it instead, and also broadcast the event. if(mapUid.HasValue) + { + DebugTools.Assert(_mapManager.IsMap(mapUid.Value)); RaiseLocalEvent(mapUid.Value, ref ev, true); + } else RaiseLocalEvent(ref ev); -- 2.52.0