Space now has an immutable, cold atmosphere.
This commit is contained in:
@@ -11,7 +11,7 @@ namespace Content.IntegrationTests.Tests.Atmos
|
||||
public class AtmosHelpersTest : ContentIntegrationTest
|
||||
{
|
||||
[Test]
|
||||
public async Task GetTileAtmosphereEntityCoordinatesNullTest()
|
||||
public async Task GetTileAtmosphereEntityCoordinatesNotNullTest()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
|
||||
@@ -26,8 +26,8 @@ namespace Content.IntegrationTests.Tests.Atmos
|
||||
var atmosphere1 = default(EntityCoordinates).GetTileAtmosphere();
|
||||
var atmosphere2 = default(EntityCoordinates).GetTileAtmosphere(entityManager);
|
||||
|
||||
Assert.Null(atmosphere1);
|
||||
Assert.Null(atmosphere2);
|
||||
Assert.NotNull(atmosphere1);
|
||||
Assert.NotNull(atmosphere2);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Content.IntegrationTests.Tests.Atmos
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetTileAirEntityCoordinatesNullTest()
|
||||
public async Task GetTileAirEntityCoordinatesNotNullTest()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Content.IntegrationTests.Tests.Atmos
|
||||
{
|
||||
var air = default(EntityCoordinates).GetTileAir();
|
||||
|
||||
Assert.Null(air);
|
||||
Assert.NotNull(air);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Content.IntegrationTests.Tests.Atmos
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TryGetTileAtmosphereEntityCoordinatesNullTest()
|
||||
public async Task TryGetTileAtmosphereEntityCoordinatesNotNullTest()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
|
||||
@@ -63,8 +63,8 @@ namespace Content.IntegrationTests.Tests.Atmos
|
||||
{
|
||||
var hasAtmosphere = default(EntityCoordinates).TryGetTileAtmosphere(out var atmosphere);
|
||||
|
||||
Assert.False(hasAtmosphere);
|
||||
Assert.Null(atmosphere);
|
||||
Assert.True(hasAtmosphere);
|
||||
Assert.NotNull(atmosphere);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace Content.IntegrationTests.Tests.Atmos
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TryGetTileTileAirEntityCoordinatesNullTest()
|
||||
public async Task TryGetTileTileAirEntityCoordinatesNotNullTest()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
|
||||
@@ -82,8 +82,8 @@ namespace Content.IntegrationTests.Tests.Atmos
|
||||
{
|
||||
var hasAir = default(EntityCoordinates).TryGetTileAir(out var air);
|
||||
|
||||
Assert.False(hasAir);
|
||||
Assert.Null(air);
|
||||
Assert.True(hasAir);
|
||||
Assert.NotNull(air);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace Content.IntegrationTests.Tests.Atmos
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetTileAtmosphereMapIndicesNullTest()
|
||||
public async Task GetTileAtmosphereMapIndicesNotNullTest()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace Content.IntegrationTests.Tests.Atmos
|
||||
{
|
||||
var atmosphere = default(MapIndices).GetTileAtmosphere(default);
|
||||
|
||||
Assert.Null(atmosphere);
|
||||
Assert.NotNull(atmosphere);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace Content.IntegrationTests.Tests.Atmos
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetTileAirMapIndicesNullTest()
|
||||
public async Task GetTileAirMapIndicesNotNullTest()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace Content.IntegrationTests.Tests.Atmos
|
||||
{
|
||||
var air = default(MapIndices).GetTileAir(default);
|
||||
|
||||
Assert.Null(air);
|
||||
Assert.NotNull(air);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace Content.IntegrationTests.Tests.Atmos
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TryGetTileAtmosphereMapIndicesNullTest()
|
||||
public async Task TryGetTileAtmosphereMapIndicesNotNullTest()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
|
||||
@@ -137,8 +137,8 @@ namespace Content.IntegrationTests.Tests.Atmos
|
||||
{
|
||||
var hasAtmosphere = default(MapIndices).TryGetTileAtmosphere(default, out var atmosphere);
|
||||
|
||||
Assert.False(hasAtmosphere);
|
||||
Assert.Null(atmosphere);
|
||||
Assert.True(hasAtmosphere);
|
||||
Assert.NotNull(atmosphere);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace Content.IntegrationTests.Tests.Atmos
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TryGetTileAirMapIndicesNullTest()
|
||||
public async Task TryGetTileAirMapIndicesNotNullTest()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
|
||||
@@ -156,8 +156,8 @@ namespace Content.IntegrationTests.Tests.Atmos
|
||||
{
|
||||
var hasAir = default(MapIndices).TryGetTileAir(default, out var air);
|
||||
|
||||
Assert.False(hasAir);
|
||||
Assert.Null(air);
|
||||
Assert.True(hasAir);
|
||||
Assert.NotNull(air);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Runtime.CompilerServices;
|
||||
using Content.Server.Atmos;
|
||||
using Content.Server.GameObjects.Components.Atmos.Piping;
|
||||
using Content.Server.GameObjects.Components.NodeContainer.NodeGroups;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Maps;
|
||||
using Robust.Server.GameObjects.EntitySystems.TileLookup;
|
||||
@@ -36,6 +37,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
[Robust.Shared.IoC.Dependency] private IServerEntityManager _serverEntityManager = default!;
|
||||
|
||||
public GridTileLookupSystem GridTileLookupSystem { get; private set; } = default!;
|
||||
public AtmosphereSystem AtmosphereSystem { get; private set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Check current execution time every n instances processed.
|
||||
@@ -172,6 +174,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
RepopulateTiles();
|
||||
|
||||
GridTileLookupSystem = EntitySystem.Get<GridTileLookupSystem>();
|
||||
AtmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
}
|
||||
|
||||
public override void OnAdd()
|
||||
@@ -189,7 +192,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
foreach (var tile in mapGrid.Grid.GetAllTiles())
|
||||
{
|
||||
if(!Tiles.ContainsKey(tile.GridIndices))
|
||||
Tiles.Add(tile.GridIndices, new TileAtmosphere(this, tile.GridIndex, tile.GridIndices, new GasMixture(GetVolumeForCells(1)){Temperature = Atmospherics.T20C}));
|
||||
Tiles.Add(tile.GridIndices, new TileAtmosphere(this, tile.GridIndex, tile.GridIndices, new GasMixture(GetVolumeForCells(1), AtmosphereSystem){Temperature = Atmospherics.T20C}));
|
||||
|
||||
Invalidate(tile.GridIndices);
|
||||
}
|
||||
@@ -215,13 +218,13 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
|
||||
if (tile == null)
|
||||
{
|
||||
tile = new TileAtmosphere(this, _gridId, indices, new GasMixture(GetVolumeForCells(1)){Temperature = Atmospherics.T20C});
|
||||
tile = new TileAtmosphere(this, _gridId, indices, new GasMixture(GetVolumeForCells(1), AtmosphereSystem){Temperature = Atmospherics.T20C});
|
||||
Tiles[indices] = tile;
|
||||
}
|
||||
|
||||
if (IsSpace(indices))
|
||||
{
|
||||
tile.Air = new GasMixture(GetVolumeForCells(1));
|
||||
tile.Air = new GasMixture(GetVolumeForCells(1), AtmosphereSystem);
|
||||
tile.Air.MarkImmutable();
|
||||
Tiles[indices] = tile;
|
||||
|
||||
@@ -236,7 +239,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
FixVacuum(tile.GridIndices);
|
||||
}
|
||||
|
||||
tile.Air ??= new GasMixture(GetVolumeForCells(1)){Temperature = Atmospherics.T20C};
|
||||
tile.Air ??= new GasMixture(GetVolumeForCells(1), AtmosphereSystem){Temperature = Atmospherics.T20C};
|
||||
}
|
||||
|
||||
AddActiveTile(tile);
|
||||
@@ -271,7 +274,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
var tile = GetTile(indices);
|
||||
if (tile?.GridIndex != _gridId) return;
|
||||
var adjacent = GetAdjacentTiles(indices);
|
||||
tile.Air = new GasMixture(GetVolumeForCells(1)){Temperature = Atmospherics.T20C};
|
||||
tile.Air = new GasMixture(GetVolumeForCells(1), AtmosphereSystem){Temperature = Atmospherics.T20C};
|
||||
Tiles[indices] = tile;
|
||||
|
||||
var ratio = 1f / adjacent.Count;
|
||||
@@ -360,41 +363,41 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
_excitedGroups.Remove(excitedGroup);
|
||||
}
|
||||
|
||||
public void AddPipeNet(IPipeNet pipeNet)
|
||||
public virtual void AddPipeNet(IPipeNet pipeNet)
|
||||
{
|
||||
_pipeNets.Add(pipeNet);
|
||||
}
|
||||
|
||||
public void RemovePipeNet(IPipeNet pipeNet)
|
||||
public virtual void RemovePipeNet(IPipeNet pipeNet)
|
||||
{
|
||||
_pipeNets.Remove(pipeNet);
|
||||
}
|
||||
|
||||
public void AddPipeNetDevice(PipeNetDeviceComponent pipeNetDevice)
|
||||
public virtual void AddPipeNetDevice(PipeNetDeviceComponent pipeNetDevice)
|
||||
{
|
||||
_pipeNetDevices.Add(pipeNetDevice);
|
||||
}
|
||||
|
||||
public void RemovePipeNetDevice(PipeNetDeviceComponent pipeNetDevice)
|
||||
public virtual void RemovePipeNetDevice(PipeNetDeviceComponent pipeNetDevice)
|
||||
{
|
||||
_pipeNetDevices.Remove(pipeNetDevice);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public TileAtmosphere? GetTile(EntityCoordinates coordinates, bool createSpace = true)
|
||||
public virtual TileAtmosphere? GetTile(EntityCoordinates coordinates, bool createSpace = true)
|
||||
{
|
||||
return GetTile(coordinates.ToMapIndices(_serverEntityManager, _mapManager), createSpace);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public TileAtmosphere? GetTile(MapIndices indices, bool createSpace = true)
|
||||
public virtual TileAtmosphere? GetTile(MapIndices indices, bool createSpace = true)
|
||||
{
|
||||
if (Tiles.TryGetValue(indices, out var tile)) return tile;
|
||||
|
||||
// We don't have that tile!
|
||||
if (IsSpace(indices) && createSpace)
|
||||
{
|
||||
return new TileAtmosphere(this, _gridId, indices, new GasMixture(GetVolumeForCells(1)){Temperature = Atmospherics.TCMB}, true);
|
||||
return new TileAtmosphere(this, _gridId, indices, new GasMixture(GetVolumeForCells(1), AtmosphereSystem){Temperature = Atmospherics.TCMB}, true);
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -416,7 +419,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsSpace(MapIndices indices)
|
||||
public virtual bool IsSpace(MapIndices indices)
|
||||
{
|
||||
// TODO ATMOS use ContentTileDefinition to define in YAML whether or not a tile is considered space
|
||||
if (!Owner.TryGetComponent(out IMapGridComponent? mapGrid)) return default;
|
||||
@@ -776,7 +779,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
return true;
|
||||
}
|
||||
|
||||
private IEnumerable<AirtightComponent> GetObstructingComponents(MapIndices indices)
|
||||
protected virtual IEnumerable<AirtightComponent> GetObstructingComponents(MapIndices indices)
|
||||
{
|
||||
var gridLookup = EntitySystem.Get<GridTileLookupSystem>();
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.Atmos;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Atmos
|
||||
{
|
||||
public class SpaceGridAtmosphereComponent : UnsimulatedGridAtmosphereComponent
|
||||
{
|
||||
public override string Name => "SpaceGridAtmosphere";
|
||||
|
||||
public override void RepopulateTiles() { }
|
||||
|
||||
public override bool IsSpace(MapIndices indices)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override TileAtmosphere? GetTile(MapIndices indices, bool createSpace = true)
|
||||
{
|
||||
return new TileAtmosphere(this, GridId.Invalid, indices, new GasMixture(2500, AtmosphereSystem), true);
|
||||
}
|
||||
|
||||
protected override IEnumerable<AirtightComponent> GetObstructingComponents(MapIndices indices)
|
||||
{
|
||||
return Enumerable.Empty<AirtightComponent>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using Content.Server.Atmos;
|
||||
using Content.Server.GameObjects.Components.Atmos.Piping;
|
||||
using Content.Server.GameObjects.Components.NodeContainer.NodeGroups;
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components.Map;
|
||||
@@ -58,6 +60,14 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
|
||||
public override void RemoveExcitedGroup(ExcitedGroup excitedGroup) { }
|
||||
|
||||
public override void AddPipeNet(IPipeNet pipeNet) { }
|
||||
|
||||
public override void RemovePipeNet(IPipeNet pipeNet) { }
|
||||
|
||||
public override void AddPipeNetDevice(PipeNetDeviceComponent pipeNetDevice) { }
|
||||
|
||||
public override void RemovePipeNetDevice(PipeNetDeviceComponent pipeNetDevice) { }
|
||||
|
||||
public override void Update(float frameTime) { }
|
||||
|
||||
public override bool ProcessTileEqualize(bool resumed = false)
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.Atmos;
|
||||
using Content.Server.Atmos.Reactions;
|
||||
using Content.Server.GameObjects.Components.Atmos;
|
||||
using Content.Shared.GameObjects.EntitySystems.Atmos;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.Interfaces.Timing;
|
||||
@@ -27,6 +28,8 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
|
||||
private GasReactionPrototype[] _gasReactions = Array.Empty<GasReactionPrototype>();
|
||||
|
||||
private SpaceGridAtmosphereComponent _spaceAtmos = default!;
|
||||
|
||||
/// <summary>
|
||||
/// List of gas reactions ordered by priority.
|
||||
/// </summary>
|
||||
@@ -44,17 +47,25 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
_gasReactions = _protoMan.EnumeratePrototypes<GasReactionPrototype>().ToArray();
|
||||
Array.Sort(_gasReactions, (a, b) => b.Priority.CompareTo(a.Priority));
|
||||
|
||||
_spaceAtmos = new SpaceGridAtmosphereComponent();
|
||||
_spaceAtmos.Initialize();
|
||||
IoCManager.InjectDependencies(_spaceAtmos);
|
||||
|
||||
_mapManager.TileChanged += OnTileChanged;
|
||||
}
|
||||
|
||||
public IGridAtmosphereComponent? GetGridAtmosphere(GridId gridId)
|
||||
{
|
||||
// TODO Return space grid atmosphere for invalid grids or grids with no atmos
|
||||
if (!gridId.IsValid())
|
||||
{
|
||||
return _spaceAtmos;
|
||||
}
|
||||
|
||||
var grid = _mapManager.GetGrid(gridId);
|
||||
|
||||
if (!EntityManager.TryGetEntity(grid.GridEntityId, out var gridEnt)) return null;
|
||||
if (!EntityManager.TryGetEntity(grid.GridEntityId, out var gridEnt)) return _spaceAtmos;
|
||||
|
||||
return gridEnt.TryGetComponent(out IGridAtmosphereComponent? atmos) ? atmos : null;
|
||||
return gridEnt.TryGetComponent(out IGridAtmosphereComponent? atmos) ? atmos : _spaceAtmos;
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
|
||||
Reference in New Issue
Block a user