Fix parallel tests unreliably failing due to statics in Atmospherics (#1914)
* Fix atmospherics statics unreliably failing parallel tests * Cache getting atmosphere system
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using Content.Server.GameObjects.Components.Atmos;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Server.Interfaces.Console;
|
||||
using Robust.Server.Interfaces.Player;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -58,7 +60,9 @@ namespace Content.Server.Atmos
|
||||
public string Help => "listgases";
|
||||
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args)
|
||||
{
|
||||
foreach (var gasPrototype in Atmospherics.Gases)
|
||||
var atmosSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
|
||||
foreach (var gasPrototype in atmosSystem.Gases)
|
||||
{
|
||||
shell.SendText(player, $"{gasPrototype.Name} ID: {gasPrototype.ID}");
|
||||
}
|
||||
|
||||
@@ -4,8 +4,10 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Content.Server.Atmos.Reactions;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Server.Interfaces;
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.Serialization;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -20,12 +22,17 @@ namespace Content.Server.Atmos
|
||||
[Serializable]
|
||||
public class GasMixture : IExposeData, IEquatable<GasMixture>, ICloneable
|
||||
{
|
||||
private readonly AtmosphereSystem _atmosphereSystem;
|
||||
|
||||
[ViewVariables]
|
||||
private float[] _moles = new float[Atmospherics.TotalNumberOfGases];
|
||||
|
||||
[ViewVariables]
|
||||
private float[] _molesArchived = new float[Atmospherics.TotalNumberOfGases];
|
||||
|
||||
[ViewVariables]
|
||||
private float _temperature = Atmospherics.TCMB;
|
||||
|
||||
public IReadOnlyList<float> Gases => _moles;
|
||||
|
||||
[ViewVariables]
|
||||
@@ -51,7 +58,7 @@ namespace Content.Server.Atmos
|
||||
|
||||
for (var i = 0; i < Atmospherics.TotalNumberOfGases; i++)
|
||||
{
|
||||
capacity += Atmospherics.GetGas(i).SpecificHeat * _moles[i];
|
||||
capacity += _atmosphereSystem.GetGas(i).SpecificHeat * _moles[i];
|
||||
}
|
||||
|
||||
return MathF.Max(capacity, Atmospherics.MinimumHeatCapacity);
|
||||
@@ -68,7 +75,7 @@ namespace Content.Server.Atmos
|
||||
|
||||
for (var i = 0; i < Atmospherics.TotalNumberOfGases; i++)
|
||||
{
|
||||
capacity += Atmospherics.GetGas(i).SpecificHeat * _molesArchived[i];
|
||||
capacity += _atmosphereSystem.GetGas(i).SpecificHeat * _molesArchived[i];
|
||||
}
|
||||
|
||||
return MathF.Max(capacity, Atmospherics.MinimumHeatCapacity);
|
||||
@@ -124,6 +131,7 @@ namespace Content.Server.Atmos
|
||||
|
||||
public GasMixture()
|
||||
{
|
||||
_atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
}
|
||||
|
||||
public GasMixture(float volume)
|
||||
@@ -131,6 +139,7 @@ namespace Content.Server.Atmos
|
||||
if (volume < 0)
|
||||
volume = 0;
|
||||
Volume = volume;
|
||||
_atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -274,7 +283,7 @@ namespace Content.Server.Atmos
|
||||
if (!(MathF.Abs(delta) >= Atmospherics.GasMinMoles)) continue;
|
||||
if (absTemperatureDelta > Atmospherics.MinimumTemperatureDeltaToConsider)
|
||||
{
|
||||
var gasHeatCapacity = delta * Atmospherics.GetGas(i).SpecificHeat;
|
||||
var gasHeatCapacity = delta * _atmosphereSystem.GetGas(i).SpecificHeat;
|
||||
if (delta > 0)
|
||||
{
|
||||
heatCapacityToSharer += gasHeatCapacity;
|
||||
|
||||
@@ -159,7 +159,8 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
pos = _position.Value;
|
||||
}
|
||||
|
||||
var gam = EntitySystem.Get<AtmosphereSystem>().GetGridAtmosphere(pos.GridID);
|
||||
var atmosSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
var gam = atmosSystem.GetGridAtmosphere(pos.GridID);
|
||||
var tile = gam?.GetTile(pos).Air;
|
||||
if (tile == null)
|
||||
{
|
||||
@@ -174,9 +175,10 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
}
|
||||
|
||||
var gases = new List<GasEntry>();
|
||||
|
||||
for (var i = 0; i < Atmospherics.TotalNumberOfGases; i++)
|
||||
{
|
||||
var gas = Atmospherics.GetGas(i);
|
||||
var gas = atmosSystem.GetGas(i);
|
||||
|
||||
if (tile.Gases[i] <= Atmospherics.GasMinMoles) continue;
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Content.Server.GameObjects.Components.Atmos;
|
||||
using Content.Server.Interfaces.GameTicking;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.GameObjects.EntitySystems.Atmos;
|
||||
using JetBrains.Annotations;
|
||||
@@ -15,8 +13,6 @@ using Robust.Shared.Interfaces.Configuration;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.Interfaces.Timing;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Timing;
|
||||
@@ -58,10 +54,13 @@ namespace Content.Server.GameObjects.EntitySystems.Atmos
|
||||
/// </summary>
|
||||
private float _updateCooldown;
|
||||
|
||||
private AtmosphereSystem _atmosphereSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_atmosphereSystem = Get<AtmosphereSystem>();
|
||||
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged;
|
||||
_mapManager.OnGridRemoved += OnGridRemoved;
|
||||
_configManager.RegisterCVar("net.gasoverlaytickrate", 3.0f);
|
||||
@@ -164,8 +163,8 @@ namespace Content.Server.GameObjects.EntitySystems.Atmos
|
||||
|
||||
for (byte i = 0; i < Atmospherics.TotalNumberOfGases; i++)
|
||||
{
|
||||
var gas = Atmospherics.GetGas(i);
|
||||
var overlay = Atmospherics.GetOverlay(i);
|
||||
var gas = _atmosphereSystem.GetGas(i);
|
||||
var overlay = _atmosphereSystem.GetOverlay(i);
|
||||
if (overlay == null || tile?.Air == null) continue;
|
||||
|
||||
var moles = tile.Air.Gases[i];
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.Atmos;
|
||||
using Content.Shared.GameObjects.EntitySystems.Atmos;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.Interfaces.Timing;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components.Map;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
@@ -15,7 +11,7 @@ using Robust.Shared.Map;
|
||||
namespace Content.Server.GameObjects.EntitySystems
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class AtmosphereSystem : EntitySystem
|
||||
public class AtmosphereSystem : SharedAtmosphereSystem
|
||||
{
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly IPauseManager _pauseManager = default!;
|
||||
|
||||
Reference in New Issue
Block a user