Fix errors with creating gas mixtures on class instantiation (#1916)

* Fix errors when gas mixtures are created on class instantiation

* Fix mistake
This commit is contained in:
DrSmugleaf
2020-08-25 16:53:59 +02:00
committed by GitHub
parent b0a18ebc5b
commit 34b2902641
4 changed files with 12 additions and 5 deletions

View File

@@ -4,6 +4,7 @@ using System.Threading.Tasks;
using Content.Server.GameObjects.EntitySystems; using Content.Server.GameObjects.EntitySystems;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using NUnit.Framework; using NUnit.Framework;
using Robust.Shared.GameObjects.Systems;
namespace Content.IntegrationTests.Tests.Atmos namespace Content.IntegrationTests.Tests.Atmos
{ {
@@ -18,10 +19,10 @@ namespace Content.IntegrationTests.Tests.Atmos
await server.WaitIdleAsync(); await server.WaitIdleAsync();
var atmosSystem = server.ResolveDependency<AtmosphereSystem>();
server.Post(() => server.Post(() =>
{ {
var atmosSystem = EntitySystem.Get<AtmosphereSystem>();
Assert.That(atmosSystem.Gases.Count(), Is.EqualTo(Atmospherics.TotalNumberOfGases)); Assert.That(atmosSystem.Gases.Count(), Is.EqualTo(Atmospherics.TotalNumberOfGases));
Assert.That(Enum.GetValues(typeof(Gas)).Length, Is.EqualTo(Atmospherics.TotalNumberOfGases)); Assert.That(Enum.GetValues(typeof(Gas)).Length, Is.EqualTo(Atmospherics.TotalNumberOfGases));

View File

@@ -10,12 +10,14 @@ namespace Content.Server.GameObjects.Components.Atmos
{ {
public override string Name => "GasMixtureHolder"; public override string Name => "GasMixtureHolder";
[ViewVariables] public GasMixture GasMixture { get; set; } = new GasMixture(); [ViewVariables] public GasMixture GasMixture { get; set; }
public override void ExposeData(ObjectSerializer serializer) public override void ExposeData(ObjectSerializer serializer)
{ {
base.ExposeData(serializer); base.ExposeData(serializer);
GasMixture = new GasMixture();
serializer.DataReadWriteFunction( serializer.DataReadWriteFunction(
"volume", "volume",
0f, 0f,

View File

@@ -29,7 +29,7 @@ namespace Content.Server.GameObjects.Components.Body.Circulatory
/// </summary> /// </summary>
[ViewVariables] public ReagentUnit EmptyVolume => _internalSolution.EmptyVolume; [ViewVariables] public ReagentUnit EmptyVolume => _internalSolution.EmptyVolume;
[ViewVariables] public GasMixture Air { get; set; } = new GasMixture(6); [ViewVariables] public GasMixture Air { get; set; }
[ViewVariables] public SolutionComponent Solution => _internalSolution; [ViewVariables] public SolutionComponent Solution => _internalSolution;
@@ -45,6 +45,8 @@ namespace Content.Server.GameObjects.Components.Body.Circulatory
{ {
base.ExposeData(serializer); base.ExposeData(serializer);
Air = new GasMixture(6);
serializer.DataField(ref _initialMaxVolume, "maxVolume", ReagentUnit.New(250)); serializer.DataField(ref _initialMaxVolume, "maxVolume", ReagentUnit.New(250));
} }

View File

@@ -21,7 +21,7 @@ namespace Content.Server.GameObjects.Components.Body.Respiratory
/// </summary> /// </summary>
[ViewVariables(VVAccess.ReadWrite)] private float Pressure { get; set; } [ViewVariables(VVAccess.ReadWrite)] private float Pressure { get; set; }
[ViewVariables] public GasMixture Air { get; set; } = new GasMixture(); [ViewVariables] public GasMixture Air { get; set; }
[ViewVariables] public LungStatus Status { get; set; } [ViewVariables] public LungStatus Status { get; set; }
@@ -29,6 +29,8 @@ namespace Content.Server.GameObjects.Components.Body.Respiratory
{ {
base.ExposeData(serializer); base.ExposeData(serializer);
Air = new GasMixture();
serializer.DataReadWriteFunction( serializer.DataReadWriteFunction(
"volume", "volume",
6, 6,