Remove 700 usages of Component.Owner (#21100)

This commit is contained in:
DrSmugleaf
2023-10-19 12:34:31 -07:00
committed by GitHub
parent 5825ffb95c
commit f560f88eb5
261 changed files with 2291 additions and 2036 deletions

View File

@@ -3,7 +3,6 @@ using Content.Server.Atmos.Components;
using Content.Server.Atmos.Reactions;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Components;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Utility;
@@ -57,7 +56,7 @@ public sealed partial class AtmosphereSystem
tile.GridIndex = uid;
}
GridRepopulateTiles(mapGrid, gridAtmosphere);
GridRepopulateTiles((uid, mapGrid, gridAtmosphere));
}
private void OnGridSplit(EntityUid uid, GridAtmosphereComponent originalGridAtmos, ref GridSplitEvent args)
@@ -65,14 +64,12 @@ public sealed partial class AtmosphereSystem
foreach (var newGrid in args.NewGrids)
{
// Make extra sure this is a valid grid.
if (!_mapManager.TryGetGrid(newGrid, out var mapGrid))
if (!TryComp(newGrid, out MapGridComponent? mapGrid))
continue;
var entity = mapGrid.Owner;
// If the new split grid has an atmosphere already somehow, use that. Otherwise, add a new one.
if (!TryComp(entity, out GridAtmosphereComponent? newGridAtmos))
newGridAtmos = AddComp<GridAtmosphereComponent>(entity);
if (!TryComp(newGrid, out GridAtmosphereComponent? newGridAtmos))
newGridAtmos = AddComp<GridAtmosphereComponent>(newGrid);
// We assume the tiles on the new grid have the same coordinates as they did on the old grid...
var enumerator = mapGrid.GetAllTilesEnumerator();
@@ -505,16 +502,15 @@ public sealed partial class AtmosphereSystem
args.Handled = component.PipeNets.Remove(args.PipeNet);
}
private void GridAddAtmosDevice(EntityUid uid, GridAtmosphereComponent component,
ref AddAtmosDeviceMethodEvent args)
private void GridAddAtmosDevice(Entity<GridAtmosphereComponent> grid, ref AddAtmosDeviceMethodEvent args)
{
if (args.Handled)
return;
if (!component.AtmosDevices.Add(args.Device))
if (!grid.Comp.AtmosDevices.Add((args.Device.Owner, args.Device)))
return;
args.Device.JoinedGrid = uid;
args.Device.JoinedGrid = grid;
args.Handled = true;
args.Result = true;
}
@@ -525,7 +521,7 @@ public sealed partial class AtmosphereSystem
if (args.Handled)
return;
if (!component.AtmosDevices.Remove(args.Device))
if (!component.AtmosDevices.Remove((args.Device.Owner, args.Device)))
return;
args.Device.JoinedGrid = null;
@@ -538,8 +534,9 @@ 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(MapGridComponent mapGrid, GridAtmosphereComponent gridAtmosphere)
private void GridRepopulateTiles(Entity<MapGridComponent, GridAtmosphereComponent> grid)
{
var (uid, mapGrid, gridAtmosphere) = grid;
var volume = GetVolumeForTiles(mapGrid, 1);
foreach (var tile in mapGrid.GetAllTiles())
@@ -551,16 +548,14 @@ public sealed partial class AtmosphereSystem
gridAtmosphere.InvalidatedCoords.Add(tile.GridIndices);
}
var uid = gridAtmosphere.Owner;
TryComp(gridAtmosphere.Owner, out GasTileOverlayComponent? overlay);
TryComp(uid, out GasTileOverlayComponent? overlay);
// Gotta do this afterwards so we can properly update adjacent tiles.
foreach (var (position, _) in gridAtmosphere.Tiles.ToArray())
{
var ev = new UpdateAdjacentMethodEvent(uid, position);
GridUpdateAdjacent(uid, gridAtmosphere, ref ev);
InvalidateVisuals(mapGrid.Owner, position, overlay);
InvalidateVisuals(uid, position, overlay);
}
}
}