Code cleanup: puddles and spreaders (#26102)
* Removed obsolete MapManager calls * More code cleanup * EnsureComp * Rerun tests
This commit is contained in:
@@ -41,7 +41,7 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
|
||||
{
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly SharedMapSystem _map = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly ITileDefinitionManager _tileDefMan = default!;
|
||||
@@ -124,7 +124,7 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
|
||||
foreach (var neighbor in args.NeighborFreeTiles)
|
||||
{
|
||||
var split = overflow.SplitSolution(spillAmount);
|
||||
TrySpillAt(neighbor.Grid.GridTileToLocal(neighbor.Tile), split, out _, false);
|
||||
TrySpillAt(_map.GridTileToLocal(neighbor.Tile.GridUid, neighbor.Grid, neighbor.Tile.GridIndices), split, out _, false);
|
||||
args.Updates--;
|
||||
|
||||
if (args.Updates <= 0)
|
||||
@@ -612,13 +612,14 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_mapManager.TryGetGrid(coordinates.GetGridUid(EntityManager), out var mapGrid))
|
||||
var gridUid = coordinates.GetGridUid(EntityManager);
|
||||
if (!TryComp<MapGridComponent>(gridUid, out var mapGrid))
|
||||
{
|
||||
puddleUid = EntityUid.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
return TrySpillAt(mapGrid.GetTileRef(coordinates), solution, out puddleUid, sound);
|
||||
return TrySpillAt(_map.GetTileRef(gridUid.Value, mapGrid, coordinates), solution, out puddleUid, sound);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -657,7 +658,7 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
|
||||
|
||||
// Let's not spill to invalid grids.
|
||||
var gridId = tileRef.GridUid;
|
||||
if (!_mapManager.TryGetGrid(gridId, out var mapGrid))
|
||||
if (!TryComp<MapGridComponent>(gridId, out var mapGrid))
|
||||
{
|
||||
puddleUid = EntityUid.Invalid;
|
||||
return false;
|
||||
@@ -678,7 +679,7 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
|
||||
|
||||
// Get normalized co-ordinate for spill location and spill it in the centre
|
||||
// TODO: Does SnapGrid or something else already do this?
|
||||
var anchored = mapGrid.GetAnchoredEntitiesEnumerator(tileRef.GridIndices);
|
||||
var anchored = _map.GetAnchoredEntitiesEnumerator(gridId, mapGrid, tileRef.GridIndices);
|
||||
var puddleQuery = GetEntityQuery<PuddleComponent>();
|
||||
var sparklesQuery = GetEntityQuery<EvaporationSparkleComponent>();
|
||||
|
||||
@@ -703,7 +704,7 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
|
||||
return true;
|
||||
}
|
||||
|
||||
var coords = mapGrid.GridTileToLocal(tileRef.GridIndices);
|
||||
var coords = _map.GridTileToLocal(gridId, mapGrid, tileRef.GridIndices);
|
||||
puddleUid = EntityManager.SpawnEntity("Puddle", coords);
|
||||
EnsureComp<PuddleComponent>(puddleUid);
|
||||
if (TryAddSolution(puddleUid, solution, sound))
|
||||
@@ -740,7 +741,7 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
|
||||
if (!TryComp<MapGridComponent>(tile.GridUid, out var grid))
|
||||
return false;
|
||||
|
||||
var anc = grid.GetAnchoredEntitiesEnumerator(tile.GridIndices);
|
||||
var anc = _map.GetAnchoredEntitiesEnumerator(tile.GridUid, grid, tile.GridIndices);
|
||||
var puddleQuery = GetEntityQuery<PuddleComponent>();
|
||||
|
||||
while (anc.MoveNext(out var ent))
|
||||
|
||||
Reference in New Issue
Block a user