Remove Explicit GridId References (#8315)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Acruid
2022-06-11 18:54:41 -07:00
committed by GitHub
parent 846321cebb
commit 4f9be42f40
131 changed files with 531 additions and 588 deletions

View File

@@ -1,8 +1,7 @@
using Content.Server.Administration;
using Content.Server.Administration;
using Content.Server.Atmos.Components;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.Map;
namespace Content.Server.Atmos.Commands
{
@@ -23,37 +22,29 @@ namespace Content.Server.Atmos.Commands
return;
}
if (!int.TryParse(args[0], out var id))
var entMan = IoCManager.Resolve<IEntityManager>();
if(EntityUid.TryParse(args[0], out var euid))
{
shell.WriteLine($"{args[0]} is not a valid integer.");
shell.WriteError($"Failed to parse euid '{args[0]}'.");
return;
}
var gridId = new GridId(id);
var mapMan = IoCManager.Resolve<IMapManager>();
if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp))
if (!entMan.HasComponent<IMapGridComponent>(euid))
{
shell.WriteLine($"{gridId} is not a valid grid id.");
shell.WriteError($"Euid '{euid}' does not exist or is not a grid.");
return;
}
if (!_entities.EntityExists(gridComp.GridEntityId))
{
shell.WriteLine("Failed to get grid entity.");
return;
}
if (_entities.HasComponent<IAtmosphereComponent>(gridComp.GridEntityId))
if (_entities.HasComponent<IAtmosphereComponent>(euid))
{
shell.WriteLine("Grid already has an atmosphere.");
return;
}
_entities.AddComponent<GridAtmosphereComponent>(gridComp.GridEntityId);
_entities.AddComponent<GridAtmosphereComponent>(euid);
shell.WriteLine($"Added atmosphere to grid {id}.");
shell.WriteLine($"Added atmosphere to grid {euid}.");
}
}
}

View File

@@ -1,4 +1,4 @@
using Content.Server.Administration;
using Content.Server.Administration;
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Administration;
using Content.Shared.Atmos;
@@ -12,22 +12,28 @@ namespace Content.Server.Atmos.Commands
{
public string Command => "addgas";
public string Description => "Adds gas at a certain position.";
public string Help => "addgas <X> <Y> <GridId> <Gas> <moles>";
public string Help => "addgas <X> <Y> <GridEid> <Gas> <moles>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length < 5) return;
if(!int.TryParse(args[0], out var x)
|| !int.TryParse(args[1], out var y)
|| !int.TryParse(args[2], out var id)
|| !EntityUid.TryParse(args[2], out var euid)
|| !(AtmosCommandUtils.TryParseGasID(args[3], out var gasId))
|| !float.TryParse(args[4], out var moles)) return;
var gridId = new GridId(id);
var entMan = IoCManager.Resolve<IEntityManager>();
if (!entMan.HasComponent<IMapGridComponent>(euid))
{
shell.WriteError($"Euid '{euid}' does not exist or is not a grid.");
return;
}
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
var indices = new Vector2i(x, y);
var tile = atmosphereSystem.GetTileMixture(gridId, indices, true);
var tile = atmosphereSystem.GetTileMixture(euid, indices, true);
if (tile == null)
{

View File

@@ -1,8 +1,7 @@
using Content.Server.Administration;
using Content.Server.Administration;
using Content.Server.Atmos.Components;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.Map;
namespace Content.Server.Atmos.Commands
{
@@ -21,39 +20,29 @@ namespace Content.Server.Atmos.Commands
return;
}
if (!int.TryParse(args[0], out var id))
{
shell.WriteLine($"{args[0]} is not a valid integer.");
return;
}
var gridId = new GridId(id);
var mapMan = IoCManager.Resolve<IMapManager>();
if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp))
{
shell.WriteLine($"{gridId} is not a valid grid id.");
return;
}
var entMan = IoCManager.Resolve<IEntityManager>();
if (!entMan.EntityExists(gridComp.GridEntityId))
if (EntityUid.TryParse(args[0], out var euid))
{
shell.WriteLine("Failed to get grid entity.");
shell.WriteError($"Failed to parse euid '{args[0]}'.");
return;
}
if (entMan.HasComponent<IAtmosphereComponent>(gridComp.GridEntityId))
if (!entMan.HasComponent<IMapGridComponent>(euid))
{
shell.WriteError($"Euid '{euid}' does not exist or is not a grid.");
return;
}
if (entMan.HasComponent<IAtmosphereComponent>(euid))
{
shell.WriteLine("Grid already has an atmosphere.");
return;
}
entMan.AddComponent<UnsimulatedGridAtmosphereComponent>(gridComp.GridEntityId);
entMan.AddComponent<UnsimulatedGridAtmosphereComponent>(euid);
shell.WriteLine($"Added unsimulated atmosphere to grid {id}.");
shell.WriteLine($"Added unsimulated atmosphere to grid {euid}.");
}
}

