Code Cleanup: Purge obsolete MapManager methods (#26279)
* GetGrid * GridExists * TryGetGrid
This commit is contained in:
@@ -270,7 +270,7 @@ public sealed partial class AnchorableSystem : EntitySystem
|
||||
// Probably ignore CanCollide on the anchoring body?
|
||||
var gridUid = coordinates.GetGridUid(EntityManager);
|
||||
|
||||
if (!_mapManager.TryGetGrid(gridUid, out var grid))
|
||||
if (!TryComp<MapGridComponent>(gridUid, out var grid))
|
||||
return false;
|
||||
|
||||
var tileIndices = grid.TileIndicesFor(coordinates);
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Content.Shared.Coordinates.Helpers
|
||||
return EntityCoordinates.FromMap(coordinates.EntityId, mapPos, xformSys);
|
||||
}
|
||||
|
||||
var grid = mapManager.GetGrid(gridId.Value);
|
||||
var grid = entMan.GetComponent<MapGridComponent>(gridId.Value);
|
||||
var tileSize = grid.TileSize;
|
||||
var localPos = coordinates.WithEntityId(gridId.Value).Position;
|
||||
var x = (int)Math.Floor(localPos.X / tileSize) + tileSize / 2f;
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Content.Shared.Physics;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Shared.Maps
|
||||
@@ -14,11 +15,11 @@ namespace Content.Shared.Maps
|
||||
/// <summary>
|
||||
/// Attempts to get the turf at map indices with grid id or null if no such turf is found.
|
||||
/// </summary>
|
||||
public static TileRef GetTileRef(this Vector2i vector2i, EntityUid gridId, IMapManager? mapManager = null)
|
||||
public static TileRef GetTileRef(this Vector2i vector2i, EntityUid gridId, IEntityManager? entityManager = null)
|
||||
{
|
||||
mapManager ??= IoCManager.Resolve<IMapManager>();
|
||||
entityManager ??= IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (!mapManager.TryGetGrid(gridId, out var grid))
|
||||
if (!entityManager.TryGetComponent<MapGridComponent>(gridId, out var grid))
|
||||
return default;
|
||||
|
||||
if (!grid.TryGetTileRef(vector2i, out var tile))
|
||||
@@ -144,9 +145,8 @@ namespace Content.Shared.Maps
|
||||
private static bool GetWorldTileBox(TileRef turf, out Box2Rotated res)
|
||||
{
|
||||
var entManager = IoCManager.Resolve<IEntityManager>();
|
||||
var map = IoCManager.Resolve<IMapManager>();
|
||||
|
||||
if (map.TryGetGrid(turf.GridUid, out var tileGrid))
|
||||
if (entManager.TryGetComponent<MapGridComponent>(turf.GridUid, out var tileGrid))
|
||||
{
|
||||
var gridRot = entManager.GetComponent<TransformComponent>(turf.GridUid).WorldRotation;
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ public sealed class TurfSystem : EntitySystem
|
||||
/// </summary>
|
||||
public EntityCoordinates GetTileCenter(TileRef turf)
|
||||
{
|
||||
var grid = _mapMan.GetGrid(turf.GridUid);
|
||||
var grid = Comp<MapGridComponent>(turf.GridUid);
|
||||
var center = (turf.GridIndices + new Vector2(0.5f, 0.5f)) * grid.TileSize;
|
||||
return new EntityCoordinates(turf.GridUid, center);
|
||||
}
|
||||
|
||||
@@ -459,7 +459,7 @@ namespace Content.Shared.Movement.Systems
|
||||
sound = null;
|
||||
|
||||
// Fallback to the map?
|
||||
if (!_mapManager.TryGetGrid(xform.GridUid, out var grid))
|
||||
if (!TryComp<MapGridComponent>(xform.GridUid, out var grid))
|
||||
{
|
||||
if (TryComp<FootstepModifierComponent>(xform.MapUid, out var modifier))
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Shared.Conveyor;
|
||||
using Content.Shared.Gravity;
|
||||
using Content.Shared.Movement.Systems;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Controllers;
|
||||
@@ -146,7 +147,7 @@ public abstract class SharedConveyorController : VirtualController
|
||||
EntityQuery<PhysicsComponent> bodyQuery)
|
||||
{
|
||||
// Check if the thing's centre overlaps the grid tile.
|
||||
var grid = MapManager.GetGrid(xform.GridUid!.Value);
|
||||
var grid = Comp<MapGridComponent>(xform.GridUid!.Value);
|
||||
var tile = grid.GetTileRef(xform.Coordinates);
|
||||
var conveyorBounds = Lookup.GetLocalBounds(tile, grid.TileSize);
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ public sealed class RCDSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
var mapGrid = _mapMan.GetGrid(gridId.Value);
|
||||
var mapGrid = Comp<MapGridComponent>(gridId.Value);
|
||||
var tile = mapGrid.GetTileRef(location);
|
||||
|
||||
if (!IsRCDStillValid(uid, comp, args.Event.User, args.Event.Target, mapGrid, tile, args.Event.StartingMode))
|
||||
@@ -157,7 +157,7 @@ public sealed class RCDSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
var mapGrid = _mapMan.GetGrid(gridId.Value);
|
||||
var mapGrid = Comp<MapGridComponent>(gridId.Value);
|
||||
var tile = mapGrid.GetTileRef(location);
|
||||
var snapPos = mapGrid.TileIndicesFor(location);
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ using JetBrains.Annotations;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Events;
|
||||
@@ -25,7 +26,6 @@ public abstract class SharedEmitSoundSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly INetManager _netMan = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly ITileDefinitionManager _tileDefMan = default!;
|
||||
[Dependency] protected readonly IRobustRandom Random = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
|
||||
@@ -54,7 +54,7 @@ public abstract class SharedEmitSoundSystem : EntitySystem
|
||||
{
|
||||
if (!args.PlaySound ||
|
||||
!TryComp<TransformComponent>(uid, out var xform) ||
|
||||
!_mapManager.TryGetGrid(xform.GridUid, out var grid))
|
||||
!TryComp<MapGridComponent>(xform.GridUid, out var grid))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace Content.Shared.SubFloor
|
||||
[UsedImplicitly]
|
||||
public abstract class SharedSubFloorHideSystem : EntitySystem
|
||||
{
|
||||
[Dependency] protected readonly IMapManager MapManager = default!;
|
||||
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
|
||||
[Dependency] private readonly SharedAmbientSoundSystem _ambientSoundSystem = default!;
|
||||
[Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
|
||||
@@ -93,7 +92,7 @@ namespace Content.Shared.SubFloor
|
||||
if (args.NewTile.Tile.IsEmpty)
|
||||
return; // Anything that was here will be unanchored anyways.
|
||||
|
||||
UpdateTile(MapManager.GetGrid(args.NewTile.GridUid), args.NewTile.GridIndices);
|
||||
UpdateTile(Comp<MapGridComponent>(args.NewTile.GridUid), args.NewTile.GridIndices);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -104,7 +103,7 @@ namespace Content.Shared.SubFloor
|
||||
if (!Resolve(uid, ref component, ref xform))
|
||||
return;
|
||||
|
||||
if (xform.Anchored && MapManager.TryGetGrid(xform.GridUid, out var grid))
|
||||
if (xform.Anchored && TryComp<MapGridComponent>(xform.GridUid, out var grid))
|
||||
component.IsUnderCover = HasFloorCover(grid, grid.TileIndicesFor(xform.Coordinates));
|
||||
else
|
||||
component.IsUnderCover = false;
|
||||
|
||||
@@ -116,7 +116,7 @@ public sealed class FloorTileSystem : EntitySystem
|
||||
}
|
||||
}
|
||||
}
|
||||
_mapManager.TryGetGrid(location.EntityId, out var mapGrid);
|
||||
TryComp<MapGridComponent>(location.EntityId, out var mapGrid);
|
||||
|
||||
foreach (var currentTile in component.OutputTiles)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user