Fix lung test (#14325)

This commit is contained in:
Leon Friedrich
2023-03-01 15:57:48 +13:00
committed by GitHub
parent c173338471
commit e9fd16f8f6
2 changed files with 26 additions and 4 deletions

View File

@@ -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<IMapManager>();
var entityManager = server.ResolveDependency<IEntityManager>();
var cfg = server.ResolveDependency<IConfigurationManager>();
var mapLoader = entityManager.System<MapLoaderSystem>();
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<AtmosphereSystem>().GetContainingMixture(human);
Assert.That(mixture.TotalMoles, Is.GreaterThan(0));
Assert.True(entityManager.HasComponent<BodyComponent>(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(() =>

View File

@@ -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);