Content changes for mapgrid kill (#12567)

This commit is contained in:
metalgearsloth
2022-11-22 13:12:04 +11:00
committed by GitHub
parent 9170e7ac9d
commit 6c76061887
75 changed files with 192 additions and 123 deletions

View File

@@ -3,6 +3,7 @@ using Content.Server.Explosion.EntitySystems;
using Content.Shared.Atmos;
using JetBrains.Annotations;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
namespace Content.Server.Atmos.EntitySystems
{
@@ -58,7 +59,7 @@ namespace Content.Server.Atmos.EntitySystems
var gridId = xform.GridUid;
var coords = xform.Coordinates;
var tilePos = grid.Grid.TileIndicesFor(coords);
var tilePos = grid.TileIndicesFor(coords);
// Update and invalidate new position.
airtight.LastPosition = (gridId.Value, tilePos);

View File

@@ -1,6 +1,7 @@
using System.Diagnostics.CodeAnalysis;
using Content.Server.Atmos.Components;
using Robust.Shared.Map;
using Robust.Shared.Map.Enumerators;
namespace Content.Server.Atmos.EntitySystems;

View File

@@ -4,6 +4,7 @@ using Content.Server.Atmos.Reactions;
using Content.Server.NodeContainer.NodeGroups;
using Content.Shared.Atmos;
using Robust.Server.GameObjects;
using Robust.Shared.Map.Components;
using Robust.Shared.Utility;
namespace Content.Server.Atmos.EntitySystems;

View File

@@ -6,6 +6,7 @@ using Content.Shared.Atmos;
using Content.Shared.Maps;
using Robust.Shared.Console;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
namespace Content.Server.Atmos.EntitySystems;
@@ -100,7 +101,7 @@ public sealed partial class AtmosphereSystem
tile.Clear();
var mixtureId = 0;
foreach (var entUid in gridComp.Grid.GetAnchoredEntities(indices))
foreach (var entUid in gridComp.GetAnchoredEntities(indices))
{
if (!TryComp(entUid, out AtmosFixMarkerComponent? afm))
continue;

View File

@@ -3,6 +3,7 @@ using Content.Server.Atmos.Components;
using Content.Server.Atmos.Reactions;
using Content.Shared.Atmos;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Utility;
namespace Content.Server.Atmos.EntitySystems;
@@ -53,7 +54,7 @@ public sealed partial class AtmosphereSystem
tile.GridIndex = uid;
}
GridRepopulateTiles(mapGrid.Grid, gridAtmosphere);
GridRepopulateTiles(mapGrid, gridAtmosphere);
}
private void OnGridSplit(EntityUid uid, GridAtmosphereComponent originalGridAtmos, ref GridSplitEvent args)
@@ -230,7 +231,7 @@ public sealed partial class AtmosphereSystem
var directions = AtmosDirection.Invalid;
var enumerator = GetObstructingComponentsEnumerator(mapGridComp.Grid, args.Tile);
var enumerator = GetObstructingComponentsEnumerator(mapGridComp, args.Tile);
while (enumerator.MoveNext(out var obstructingComponent))
{
@@ -332,7 +333,7 @@ public sealed partial class AtmosphereSystem
return;
tile.AdjacentBits = AtmosDirection.Invalid;
tile.BlockedAirflow = GetBlockedDirections(mapGridComp.Grid, tile.GridIndices);
tile.BlockedAirflow = GetBlockedDirections(mapGridComp, tile.GridIndices);
for (var i = 0; i < Atmospherics.Directions; i++)
{
@@ -349,7 +350,7 @@ public sealed partial class AtmosphereSystem
var oppositeDirection = direction.GetOpposite();
adjacent.BlockedAirflow = GetBlockedDirections(mapGridComp.Grid, adjacent.GridIndices);
adjacent.BlockedAirflow = GetBlockedDirections(mapGridComp, adjacent.GridIndices);
// Pass in MapGridComponent so we don't have to resolve it for every adjacent direction.
var tileBlockedEv = new IsTileAirBlockedMethodEvent(uid, tile.GridIndices, direction, mapGridComp);
@@ -456,7 +457,7 @@ public sealed partial class AtmosphereSystem
tile.Air = new GasMixture
{
Volume = GetVolumeForTiles(mapGridComp.Grid, 1),
Volume = GetVolumeForTiles(mapGridComp, 1),
Temperature = Atmospherics.T20C
};
@@ -533,7 +534,7 @@ public sealed partial class AtmosphereSystem
/// </summary>
/// <param name="mapGrid">The grid where to get all valid tiles from.</param>
/// <param name="gridAtmosphere">The grid atmosphere where the tiles will be repopulated.</param>
private void GridRepopulateTiles(IMapGrid mapGrid, GridAtmosphereComponent gridAtmosphere)
private void GridRepopulateTiles(MapGridComponent mapGrid, GridAtmosphereComponent gridAtmosphere)
{
var volume = GetVolumeForTiles(mapGrid, 1);

View File

@@ -8,6 +8,7 @@ using Robust.Shared.Physics.Components;
using Robust.Shared.Random;
using Robust.Shared.Utility;
using System.Linq;
using Robust.Shared.Map.Components;
namespace Content.Server.Atmos.EntitySystems
{
@@ -25,7 +26,7 @@ namespace Content.Server.Atmos.EntitySystems
private readonly TileAtmosphere[] _depressurizeSpaceTiles = new TileAtmosphere[Atmospherics.MonstermosHardTileLimit];
private readonly TileAtmosphere[] _depressurizeProgressionOrder = new TileAtmosphere[Atmospherics.MonstermosHardTileLimit * 2];
private void EqualizePressureInZone(IMapGrid mapGrid, GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile, int cycleNum)
private void EqualizePressureInZone(MapGridComponent mapGrid, GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile, int cycleNum)
{
if (tile.Air == null || (tile.MonstermosInfo.LastCycle >= cycleNum))
return; // Already done.
@@ -354,7 +355,7 @@ namespace Content.Server.Atmos.EntitySystems
Array.Clear(_equalizeQueue, 0, Atmospherics.MonstermosTileLimit);
}
private void ExplosivelyDepressurize(IMapGrid mapGrid, GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile, int cycleNum)
private void ExplosivelyDepressurize(MapGridComponent mapGrid, GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile, int cycleNum)
{
// Check if explosive depressurization is enabled and if the tile is valid.
if (!MonstermosDepressurization || tile.Air == null)
@@ -603,7 +604,7 @@ namespace Content.Server.Atmos.EntitySystems
adj.MonstermosInfo[direction.GetOpposite()] -= amount;
}
private void HandleDecompressionFloorRip(IMapGrid mapGrid, TileAtmosphere tile, float sum)
private void HandleDecompressionFloorRip(MapGridComponent mapGrid, TileAtmosphere tile, float sum)
{
if (!MonstermosRipTiles)
return;

View File

@@ -3,6 +3,7 @@ using Content.Server.Atmos.Piping.Components;
using Content.Server.NodeContainer.NodeGroups;
using Content.Shared.Atmos;
using Content.Shared.Maps;
using Robust.Shared.Map.Components;
using Robust.Shared.Physics.Components;
using Robust.Shared.Timing;
@@ -48,17 +49,16 @@ namespace Content.Server.Atmos.EntitySystems
if (!TryComp(uid, out MapGridComponent? mapGridComp))
return true;
var mapGrid = mapGridComp.Grid;
var mapUid = _mapManager.GetMapEntityIdOrThrow(Transform(mapGridComp.Owner).MapID);
var volume = GetVolumeForTiles(mapGrid, 1);
var volume = GetVolumeForTiles(mapGridComp, 1);
var number = 0;
while (atmosphere.CurrentRunInvalidatedCoordinates.TryDequeue(out var indices))
{
if (!atmosphere.Tiles.TryGetValue(indices, out var tile))
{
tile = new TileAtmosphere(mapGrid.GridEntityId, indices,
tile = new TileAtmosphere(mapGridComp.GridEntityId, indices,
new GasMixture(volume) { Temperature = Atmospherics.T20C });
atmosphere.Tiles[indices] = tile;
}
@@ -78,7 +78,7 @@ namespace Content.Server.Atmos.EntitySystems
}
// Call this instead of the grid method as the map has a say on whether the tile is space or not.
if ((!mapGrid.TryGetTileRef(indices, out var t) || t.IsSpace(_tileDefinitionManager)) && !isAirBlocked)
if ((!mapGridComp.TryGetTileRef(indices, out var t) || t.IsSpace(_tileDefinitionManager)) && !isAirBlocked)
{
tile.Air = GetTileMixture(null, mapUid, indices);
tile.MolesArchived = tile.Air != null ? new float[Atmospherics.AdjustedNumberOfGases] : null;
@@ -87,7 +87,7 @@ namespace Content.Server.Atmos.EntitySystems
{
var nullAir = false;
var enumerator = GetObstructingComponentsEnumerator(mapGrid, indices);
var enumerator = GetObstructingComponentsEnumerator(mapGridComp, indices);
while (enumerator.MoveNext(out var airtight))
{
@@ -109,7 +109,7 @@ namespace Content.Server.Atmos.EntitySystems
}
else
{
if (tile.Air == null && NeedsVacuumFixing(mapGrid, indices))
if (tile.Air == null && NeedsVacuumFixing(mapGridComp, indices))
{
var vacuumEv = new FixTileVacuumMethodEvent(uid, indices);
GridFixTileVacuum(uid, atmosphere, ref vacuumEv);
@@ -133,12 +133,12 @@ namespace Content.Server.Atmos.EntitySystems
AddActiveTile(atmosphere, tile);
// TODO ATMOS: Query all the contents of this tile (like walls) and calculate the correct thermal conductivity and heat capacity
var tileDef = mapGrid.TryGetTileRef(indices, out var tileRef)
var tileDef = mapGridComp.TryGetTileRef(indices, out var tileRef)
? tileRef.GetContentTileDefinition(_tileDefinitionManager) : null;
tile.ThermalConductivity = tileDef?.ThermalConductivity ?? 0.5f;
tile.HeatCapacity = tileDef?.HeatCapacity ?? float.PositiveInfinity;
InvalidateVisuals(mapGrid.GridEntityId, indices);
InvalidateVisuals(mapGridComp.GridEntityId, indices);
for (var i = 0; i < Atmospherics.Directions; i++)
{
@@ -171,12 +171,10 @@ namespace Content.Server.Atmos.EntitySystems
if (!TryComp(uid, out MapGridComponent? mapGridComp))
throw new Exception("Tried to process a grid atmosphere on an entity that isn't a grid!");
var mapGrid = mapGridComp.Grid;
var number = 0;
while (atmosphere.CurrentRunTiles.TryDequeue(out var tile))
{
EqualizePressureInZone(mapGrid, atmosphere, tile, atmosphere.UpdateCounter);
EqualizePressureInZone(mapGridComp, atmosphere, tile, atmosphere.UpdateCounter);
if (number++ < LagCheckIterations) continue;
number = 0;

View File

@@ -3,6 +3,7 @@ using Content.Server.Atmos.Components;
using Content.Shared.Atmos;
using Content.Shared.Maps;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
namespace Content.Server.Atmos.EntitySystems;
@@ -38,7 +39,7 @@ public partial class AtmosphereSystem
_gasTileOverlaySystem.Invalidate(gridUid, tile);
}
public bool NeedsVacuumFixing(IMapGrid mapGrid, Vector2i indices)
public bool NeedsVacuumFixing(MapGridComponent mapGrid, Vector2i indices)
{
var value = false;
@@ -58,7 +59,7 @@ public partial class AtmosphereSystem
/// <param name="mapGrid">The grid in question.</param>
/// <param name="tiles">The amount of tiles.</param>
/// <returns>The volume in liters that the tiles occupy.</returns>
private float GetVolumeForTiles(IMapGrid mapGrid, int tiles = 1)
private float GetVolumeForTiles(MapGridComponent mapGrid, int tiles = 1)
{
return Atmospherics.CellVolume * mapGrid.TileSize * tiles;
}
@@ -69,7 +70,7 @@ public partial class AtmosphereSystem
/// <param name="mapGrid">The grid where to get the tile.</param>
/// <param name="tile">The indices of the tile.</param>
/// <returns>The enumerator for the airtight components.</returns>
public AtmosObstructionEnumerator GetObstructingComponentsEnumerator(IMapGrid mapGrid, Vector2i tile)
public AtmosObstructionEnumerator GetObstructingComponentsEnumerator(MapGridComponent mapGrid, Vector2i tile)
{
var ancEnumerator = mapGrid.GetAnchoredEntitiesEnumerator(tile);
var airQuery = GetEntityQuery<AirtightComponent>();
@@ -78,7 +79,7 @@ public partial class AtmosphereSystem
return enumerator;
}
private AtmosDirection GetBlockedDirections(IMapGrid mapGrid, Vector2i indices)
private AtmosDirection GetBlockedDirections(MapGridComponent mapGrid, Vector2i indices)
{
var value = AtmosDirection.Invalid;
@@ -98,7 +99,7 @@ public partial class AtmosphereSystem
/// </summary>
/// <param name="mapGrid">The grid in question.</param>
/// <param name="tile">The indices of the tile.</param>
private void PryTile(IMapGrid mapGrid, Vector2i tile)
private void PryTile(MapGridComponent mapGrid, Vector2i tile)
{
if (!mapGrid.TryGetTileRef(tile, out var tileRef))
return;