View File

@@ -18,7 +18,7 @@ namespace Content.Server.Atmos.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
GridId gridId;
EntityUid gridId;
Gas? gas = null;
var entMan = IoCManager.Resolve<IEntityManager>();
@@ -39,9 +39,9 @@ namespace Content.Server.Atmos.Commands
return;
}
gridId = entMan.GetComponent<TransformComponent>(playerEntity).GridID;
gridId = entMan.GetComponent<TransformComponent>(playerEntity).GridEntityId;
if (gridId == GridId.Invalid)
if (gridId == EntityUid.Invalid)
{
shell.WriteLine("You aren't on a grid to delete gas from.");
return;
@@ -51,7 +51,7 @@ namespace Content.Server.Atmos.Commands
}
case 1:
{
if (!int.TryParse(args[0], out var number))
if (!EntityUid.TryParse(args[0], out var number))
{
// Argument is a gas
if (player == null)
@@ -66,9 +66,9 @@ namespace Content.Server.Atmos.Commands
return;
}
gridId = entMan.GetComponent<TransformComponent>(playerEntity).GridID;
gridId = entMan.GetComponent<TransformComponent>(playerEntity).GridEntityId;
if (gridId == GridId.Invalid)
if (gridId == EntityUid.Invalid)
{
shell.WriteLine("You aren't on a grid to delete gas from.");
return;
@@ -85,27 +85,20 @@ namespace Content.Server.Atmos.Commands
}
// Argument is a grid
gridId = new GridId(number);
if (gridId == GridId.Invalid)
{
shell.WriteLine($"{gridId} is not a valid grid id.");
return;
}
gridId = number;
break;
}
case 2:
{
if (!int.TryParse(args[0], out var first))
if (!EntityUid.TryParse(args[0], out var first))
{
shell.WriteLine($"{args[0]} is not a valid integer for a grid id.");
return;
}
gridId = new GridId(first);
gridId = first;
if (gridId == GridId.Invalid)
if (gridId == EntityUid.Invalid)
{
shell.WriteLine($"{gridId} is not a valid grid id.");
return;

View File

@@ -1,4 +1,4 @@
using Content.Server.Administration;
using Content.Server.Administration;
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Administration;
using Content.Shared.Atmos;
@@ -12,17 +12,15 @@ namespace Content.Server.Atmos.Commands
{
public string Command => "fillgas";
public string Description => "Adds gas to all tiles in a grid.";
public string Help => "fillgas <GridId> <Gas> <moles>";
public string Help => "fillgas <GridEid> <Gas> <moles>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length < 3) return;
if(!int.TryParse(args[0], out var id)
if(!EntityUid.TryParse(args[0], out var gridId)
|| !(AtmosCommandUtils.TryParseGasID(args[1], out var gasId))
|| !float.TryParse(args[2], out var moles)) return;
var gridId = new GridId(id);
var mapMan = IoCManager.Resolve<IMapManager>();
if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out _))

View File

@@ -1,4 +1,4 @@
using Content.Server.Administration;
using Content.Server.Administration;
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Administration;
using Robust.Shared.Console;
@@ -18,15 +18,13 @@ namespace Content.Server.Atmos.Commands
if (args.Length < 5) return;
if(!int.TryParse(args[0], out var x)
|| !int.TryParse(args[1], out var y)
|| !int.TryParse(args[2], out var id)
|| !EntityUid.TryParse(args[2], out var id)
|| !float.TryParse(args[3], out var amount)
|| !bool.TryParse(args[4], out var ratio)) return;
var gridId = new GridId(id);
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
var indices = new Vector2i(x, y);
var tile = atmosphereSystem.GetTileMixture(gridId, indices, true);
var tile = atmosphereSystem.GetTileMixture(id, indices, true);
if (tile == null)
{

View File

@@ -1,4 +1,4 @@
using Content.Server.Administration;
using Content.Server.Administration;
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Administration;
using Content.Shared.Atmos;
@@ -17,11 +17,9 @@ namespace Content.Server.Atmos.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length < 2) return;
if(!int.TryParse(args[0], out var id)
if(!EntityUid.TryParse(args[0], out var gridId)
|| !float.TryParse(args[1], out var temperature)) return;
var gridId = new GridId(id);
var mapMan = IoCManager.Resolve<IMapManager>();
if (temperature < Atmospherics.TCMB)

View File

@@ -1,4 +1,4 @@
using Content.Server.Administration;
using Content.Server.Administration;
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Administration;
using Content.Shared.Atmos;
@@ -19,11 +19,9 @@ namespace Content.Server.Atmos.Commands
if (args.Length < 4) return;
if(!int.TryParse(args[0], out var x)
|| !int.TryParse(args[1], out var y)
|| !int.TryParse(args[2], out var id)
|| !EntityUid.TryParse(args[2], out var gridId)
|| !float.TryParse(args[3], out var temperature)) return;
var gridId = new GridId(id);
if (temperature < Atmospherics.TCMB)
{
shell.WriteLine("Invalid temperature.");

View File

@@ -7,7 +7,7 @@ namespace Content.Server.Atmos.Components
[RegisterComponent]
public sealed class AirtightComponent : Component
{
public (GridId Grid, Vector2i Tile) LastPosition { get; set; }
public (EntityUid Grid, Vector2i Tile) LastPosition { get; set; }
[DataField("airBlockedDirection", customTypeSerializer: typeof(FlagSerializer<AtmosDirectionFlags>))]
[ViewVariables]

View File

@@ -44,7 +44,7 @@ namespace Content.Server.Atmos.EntitySystems
var xform = Transform(uid);
// If the grid is deleting no point updating atmos.
if (_mapManager.TryGetGrid(xform.GridID, out var grid))
if (_mapManager.TryGetGrid(xform.GridEntityId, out var grid))
{
if (MetaData(grid.GridEntityId).EntityLifeStage > EntityLifeStage.MapInitialized) return;
}
@@ -56,7 +56,7 @@ namespace Content.Server.Atmos.EntitySystems
{
var xform = Transform(uid);
var gridId = xform.GridID;
var gridId = xform.GridEntityId;
var coords = xform.Coordinates;
var grid = _mapManager.GetGrid(gridId);
@@ -100,15 +100,15 @@ namespace Content.Server.Atmos.EntitySystems
{
if (!Resolve(airtight.Owner, ref xform)) return;
if (!xform.Anchored || !xform.GridID.IsValid())
if (!xform.Anchored || !xform.GridEntityId.IsValid())
return;
var grid = _mapManager.GetGrid(xform.GridID);
airtight.LastPosition = (xform.GridID, grid.TileIndicesFor(xform.Coordinates));
var grid = _mapManager.GetGrid(xform.GridEntityId);
airtight.LastPosition = (xform.GridEntityId, grid.TileIndicesFor(xform.Coordinates));
InvalidatePosition(airtight.LastPosition.Item1, airtight.LastPosition.Item2, airtight.FixVacuum && !airtight.AirBlocked);
}
public void InvalidatePosition(GridId gridId, Vector2i pos, bool fixVacuum = false)
public void InvalidatePosition(EntityUid gridId, Vector2i pos, bool fixVacuum = false)
{
if (!gridId.IsValid())
return;

View File

@@ -157,7 +157,7 @@ namespace Content.Server.Atmos.EntitySystems
}
}
RaiseNetworkEvent(new AtmosDebugOverlayMessage(grid.Index, baseTile, debugOverlayContent), session.ConnectedClient);
RaiseNetworkEvent(new AtmosDebugOverlayMessage(grid.GridEntityId, baseTile, debugOverlayContent), session.ConnectedClient);
}
}
}

View File

@@ -57,26 +57,25 @@ public sealed partial class AtmosphereSystem
mixtures[5].AdjustMoles(Gas.Plasma, Atmospherics.MolesCellGasMiner);
mixtures[5].Temperature = 5000f;
var entMan = IoCManager.Resolve<IEntityManager>();
foreach (var gid in args)
{
// I like offering detailed error messages, that's why I don't use one of the extension methods.
if (!int.TryParse(gid, out var i) || i <= 0)
if(EntityUid.TryParse(gid, out var euid))
{
shell.WriteError($"Invalid grid ID \"{gid}\".");
continue;
shell.WriteError($"Failed to parse euid '{gid}'.");
return;
}
var gridId = new GridId(i);
if (!_mapManager.TryGetGrid(gridId, out var mapGrid))
if (!TryComp(euid, out IMapGridComponent? gridComp))
{
shell.WriteError($"Grid \"{i}\" doesn't exist.");
continue;
shell.WriteError($"Euid '{euid}' does not exist or is not a grid.");
return;
}
if (!TryComp(mapGrid.GridEntityId, out GridAtmosphereComponent? gridAtmosphere))
if (!TryComp(euid, out GridAtmosphereComponent? gridAtmosphere))
{
shell.WriteError($"Grid \"{i}\" has no atmosphere component, try addatmos.");
shell.WriteError($"Grid \"{euid}\" has no atmosphere component, try addatmos.");
continue;
}
@@ -88,7 +87,7 @@ public sealed partial class AtmosphereSystem
tile.Clear();
var mixtureId = 0;
foreach (var entUid in mapGrid.GetAnchoredEntities(indices))
foreach (var entUid in gridComp.Grid.GetAnchoredEntities(indices))
{
if (!TryComp(entUid, out AtmosFixMarkerComponent? afm))
continue;

View File

@@ -40,7 +40,7 @@ namespace Content.Server.Atmos.EntitySystems
{
try
{
gridAtmosphere.Tiles.Add(indices, new TileAtmosphere(mapGrid.GridIndex, indices, (GasMixture) gridAtmosphere.UniqueMixes![mix].Clone()));
gridAtmosphere.Tiles.Add(indices, new TileAtmosphere(mapGrid.Owner, indices, (GasMixture) gridAtmosphere.UniqueMixes![mix].Clone()));
}
catch (ArgumentOutOfRangeException)
{
@@ -125,7 +125,7 @@ namespace Content.Server.Atmos.EntitySystems
/// </summary>
/// <param name="grid">Grid to be checked.</param>
/// <returns>Whether the grid has a simulated atmosphere.</returns>
public bool IsSimulatedGrid(GridId grid)
public bool IsSimulatedGrid(EntityUid grid)
{
if (!_mapManager.TryGetGrid(grid, out var mapGrid))
return false;
@@ -160,7 +160,7 @@ namespace Content.Server.Atmos.EntitySystems
/// <param name="grid">Grid where to get all tile mixtures from.</param>
/// <param name="invalidate">Whether to invalidate all tiles.</param>
/// <returns>All tile mixtures in a grid.</returns>
public IEnumerable<GasMixture> GetAllTileMixtures(GridId grid, bool invalidate = false)
public IEnumerable<GasMixture> GetAllTileMixtures(EntityUid grid, bool invalidate = false)
{
// Return an array with a single space gas mixture for invalid grids.
if (!grid.IsValid())
@@ -207,7 +207,7 @@ namespace Content.Server.Atmos.EntitySystems
/// <param name="grid">The grid in question.</param>
/// <param name="tiles">The amount of tiles.</param>
/// <returns>The volume in liters that the tiles occupy.</returns>
public float GetVolumeForTiles(GridId grid, int tiles = 1)
public float GetVolumeForTiles(EntityUid grid, int tiles = 1)
{
if (!_mapManager.TryGetGrid(grid, out var mapGrid))
return Atmospherics.CellVolume * tiles;
@@ -289,7 +289,7 @@ namespace Content.Server.Atmos.EntitySystems
foreach (var tile in mapGrid.GetAllTiles())
{
if(!gridAtmosphere.Tiles.ContainsKey(tile.GridIndices))
gridAtmosphere.Tiles[tile.GridIndices] = new TileAtmosphere(tile.GridIndex, tile.GridIndices, new GasMixture(volume){Temperature = Atmospherics.T20C});
gridAtmosphere.Tiles[tile.GridIndices] = new TileAtmosphere(tile.GridUid, tile.GridIndices, new GasMixture(volume){Temperature = Atmospherics.T20C});
InvalidateTile(gridAtmosphere, tile.GridIndices);
}
@@ -297,7 +297,7 @@ namespace Content.Server.Atmos.EntitySystems
foreach (var (position, tile) in gridAtmosphere.Tiles.ToArray())
{
UpdateAdjacent(mapGrid, gridAtmosphere, tile);
InvalidateVisuals(mapGrid.Index, position);
InvalidateVisuals(mapGrid.GridEntityId, position);
}
}
@@ -337,7 +337,7 @@ namespace Content.Server.Atmos.EntitySystems
/// </summary>
/// <param name="grid">Grid where to invalidate the tile.</param>
/// <param name="tile">The indices of the tile.</param>
public void InvalidateTile(GridId grid, Vector2i tile)
public void InvalidateTile(EntityUid grid, Vector2i tile)
{
if (!_mapManager.TryGetGrid(grid, out var mapGrid))
return;
@@ -371,7 +371,7 @@ namespace Content.Server.Atmos.EntitySystems
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void InvalidateVisuals(GridId grid, Vector2i tile)
public void InvalidateVisuals(EntityUid grid, Vector2i tile)
{
_gasTileOverlaySystem.Invalidate(grid, tile);
}
@@ -401,7 +401,7 @@ namespace Content.Server.Atmos.EntitySystems
/// <param name="tile">Indices of the tile.</param>
/// <remarks>Do NOT use this outside of atmos internals.</remarks>
/// <returns>The Tile Atmosphere in the position, or null.</returns>
public TileAtmosphere? GetTileAtmosphere(GridId grid, Vector2i tile)
public TileAtmosphere? GetTileAtmosphere(EntityUid grid, Vector2i tile)
{
if (!_mapManager.TryGetGrid(grid, out var mapGrid))
return null;
@@ -450,7 +450,7 @@ namespace Content.Server.Atmos.EntitySystems
/// <param name="tile">Indices of the tile.</param>
/// <remarks>Do NOT use this outside of atmos internals.</remarks>
/// <returns>The tile atmosphere of a specific position in a grid, a space tile atmosphere if the tile is space or null if the grid doesn't exist.</returns>
public TileAtmosphere? GetTileAtmosphereOrCreateSpace(GridId grid, Vector2i tile)
public TileAtmosphere? GetTileAtmosphereOrCreateSpace(EntityUid grid, Vector2i tile)
{
if (!_mapManager.TryGetGrid(grid, out var mapGrid))
return null;
@@ -480,7 +480,7 @@ namespace Content.Server.Atmos.EntitySystems
// attempts to get the tile atmosphere for it before it has been revalidated by atmos.
// The tile atmosphere will get revalidated on the next atmos tick, however.
return tileAtmosphere ?? new TileAtmosphere(mapGrid.Index, tile, new GasMixture(Atmospherics.CellVolume) {Temperature = Atmospherics.TCMB}, true);
return tileAtmosphere ?? new TileAtmosphere(mapGrid.GridEntityId, tile, new GasMixture(Atmospherics.CellVolume) {Temperature = Atmospherics.TCMB}, true);
}
#endregion
@@ -502,7 +502,7 @@ namespace Content.Server.Atmos.EntitySystems
/// </summary>
/// <param name="grid">Grid where to get the tile.</param>
/// <param name="tile">Indices of the tile to be activated.</param>
public void AddActiveTile(GridId grid, Vector2i tile)
public void AddActiveTile(EntityUid grid, Vector2i tile)
{
if (!_mapManager.TryGetGrid(grid, out var mapGrid))
return;
@@ -563,7 +563,7 @@ namespace Content.Server.Atmos.EntitySystems
/// <param name="grid">Grid where to get the tile.</param>
/// <param name="tile">Indices of the tile to be deactivated.</param>
/// <param name="disposeExcitedGroup">Whether to dispose of the tile's <see cref="ExcitedGroup"/></param>
public void RemoveActiveTile(GridId grid, Vector2i tile, bool disposeExcitedGroup = true)
public void RemoveActiveTile(EntityUid grid, Vector2i tile, bool disposeExcitedGroup = true)
{
if (!_mapManager.TryGetGrid(grid, out var mapGrid))
return;
@@ -632,7 +632,7 @@ namespace Content.Server.Atmos.EntitySystems
/// <param name="tile">Indices of the tile.</param>
/// <param name="invalidate">Whether to invalidate the tile.</param>
/// <returns>The tile mixture, or null</returns>
public GasMixture? GetTileMixture(GridId grid, Vector2i tile, bool invalidate = false)
public GasMixture? GetTileMixture(EntityUid grid, Vector2i tile, bool invalidate = false)
{
// Always return space gas mixtures for invalid grids (grid 0)
if (!grid.IsValid())
@@ -699,7 +699,7 @@ namespace Content.Server.Atmos.EntitySystems
/// <param name="grid">Grid where to get the tile.</param>
/// <param name="tile">Indices of the tile.</param>
/// <returns>Reaction results.</returns>
public ReactionResult React(GridId grid, Vector2i tile)
public ReactionResult React(EntityUid grid, Vector2i tile)
{
if (!_mapManager.TryGetGrid(grid, out var mapGrid))
return ReactionResult.NoReaction;
@@ -755,7 +755,7 @@ namespace Content.Server.Atmos.EntitySystems
/// <param name="tile">Indices of the tile.</param>
/// <param name="direction">Directions to check.</param>
/// <returns>Whether the tile is blocked in the directions specified.</returns>
public bool IsTileAirBlocked(GridId grid, Vector2i tile, AtmosDirection direction = AtmosDirection.All)
public bool IsTileAirBlocked(EntityUid grid, Vector2i tile, AtmosDirection direction = AtmosDirection.All)
{
if (!_mapManager.TryGetGrid(grid, out var mapGrid))
return false;
@@ -816,7 +816,7 @@ namespace Content.Server.Atmos.EntitySystems
/// <param name="grid">Grid where to check the tile.</param>
/// <param name="tile">Indices of the tile.</param>
/// <returns>Whether the tile is space or not.</returns>
public bool IsTileSpace(GridId grid, Vector2i tile)
public bool IsTileSpace(EntityUid grid, Vector2i tile)
{
return !_mapManager.TryGetGrid(grid, out var mapGrid) || IsTileSpace(mapGrid, tile);
}
@@ -847,7 +847,7 @@ namespace Content.Server.Atmos.EntitySystems
/// <summary>
/// Get a tile's heat capacity, based on the tile type, tile contents and tile gas mixture.
/// </summary>
public float GetTileHeatCapacity(GridId grid, Vector2i tile)
public float GetTileHeatCapacity(EntityUid grid, Vector2i tile)
{
// Always return space gas mixtures for invalid grids (grid 0)
if (!grid.IsValid())
@@ -913,7 +913,7 @@ namespace Content.Server.Atmos.EntitySystems
/// <param name="tile">Indices of the tile.</param>
/// <param name="includeBlocked">Whether to include tiles in directions the tile is air-blocked in.</param>
/// <returns>The positions adjacent to the tile.</returns>
public IEnumerable<Vector2i> GetAdjacentTiles(GridId grid, Vector2i tile, bool includeBlocked = false)
public IEnumerable<Vector2i> GetAdjacentTiles(EntityUid grid, Vector2i tile, bool includeBlocked = false)
{
if (!_mapManager.TryGetGrid(grid, out var mapGrid))
return Enumerable.Empty<Vector2i>();
@@ -986,7 +986,7 @@ namespace Content.Server.Atmos.EntitySystems
/// <param name="includeBlocked">Whether to include tiles in directions the tile is air-blocked in.</param>
/// <param name="invalidate">Whether to invalidate all adjacent tiles.</param>
/// <returns>All adjacent tile gas mixtures to the tile in question</returns>
public IEnumerable<GasMixture> GetAdjacentTileMixtures(GridId grid, Vector2i tile, bool includeBlocked = false, bool invalidate = false)
public IEnumerable<GasMixture> GetAdjacentTileMixtures(EntityUid grid, Vector2i tile, bool includeBlocked = false, bool invalidate = false)
{
// For invalid grids, return an array with a single space gas mixture in it.
if (!grid.IsValid())
@@ -1073,7 +1073,7 @@ namespace Content.Server.Atmos.EntitySystems
/// </summary>
/// <param name="grid">Grid where to get the tile.</param>
/// <param name="tile">Indices of the tile.</param>
public void UpdateAdjacent(GridId grid, Vector2i tile)
public void UpdateAdjacent(EntityUid grid, Vector2i tile)
{
if (!_mapManager.TryGetGrid(grid, out var mapGrid))
return;
@@ -1149,7 +1149,7 @@ namespace Content.Server.Atmos.EntitySystems
/// <param name="grid">Grid where to get the tile.</param>
/// <param name="tile">Indices of the tile.</param>
/// <param name="direction">Direction to be updated.</param>
public void UpdateAdjacent(GridId grid, Vector2i tile, AtmosDirection direction)
public void UpdateAdjacent(EntityUid grid, Vector2i tile, AtmosDirection direction)
{
if (!_mapManager.TryGetGrid(grid, out var mapGrid))
return;
@@ -1227,7 +1227,7 @@ namespace Content.Server.Atmos.EntitySystems
/// <param name="exposedTemperature">Temperature to expose to the tile.</param>
/// <param name="exposedVolume">Volume of the exposed temperature.</param>
/// <param name="soh">If true, the existing hotspot values will be set to the exposed values, but only if they're smaller.</param>
public void HotspotExpose(GridId grid, Vector2i tile, float exposedTemperature, float exposedVolume, bool soh = false)
public void HotspotExpose(EntityUid grid, Vector2i tile, float exposedTemperature, float exposedVolume, bool soh = false)
{
if (!_mapManager.TryGetGrid(grid, out var mapGrid))
return;
@@ -1264,7 +1264,7 @@ namespace Content.Server.Atmos.EntitySystems
/// </summary>
/// <param name="grid">Grid where to get the tile.</param>
/// <param name="tile">Indices of the tile.</param>
public void HotspotExtinguish(GridId grid, Vector2i tile)
public void HotspotExtinguish(EntityUid grid, Vector2i tile)
{
if (!_mapManager.TryGetGrid(grid, out var mapGrid))
return;
@@ -1313,7 +1313,7 @@ namespace Content.Server.Atmos.EntitySystems
/// <param name="grid">Grid where to get the tile</param>
/// <param name="tile">Indices for the tile</param>
/// <returns>Whether the hotspot is active or not.</returns>
public bool IsHotspotActive(GridId grid, Vector2i tile)
public bool IsHotspotActive(EntityUid grid, Vector2i tile)
{
if (!_mapManager.TryGetGrid(grid, out var mapGrid))
return false;
@@ -1376,7 +1376,7 @@ namespace Content.Server.Atmos.EntitySystems
public bool AddAtmosDevice(AtmosDeviceComponent atmosDevice)
{
var grid = Comp<TransformComponent>(atmosDevice.Owner).GridID;
var grid = Comp<TransformComponent>(atmosDevice.Owner).GridEntityId;
if (!_mapManager.TryGetGrid(grid, out var mapGrid))
return false;
@@ -1438,7 +1438,7 @@ namespace Content.Server.Atmos.EntitySystems
/// <param name="grid">Grid where to get the tile.</param>
/// <param name="tile">Indices of the tile.</param>
/// <returns>Whether the tile's gas mixture is probably safe.</returns>
public bool IsTileMixtureProbablySafe(GridId grid, Vector2i tile)
public bool IsTileMixtureProbablySafe(EntityUid grid, Vector2i tile)
{
return IsMixtureProbablySafe(GetTileMixture(grid, tile));
}
@@ -1491,7 +1491,7 @@ namespace Content.Server.Atmos.EntitySystems
/// </summary>
/// <param name="grid">Grid where to get the tile.</param>
/// <param name="tile">Indices of the tile.</param>
public void FixVacuum(GridId grid, Vector2i tile)
public void FixVacuum(EntityUid grid, Vector2i tile)
{
if (!_mapManager.TryGetGrid(grid, out var mapGrid))
return;
@@ -1558,7 +1558,7 @@ namespace Content.Server.Atmos.EntitySystems
return tile.GridIndices.GetTileRef(tile.GridIndex, _mapManager);
}
public bool TryGetGridAndTile(MapCoordinates coordinates, [NotNullWhen(true)] out (GridId Grid, Vector2i Tile)? tuple)
public bool TryGetGridAndTile(MapCoordinates coordinates, [NotNullWhen(true)] out (EntityUid Grid, Vector2i Tile)? tuple)
{
if (!_mapManager.TryFindGridAt(coordinates, out var grid))
{
@@ -1566,11 +1566,11 @@ namespace Content.Server.Atmos.EntitySystems
return false;
}
tuple = (grid.Index, grid.TileIndicesFor(coordinates));
tuple = (grid.GridEntityId, grid.TileIndicesFor(coordinates));
return true;
}
public bool TryGetGridAndTile(EntityCoordinates coordinates, [NotNullWhen(true)] out (GridId Grid, Vector2i Tile)? tuple)
public bool TryGetGridAndTile(EntityCoordinates coordinates, [NotNullWhen(true)] out (EntityUid Grid, Vector2i Tile)? tuple)
{
if (!coordinates.IsValid(EntityManager))
{
@@ -1578,7 +1578,7 @@ namespace Content.Server.Atmos.EntitySystems
return false;
}
var gridId = coordinates.GetGridId(EntityManager);
var gridId = coordinates.GetGridEntityId(EntityManager);
if (!_mapManager.TryGetGrid(gridId, out var grid))
{

View File

@@ -54,7 +54,7 @@ namespace Content.Server.Atmos.EntitySystems
if (tile == null)
{
tile = new TileAtmosphere(mapGrid.Index, indices, new GasMixture(volume){Temperature = Atmospherics.T20C});
tile = new TileAtmosphere(mapGrid.GridEntityId, indices, new GasMixture(volume){Temperature = Atmospherics.T20C});
atmosphere.Tiles[indices] = tile;
}
@@ -110,7 +110,7 @@ namespace Content.Server.Atmos.EntitySystems
var tileDef = GetTile(tile)?.Tile.GetContentTileDefinition(_tileDefinitionManager);
tile.ThermalConductivity = tileDef?.ThermalConductivity ?? 0.5f;
tile.HeatCapacity = tileDef?.HeatCapacity ?? float.PositiveInfinity;
InvalidateVisuals(mapGrid.Index, indices);
InvalidateVisuals(mapGrid.GridEntityId, indices);
for (var i = 0; i < Atmospherics.Directions; i++)
{

View File

@@ -58,7 +58,7 @@ namespace Content.Server.Atmos.EntitySystems
return;
}
InvalidateTile(ev.NewTile.GridIndex, ev.NewTile.GridIndices);
InvalidateTile(ev.NewTile.GridUid, ev.NewTile.GridIndices);
}
public override void Update(float frameTime)

View File

@@ -29,7 +29,7 @@ namespace Content.Server.Atmos.EntitySystems
/// <summary>
/// The tiles that have had their atmos data updated since last tick
/// </summary>
private readonly Dictionary<GridId, HashSet<Vector2i>> _invalidTiles = new();
private readonly Dictionary<EntityUid, HashSet<Vector2i>> _invalidTiles = new();
private readonly Dictionary<IPlayerSession, PlayerGasOverlay> _knownPlayerChunks =
new();
@@ -37,7 +37,7 @@ namespace Content.Server.Atmos.EntitySystems
/// <summary>
/// Gas data stored in chunks to make PVS / bubbling easier.
/// </summary>
private readonly Dictionary<GridId, Dictionary<Vector2i, GasOverlayChunk>> _overlay =
private readonly Dictionary<EntityUid, Dictionary<Vector2i, GasOverlayChunk>> _overlay =
new();
/// <summary>
@@ -77,7 +77,7 @@ namespace Content.Server.Atmos.EntitySystems
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Invalidate(GridId gridIndex, Vector2i indices)
public void Invalidate(EntityUid gridIndex, Vector2i indices)
{
if (!_invalidTiles.TryGetValue(gridIndex, out var existing))
{
@@ -88,7 +88,7 @@ namespace Content.Server.Atmos.EntitySystems
existing.Add(indices);
}
private GasOverlayChunk GetOrCreateChunk(GridId gridIndex, Vector2i indices)
private GasOverlayChunk GetOrCreateChunk(EntityUid gridIndex, Vector2i indices)
{
if (!_overlay.TryGetValue(gridIndex, out var chunks))
{
@@ -204,7 +204,7 @@ namespace Content.Server.Atmos.EntitySystems
foreach (var grid in _mapManager.FindGridsIntersecting(xform.MapID, worldBounds))
{
if (!_overlay.TryGetValue(grid.Index, out var chunks))
if (!_overlay.TryGetValue(grid.GridEntityId, out var chunks))
{
continue;
}
@@ -256,7 +256,7 @@ namespace Content.Server.Atmos.EntitySystems
AccumulatedFrameTime -= _updateCooldown;
var gridAtmosComponents = new Dictionary<GridId, GridAtmosphereComponent>();
var gridAtmosComponents = new Dictionary<EntityUid, GridAtmosphereComponent>();
var updatedTiles = new Dictionary<GasOverlayChunk, HashSet<Vector2i>>();
// So up to this point we've been caching the updated tiles for multiple ticks.
@@ -351,7 +351,7 @@ namespace Content.Server.Atmos.EntitySystems
overlay.RemoveChunk(chunk);
}
var clientInvalids = new Dictionary<GridId, List<(Vector2i, GasOverlayData)>>();
var clientInvalids = new Dictionary<EntityUid, List<(Vector2i, GasOverlayData)>>();
// Check for any dirty chunks in range and bundle the data to send to the client.
foreach (var chunk in chunksInRange)
@@ -378,13 +378,13 @@ namespace Content.Server.Atmos.EntitySystems
}
private sealed class PlayerGasOverlay
{
private readonly Dictionary<GridId, Dictionary<Vector2i, GasOverlayChunk>> _data =
private readonly Dictionary<EntityUid, Dictionary<Vector2i, GasOverlayChunk>> _data =
new();
private readonly Dictionary<GasOverlayChunk, GameTick> _lastSent =
new();
public GasOverlayMessage UpdateClient(GridId grid, List<(Vector2i, GasOverlayData)> data)
public GasOverlayMessage UpdateClient(EntityUid grid, List<(Vector2i, GasOverlayData)> data)
{
return new(grid, data);
}

View File

@@ -32,7 +32,7 @@ namespace Content.Server.Atmos.Piping.Components
[ViewVariables]
public TimeSpan LastProcess { get; set; } = TimeSpan.Zero;
public GridId? JoinedGrid { get; set; }
public EntityUid? JoinedGrid { get; set; }
}
public sealed class AtmosDeviceUpdateEvent : EntityEventArgs

View File

@@ -29,7 +29,7 @@ public sealed class AtmosPipeAppearanceSystem : EntitySystem
if (!Resolve(uid, ref appearance, ref container, ref xform, false))
return;
if (!_mapManager.TryGetGrid(xform.GridID, out var grid))
if (!_mapManager.TryGetGrid(xform.GridEntityId, out var grid))
return;
// get connected entities

View File

@@ -30,7 +30,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
return;
// If we can't find any ports, cancel the anchoring.
if(!FindGasPortIn(transform.GridID, transform.Coordinates, out _))
if(!FindGasPortIn(transform.GridEntityId, transform.Coordinates, out _))
args.Cancel();
}
@@ -50,7 +50,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
}
}
private bool FindGasPortIn(GridId gridId, EntityCoordinates coordinates, [NotNullWhen(true)] out GasPortComponent? port)
private bool FindGasPortIn(EntityUid gridId, EntityCoordinates coordinates, [NotNullWhen(true)] out GasPortComponent? port)
{
port = null;

View File

@@ -62,7 +62,7 @@ namespace Content.Server.Atmos
public AtmosDirection LastPressureDirection;
[ViewVariables]
public GridId GridIndex { get; }
public EntityUid GridIndex { get; }
[ViewVariables]
public TileRef? Tile => GridIndices.GetTileRef(GridIndex);
@@ -93,7 +93,7 @@ namespace Content.Server.Atmos
[ViewVariables]
public AtmosDirection BlockedAirflow { get; set; } = AtmosDirection.Invalid;
public TileAtmosphere(GridId gridIndex, Vector2i gridIndices, GasMixture? mixture = null, bool immutable = false)
public TileAtmosphere(EntityUid gridIndex, Vector2i gridIndices, GasMixture? mixture = null, bool immutable = false)
{
GridIndex = gridIndex;
GridIndices = gridIndices;