Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mirror: Code Cleanup: Purge Obsolete MapManager Methods #300

10 changes: 5 additions & 5 deletions Content.Client/IconSmoothing/IconSmoothSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private void OnStartup(EntityUid uid, IconSmoothComponent component, ComponentSt
var xform = Transform(uid);
if (xform.Anchored)
{
component.LastPosition = _mapManager.TryGetGrid(xform.GridUid, out var grid)
component.LastPosition = TryComp<MapGridComponent>(xform.GridUid, out var grid)
? (xform.GridUid.Value, grid.TileIndicesFor(xform.Coordinates))
: (null, new Vector2i(0, 0));

Expand Down Expand Up @@ -134,7 +134,7 @@ public void DirtyNeighbours(EntityUid uid, IconSmoothComponent? comp = null, Tra

Vector2i pos;

if (transform.Anchored && _mapManager.TryGetGrid(transform.GridUid, out var grid))
if (transform.Anchored && TryComp<MapGridComponent>(transform.GridUid, out var grid))
{
pos = grid.CoordinatesToTile(transform.Coordinates);
}
Expand All @@ -144,7 +144,7 @@ public void DirtyNeighbours(EntityUid uid, IconSmoothComponent? comp = null, Tra
if (comp.LastPosition is not (EntityUid gridId, Vector2i oldPos))
return;

if (!_mapManager.TryGetGrid(gridId, out grid))
if (!TryComp(gridId, out grid))
return;

pos = oldPos;
Expand Down Expand Up @@ -206,7 +206,7 @@ private void CalculateNewSprite(EntityUid uid,
{
var directions = DirectionFlag.None;

if (_mapManager.TryGetGrid(xform.GridUid, out grid))
if (TryComp(xform.GridUid, out grid))
{
var pos = grid.TileIndicesFor(xform.Coordinates);

Expand Down Expand Up @@ -240,7 +240,7 @@ private void CalculateNewSprite(EntityUid uid,

if (xform.Anchored)
{
if (!_mapManager.TryGetGrid(xform.GridUid, out grid))
if (!TryComp(xform.GridUid, out grid))
{
Logger.Error($"Failed to calculate IconSmoothComponent sprite in {uid} because grid {xform.GridUid} was missing.");
return;
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Movement/Systems/JetpackSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Content.Shared.Movement.Systems;
using Robust.Client.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Physics.Components;
using Robust.Shared.Timing;

Expand All @@ -12,7 +13,6 @@ namespace Content.Client.Movement.Systems;
public sealed class JetpackSystem : SharedJetpackSystem
{
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly ClothingSystem _clothing = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;

Expand Down Expand Up @@ -75,7 +75,7 @@ private void CreateParticles(EntityUid uid)
var coordinates = uidXform.Coordinates;
var gridUid = coordinates.GetGridUid(EntityManager);

if (_mapManager.TryGetGrid(gridUid, out var grid))
if (TryComp<MapGridComponent>(gridUid, out var grid))
{
coordinates = new EntityCoordinates(gridUid.Value, grid.WorldToLocal(coordinates.ToMapPos(EntityManager, _transform)));
}
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/NodeContainer/NodeVisualizationOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private void DrawScreen(in OverlayDrawArgs args)


var xform = _entityManager.GetComponent<TransformComponent>(_entityManager.GetEntity(node.Entity));
if (!_mapManager.TryGetGrid(xform.GridUid, out var grid))
if (!_entityManager.TryGetComponent<MapGridComponent>(xform.GridUid, out var grid))
return;
var gridTile = grid.TileIndicesFor(xform.Coordinates);

Expand Down Expand Up @@ -145,7 +145,7 @@ private void DrawWorld(in OverlayDrawArgs overlayDrawArgs)

foreach (var (gridId, gridDict) in _gridIndex)
{
var grid = _mapManager.GetGrid(gridId);
var grid = _entityManager.GetComponent<MapGridComponent>(gridId);
var (_, _, worldMatrix, invMatrix) = _entityManager.GetComponent<TransformComponent>(gridId).GetWorldPositionRotationMatrixWithInv();

var lCursorBox = invMatrix.TransformBox(cursorBox);
Expand Down
9 changes: 4 additions & 5 deletions Content.Client/Radiation/Overlays/RadiationDebugOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Shared.Enums;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;

namespace Content.Client.Radiation.Overlays;

public sealed class RadiationDebugOverlay : Overlay
{
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
private readonly RadiationSystem _radiation;

Expand Down Expand Up @@ -63,7 +62,7 @@ private void DrawScreenRays(OverlayDrawArgs args)
{
var gridUid = _entityManager.GetEntity(netGrid);

if (!_mapManager.TryGetGrid(gridUid, out var grid))
if (!_entityManager.TryGetComponent<MapGridComponent>(gridUid, out var grid))
continue;

foreach (var (tile, rads) in blockers)
Expand All @@ -88,7 +87,7 @@ private void DrawScreenResistance(OverlayDrawArgs args)
{
var gridUid = _entityManager.GetEntity(netGrid);

if (!_mapManager.TryGetGrid(gridUid, out var grid))
if (!_entityManager.TryGetComponent<MapGridComponent>(gridUid, out var grid))
continue;
if (query.TryGetComponent(gridUid, out var trs) && trs.MapID != args.MapId)
continue;
Expand Down Expand Up @@ -127,7 +126,7 @@ private void DrawWorld(in OverlayDrawArgs args)
{
var gridUid = _entityManager.GetEntity(netGrid);

if (!_mapManager.TryGetGrid(gridUid, out var grid))
if (!_entityManager.TryGetComponent<MapGridComponent>(gridUid, out var grid))
continue;
var (destTile, _) = blockers.Last();
var destWorld = grid.GridTileToWorldPos(destTile);
Expand Down
4 changes: 2 additions & 2 deletions Content.IntegrationTests/Tests/Fluids/FluidSpillTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ await server.WaitPost(() =>
var puddleOrigin = new Vector2i(0, 0);
await server.WaitAssertion(() =>
{
var grid = mapManager.GetGrid(gridId);
var grid = entityManager.GetComponent<MapGridComponent>(gridId);
var solution = new Solution("Blood", FixedPoint2.New(100));
var tileRef = grid.GetTileRef(puddleOrigin);
#pragma warning disable NUnit2045 // Interdependent tests
Expand All @@ -86,7 +86,7 @@ await server.WaitAssertion(() =>

await server.WaitAssertion(() =>
{
var grid = mapManager.GetGrid(gridId);
var grid = entityManager.GetComponent<MapGridComponent>(gridId);
var puddle = GetPuddleEntity(entityManager, grid, puddleOrigin);

#pragma warning disable NUnit2045 // Interdependent tests
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Anomaly/AnomalySystem.Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace Content.Server.Anomaly;
/// </summary>
public sealed partial class AnomalySystem
{
[Dependency] private readonly MapSystem _mapSystem = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;

private void InitializeGenerator()
Expand Down
7 changes: 2 additions & 5 deletions Content.Server/Anomaly/Effects/GasProducerAnomalySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
using Content.Server.Anomaly.Components;
using Content.Shared.Anomaly.Components;
using Content.Shared.Atmos;
using Robust.Server.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Random;
using System.Linq;
using System.Numerics;
using Robust.Shared.Map.Components;

namespace Content.Server.Anomaly.Effects;

Expand All @@ -16,8 +15,6 @@ namespace Content.Server.Anomaly.Effects;
public sealed class GasProducerAnomalySystem : EntitySystem
{
[Dependency] private readonly AtmosphereSystem _atmosphere = default!;
[Dependency] private readonly TransformSystem _xform = default!;
[Dependency] private readonly IMapManager _map = default!;
[Dependency] private readonly IRobustRandom _random = default!;

public override void Initialize()
Expand Down Expand Up @@ -55,7 +52,7 @@ private void ReleaseGas(EntityUid uid, Gas gas, float mols, float radius, int co
{
var xform = Transform(uid);

if (!_map.TryGetGrid(xform.GridUid, out var grid))
if (!TryComp<MapGridComponent>(xform.GridUid, out var grid))
return;

var localpos = xform.Coordinates.Position;
Expand Down
5 changes: 2 additions & 3 deletions Content.Server/Atmos/Commands/DeleteGasCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
using Content.Shared.Administration;
using Content.Shared.Atmos;
using Robust.Shared.Console;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;

namespace Content.Server.Atmos.Commands
{
[AdminCommand(AdminFlags.Debug)]
public sealed class DeleteGasCommand : IConsoleCommand
{
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;

public string Command => "deletegas";
public string Description => "Removes all gases from a grid, or just of one type if specified.";
Expand Down Expand Up @@ -119,7 +118,7 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
return;
}

if (!_mapManager.TryGetGrid(gridId, out _))
if (!_entManager.TryGetComponent<MapGridComponent>(gridId, out _))
{
shell.WriteLine($"No grid exists with id {gridId}");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
using Content.Server.NodeContainer.Nodes;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Components;
using Robust.Server.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;

namespace Content.Server.Atmos.Piping.EntitySystems;

public sealed class AtmosPipeAppearanceSystem : EntitySystem
{
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;

public override void Initialize()
Expand All @@ -31,7 +29,7 @@ private void UpdateAppearance(EntityUid uid, AppearanceComponent? appearance = n
if (!Resolve(uid, ref appearance, ref container, ref xform, false))
return;

if (!_mapManager.TryGetGrid(xform.GridUid, out var grid))
if (!TryComp<MapGridComponent>(xform.GridUid, out var grid))
return;

// get connected entities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
using Content.Shared.Atmos.Piping.Unary.Components;
using Content.Shared.Construction.Components;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;

namespace Content.Server.Atmos.Piping.Unary.EntitySystems
{
[UsedImplicitly]
public sealed class GasPortableSystem : EntitySystem
{
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly NodeContainerSystem _nodeContainer = default!;

Expand Down Expand Up @@ -58,7 +57,7 @@ public bool FindGasPortIn(EntityUid? gridId, EntityCoordinates coordinates, [Not
{
port = null;

if (!_mapManager.TryGetGrid(gridId, out var grid))
if (!TryComp<MapGridComponent>(gridId, out var grid))
return false;

foreach (var entityUid in grid.GetLocal(coordinates))
Expand Down
3 changes: 2 additions & 1 deletion Content.Server/Decals/Commands/EditDecalCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;

namespace Content.Server.Decals;

Expand Down Expand Up @@ -43,7 +44,7 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
return;
}

if (!_mapManager.GridExists(gridId))
if (!_entManager.HasComponent<MapGridComponent>(gridId))
{
shell.WriteError($"No grid with gridId {gridId} exists.");
return;
Expand Down
3 changes: 2 additions & 1 deletion Content.Server/Decals/Commands/RemoveDecalCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using SQLitePCL;

namespace Content.Server.Decals.Commands
Expand Down Expand Up @@ -31,7 +32,7 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)

if (!NetEntity.TryParse(args[1], out var rawGridIdNet) ||
!_entManager.TryGetEntity(rawGridIdNet, out var rawGridId) ||
!_mapManager.GridExists(rawGridId))
!_entManager.HasComponent<MapGridComponent>(rawGridId))
{
shell.WriteError("Failed parsing gridId.");
return;
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Decals/DecalSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private void OnGridSplit(ref PostGridSplitEvent ev)
return;

// Transfer decals over to the new grid.
var enumerator = MapManager.GetGrid(ev.Grid).GetAllTilesEnumerator();
var enumerator = Comp<MapGridComponent>(ev.Grid).GetAllTilesEnumerator();

var oldChunkCollection = oldComp.ChunkCollection.ChunkCollection;
var chunkCollection = newComp.ChunkCollection.ChunkCollection;
Expand Down
10 changes: 2 additions & 8 deletions Content.Server/Disposal/Tube/DisposalTubeSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,23 @@
using Content.Server.Disposal.Unit.Components;
using Content.Server.Disposal.Unit.EntitySystems;
using Content.Server.Popups;
using Content.Server.UserInterface;
using Content.Shared.Destructible;
using Content.Shared.Disposal.Components;
using Content.Shared.Hands.Components;
using Content.Shared.Movement.Events;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Random;
using Robust.Shared.Timing;
using static Content.Shared.Disposal.Components.SharedDisposalRouterComponent;
using static Content.Shared.Disposal.Components.SharedDisposalTaggerComponent;

namespace Content.Server.Disposal.Tube
{
public sealed class DisposalTubeSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
[Dependency] private readonly PopupSystem _popups = default!;
Expand Down Expand Up @@ -349,7 +343,7 @@ private void UpdateAnchored(EntityUid uid, DisposalTubeComponent component, bool
var oppositeDirection = nextDirection.GetOpposite();

var xform = Transform(target);
if (!_mapManager.TryGetGrid(xform.GridUid, out var grid))
if (!TryComp<MapGridComponent>(xform.GridUid, out var grid))
return null;

var position = xform.Coordinates;
Expand Down
9 changes: 4 additions & 5 deletions Content.Server/Dragon/DragonSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@
using Content.Shared.Mind.Components;
using Content.Shared.Mobs;
using Content.Shared.Movement.Systems;
using Robust.Shared.Audio;
using Content.Shared.NPC.Systems;

Check failure on line 13 in Content.Server/Dragon/DragonSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'Systems' does not exist in the namespace 'Content.Shared.NPC' (are you missing an assembly reference?)

Check failure on line 13 in Content.Server/Dragon/DragonSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'Systems' does not exist in the namespace 'Content.Shared.NPC' (are you missing an assembly reference?)

Check failure on line 13 in Content.Server/Dragon/DragonSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'Systems' does not exist in the namespace 'Content.Shared.NPC' (are you missing an assembly reference?)

Check failure on line 13 in Content.Server/Dragon/DragonSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'Systems' does not exist in the namespace 'Content.Shared.NPC' (are you missing an assembly reference?)

Check failure on line 13 in Content.Server/Dragon/DragonSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'Systems' does not exist in the namespace 'Content.Shared.NPC' (are you missing an assembly reference?)

Check failure on line 13 in Content.Server/Dragon/DragonSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'Systems' does not exist in the namespace 'Content.Shared.NPC' (are you missing an assembly reference?)

Check failure on line 13 in Content.Server/Dragon/DragonSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'Systems' does not exist in the namespace 'Content.Shared.NPC' (are you missing an assembly reference?)

Check failure on line 13 in Content.Server/Dragon/DragonSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'Systems' does not exist in the namespace 'Content.Shared.NPC' (are you missing an assembly reference?)
using Content.Shared.Zombies;
using Robust.Shared.Audio.Systems;
using Robust.Shared.GameStates;
using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Map.Components;

namespace Content.Server.Dragon;

public sealed partial class DragonSystem : EntitySystem
{
[Dependency] private readonly CarpRiftsConditionSystem _carpRifts = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly ITileDefinitionManager _tileDef = default!;
[Dependency] private readonly MovementSpeedModifierSystem _movement = default!;
[Dependency] private readonly PopupSystem _popup = default!;
Expand Down Expand Up @@ -137,7 +136,7 @@
var xform = Transform(uid);

// Have to be on a grid fam
if (!_mapManager.TryGetGrid(xform.GridUid, out var grid))
if (!TryComp<MapGridComponent>(xform.GridUid, out var grid))
{
_popup.PopupEntity(Loc.GetString("carp-rift-anchor"), uid, uid);
return;
Expand Down
Loading
Loading