Nullable grid Uid (#8798)
This commit is contained in:
@@ -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.GridEntityId, out var grid))
|
||||
if (_mapManager.TryGetGrid(xform.GridUid, out var grid))
|
||||
{
|
||||
if (MetaData(grid.GridEntityId).EntityLifeStage > EntityLifeStage.MapInitialized) return;
|
||||
}
|
||||
@@ -56,15 +56,17 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
{
|
||||
var xform = Transform(uid);
|
||||
|
||||
var gridId = xform.GridEntityId;
|
||||
if (!TryComp(xform.GridUid, out IMapGridComponent? grid))
|
||||
return;
|
||||
|
||||
var gridId = xform.GridUid;
|
||||
var coords = xform.Coordinates;
|
||||
|
||||
var grid = _mapManager.GetGrid(gridId);
|
||||
var tilePos = grid.TileIndicesFor(coords);
|
||||
var tilePos = grid.Grid.TileIndicesFor(coords);
|
||||
|
||||
// Update and invalidate new position.
|
||||
airtight.LastPosition = (gridId, tilePos);
|
||||
InvalidatePosition(gridId, tilePos);
|
||||
airtight.LastPosition = (gridId.Value, tilePos);
|
||||
InvalidatePosition(gridId.Value, tilePos);
|
||||
}
|
||||
|
||||
private void OnAirtightReAnchor(EntityUid uid, AirtightComponent airtight, ref ReAnchorEvent args)
|
||||
@@ -100,11 +102,10 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
{
|
||||
if (!Resolve(airtight.Owner, ref xform)) return;
|
||||
|
||||
if (!xform.Anchored || !xform.GridEntityId.IsValid())
|
||||
if (!xform.Anchored || !_mapManager.TryGetGrid(xform.GridUid, out var grid))
|
||||
return;
|
||||
|
||||
var grid = _mapManager.GetGrid(xform.GridEntityId);
|
||||
airtight.LastPosition = (xform.GridEntityId, grid.TileIndicesFor(xform.Coordinates));
|
||||
airtight.LastPosition = (xform.GridUid.Value, grid.TileIndicesFor(xform.Coordinates));
|
||||
InvalidatePosition(airtight.LastPosition.Item1, airtight.LastPosition.Item2, airtight.FixVacuum && !airtight.AirBlocked);
|
||||
}
|
||||
|
||||
|
||||
@@ -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(EntityUid grid)
|
||||
public bool IsSimulatedGrid(EntityUid? grid)
|
||||
{
|
||||
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).GridEntityId;
|
||||
var grid = Comp<TransformComponent>(atmosDevice.Owner).GridUid;
|
||||
|
||||
if (!_mapManager.TryGetGrid(grid, out var mapGrid))
|
||||
return false;
|
||||
@@ -1578,7 +1578,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
return false;
|
||||
}
|
||||
|
||||
var gridId = coordinates.GetGridEntityId(EntityManager);
|
||||
var gridId = coordinates.GetGridUid(EntityManager);
|
||||
|
||||
if (!_mapManager.TryGetGrid(gridId, out var grid))
|
||||
{
|
||||
@@ -1586,7 +1586,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
return false;
|
||||
}
|
||||
|
||||
tuple = (gridId, grid.TileIndicesFor(coordinates));
|
||||
tuple = (gridId.Value, grid.TileIndicesFor(coordinates));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -161,7 +161,6 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
xforms.GetComponent(entity),
|
||||
body);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user