AtmosphereSystem no longer creates a component manually. (#3839)

- Maps get SpaceGridAtmosphereComponent added automatically
This commit is contained in:
Vera Aguilera Puerto
2021-04-13 13:17:10 +02:00
committed by GitHub
parent 30d5b58319
commit c17426dfa7
21 changed files with 97 additions and 257 deletions

View File

@@ -141,7 +141,9 @@ namespace Content.Server.GameObjects.Components.Atmos
UpdatePosition(_lastPosition.Item1, _lastPosition.Item2);
if (_fixVacuum)
_atmosphereSystem.GetGridAtmosphere(_lastPosition.Item1).FixVacuum(_lastPosition.Item2);
{
_atmosphereSystem.GetGridAtmosphere(_lastPosition.Item1)?.FixVacuum(_lastPosition.Item2);
}
}
private void OnTransformMove()
@@ -165,8 +167,8 @@ namespace Content.Server.GameObjects.Components.Atmos
{
var gridAtmos = _atmosphereSystem.GetGridAtmosphere(gridId);
gridAtmos.UpdateAdjacentBits(pos);
gridAtmos.Invalidate(pos);
gridAtmos?.UpdateAdjacentBits(pos);
gridAtmos?.Invalidate(pos);
}
}
}

View File

@@ -61,7 +61,7 @@ namespace Content.Server.GameObjects.Components.Atmos
{
return;
}
if (IsHoldingPressure())
{
Owner.PopupMessage(eventArgs.User, Loc.GetString("A gush of air blows in your face... Maybe you should reconsider."));
@@ -76,15 +76,12 @@ namespace Content.Server.GameObjects.Components.Atmos
{
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
if (!Owner.Transform.Coordinates.TryGetTileAtmosphere(out var tileAtmos))
return false;
var gridAtmosphere = atmosphereSystem.GetGridAtmosphere(Owner.Transform.GridID);
var gridAtmosphere = atmosphereSystem.GetGridAtmosphere(Owner.Transform.Coordinates);
var minMoles = float.MaxValue;
var maxMoles = 0f;
foreach (var (_, adjacent) in gridAtmosphere.GetAdjacentTiles(tileAtmos.GridIndices))
foreach (var (_, adjacent) in gridAtmosphere.GetAdjacentTiles(Owner.Transform.Coordinates))
{
// includeAirBlocked remains false, and therefore Air must be present
var moles = adjacent.Air!.TotalMoles;
@@ -107,7 +104,7 @@ namespace Content.Server.GameObjects.Components.Atmos
if (tileAtmos.Hotspot.Valid)
return true;
var gridAtmosphere = atmosphereSystem.GetGridAtmosphere(Owner.Transform.GridID);
var gridAtmosphere = atmosphereSystem.GetGridAtmosphere(Owner.Transform.Coordinates);
foreach (var (_, adjacent) in gridAtmosphere.GetAdjacentTiles(tileAtmos.GridIndices))
{

View File

@@ -125,7 +125,7 @@ namespace Content.Server.GameObjects.Components.Atmos
{
// Already get the pressure before Dirty(), because we can't get the EntitySystem in that thread or smth
var pressure = 0f;
var gam = EntitySystem.Get<AtmosphereSystem>().GetGridAtmosphere(Owner.Transform.GridID);
var gam = EntitySystem.Get<AtmosphereSystem>().GetGridAtmosphere(Owner.Transform.Coordinates);
var tile = gam?.GetTile(Owner.Transform.Coordinates)?.Air;
if (tile != null)
{
@@ -185,7 +185,7 @@ namespace Content.Server.GameObjects.Components.Atmos
}
var atmosSystem = EntitySystem.Get<AtmosphereSystem>();
var gam = atmosSystem.GetGridAtmosphere(pos.GetGridId(Owner.EntityManager));
var gam = atmosSystem.GetGridAtmosphere(pos);
var tile = gam.GetTile(pos)?.Air;
if (tile == null)
{

View File

@@ -514,6 +514,11 @@ namespace Content.Server.GameObjects.Components.Atmos
return _mapGridComponent.Grid.GetTileRef(indices).IsSpace();
}
public Dictionary<AtmosDirection, TileAtmosphere> GetAdjacentTiles(EntityCoordinates coordinates, bool includeAirBlocked = false)
{
return GetAdjacentTiles(coordinates.ToVector2i(_serverEntityManager, _mapManager), includeAirBlocked);
}
public Dictionary<AtmosDirection, TileAtmosphere> GetAdjacentTiles(Vector2i indices, bool includeAirBlocked = false)
{
var sides = new Dictionary<AtmosDirection, TileAtmosphere>();

View File

@@ -38,7 +38,7 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
private void JoinGridAtmos()
{
var gridAtmos = EntitySystem.Get<AtmosphereSystem>()
.GetGridAtmosphere(Owner.Transform.GridID);
.GetGridAtmosphere(Owner.Transform.Coordinates);
JoinedGridAtmos = gridAtmos;
JoinedGridAtmos.AddPipeNetDevice(this);
}

View File

@@ -63,7 +63,7 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Scrubbers
if (!SiphonEnabled)
return;
var tileAtmos = Owner.Transform.Coordinates.GetTileAtmosphere(Owner.EntityManager);
var tileAtmos = Owner.Transform.Coordinates.GetTileAtmosphere();
if (_scrubberOutlet == null || tileAtmos == null || tileAtmos.Air == null)
return;

View File

@@ -63,7 +63,7 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Vents
if (!VentEnabled)
return;
var tileAtmos = Owner.Transform.Coordinates.GetTileAtmosphere(Owner.EntityManager);
var tileAtmos = Owner.Transform.Coordinates.GetTileAtmosphere();
if (_ventInlet == null || tileAtmos == null || tileAtmos.Air == null)
return;

View File

@@ -2,11 +2,14 @@
using System.Collections.Generic;
using System.Linq;
using Content.Server.Atmos;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Maths;
namespace Content.Server.GameObjects.Components.Atmos
{
[RegisterComponent]
[ComponentReference(typeof(IGridAtmosphereComponent))]
public class SpaceGridAtmosphereComponent : UnsimulatedGridAtmosphereComponent
{
public override string Name => "SpaceGridAtmosphere";

View File

@@ -283,7 +283,7 @@ namespace Content.Server.GameObjects.Components.Disposal
var atmosSystem = EntitySystem.Get<AtmosphereSystem>();
atmosSystem
.GetGridAtmosphere(Owner.Transform.GridID)?
.GetGridAtmosphere(Owner.Transform.Coordinates)?
.Invalidate(tileAtmos.GridIndices);
}