From 4f9be42f4060bde4cb15c86a312dc13922293f9d Mon Sep 17 00:00:00 2001 From: Acruid Date: Sat, 11 Jun 2022 18:54:41 -0700 Subject: [PATCH] Remove Explicit GridId References (#8315) Co-authored-by: metalgearsloth --- .../AI/ClientPathfindingDebugSystem.cs | 20 +++--- .../SpawnExplosion/ExplosionDebugOverlay.cs | 2 +- .../UI/Tabs/AtmosTab/AddAtmosWindow.xaml.cs | 10 +-- .../UI/Tabs/AtmosTab/AddGasWindow.xaml.cs | 10 +-- .../UI/Tabs/AtmosTab/FillGasWindow.xaml.cs | 10 +-- .../AtmosTab/SetTemperatureWindow.xaml.cs | 10 +-- .../EntitySystems/AtmosDebugOverlaySystem.cs | 6 +- .../EntitySystems/GasTileOverlaySystem.cs | 11 ++-- .../Atmos/Overlays/AtmosDebugOverlay.cs | 6 +- .../Atmos/Overlays/FireTileOverlay.cs | 4 +- .../Atmos/Overlays/GasTileOverlay.cs | 4 +- Content.Client/Audio/BackgroundAudioSystem.cs | 2 +- Content.Client/Decals/DecalOverlay.cs | 3 +- Content.Client/Decals/DecalSystem.cs | 10 ++- .../Explosion/ExplosionOverlaySystem.cs | 2 +- Content.Client/Eye/EyeLerpingSystem.cs | 2 +- .../IconSmoothing/IconSmoothComponent.cs | 3 +- .../IconSmoothing/IconSmoothSystem.cs | 14 ++-- .../NodeContainer/NodeVisualizationOverlay.cs | 8 +-- .../Physics/Controllers/MoverController.cs | 2 +- .../Tests/Body/LungTest.cs | 14 ++-- Content.IntegrationTests/Tests/EntityTest.cs | 21 +----- .../Tests/Fluids/FluidSpillTest.cs | 10 +-- .../Tests/Fluids/PuddleTest.cs | 8 +-- .../Tests/SaveLoadSaveTest.cs | 5 +- Content.MapRenderer/Painters/GridPainter.cs | 28 ++++---- Content.MapRenderer/Painters/TilePainter.cs | 4 +- .../Inventory/InteractWithEntityOperator.cs | 2 +- .../Accessible/AiReachableSystem.cs | 18 +++--- .../AI/Pathfinding/PathfindingHelpers.cs | 2 +- .../AI/Pathfinding/PathfindingSystem.Grid.cs | 18 +++--- .../ServerPathfindingDebugSystem.cs | 12 ++-- .../AI/Steering/AiSteeringSystem.cs | 14 ++-- .../AI/Utility/Actions/Idle/WanderAndWait.cs | 2 +- .../Movement/TargetDistanceCon.cs | 2 +- Content.Server/AI/Utils/Visibility.cs | 2 +- Content.Server/AME/AntimatterEngineSystem.cs | 4 +- .../Commands/VariantizeCommand.cs | 17 +++-- .../Administration/Commands/WarpCommand.cs | 13 ++-- .../Atmos/Commands/AddAtmosCommand.cs | 29 +++------ .../Atmos/Commands/AddGasCommand.cs | 16 +++-- .../Commands/AddUnsimulatedAtmosCommand.cs | 35 ++++------ .../Atmos/Commands/DeleteGasCommand.cs | 27 +++----- .../Atmos/Commands/FillGasCommand.cs | 8 +-- .../Atmos/Commands/RemoveGasCommand.cs | 8 +-- .../Commands/SetAtmosTemperatureCommand.cs | 6 +- .../Atmos/Commands/SetTemperatureCommand.cs | 6 +- .../Atmos/Components/AirtightComponent.cs | 2 +- .../Atmos/EntitySystems/AirtightSystem.cs | 12 ++-- .../EntitySystems/AtmosDebugOverlaySystem.cs | 2 +- .../AtmosphereSystem.Commands.cs | 23 ++++--- .../EntitySystems/AtmosphereSystem.Grid.cs | 64 +++++++++---------- .../AtmosphereSystem.Processing.cs | 4 +- .../Atmos/EntitySystems/AtmosphereSystem.cs | 2 +- .../EntitySystems/GasTileOverlaySystem.cs | 18 +++--- .../Piping/Components/AtmosDeviceComponent.cs | 2 +- .../AtmosPipeAppearanceSystem.cs | 2 +- .../Unary/EntitySystems/GasPortableSystem.cs | 4 +- Content.Server/Atmos/TileAtmosphere.cs | 4 +- .../Components/SolutionAreaEffectComponent.cs | 4 +- .../Chemistry/EntitySystems/VaporSystem.cs | 6 +- .../TileReactions/CleanTileReaction.cs | 6 +- .../TileReactions/ExtinguishTileReaction.cs | 10 +-- .../TileReactions/FlammableTileReaction.cs | 8 +-- .../Commands/FixRotationsCommand.cs | 10 +-- .../Commands/TileReplaceCommand.cs | 10 +-- .../Construction/Commands/TileWallsCommand.cs | 10 +-- .../Conditions/ComponentInTile.cs | 4 +- .../Coordinates/Helpers/SnapgridHelper.cs | 2 +- .../Decals/Commands/AddDecalCommand.cs | 2 +- .../Decals/Commands/EditDecalCommand.cs | 5 +- .../Decals/Commands/RemoveDecalCommand.cs | 6 +- Content.Server/Decals/DecalSystem.cs | 64 +++++++++---------- .../Systems/WiredNetworkSystem.cs | 2 +- .../Disposal/Tube/DisposalTubeSystem.cs | 2 +- .../Unit/EntitySystems/DisposableSystem.cs | 2 +- .../Unit/EntitySystems/DisposalUnitSystem.cs | 2 +- .../EntitySystems/SpawnAfterInteractSystem.cs | 2 +- .../EntitySystems/ExplosionGridTileFlood.cs | 4 +- .../EntitySystems/ExplosionSpaceTileFlood.cs | 4 +- .../EntitySystems/ExplosionSystem.Airtight.cs | 14 ++-- .../EntitySystems/ExplosionSystem.GridMap.cs | 14 ++-- .../EntitySystems/ExplosionSystem.TileFill.cs | 22 +++---- .../EntitySystems/ExplosionSystem.cs | 4 +- .../EntitySystems/FluidSpreaderSystem.cs | 4 +- .../Fluids/EntitySystems/MoppingSystem.cs | 2 +- .../Fluids/EntitySystems/SpillableSystem.cs | 4 +- .../Fluids/EntitySystems/SpraySystem.cs | 5 +- .../GameTicking/GameTicker.RoundFlow.cs | 11 ++-- .../EntitySystems/GravityGeneratorSystem.cs | 6 +- .../EntitySystems/GravityShakeSystem.cs | 10 +-- .../Gravity/EntitySystems/GravitySystem.cs | 8 +-- .../Gravity/EntitySystems/WeightlessSystem.cs | 12 ++-- Content.Server/Interaction/TilePryCommand.cs | 2 +- Content.Server/Kudzu/SpreaderSystem.cs | 4 +- .../CrewMonitoringConsoleSystem.cs | 2 +- Content.Server/Mind/MindSystem.cs | 4 +- .../EntitySystems/NodeGroupSystem.cs | 2 +- .../NodeContainer/NodeGroups/BaseNodeGroup.cs | 4 +- .../NodeContainer/NodeGroups/PipeNet.cs | 3 +- .../ParticleAcceleratorControlBoxComponent.cs | 4 +- .../Physics/Controllers/ConveyorController.cs | 2 +- .../Physics/Controllers/MoverController.cs | 2 +- .../Power/EntitySystems/CableSystem.Placer.cs | 3 +- .../Power/EntitySystems/CableVisSystem.cs | 2 +- .../EntitySystems/ExtensionCableSystem.cs | 6 +- Content.Server/Power/NodeGroups/ApcNet.cs | 4 +- .../Shuttles/EntitySystems/DockingSystem.cs | 12 ++-- .../EntitySystems/ShuttleConsoleSystem.cs | 4 +- .../EntitySystems/SpaceGarbageSystem.cs | 2 +- .../Shuttles/EntitySystems/ThrusterSystem.cs | 14 ++-- Content.Server/Sound/EmitSoundSystem.cs | 2 +- .../Station/Systems/StationSystem.cs | 38 ++++++----- .../StationEvents/Events/GasLeak.cs | 8 +-- .../StationEvents/Events/RadiationStorm.cs | 4 +- Content.Server/SubFloor/SubFloorHideSystem.cs | 2 +- Content.Server/Tools/ToolSystem.TilePrying.cs | 2 +- Content.Shared/AI/SharedAiDebug.cs | 8 +-- .../SharedAtmosDebugOverlaySystem.cs | 6 +- .../SharedGasTileOverlaySystem.cs | 6 +- Content.Shared/Atmos/GasOverlayChunk.cs | 4 +- .../Decals/DecalChunkUpdateEvent.cs | 4 +- Content.Shared/Decals/SharedDecalSystem.cs | 11 ++-- Content.Shared/Explosion/ExplosionEvents.cs | 4 +- .../Friction/SharedTileFrictionController.cs | 2 +- .../Gravity/GravityChangedMessage.cs | 4 +- Content.Shared/Maps/TurfHelpers.cs | 22 +++---- .../MovementIgnoreGravityComponent.cs | 2 +- .../Movement/SharedMoverController.cs | 18 +++--- .../SubFloor/SharedSubFloorHideSystem.cs | 4 +- Content.Shared/SubFloor/TrayScannerSystem.cs | 2 +- 131 files changed, 531 insertions(+), 588 deletions(-) diff --git a/Content.Client/AI/ClientPathfindingDebugSystem.cs b/Content.Client/AI/ClientPathfindingDebugSystem.cs index 23414557dc..ef2a24abc5 100644 --- a/Content.Client/AI/ClientPathfindingDebugSystem.cs +++ b/Content.Client/AI/ClientPathfindingDebugSystem.cs @@ -197,17 +197,17 @@ namespace Content.Client.AI private readonly Dictionary _graphColors = new(); // Cached regions - public readonly Dictionary>> CachedRegions = + public readonly Dictionary>> CachedRegions = new(); - private readonly Dictionary> _cachedRegionColors = + private readonly Dictionary> _cachedRegionColors = new(); // Regions - public readonly Dictionary>>> Regions = + public readonly Dictionary>>> Regions = new(); - private readonly Dictionary>> _regionColors = + private readonly Dictionary>> _regionColors = new(); // Route debugging @@ -260,7 +260,7 @@ namespace Content.Client.AI #region Regions //Server side debugger should increment every region - public void UpdateCachedRegions(GridId gridId, Dictionary> messageRegions, bool cached) + public void UpdateCachedRegions(EntityUid gridId, Dictionary> messageRegions, bool cached) { if (!CachedRegions.ContainsKey(gridId)) { @@ -294,7 +294,7 @@ namespace Content.Client.AI private void DrawCachedRegions(DrawingHandleScreen screenHandle, Box2 viewport) { var transform = _entities.GetComponentOrNull(_playerManager.LocalPlayer?.ControlledEntity); - if (transform == null || !CachedRegions.TryGetValue(transform.GridID, out var entityRegions)) + if (transform == null || !CachedRegions.TryGetValue(transform.GridEntityId, out var entityRegions)) { return; } @@ -312,12 +312,12 @@ namespace Content.Client.AI screenTile.X + 15.0f, screenTile.Y + 15.0f); - screenHandle.DrawRect(box, _cachedRegionColors[transform.GridID][region]); + screenHandle.DrawRect(box, _cachedRegionColors[transform.GridEntityId][region]); } } } - public void UpdateRegions(GridId gridId, Dictionary>> messageRegions) + public void UpdateRegions(EntityUid gridId, Dictionary>> messageRegions) { if (!Regions.ContainsKey(gridId)) { @@ -344,7 +344,7 @@ namespace Content.Client.AI { var attachedEntity = _playerManager.LocalPlayer?.ControlledEntity; if (!_entities.TryGetComponent(attachedEntity, out TransformComponent? transform) || - !Regions.TryGetValue(transform.GridID, out var entityRegions)) + !Regions.TryGetValue(transform.GridEntityId, out var entityRegions)) { return; } @@ -364,7 +364,7 @@ namespace Content.Client.AI screenTile.X + 15.0f, screenTile.Y + 15.0f); - screenHandle.DrawRect(box, _regionColors[_entities.GetComponent(attachedEntity.Value).GridID][chunk][region]); + screenHandle.DrawRect(box, _regionColors[_entities.GetComponent(attachedEntity.Value).GridEntityId][chunk][region]); } } } diff --git a/Content.Client/Administration/UI/SpawnExplosion/ExplosionDebugOverlay.cs b/Content.Client/Administration/UI/SpawnExplosion/ExplosionDebugOverlay.cs index cc00f754a6..2a2e88d107 100644 --- a/Content.Client/Administration/UI/SpawnExplosion/ExplosionDebugOverlay.cs +++ b/Content.Client/Administration/UI/SpawnExplosion/ExplosionDebugOverlay.cs @@ -15,7 +15,7 @@ public sealed class ExplosionDebugOverlay : Overlay [Dependency] private readonly IMapManager _mapManager = default!; public Dictionary>? SpaceTiles; - public Dictionary>> Tiles = new(); + public Dictionary>> Tiles = new(); public List Intensity = new(); public float TotalIntensity; public float Slope; diff --git a/Content.Client/Administration/UI/Tabs/AtmosTab/AddAtmosWindow.xaml.cs b/Content.Client/Administration/UI/Tabs/AtmosTab/AddAtmosWindow.xaml.cs index bc27287d28..d4f69e14e4 100644 --- a/Content.Client/Administration/UI/Tabs/AtmosTab/AddAtmosWindow.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/AtmosTab/AddAtmosWindow.xaml.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using JetBrains.Annotations; using Robust.Client.AutoGenerated; @@ -20,12 +20,12 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab protected override void EnteredTree() { - _data = IoCManager.Resolve().GetAllGrids().Where(g => (int) g.Index != 0); + _data = IoCManager.Resolve().GetAllGrids().Where(g => (int) g.GridEntityId != 0); foreach (var grid in _data) { var player = IoCManager.Resolve().LocalPlayer?.ControlledEntity; - var playerGrid = IoCManager.Resolve().GetComponentOrNull(player)?.GridID; - GridOptions.AddItem($"{grid.Index} {(playerGrid == grid.Index ? " (Current)" : "")}"); + var playerGrid = IoCManager.Resolve().GetComponentOrNull(player)?.GridEntityId; + GridOptions.AddItem($"{grid.GridEntityId} {(playerGrid == grid.GridEntityId ? " (Current)" : "")}"); } GridOptions.OnItemSelected += eventArgs => GridOptions.SelectId(eventArgs.Id); @@ -37,7 +37,7 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab if (_data == null) return; var dataList = _data.ToList(); - var selectedGrid = dataList[GridOptions.SelectedId].Index; + var selectedGrid = dataList[GridOptions.SelectedId].GridEntityId; IoCManager.Resolve().ExecuteCommand($"addatmos {selectedGrid}"); } } diff --git a/Content.Client/Administration/UI/Tabs/AtmosTab/AddGasWindow.xaml.cs b/Content.Client/Administration/UI/Tabs/AtmosTab/AddGasWindow.xaml.cs index 4818ed804b..d8333eefb9 100644 --- a/Content.Client/Administration/UI/Tabs/AtmosTab/AddGasWindow.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/AtmosTab/AddGasWindow.xaml.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using Content.Client.Atmos.EntitySystems; using Content.Shared.Atmos.Prototypes; @@ -24,12 +24,12 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab protected override void EnteredTree() { // Fill out grids - _gridData = IoCManager.Resolve().GetAllGrids().Where(g => (int) g.Index != 0); + _gridData = IoCManager.Resolve().GetAllGrids().Where(g => (int) g.GridEntityId != 0); foreach (var grid in _gridData) { var player = IoCManager.Resolve().LocalPlayer?.ControlledEntity; - var playerGrid = IoCManager.Resolve().GetComponentOrNull(player)?.GridID; - GridOptions.AddItem($"{grid.Index} {(playerGrid == grid.Index ? " (Current)" : "")}"); + var playerGrid = IoCManager.Resolve().GetComponentOrNull(player)?.GridEntityId; + GridOptions.AddItem($"{grid.GridEntityId} {(playerGrid == grid.GridEntityId ? " (Current)" : "")}"); } GridOptions.OnItemSelected += eventArgs => GridOptions.SelectId(eventArgs.Id); @@ -52,7 +52,7 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab return; var gridList = _gridData.ToList(); - var gridIndex = gridList[GridOptions.SelectedId].Index; + var gridIndex = gridList[GridOptions.SelectedId].GridEntityId; var gasList = _gasData.ToList(); var gasId = gasList[GasOptions.SelectedId].ID; diff --git a/Content.Client/Administration/UI/Tabs/AtmosTab/FillGasWindow.xaml.cs b/Content.Client/Administration/UI/Tabs/AtmosTab/FillGasWindow.xaml.cs index 7e5fa9c19f..f9577ea763 100644 --- a/Content.Client/Administration/UI/Tabs/AtmosTab/FillGasWindow.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/AtmosTab/FillGasWindow.xaml.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using Content.Client.Atmos.EntitySystems; using Content.Shared.Atmos.Prototypes; @@ -24,12 +24,12 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab protected override void EnteredTree() { // Fill out grids - _gridData = IoCManager.Resolve().GetAllGrids().Where(g => (int) g.Index != 0); + _gridData = IoCManager.Resolve().GetAllGrids().Where(g => (int) g.GridEntityId != 0); foreach (var grid in _gridData) { var player = IoCManager.Resolve().LocalPlayer?.ControlledEntity; - var playerGrid = IoCManager.Resolve().GetComponentOrNull(player)?.GridID; - GridOptions.AddItem($"{grid.Index} {(playerGrid == grid.Index ? " (Current)" : "")}"); + var playerGrid = IoCManager.Resolve().GetComponentOrNull(player)?.GridEntityId; + GridOptions.AddItem($"{grid.GridEntityId} {(playerGrid == grid.GridEntityId ? " (Current)" : "")}"); } GridOptions.OnItemSelected += eventArgs => GridOptions.SelectId(eventArgs.Id); @@ -52,7 +52,7 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab return; var gridList = _gridData.ToList(); - var gridIndex = gridList[GridOptions.SelectedId].Index; + var gridIndex = gridList[GridOptions.SelectedId].GridEntityId; var gasList = _gasData.ToList(); var gasId = gasList[GasOptions.SelectedId].ID; diff --git a/Content.Client/Administration/UI/Tabs/AtmosTab/SetTemperatureWindow.xaml.cs b/Content.Client/Administration/UI/Tabs/AtmosTab/SetTemperatureWindow.xaml.cs index af0b1b6e18..69f3ed362c 100644 --- a/Content.Client/Administration/UI/Tabs/AtmosTab/SetTemperatureWindow.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/AtmosTab/SetTemperatureWindow.xaml.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using JetBrains.Annotations; using Robust.Client.AutoGenerated; @@ -20,12 +20,12 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab protected override void EnteredTree() { - _data = IoCManager.Resolve().GetAllGrids().Where(g => (int) g.Index != 0); + _data = IoCManager.Resolve().GetAllGrids().Where(g => (int) g.GridEntityId != 0); foreach (var grid in _data) { var player = IoCManager.Resolve().LocalPlayer?.ControlledEntity; - var playerGrid = IoCManager.Resolve().GetComponentOrNull(player)?.GridID; - GridOptions.AddItem($"{grid.Index} {(playerGrid == grid.Index ? " (Current)" : "")}"); + var playerGrid = IoCManager.Resolve().GetComponentOrNull(player)?.GridEntityId; + GridOptions.AddItem($"{grid.GridEntityId} {(playerGrid == grid.GridEntityId ? " (Current)" : "")}"); } GridOptions.OnItemSelected += eventArgs => GridOptions.SelectId(eventArgs.Id); @@ -37,7 +37,7 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab if (_data == null) return; var dataList = _data.ToList(); - var selectedGrid = dataList[GridOptions.SelectedId].Index; + var selectedGrid = dataList[GridOptions.SelectedId].GridEntityId; IoCManager.Resolve() .ExecuteCommand($"settemp {TileXSpin.Value} {TileYSpin.Value} {selectedGrid} {TemperatureSpin.Value}"); } diff --git a/Content.Client/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs b/Content.Client/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs index 85f2c5fe24..3ef44f1caf 100644 --- a/Content.Client/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs +++ b/Content.Client/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs @@ -15,7 +15,7 @@ namespace Content.Client.Atmos.EntitySystems internal sealed class AtmosDebugOverlaySystem : SharedAtmosDebugOverlaySystem { - private readonly Dictionary _tileData = + private readonly Dictionary _tileData = new(); // Configuration set by debug commands and used by AtmosDebugOverlay { @@ -77,12 +77,12 @@ namespace Content.Client.Atmos.EntitySystems _tileData.Clear(); } - public bool HasData(GridId gridId) + public bool HasData(EntityUid gridId) { return _tileData.ContainsKey(gridId); } - public AtmosDebugOverlayData? GetData(GridId gridIndex, Vector2i indices) + public AtmosDebugOverlayData? GetData(EntityUid gridIndex, Vector2i indices) { if (!_tileData.TryGetValue(gridIndex, out var srcMsg)) return null; diff --git a/Content.Client/Atmos/EntitySystems/GasTileOverlaySystem.cs b/Content.Client/Atmos/EntitySystems/GasTileOverlaySystem.cs index e9b31b37ee..0618f0c9e0 100644 --- a/Content.Client/Atmos/EntitySystems/GasTileOverlaySystem.cs +++ b/Content.Client/Atmos/EntitySystems/GasTileOverlaySystem.cs @@ -5,7 +5,6 @@ using JetBrains.Annotations; using Robust.Client.Graphics; using Robust.Client.ResourceManagement; using Robust.Client.Utility; -using Robust.Shared.Map; using Robust.Shared.Utility; namespace Content.Client.Atmos.EntitySystems @@ -31,7 +30,7 @@ namespace Content.Client.Atmos.EntitySystems public readonly int[] FireFrameCounter = new int[FireStates]; public readonly Texture[][] FireFrames = new Texture[FireStates][]; - private readonly Dictionary> _tileData = + private readonly Dictionary> _tileData = new(); public const int GasOverlayZIndex = 1; @@ -95,7 +94,7 @@ namespace Content.Client.Atmos.EntitySystems } // Slightly different to the server-side system version - private GasOverlayChunk GetOrCreateChunk(GridId gridId, Vector2i indices) + private GasOverlayChunk GetOrCreateChunk(EntityUid gridId, Vector2i indices) { if (!_tileData.TryGetValue(gridId, out var chunks)) { @@ -130,12 +129,12 @@ namespace Content.Client.Atmos.EntitySystems } } - public bool HasData(GridId gridId) + public bool HasData(EntityUid gridId) { return _tileData.ContainsKey(gridId); } - public GasOverlayEnumerator GetOverlays(GridId gridIndex, Vector2i indices) + public GasOverlayEnumerator GetOverlays(EntityUid gridIndex, Vector2i indices) { if (!_tileData.TryGetValue(gridIndex, out var chunks)) return default; @@ -149,7 +148,7 @@ namespace Content.Client.Atmos.EntitySystems return new GasOverlayEnumerator(overlays, this); } - public FireOverlayEnumerator GetFireOverlays(GridId gridIndex, Vector2i indices) + public FireOverlayEnumerator GetFireOverlays(EntityUid gridIndex, Vector2i indices) { if (!_tileData.TryGetValue(gridIndex, out var chunks)) return default; diff --git a/Content.Client/Atmos/Overlays/AtmosDebugOverlay.cs b/Content.Client/Atmos/Overlays/AtmosDebugOverlay.cs index f021001f4e..ee8781debb 100644 --- a/Content.Client/Atmos/Overlays/AtmosDebugOverlay.cs +++ b/Content.Client/Atmos/Overlays/AtmosDebugOverlay.cs @@ -1,4 +1,4 @@ -using Content.Client.Atmos.EntitySystems; +using Content.Client.Atmos.EntitySystems; using Content.Shared.Atmos; using Content.Shared.Atmos.EntitySystems; using Robust.Client.Graphics; @@ -41,7 +41,7 @@ namespace Content.Client.Atmos.Overlays foreach (var mapGrid in _mapManager.FindGridsIntersecting(mapId, worldBounds)) { - if (!_atmosDebugOverlaySystem.HasData(mapGrid.Index)) + if (!_atmosDebugOverlaySystem.HasData(mapGrid.GridEntityId)) continue; drawHandle.SetTransform(mapGrid.WorldMatrix); @@ -50,7 +50,7 @@ namespace Content.Client.Atmos.Overlays { foreach (var tile in mapGrid.GetTilesIntersecting(worldBounds)) { - var dataMaybeNull = _atmosDebugOverlaySystem.GetData(mapGrid.Index, tile.GridIndices); + var dataMaybeNull = _atmosDebugOverlaySystem.GetData(mapGrid.GridEntityId, tile.GridIndices); if (dataMaybeNull != null) { var data = (SharedAtmosDebugOverlaySystem.AtmosDebugOverlayData) dataMaybeNull!; diff --git a/Content.Client/Atmos/Overlays/FireTileOverlay.cs b/Content.Client/Atmos/Overlays/FireTileOverlay.cs index d22d617430..b32f8699fc 100644 --- a/Content.Client/Atmos/Overlays/FireTileOverlay.cs +++ b/Content.Client/Atmos/Overlays/FireTileOverlay.cs @@ -36,14 +36,14 @@ namespace Content.Client.Atmos.Overlays foreach (var mapGrid in _mapManager.FindGridsIntersecting(mapId, worldBounds)) { - if (!_gasTileOverlaySystem.HasData(mapGrid.Index)) + if (!_gasTileOverlaySystem.HasData(mapGrid.GridEntityId)) continue; drawHandle.SetTransform(mapGrid.WorldMatrix); foreach (var tile in mapGrid.GetTilesIntersecting(worldBounds)) { - var enumerator = _gasTileOverlaySystem.GetFireOverlays(mapGrid.Index, tile.GridIndices); + var enumerator = _gasTileOverlaySystem.GetFireOverlays(mapGrid.GridEntityId, tile.GridIndices); while (enumerator.MoveNext(out var tuple)) { drawHandle.DrawTexture(tuple.Texture, new Vector2(tile.X, tile.Y), tuple.Color); diff --git a/Content.Client/Atmos/Overlays/GasTileOverlay.cs b/Content.Client/Atmos/Overlays/GasTileOverlay.cs index 48be409e71..b97eaa15dc 100644 --- a/Content.Client/Atmos/Overlays/GasTileOverlay.cs +++ b/Content.Client/Atmos/Overlays/GasTileOverlay.cs @@ -35,14 +35,14 @@ namespace Content.Client.Atmos.Overlays foreach (var mapGrid in _mapManager.FindGridsIntersecting(mapId, worldBounds)) { - if (!_gasTileOverlaySystem.HasData(mapGrid.Index)) + if (!_gasTileOverlaySystem.HasData(mapGrid.GridEntityId)) continue; drawHandle.SetTransform(mapGrid.WorldMatrix); foreach (var tile in mapGrid.GetTilesIntersecting(worldBounds)) { - var enumerator = _gasTileOverlaySystem.GetOverlays(mapGrid.Index, tile.GridIndices); + var enumerator = _gasTileOverlaySystem.GetOverlays(mapGrid.GridEntityId, tile.GridIndices); while (enumerator.MoveNext(out var tuple)) { drawHandle.DrawTexture(tuple.Texture, new Vector2(tile.X, tile.Y), tuple.Color); diff --git a/Content.Client/Audio/BackgroundAudioSystem.cs b/Content.Client/Audio/BackgroundAudioSystem.cs index 78b6df21ff..1e6fca9c14 100644 --- a/Content.Client/Audio/BackgroundAudioSystem.cs +++ b/Content.Client/Audio/BackgroundAudioSystem.cs @@ -89,7 +89,7 @@ namespace Content.Client.Audio { if(_playMan.LocalPlayer is null || _playMan.LocalPlayer.ControlledEntity != message.Entity) return; if (!TryComp(message.Entity, out var xform) || - !_mapManager.TryGetGrid(xform.GridID, out var grid)) return; + !_mapManager.TryGetGrid(xform.GridEntityId, out var grid)) return; var tileDef = (ContentTileDefinition) _tileDefMan[grid.GetTileRef(xform.Coordinates).Tile.TypeId]; diff --git a/Content.Client/Decals/DecalOverlay.cs b/Content.Client/Decals/DecalOverlay.cs index 03b7f87cc0..3370ac34f6 100644 --- a/Content.Client/Decals/DecalOverlay.cs +++ b/Content.Client/Decals/DecalOverlay.cs @@ -47,8 +47,7 @@ namespace Content.Client.Decals { if (zIndexDictionary.Count == 0) continue; - var gridUid = _mapManager.GetGridEuid(gridId); - var xform = xformQuery.GetComponent(gridUid); + var xform = xformQuery.GetComponent(gridId); handle.SetTransform(_transform.GetWorldMatrix(xform, xformQuery)); diff --git a/Content.Client/Decals/DecalSystem.cs b/Content.Client/Decals/DecalSystem.cs index de8be03a23..4bf7baee12 100644 --- a/Content.Client/Decals/DecalSystem.cs +++ b/Content.Client/Decals/DecalSystem.cs @@ -1,8 +1,6 @@ using Content.Shared.Decals; using Robust.Client.GameObjects; using Robust.Client.Graphics; -using Robust.Shared.Map; -using Robust.Shared.Utility; namespace Content.Client.Decals { @@ -13,8 +11,8 @@ namespace Content.Client.Decals [Dependency] private readonly SpriteSystem _sprites = default!; private DecalOverlay _overlay = default!; - public Dictionary>> DecalRenderIndex = new(); - private Dictionary> DecalZIndexIndex = new(); + public Dictionary>> DecalRenderIndex = new(); + private Dictionary> DecalZIndexIndex = new(); public override void Initialize() { @@ -58,13 +56,13 @@ namespace Content.Client.Decals _overlayManager.RemoveOverlay(_overlay); } - protected override bool RemoveDecalHook(GridId gridId, uint uid) + protected override bool RemoveDecalHook(EntityUid gridId, uint uid) { RemoveDecalFromRenderIndex(gridId, uid); return base.RemoveDecalHook(gridId, uid); } - private void RemoveDecalFromRenderIndex(GridId gridId, uint uid) + private void RemoveDecalFromRenderIndex(EntityUid gridId, uint uid) { var zIndex = DecalZIndexIndex[gridId][uid]; diff --git a/Content.Client/Explosion/ExplosionOverlaySystem.cs b/Content.Client/Explosion/ExplosionOverlaySystem.cs index 0e52ac92cc..81004167d3 100644 --- a/Content.Client/Explosion/ExplosionOverlaySystem.cs +++ b/Content.Client/Explosion/ExplosionOverlaySystem.cs @@ -193,7 +193,7 @@ public sealed class ExplosionOverlaySystem : EntitySystem internal sealed class Explosion { public readonly Dictionary>? SpaceTiles; - public readonly Dictionary>> Tiles; + public readonly Dictionary>> Tiles; public readonly List Intensity; public readonly EntityUid LightEntity; public readonly MapId Map; diff --git a/Content.Client/Eye/EyeLerpingSystem.cs b/Content.Client/Eye/EyeLerpingSystem.cs index 95d9123b87..70deb4d5b5 100644 --- a/Content.Client/Eye/EyeLerpingSystem.cs +++ b/Content.Client/Eye/EyeLerpingSystem.cs @@ -105,7 +105,7 @@ public sealed class EyeLerpingSystem : EntitySystem if (!TryComp(uid, out TransformComponent? transform) || !TryComp(uid, out EyeComponent? eye) || eye.Eye == null - || !_mapManager.TryGetGrid(transform.GridID, out var grid)) + || !_mapManager.TryGetGrid(transform.GridEntityId, out var grid)) { _toRemove.Add(uid); return; diff --git a/Content.Client/IconSmoothing/IconSmoothComponent.cs b/Content.Client/IconSmoothing/IconSmoothComponent.cs index a469cbc634..f497cbf60a 100644 --- a/Content.Client/IconSmoothing/IconSmoothComponent.cs +++ b/Content.Client/IconSmoothing/IconSmoothComponent.cs @@ -1,5 +1,4 @@ using JetBrains.Annotations; -using Robust.Shared.Map; namespace Content.Client.IconSmoothing { @@ -14,7 +13,7 @@ namespace Content.Client.IconSmoothing [RegisterComponent] public sealed class IconSmoothComponent : Component { - public (GridId, Vector2i)? LastPosition; + public (EntityUid, Vector2i)? LastPosition; /// /// We will smooth with other objects with the same key. diff --git a/Content.Client/IconSmoothing/IconSmoothSystem.cs b/Content.Client/IconSmoothing/IconSmoothSystem.cs index e368b402e1..9322ff3cdf 100644 --- a/Content.Client/IconSmoothing/IconSmoothSystem.cs +++ b/Content.Client/IconSmoothing/IconSmoothSystem.cs @@ -33,9 +33,9 @@ namespace Content.Client.IconSmoothing var xform = Transform(uid); if (xform.Anchored) { - component.LastPosition = _mapManager.TryGetGrid(xform.GridID, out var grid) - ? (xform.GridID, grid.TileIndicesFor(xform.Coordinates)) - : (GridId.Invalid, new Vector2i(0, 0)); + component.LastPosition = _mapManager.TryGetGrid(xform.GridEntityId, out var grid) + ? (xform.GridEntityId, grid.TileIndicesFor(xform.Coordinates)) + : (EntityUid.Invalid, new Vector2i(0, 0)); DirtyNeighbours(uid, component); } @@ -111,14 +111,14 @@ namespace Content.Client.IconSmoothing Vector2i pos; - if (transform.Anchored && _mapManager.TryGetGrid(transform.GridID, out var grid)) + if (transform.Anchored && _mapManager.TryGetGrid(transform.GridEntityId, out var grid)) { pos = grid.CoordinatesToTile(transform.Coordinates); } else { // Entity is no longer valid, update around the last position it was at. - if (comp.LastPosition is not (GridId gridId, Vector2i oldPos)) + if (comp.LastPosition is not (EntityUid gridId, Vector2i oldPos)) return; if (!_mapManager.TryGetGrid(gridId, out grid)) @@ -191,9 +191,9 @@ namespace Content.Client.IconSmoothing if (xform.Anchored) { - if (!_mapManager.TryGetGrid(xform.GridID, out grid)) + if (!_mapManager.TryGetGrid(xform.GridEntityId, out grid)) { - Logger.Error($"Failed to calculate IconSmoothComponent sprite in {uid} because grid {xform.GridID} was missing."); + Logger.Error($"Failed to calculate IconSmoothComponent sprite in {uid} because grid {xform.GridEntityId} was missing."); return; } } diff --git a/Content.Client/NodeContainer/NodeVisualizationOverlay.cs b/Content.Client/NodeContainer/NodeVisualizationOverlay.cs index 82c6b874d3..2b0cba6b88 100644 --- a/Content.Client/NodeContainer/NodeVisualizationOverlay.cs +++ b/Content.Client/NodeContainer/NodeVisualizationOverlay.cs @@ -20,7 +20,7 @@ namespace Content.Client.NodeContainer private readonly IEntityManager _entityManager; private readonly Dictionary<(int, int), NodeRenderData> _nodeIndex = new(); - private readonly Dictionary>> _gridIndex = new (); + private readonly Dictionary>> _gridIndex = new (); private readonly Font _font; @@ -76,7 +76,7 @@ namespace Content.Client.NodeContainer var node = _system.NodeLookup[(groupId, nodeId)]; - var gridId = _entityManager.GetComponent(node.Entity).GridID; + var gridId = _entityManager.GetComponent(node.Entity).GridEntityId; var grid = _mapManager.GetGrid(gridId); var gridTile = grid.TileIndicesFor(_entityManager.GetComponent(node.Entity).Coordinates); @@ -112,12 +112,12 @@ namespace Content.Client.NodeContainer foreach (var grid in _mapManager.FindGridsIntersecting(map, worldAABB)) { - foreach (var entity in _lookup.GetEntitiesIntersecting(grid.Index, worldAABB)) + foreach (var entity in _lookup.GetEntitiesIntersecting(grid.GridEntityId, worldAABB)) { if (!_system.Entities.TryGetValue(entity, out var nodeData)) continue; - var gridDict = _gridIndex.GetOrNew(grid.Index); + var gridDict = _gridIndex.GetOrNew(grid.GridEntityId); var coords = xformQuery.GetComponent(entity).Coordinates; // TODO: This probably shouldn't be capable of returning NaN... diff --git a/Content.Client/Physics/Controllers/MoverController.cs b/Content.Client/Physics/Controllers/MoverController.cs index c93c142da3..39d5517811 100644 --- a/Content.Client/Physics/Controllers/MoverController.cs +++ b/Content.Client/Physics/Controllers/MoverController.cs @@ -27,7 +27,7 @@ namespace Content.Client.Physics.Controllers return; } - if (xform.GridID != GridId.Invalid) + if (xform.GridEntityId != EntityUid.Invalid) mover.LastGridAngle = GetParentGridAngle(xform, mover); // Essentially we only want to set our mob to predicted so every other entity we just interpolate diff --git a/Content.IntegrationTests/Tests/Body/LungTest.cs b/Content.IntegrationTests/Tests/Body/LungTest.cs index 69dc96e53d..60cf1c88a8 100644 --- a/Content.IntegrationTests/Tests/Body/LungTest.cs +++ b/Content.IntegrationTests/Tests/Body/LungTest.cs @@ -1,4 +1,4 @@ -using System.Threading.Tasks; +using System.Threading.Tasks; using Content.Server.Atmos.Components; using Content.Server.Body.Components; using Content.Server.Body.Systems; @@ -61,7 +61,7 @@ namespace Content.IntegrationTests.Tests.Body MetabolizerSystem metaSys = default; MapId mapId; - GridId? grid = null; + EntityUid? grid = null; SharedBodyComponent body = default; EntityUid human = default; GridAtmosphereComponent relevantAtmos = default; @@ -91,12 +91,11 @@ namespace Content.IntegrationTests.Tests.Body await server.WaitAssertion(() => { var coords = new Vector2(0.5f, -1f); - var geid = mapManager.GetGridEuid(grid.Value); - var coordinates = new EntityCoordinates(geid, coords); + var coordinates = new EntityCoordinates(grid.Value, coords); human = entityManager.SpawnEntity("HumanBodyDummy", coordinates); respSys = EntitySystem.Get(); metaSys = EntitySystem.Get(); - relevantAtmos = entityManager.GetComponent(geid); + relevantAtmos = entityManager.GetComponent(grid.Value); startingMoles = GetMapMoles(); Assert.True(entityManager.TryGetComponent(human, out body)); @@ -138,7 +137,7 @@ namespace Content.IntegrationTests.Tests.Body var entityManager = server.ResolveDependency(); MapId mapId; - GridId? grid = null; + EntityUid? grid = null; RespiratorComponent respirator = null; EntityUid human = default; @@ -155,8 +154,7 @@ namespace Content.IntegrationTests.Tests.Body await server.WaitAssertion(() => { var center = new Vector2(0.5f, -1.5f); - var geid = mapManager.GetGridEuid(grid.Value); - var coordinates = new EntityCoordinates(geid, center); + var coordinates = new EntityCoordinates(grid.Value, center); human = entityManager.SpawnEntity("HumanBodyDummy", coordinates); Assert.True(entityManager.HasComponent(human)); diff --git a/Content.IntegrationTests/Tests/EntityTest.cs b/Content.IntegrationTests/Tests/EntityTest.cs index 0a94412cfb..07e4fcb082 100644 --- a/Content.IntegrationTests/Tests/EntityTest.cs +++ b/Content.IntegrationTests/Tests/EntityTest.cs @@ -45,12 +45,7 @@ namespace Content.IntegrationTests.Tests mapManager.AddUninitializedMap(mapId); - var gridId = new GridId(1); - - if (!mapManager.TryGetGrid(gridId, out grid)) - { - grid = mapManager.CreateGrid(mapId, gridId); - } + grid = mapManager.CreateGrid(mapId); var tileDefinition = tileDefinitionManager["underplating"]; var tile = new Tile(tileDefinition.TileId); @@ -136,12 +131,7 @@ namespace Content.IntegrationTests.Tests mapManager.AddUninitializedMap(mapId); - var gridId = new GridId(1); - - if (!mapManager.TryGetGrid(gridId, out grid)) - { - grid = mapManager.CreateGrid(mapId, gridId); - } + grid = mapManager.CreateGrid(mapId); var tileDefinition = tileDefinitionManager["underplating"]; var tile = new Tile(tileDefinition.TileId); @@ -239,12 +229,7 @@ namespace Content.IntegrationTests.Tests mapManager.AddUninitializedMap(mapId); - var gridId = new GridId(1); - - if (!mapManager.TryGetGrid(gridId, out grid)) - { - grid = mapManager.CreateGrid(mapId, gridId); - } + grid = mapManager.CreateGrid(mapId); var tileDefinition = tileDefinitionManager["underplating"]; var tile = new Tile(tileDefinition.TileId); diff --git a/Content.IntegrationTests/Tests/Fluids/FluidSpillTest.cs b/Content.IntegrationTests/Tests/Fluids/FluidSpillTest.cs index cbe33e21a2..ca4914f322 100644 --- a/Content.IntegrationTests/Tests/Fluids/FluidSpillTest.cs +++ b/Content.IntegrationTests/Tests/Fluids/FluidSpillTest.cs @@ -1,4 +1,4 @@ -#nullable enable +#nullable enable using System; using System.Threading.Tasks; using Content.Server.Fluids.Components; @@ -55,13 +55,13 @@ public sealed class FluidSpill : ContentIntegrationTest var spillSystem = server.ResolveDependency().GetEntitySystem(); var gameTiming = server.ResolveDependency(); MapId mapId; - GridId gridId = default; + EntityUid gridId = default; await server.WaitPost(() => { mapId = mapManager.CreateMap(); var grid = mapManager.CreateGrid(mapId); - gridId = grid.Index; + gridId = grid.GridEntityId; for (var x = 0; x < 3; x++) { @@ -118,7 +118,7 @@ public sealed class FluidSpill : ContentIntegrationTest var spillSystem = server.ResolveDependency().GetEntitySystem(); var gameTiming = server.ResolveDependency(); MapId mapId; - GridId gridId = default; + EntityUid gridId = default; await server.WaitPost(() => { @@ -133,7 +133,7 @@ public sealed class FluidSpill : ContentIntegrationTest } } - gridId = grid.Index; + gridId = grid.GridEntityId; }); await server.WaitAssertion(() => diff --git a/Content.IntegrationTests/Tests/Fluids/PuddleTest.cs b/Content.IntegrationTests/Tests/Fluids/PuddleTest.cs index 0f99261f30..71fd46ed68 100644 --- a/Content.IntegrationTests/Tests/Fluids/PuddleTest.cs +++ b/Content.IntegrationTests/Tests/Fluids/PuddleTest.cs @@ -92,8 +92,7 @@ namespace Content.IntegrationTests.Tests.Fluids MapId sMapId = default; IMapGrid sGrid; - GridId sGridId = default; - EntityUid sGridEntity = default; + EntityUid sGridId = default; EntityCoordinates sCoordinates = default; // Spawn a paused map with one tile to spawn puddles on @@ -102,9 +101,8 @@ namespace Content.IntegrationTests.Tests.Fluids sMapId = sMapManager.CreateMap(); sMapManager.SetMapPaused(sMapId, true); sGrid = sMapManager.CreateGrid(sMapId); - sGridId = sGrid.Index; - sGridEntity = sGrid.GridEntityId; - entityManager.GetComponent(sGridEntity).EntityPaused = true; // See https://github.com/space-wizards/RobustToolbox/issues/1444 + sGridId = sGrid.GridEntityId; + entityManager.GetComponent(sGridId).EntityPaused = true; // See https://github.com/space-wizards/RobustToolbox/issues/1444 var tileDefinition = sTileDefinitionManager["underplating"]; var tile = new Tile(tileDefinition.TileId); diff --git a/Content.IntegrationTests/Tests/SaveLoadSaveTest.cs b/Content.IntegrationTests/Tests/SaveLoadSaveTest.cs index 1188fb906f..a9ff9fe7fc 100644 --- a/Content.IntegrationTests/Tests/SaveLoadSaveTest.cs +++ b/Content.IntegrationTests/Tests/SaveLoadSaveTest.cs @@ -25,8 +25,9 @@ namespace Content.IntegrationTests.Tests var mapManager = server.ResolveDependency(); server.Post(() => { - // TODO: Un-hardcode the grid Id for this test. - mapLoader.SaveBlueprint(new GridId(1), "save load save 1.yml"); + // TODO: Properly find the "main" station grid. + var grid0 = mapManager.GetAllGrids().First(); + mapLoader.SaveBlueprint(grid0.GridEntityId, "save load save 1.yml"); var mapId = mapManager.CreateMap(); var grid = mapLoader.LoadBlueprint(mapId, "save load save 1.yml").gridId; mapLoader.SaveBlueprint(grid!.Value, "save load save 2.yml"); diff --git a/Content.MapRenderer/Painters/GridPainter.cs b/Content.MapRenderer/Painters/GridPainter.cs index df1d88a3a7..bb355f28ad 100644 --- a/Content.MapRenderer/Painters/GridPainter.cs +++ b/Content.MapRenderer/Painters/GridPainter.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; @@ -25,8 +25,8 @@ namespace Content.MapRenderer.Painters private readonly IEntityManager _sEntityManager; private readonly IMapManager _sMapManager; - private readonly ConcurrentDictionary> _entities; - private readonly Dictionary> _decals; + private readonly ConcurrentDictionary> _entities; + private readonly Dictionary> _decals; public GridPainter(ClientIntegrationInstance client, ServerIntegrationInstance server) { @@ -48,27 +48,27 @@ namespace Content.MapRenderer.Painters var stopwatch = new Stopwatch(); stopwatch.Start(); - if (!_entities.TryGetValue(grid.Index, out var entities)) + if (!_entities.TryGetValue(grid.GridEntityId, out var entities)) { - Console.WriteLine($"No entities found on grid {grid.Index}"); + Console.WriteLine($"No entities found on grid {grid.GridEntityId}"); return; } // Decals are always painted before entities, and are also optional. - if (_decals.TryGetValue(grid.Index, out var decals)) + if (_decals.TryGetValue(grid.GridEntityId, out var decals)) _decalPainter.Run(gridCanvas, decals); _entityPainter.Run(gridCanvas, entities); - Console.WriteLine($"{nameof(GridPainter)} painted grid {grid.Index} in {(int) stopwatch.Elapsed.TotalMilliseconds} ms"); + Console.WriteLine($"{nameof(GridPainter)} painted grid {grid.GridEntityId} in {(int) stopwatch.Elapsed.TotalMilliseconds} ms"); } - private ConcurrentDictionary> GetEntities() + private ConcurrentDictionary> GetEntities() { var stopwatch = new Stopwatch(); stopwatch.Start(); - var components = new ConcurrentDictionary>(); + var components = new ConcurrentDictionary>(); foreach (var entity in _sEntityManager.GetEntities()) { @@ -90,14 +90,14 @@ namespace Content.MapRenderer.Painters } var transform = _sEntityManager.GetComponent(entity); - if (_cMapManager.TryGetGrid(transform.GridID, out var grid)) + if (_cMapManager.TryGetGrid(transform.GridEntityId, out var grid)) { var position = transform.LocalPosition; var (x, y) = TransformLocalPosition(position, grid); var data = new EntityData(sprite, x, y); - components.GetOrAdd(transform.GridID, _ => new List()).Add(data); + components.GetOrAdd(transform.GridEntityId, _ => new List()).Add(data); } } @@ -106,12 +106,12 @@ namespace Content.MapRenderer.Painters return components; } - private Dictionary> GetDecals() + private Dictionary> GetDecals() { var stopwatch = new Stopwatch(); stopwatch.Start(); - var decals = new Dictionary>(); + var decals = new Dictionary>(); foreach (var grid in _sMapManager.GetAllGrids()) { @@ -126,7 +126,7 @@ namespace Content.MapRenderer.Painters foreach (var (_, decal) in list) { var (x, y) = TransformLocalPosition(decal.Coordinates, grid); - decals.GetOrNew(grid.Index).Add(new DecalData(decal, x, y)); + decals.GetOrNew(grid.GridEntityId).Add(new DecalData(decal, x, y)); } } } diff --git a/Content.MapRenderer/Painters/TilePainter.cs b/Content.MapRenderer/Painters/TilePainter.cs index e0985994a5..6718443422 100644 --- a/Content.MapRenderer/Painters/TilePainter.cs +++ b/Content.MapRenderer/Painters/TilePainter.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using Robust.Client.Graphics; @@ -51,7 +51,7 @@ namespace Content.MapRenderer.Painters i++; }); - Console.WriteLine($"{nameof(TilePainter)} painted {i} tiles on grid {grid.Index} in {(int) stopwatch.Elapsed.TotalMilliseconds} ms"); + Console.WriteLine($"{nameof(TilePainter)} painted {i} tiles on grid {grid.GridEntityId} in {(int) stopwatch.Elapsed.TotalMilliseconds} ms"); } private Dictionary> GetTileImages( diff --git a/Content.Server/AI/Operators/Inventory/InteractWithEntityOperator.cs b/Content.Server/AI/Operators/Inventory/InteractWithEntityOperator.cs index 06f2dfe16b..435d14462d 100644 --- a/Content.Server/AI/Operators/Inventory/InteractWithEntityOperator.cs +++ b/Content.Server/AI/Operators/Inventory/InteractWithEntityOperator.cs @@ -26,7 +26,7 @@ namespace Content.Server.AI.Operators.Inventory { var targetTransform = _entMan.GetComponent(_useTarget); - if (targetTransform.GridID != _entMan.GetComponent(_owner).GridID) + if (targetTransform.GridEntityId != _entMan.GetComponent(_owner).GridEntityId) { return Outcome.Failed; } diff --git a/Content.Server/AI/Pathfinding/Accessible/AiReachableSystem.cs b/Content.Server/AI/Pathfinding/Accessible/AiReachableSystem.cs index 4601e28e0c..a5ae55d95a 100644 --- a/Content.Server/AI/Pathfinding/Accessible/AiReachableSystem.cs +++ b/Content.Server/AI/Pathfinding/Accessible/AiReachableSystem.cs @@ -46,7 +46,7 @@ namespace Content.Server.AI.Pathfinding.Accessible /// Regions are groups of nodes with the same profile (for pathfinding purposes) /// i.e. same collision, not-space, same access, etc. /// - private readonly Dictionary>> _regions = + private readonly Dictionary>> _regions = new(); /// @@ -168,10 +168,10 @@ namespace Content.Server.AI.Pathfinding.Accessible { var xform = EntityManager.GetComponent(target); // TODO: Handle this gracefully instead of just failing. - if (!xform.GridID.IsValid()) + if (!xform.GridEntityId.IsValid()) return false; - var targetTile = _mapManager.GetGrid(xform.GridID).GetTileRef(xform.Coordinates); + var targetTile = _mapManager.GetGrid(xform.GridEntityId).GetTileRef(xform.Coordinates); var targetNode = _pathfindingSystem.GetNode(targetTile); var collisionMask = 0; @@ -206,10 +206,10 @@ namespace Content.Server.AI.Pathfinding.Accessible { var xform = EntityManager.GetComponent(entity); - if (xform.GridID != targetNode.TileRef.GridIndex) + if (xform.GridEntityId != targetNode.TileRef.GridUid) return false; - var entityTile = _mapManager.GetGrid(xform.GridID).GetTileRef(xform.Coordinates); + var entityTile = _mapManager.GetGrid(xform.GridEntityId).GetTileRef(xform.Coordinates); var entityNode = _pathfindingSystem.GetNode(entityTile); var entityRegion = GetRegion(entityNode); var targetRegion = GetRegion(targetNode); @@ -421,12 +421,12 @@ namespace Content.Server.AI.Pathfinding.Accessible { var xform = EntityManager.GetComponent(entity); - if (!xform.GridID.IsValid()) + if (!xform.GridEntityId.IsValid()) { return null; } - var entityTile = _mapManager.GetGrid(xform.GridID).GetTileRef(xform.Coordinates); + var entityTile = _mapManager.GetGrid(xform.GridEntityId).GetTileRef(xform.Coordinates); var entityNode = _pathfindingSystem.GetNode(entityTile); return GetRegion(entityNode); } @@ -709,7 +709,7 @@ namespace Content.Server.AI.Pathfinding.Accessible } #if DEBUG - private void SendRegionsDebugMessage(GridId gridId) + private void SendRegionsDebugMessage(EntityUid gridId) { if (_subscribedSessions.Count == 0) return; var grid = _mapManager.GetGrid(gridId); @@ -757,7 +757,7 @@ namespace Content.Server.AI.Pathfinding.Accessible /// /// /// - private void SendRegionCacheMessage(GridId gridId, IEnumerable regions, bool cached) + private void SendRegionCacheMessage(EntityUid gridId, IEnumerable regions, bool cached) { if (_subscribedSessions.Count == 0) return; diff --git a/Content.Server/AI/Pathfinding/PathfindingHelpers.cs b/Content.Server/AI/Pathfinding/PathfindingHelpers.cs index 74ee0416d1..b3d011493e 100644 --- a/Content.Server/AI/Pathfinding/PathfindingHelpers.cs +++ b/Content.Server/AI/Pathfinding/PathfindingHelpers.cs @@ -160,7 +160,7 @@ namespace Content.Server.AI.Pathfinding cameFrom.Remove(previousCurrent); var pathfindingSystem = IoCManager.Resolve().GetEntitySystem(); var mapManager = IoCManager.Resolve(); - var grid = mapManager.GetGrid(current.TileRef.GridIndex); + var grid = mapManager.GetGrid(current.TileRef.GridUid); // Get all the intermediate nodes while (true) diff --git a/Content.Server/AI/Pathfinding/PathfindingSystem.Grid.cs b/Content.Server/AI/Pathfinding/PathfindingSystem.Grid.cs index 24a8bcdfea..c69fa730b6 100644 --- a/Content.Server/AI/Pathfinding/PathfindingSystem.Grid.cs +++ b/Content.Server/AI/Pathfinding/PathfindingSystem.Grid.cs @@ -97,7 +97,7 @@ public sealed partial class PathfindingSystem private PathfindingChunk CreateChunk(GridPathfindingComponent comp, Vector2i indices) { var grid = _mapManager.GetGrid(comp.Owner); - var newChunk = new PathfindingChunk(grid.Index, indices); + var newChunk = new PathfindingChunk(grid.GridEntityId, indices); comp.Graph.Add(indices, newChunk); newChunk.Initialize(grid); @@ -121,7 +121,7 @@ public sealed partial class PathfindingSystem private void OnTileUpdate(TileRef tile) { - if (!_mapManager.GridExists(tile.GridIndex)) return; + if (!_mapManager.GridExists(tile.GridUid)) return; var node = GetNode(tile); node.UpdateTile(tile); @@ -129,7 +129,7 @@ public sealed partial class PathfindingSystem private bool IsRelevant(TransformComponent xform, PhysicsComponent physics) { - return xform.GridID != GridId.Invalid && (TrackedCollisionLayers & physics.CollisionLayer) != 0; + return xform.GridEntityId != EntityUid.Invalid && (TrackedCollisionLayers & physics.CollisionLayer) != 0; } /// @@ -143,7 +143,7 @@ public sealed partial class PathfindingSystem !Resolve(entity, ref physics, false)) return; if (!IsRelevant(xform, physics) || - !_mapManager.TryGetGrid(xform.GridID, out var grid)) + !_mapManager.TryGetGrid(xform.GridEntityId, out var grid)) { return; } @@ -158,7 +158,7 @@ public sealed partial class PathfindingSystem private void OnEntityRemove(EntityUid entity, TransformComponent? xform = null) { if (!Resolve(entity, ref xform, false) || - !_mapManager.TryGetGrid(xform.GridID, out var grid)) return; + !_mapManager.TryGetGrid(xform.GridEntityId, out var grid)) return; var node = GetNode(grid.GetTileRef(xform.Coordinates)); node.RemoveEntity(entity); @@ -166,7 +166,7 @@ public sealed partial class PathfindingSystem private void OnEntityRemove(EntityUid entity, EntityCoordinates coordinates) { - var gridId = coordinates.GetGridId(EntityManager); + var gridId = coordinates.GetGridEntityId(EntityManager); if (!_mapManager.TryGetGrid(gridId, out var grid)) return; var node = GetNode(grid.GetTileRef(coordinates)); @@ -175,13 +175,13 @@ public sealed partial class PathfindingSystem private PathfindingNode? GetNode(TransformComponent xform) { - if (!_mapManager.TryGetGrid(xform.GridID, out var grid)) return null; + if (!_mapManager.TryGetGrid(xform.GridEntityId, out var grid)) return null; return GetNode(grid.GetTileRef(xform.Coordinates)); } private PathfindingNode? GetNode(EntityCoordinates coordinates) { - if (!_mapManager.TryGetGrid(coordinates.GetGridId(EntityManager), out var grid)) return null; + if (!_mapManager.TryGetGrid(coordinates.GetGridEntityId(EntityManager), out var grid)) return null; return GetNode(grid.GetTileRef(coordinates)); } @@ -215,7 +215,7 @@ public sealed partial class PathfindingSystem // Also look at increasing tile cost the more physics entities are on it public bool CanTraverse(EntityUid entity, EntityCoordinates coordinates) { - var gridId = coordinates.GetGridId(EntityManager); + var gridId = coordinates.GetGridEntityId(EntityManager); var tile = _mapManager.GetGrid(gridId).GetTileRef(coordinates); var node = GetNode(tile); return CanTraverse(entity, node); diff --git a/Content.Server/AI/Pathfinding/ServerPathfindingDebugSystem.cs b/Content.Server/AI/Pathfinding/ServerPathfindingDebugSystem.cs index 85c24a835c..e8020e41ef 100644 --- a/Content.Server/AI/Pathfinding/ServerPathfindingDebugSystem.cs +++ b/Content.Server/AI/Pathfinding/ServerPathfindingDebugSystem.cs @@ -29,16 +29,16 @@ namespace Content.Server.AI.Pathfinding var route = new List(); foreach (var tile in routeDebug.Route) { - var tileGrid = mapManager.GetGrid(tile.GridIndex).GridTileToLocal(tile.GridIndices); + var tileGrid = mapManager.GetGrid(tile.GridUid).GridTileToLocal(tile.GridIndices); route.Add(tileGrid.ToMapPos(EntityManager)); } var cameFrom = new Dictionary(); foreach (var (from, to) in routeDebug.CameFrom) { - var tileOneGrid = mapManager.GetGrid(from.GridIndex).GridTileToLocal(from.GridIndices); + var tileOneGrid = mapManager.GetGrid(from.GridUid).GridTileToLocal(from.GridIndices); var tileOneWorld = tileOneGrid.ToMapPos(EntityManager); - var tileTwoGrid = mapManager.GetGrid(to.GridIndex).GridTileToLocal(to.GridIndices); + var tileTwoGrid = mapManager.GetGrid(to.GridUid).GridTileToLocal(to.GridIndices); var tileTwoWorld = tileTwoGrid.ToMapPos(EntityManager); cameFrom[tileOneWorld] = tileTwoWorld; } @@ -46,7 +46,7 @@ namespace Content.Server.AI.Pathfinding var gScores = new Dictionary(); foreach (var (tile, score) in routeDebug.GScores) { - var tileGrid = mapManager.GetGrid(tile.GridIndex).GridTileToLocal(tile.GridIndices); + var tileGrid = mapManager.GetGrid(tile.GridUid).GridTileToLocal(tile.GridIndices); gScores[tileGrid.ToMapPos(EntityManager)] = score; } @@ -67,14 +67,14 @@ namespace Content.Server.AI.Pathfinding var route = new List(); foreach (var tile in routeDebug.Route) { - var tileGrid = mapManager.GetGrid(tile.GridIndex).GridTileToLocal(tile.GridIndices); + var tileGrid = mapManager.GetGrid(tile.GridUid).GridTileToLocal(tile.GridIndices); route.Add(tileGrid.ToMapPos(EntityManager)); } var jumpNodes = new List(); foreach (var tile in routeDebug.JumpNodes) { - var tileGrid = mapManager.GetGrid(tile.GridIndex).GridTileToLocal(tile.GridIndices); + var tileGrid = mapManager.GetGrid(tile.GridUid).GridTileToLocal(tile.GridIndices); jumpNodes.Add(tileGrid.ToMapPos(EntityManager)); } diff --git a/Content.Server/AI/Steering/AiSteeringSystem.cs b/Content.Server/AI/Steering/AiSteeringSystem.cs index a60947dab8..14f5a2c974 100644 --- a/Content.Server/AI/Steering/AiSteeringSystem.cs +++ b/Content.Server/AI/Steering/AiSteeringSystem.cs @@ -242,7 +242,7 @@ namespace Content.Server.AI.Steering if (Deleted(entity) || !EntityManager.TryGetComponent(entity, out AiControllerComponent? controller) || !controller.CanMove || - !EntityManager.GetComponent(entity).GridID.IsValid()) + !EntityManager.GetComponent(entity).GridEntityId.IsValid()) { return SteeringStatus.NoPath; } @@ -255,7 +255,7 @@ namespace Content.Server.AI.Steering return SteeringStatus.NoPath; } - if (_mapManager.IsGridPaused(EntityManager.GetComponent(entity).GridID)) + if (_mapManager.IsGridPaused(EntityManager.GetComponent(entity).GridEntityId)) { controller.VelocityDir = Vector2.Zero; return SteeringStatus.Pending; @@ -263,7 +263,7 @@ namespace Content.Server.AI.Steering // Validation // Check if we can even arrive -> Currently only samegrid movement supported - if (EntityManager.GetComponent(entity).GridID != steeringRequest.TargetGrid.GetGridId(EntityManager)) + if (EntityManager.GetComponent(entity).GridEntityId != steeringRequest.TargetGrid.GetGridEntityId(EntityManager)) { controller.VelocityDir = Vector2.Zero; return SteeringStatus.NoPath; @@ -408,7 +408,7 @@ namespace Content.Server.AI.Steering } var cancelToken = new CancellationTokenSource(); - var gridManager = _mapManager.GetGrid(EntityManager.GetComponent(entity).GridID); + var gridManager = _mapManager.GetGrid(EntityManager.GetComponent(entity).GridEntityId); var startTile = gridManager.GetTileRef(EntityManager.GetComponent(entity).Coordinates); var endTile = gridManager.GetTileRef(steeringRequest.TargetGrid); var collisionMask = 0; @@ -439,7 +439,7 @@ namespace Content.Server.AI.Steering { _pathfindingRequests.Remove(entity); - var entityTile = _mapManager.GetGrid(EntityManager.GetComponent(entity).GridID).GetTileRef(EntityManager.GetComponent(entity).Coordinates); + var entityTile = _mapManager.GetGrid(EntityManager.GetComponent(entity).GridEntityId).GetTileRef(EntityManager.GetComponent(entity).Coordinates); var tile = path.Dequeue(); var closestDistance = PathfindingHelpers.OctileDistance(entityTile, tile); @@ -508,7 +508,7 @@ namespace Content.Server.AI.Steering { if (_paths[entity].Count == 0) return; var nextTile = dequeue ? _paths[entity].Dequeue() : _paths[entity].Peek(); - var nextGrid = _mapManager.GetGrid(EntityManager.GetComponent(entity).GridID).GridTileToLocal(nextTile.GridIndices); + var nextGrid = _mapManager.GetGrid(EntityManager.GetComponent(entity).GridEntityId).GridTileToLocal(nextTile.GridIndices); _nextGrid[entity] = nextGrid; } @@ -631,7 +631,7 @@ namespace Content.Server.AI.Steering var checkTiles = new HashSet(); var avoidTiles = new HashSet(); var entityGridCoords = EntityManager.GetComponent(entity).Coordinates; - var grid = _mapManager.GetGrid(EntityManager.GetComponent(entity).GridID); + var grid = _mapManager.GetGrid(EntityManager.GetComponent(entity).GridEntityId); var currentTile = grid.GetTileRef(entityGridCoords); var halfwayTile = grid.GetTileRef(entityGridCoords.Offset(direction / 2)); var nextTile = grid.GetTileRef(entityGridCoords.Offset(direction)); diff --git a/Content.Server/AI/Utility/Actions/Idle/WanderAndWait.cs b/Content.Server/AI/Utility/Actions/Idle/WanderAndWait.cs index a49f6e80c7..9dbfd0c1f0 100644 --- a/Content.Server/AI/Utility/Actions/Idle/WanderAndWait.cs +++ b/Content.Server/AI/Utility/Actions/Idle/WanderAndWait.cs @@ -77,7 +77,7 @@ namespace Content.Server.AI.Utility.Actions.Idle var targetNode = robustRandom.Pick(reachableNodes); var mapManager = IoCManager.Resolve(); - var grid = mapManager.GetGrid(IoCManager.Resolve().GetComponent(Owner).GridID); + var grid = mapManager.GetGrid(IoCManager.Resolve().GetComponent(Owner).GridEntityId); var targetGrid = grid.GridTileToLocal(targetNode.TileRef.GridIndices); return targetGrid; diff --git a/Content.Server/AI/Utility/Considerations/Movement/TargetDistanceCon.cs b/Content.Server/AI/Utility/Considerations/Movement/TargetDistanceCon.cs index d14023599c..43f1a6bb26 100644 --- a/Content.Server/AI/Utility/Considerations/Movement/TargetDistanceCon.cs +++ b/Content.Server/AI/Utility/Considerations/Movement/TargetDistanceCon.cs @@ -11,7 +11,7 @@ namespace Content.Server.AI.Utility.Considerations.Movement var entities = IoCManager.Resolve(); if (context.GetState().GetValue() is not {Valid: true} target || entities.Deleted(target) || - entities.GetComponent(target).GridID != entities.GetComponent(self).GridID) + entities.GetComponent(target).GridEntityId != entities.GetComponent(self).GridEntityId) { return 0.0f; } diff --git a/Content.Server/AI/Utils/Visibility.cs b/Content.Server/AI/Utils/Visibility.cs index 9e74eff222..1fa18ed7ee 100644 --- a/Content.Server/AI/Utils/Visibility.cs +++ b/Content.Server/AI/Utils/Visibility.cs @@ -22,7 +22,7 @@ namespace Content.Server.AI.Utils { var transform = entityManager.GetComponent(entity); - if (transform.Coordinates.GetGridId(entityManager) != grid.GetGridId(entityManager)) + if (transform.Coordinates.GetGridEntityId(entityManager) != grid.GetGridEntityId(entityManager)) { continue; } diff --git a/Content.Server/AME/AntimatterEngineSystem.cs b/Content.Server/AME/AntimatterEngineSystem.cs index e804bc4089..e0bcbf59c2 100644 --- a/Content.Server/AME/AntimatterEngineSystem.cs +++ b/Content.Server/AME/AntimatterEngineSystem.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using Content.Server.AME.Components; using Content.Server.Power.Components; using Content.Server.Hands.Components; @@ -90,7 +90,7 @@ namespace Content.Server.AME if (!_toolSystem.HasQuality(args.Used, component.QualityNeeded)) return; - if (!_mapManager.TryGetGrid(args.ClickLocation.GetGridId(EntityManager), out var mapGrid)) + if (!_mapManager.TryGetGrid(args.ClickLocation.GetGridEntityId(EntityManager), out var mapGrid)) return; // No AME in space. var snapPos = mapGrid.TileIndicesFor(args.ClickLocation); diff --git a/Content.Server/Administration/Commands/VariantizeCommand.cs b/Content.Server/Administration/Commands/VariantizeCommand.cs index ed96906ed9..9a51bf613f 100644 --- a/Content.Server/Administration/Commands/VariantizeCommand.cs +++ b/Content.Server/Administration/Commands/VariantizeCommand.cs @@ -9,7 +9,6 @@ namespace Content.Server.Administration.Commands; [AdminCommand(AdminFlags.Mapping)] public sealed class VariantizeCommand : IConsoleCommand { - public string Command => "variantize"; public string Description => Loc.GetString("variantize-command-description"); @@ -24,26 +23,26 @@ public sealed class VariantizeCommand : IConsoleCommand return; } - var mapManager = IoCManager.Resolve(); + var entMan = IoCManager.Resolve(); var random = IoCManager.Resolve(); - if (!int.TryParse(args[0], out var targetId)) + if (EntityUid.TryParse(args[0], out var euid)) { - shell.WriteError(Loc.GetString("shell-argument-must-be-number")); + shell.WriteError($"Failed to parse euid '{args[0]}'."); return; } - var gridId = new GridId(targetId); - if (!mapManager.TryGetGrid(gridId, out var grid)) + if (!entMan.TryGetComponent(euid, out IMapGridComponent? gridComp)) { - shell.WriteError(Loc.GetString("shell-invalid-grid-id")); + shell.WriteError($"Euid '{euid}' does not exist or is not a grid."); return; } - foreach (var tile in grid.GetAllTiles()) + + foreach (var tile in gridComp.Grid.GetAllTiles()) { var def = tile.GetContentTileDefinition(); var newTile = new Tile(tile.Tile.TypeId, tile.Tile.Flags, random.Pick(def.PlacementVariants)); - grid.SetTile(tile.GridIndices, newTile); + gridComp.Grid.SetTile(tile.GridIndices, newTile); } } } diff --git a/Content.Server/Administration/Commands/WarpCommand.cs b/Content.Server/Administration/Commands/WarpCommand.cs index 11f62216a9..5d2d02725b 100644 --- a/Content.Server/Administration/Commands/WarpCommand.cs +++ b/Content.Server/Administration/Commands/WarpCommand.cs @@ -52,7 +52,7 @@ namespace Content.Server.Administration.Commands var mapManager = IoCManager.Resolve(); var currentMap = entMan.GetComponent(playerEntity).MapID; - var currentGrid = entMan.GetComponent(playerEntity).GridID; + var currentGrid = entMan.GetComponent(playerEntity).GridEntityId; var found = entMan.EntityQuery(true) .Where(p => p.Location == location) @@ -62,8 +62,8 @@ namespace Content.Server.Administration.Commands // Sort so that warp points on the same grid/map are first. // So if you have two maps loaded with the same warp points, // it will prefer the warp points on the map you're currently on. - var aGrid = a.GetGridId(entMan); - var bGrid = b.GetGridId(entMan); + var aGrid = a.GetGridEntityId(entMan); + var bGrid = b.GetGridEntityId(entMan); if (aGrid == bGrid) { @@ -80,8 +80,8 @@ namespace Content.Server.Administration.Commands return 1; } - var mapA = mapManager.GetGrid(aGrid).ParentMapId; - var mapB = mapManager.GetGrid(bGrid).ParentMapId; + var mapA = a.GetMapId(entMan); + var mapB = a.GetMapId(entMan); if (mapA == mapB) { @@ -102,7 +102,8 @@ namespace Content.Server.Administration.Commands })) .FirstOrDefault(); - if (found.GetGridId(entMan) != GridId.Invalid) + var entityUid = found.GetGridEntityId(entMan); + if (entityUid != EntityUid.Invalid) { entMan.GetComponent(playerEntity).Coordinates = found; if (entMan.TryGetComponent(playerEntity, out IPhysBody? physics)) diff --git a/Content.Server/Atmos/Commands/AddAtmosCommand.cs b/Content.Server/Atmos/Commands/AddAtmosCommand.cs index 3f28256fc5..6de7f53da8 100644 --- a/Content.Server/Atmos/Commands/AddAtmosCommand.cs +++ b/Content.Server/Atmos/Commands/AddAtmosCommand.cs @@ -1,8 +1,7 @@ -using Content.Server.Administration; +using Content.Server.Administration; using Content.Server.Atmos.Components; using Content.Shared.Administration; using Robust.Shared.Console; -using Robust.Shared.Map; namespace Content.Server.Atmos.Commands { @@ -23,37 +22,29 @@ namespace Content.Server.Atmos.Commands return; } - if (!int.TryParse(args[0], out var id)) + var entMan = IoCManager.Resolve(); + + if(EntityUid.TryParse(args[0], out var euid)) { - shell.WriteLine($"{args[0]} is not a valid integer."); + shell.WriteError($"Failed to parse euid '{args[0]}'."); return; } - var gridId = new GridId(id); - - var mapMan = IoCManager.Resolve(); - - if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp)) + if (!entMan.HasComponent(euid)) { - shell.WriteLine($"{gridId} is not a valid grid id."); + shell.WriteError($"Euid '{euid}' does not exist or is not a grid."); return; } - if (!_entities.EntityExists(gridComp.GridEntityId)) - { - shell.WriteLine("Failed to get grid entity."); - return; - } - - if (_entities.HasComponent(gridComp.GridEntityId)) + if (_entities.HasComponent(euid)) { shell.WriteLine("Grid already has an atmosphere."); return; } - _entities.AddComponent(gridComp.GridEntityId); + _entities.AddComponent(euid); - shell.WriteLine($"Added atmosphere to grid {id}."); + shell.WriteLine($"Added atmosphere to grid {euid}."); } } } diff --git a/Content.Server/Atmos/Commands/AddGasCommand.cs b/Content.Server/Atmos/Commands/AddGasCommand.cs index 2145ee342a..ed1c467ff0 100644 --- a/Content.Server/Atmos/Commands/AddGasCommand.cs +++ b/Content.Server/Atmos/Commands/AddGasCommand.cs @@ -1,4 +1,4 @@ -using Content.Server.Administration; +using Content.Server.Administration; using Content.Server.Atmos.EntitySystems; using Content.Shared.Administration; using Content.Shared.Atmos; @@ -12,22 +12,28 @@ namespace Content.Server.Atmos.Commands { public string Command => "addgas"; public string Description => "Adds gas at a certain position."; - public string Help => "addgas "; + public string Help => "addgas "; public void Execute(IConsoleShell shell, string argStr, string[] args) { if (args.Length < 5) return; + if(!int.TryParse(args[0], out var x) || !int.TryParse(args[1], out var y) - || !int.TryParse(args[2], out var id) + || !EntityUid.TryParse(args[2], out var euid) || !(AtmosCommandUtils.TryParseGasID(args[3], out var gasId)) || !float.TryParse(args[4], out var moles)) return; - var gridId = new GridId(id); + var entMan = IoCManager.Resolve(); + if (!entMan.HasComponent(euid)) + { + shell.WriteError($"Euid '{euid}' does not exist or is not a grid."); + return; + } var atmosphereSystem = EntitySystem.Get(); var indices = new Vector2i(x, y); - var tile = atmosphereSystem.GetTileMixture(gridId, indices, true); + var tile = atmosphereSystem.GetTileMixture(euid, indices, true); if (tile == null) { diff --git a/Content.Server/Atmos/Commands/AddUnsimulatedAtmosCommand.cs b/Content.Server/Atmos/Commands/AddUnsimulatedAtmosCommand.cs index 591a93988c..bae412a261 100644 --- a/Content.Server/Atmos/Commands/AddUnsimulatedAtmosCommand.cs +++ b/Content.Server/Atmos/Commands/AddUnsimulatedAtmosCommand.cs @@ -1,8 +1,7 @@ -using Content.Server.Administration; +using Content.Server.Administration; using Content.Server.Atmos.Components; using Content.Shared.Administration; using Robust.Shared.Console; -using Robust.Shared.Map; namespace Content.Server.Atmos.Commands { @@ -21,39 +20,29 @@ namespace Content.Server.Atmos.Commands return; } - if (!int.TryParse(args[0], out var id)) - { - shell.WriteLine($"{args[0]} is not a valid integer."); - return; - } - - var gridId = new GridId(id); - - var mapMan = IoCManager.Resolve(); - - if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp)) - { - shell.WriteLine($"{gridId} is not a valid grid id."); - return; - } - var entMan = IoCManager.Resolve(); - if (!entMan.EntityExists(gridComp.GridEntityId)) + if (EntityUid.TryParse(args[0], out var euid)) { - shell.WriteLine("Failed to get grid entity."); + shell.WriteError($"Failed to parse euid '{args[0]}'."); return; } - if (entMan.HasComponent(gridComp.GridEntityId)) + if (!entMan.HasComponent(euid)) + { + shell.WriteError($"Euid '{euid}' does not exist or is not a grid."); + return; + } + + if (entMan.HasComponent(euid)) { shell.WriteLine("Grid already has an atmosphere."); return; } - entMan.AddComponent(gridComp.GridEntityId); + entMan.AddComponent(euid); - shell.WriteLine($"Added unsimulated atmosphere to grid {id}."); + shell.WriteLine($"Added unsimulated atmosphere to grid {euid}."); } } diff --git a/Content.Server/Atmos/Commands/DeleteGasCommand.cs b/Content.Server/Atmos/Commands/DeleteGasCommand.cs index e32a57d137..4678a86fc6 100644 --- a/Content.Server/Atmos/Commands/DeleteGasCommand.cs +++ b/Content.Server/Atmos/Commands/DeleteGasCommand.cs @@ -18,7 +18,7 @@ namespace Content.Server.Atmos.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { var player = shell.Player as IPlayerSession; - GridId gridId; + EntityUid gridId; Gas? gas = null; var entMan = IoCManager.Resolve(); @@ -39,9 +39,9 @@ namespace Content.Server.Atmos.Commands return; } - gridId = entMan.GetComponent(playerEntity).GridID; + gridId = entMan.GetComponent(playerEntity).GridEntityId; - if (gridId == GridId.Invalid) + if (gridId == EntityUid.Invalid) { shell.WriteLine("You aren't on a grid to delete gas from."); return; @@ -51,7 +51,7 @@ namespace Content.Server.Atmos.Commands } case 1: { - if (!int.TryParse(args[0], out var number)) + if (!EntityUid.TryParse(args[0], out var number)) { // Argument is a gas if (player == null) @@ -66,9 +66,9 @@ namespace Content.Server.Atmos.Commands return; } - gridId = entMan.GetComponent(playerEntity).GridID; + gridId = entMan.GetComponent(playerEntity).GridEntityId; - if (gridId == GridId.Invalid) + if (gridId == EntityUid.Invalid) { shell.WriteLine("You aren't on a grid to delete gas from."); return; @@ -85,27 +85,20 @@ namespace Content.Server.Atmos.Commands } // Argument is a grid - gridId = new GridId(number); - - if (gridId == GridId.Invalid) - { - shell.WriteLine($"{gridId} is not a valid grid id."); - return; - } - + gridId = number; break; } case 2: { - if (!int.TryParse(args[0], out var first)) + if (!EntityUid.TryParse(args[0], out var first)) { shell.WriteLine($"{args[0]} is not a valid integer for a grid id."); return; } - gridId = new GridId(first); + gridId = first; - if (gridId == GridId.Invalid) + if (gridId == EntityUid.Invalid) { shell.WriteLine($"{gridId} is not a valid grid id."); return; diff --git a/Content.Server/Atmos/Commands/FillGasCommand.cs b/Content.Server/Atmos/Commands/FillGasCommand.cs index 7b1cfd8e6b..a1b98660f8 100644 --- a/Content.Server/Atmos/Commands/FillGasCommand.cs +++ b/Content.Server/Atmos/Commands/FillGasCommand.cs @@ -1,4 +1,4 @@ -using Content.Server.Administration; +using Content.Server.Administration; using Content.Server.Atmos.EntitySystems; using Content.Shared.Administration; using Content.Shared.Atmos; @@ -12,17 +12,15 @@ namespace Content.Server.Atmos.Commands { public string Command => "fillgas"; public string Description => "Adds gas to all tiles in a grid."; - public string Help => "fillgas "; + public string Help => "fillgas "; public void Execute(IConsoleShell shell, string argStr, string[] args) { if (args.Length < 3) return; - if(!int.TryParse(args[0], out var id) + if(!EntityUid.TryParse(args[0], out var gridId) || !(AtmosCommandUtils.TryParseGasID(args[1], out var gasId)) || !float.TryParse(args[2], out var moles)) return; - var gridId = new GridId(id); - var mapMan = IoCManager.Resolve(); if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out _)) diff --git a/Content.Server/Atmos/Commands/RemoveGasCommand.cs b/Content.Server/Atmos/Commands/RemoveGasCommand.cs index 879a2a4dcd..09c9af53d6 100644 --- a/Content.Server/Atmos/Commands/RemoveGasCommand.cs +++ b/Content.Server/Atmos/Commands/RemoveGasCommand.cs @@ -1,4 +1,4 @@ -using Content.Server.Administration; +using Content.Server.Administration; using Content.Server.Atmos.EntitySystems; using Content.Shared.Administration; using Robust.Shared.Console; @@ -18,15 +18,13 @@ namespace Content.Server.Atmos.Commands if (args.Length < 5) return; if(!int.TryParse(args[0], out var x) || !int.TryParse(args[1], out var y) - || !int.TryParse(args[2], out var id) + || !EntityUid.TryParse(args[2], out var id) || !float.TryParse(args[3], out var amount) || !bool.TryParse(args[4], out var ratio)) return; - var gridId = new GridId(id); - var atmosphereSystem = EntitySystem.Get(); var indices = new Vector2i(x, y); - var tile = atmosphereSystem.GetTileMixture(gridId, indices, true); + var tile = atmosphereSystem.GetTileMixture(id, indices, true); if (tile == null) { diff --git a/Content.Server/Atmos/Commands/SetAtmosTemperatureCommand.cs b/Content.Server/Atmos/Commands/SetAtmosTemperatureCommand.cs index 2f04547247..5e87f577f4 100644 --- a/Content.Server/Atmos/Commands/SetAtmosTemperatureCommand.cs +++ b/Content.Server/Atmos/Commands/SetAtmosTemperatureCommand.cs @@ -1,4 +1,4 @@ -using Content.Server.Administration; +using Content.Server.Administration; using Content.Server.Atmos.EntitySystems; using Content.Shared.Administration; using Content.Shared.Atmos; @@ -17,11 +17,9 @@ namespace Content.Server.Atmos.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { if (args.Length < 2) return; - if(!int.TryParse(args[0], out var id) + if(!EntityUid.TryParse(args[0], out var gridId) || !float.TryParse(args[1], out var temperature)) return; - var gridId = new GridId(id); - var mapMan = IoCManager.Resolve(); if (temperature < Atmospherics.TCMB) diff --git a/Content.Server/Atmos/Commands/SetTemperatureCommand.cs b/Content.Server/Atmos/Commands/SetTemperatureCommand.cs index 228556acfe..3367c80294 100644 --- a/Content.Server/Atmos/Commands/SetTemperatureCommand.cs +++ b/Content.Server/Atmos/Commands/SetTemperatureCommand.cs @@ -1,4 +1,4 @@ -using Content.Server.Administration; +using Content.Server.Administration; using Content.Server.Atmos.EntitySystems; using Content.Shared.Administration; using Content.Shared.Atmos; @@ -19,11 +19,9 @@ namespace Content.Server.Atmos.Commands if (args.Length < 4) return; if(!int.TryParse(args[0], out var x) || !int.TryParse(args[1], out var y) - || !int.TryParse(args[2], out var id) + || !EntityUid.TryParse(args[2], out var gridId) || !float.TryParse(args[3], out var temperature)) return; - var gridId = new GridId(id); - if (temperature < Atmospherics.TCMB) { shell.WriteLine("Invalid temperature."); diff --git a/Content.Server/Atmos/Components/AirtightComponent.cs b/Content.Server/Atmos/Components/AirtightComponent.cs index 309841b500..2060839481 100644 --- a/Content.Server/Atmos/Components/AirtightComponent.cs +++ b/Content.Server/Atmos/Components/AirtightComponent.cs @@ -7,7 +7,7 @@ namespace Content.Server.Atmos.Components [RegisterComponent] public sealed class AirtightComponent : Component { - public (GridId Grid, Vector2i Tile) LastPosition { get; set; } + public (EntityUid Grid, Vector2i Tile) LastPosition { get; set; } [DataField("airBlockedDirection", customTypeSerializer: typeof(FlagSerializer))] [ViewVariables] diff --git a/Content.Server/Atmos/EntitySystems/AirtightSystem.cs b/Content.Server/Atmos/EntitySystems/AirtightSystem.cs index 1ad44a2487..7fd0078416 100644 --- a/Content.Server/Atmos/EntitySystems/AirtightSystem.cs +++ b/Content.Server/Atmos/EntitySystems/AirtightSystem.cs @@ -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.GridID, out var grid)) + if (_mapManager.TryGetGrid(xform.GridEntityId, out var grid)) { if (MetaData(grid.GridEntityId).EntityLifeStage > EntityLifeStage.MapInitialized) return; } @@ -56,7 +56,7 @@ namespace Content.Server.Atmos.EntitySystems { var xform = Transform(uid); - var gridId = xform.GridID; + var gridId = xform.GridEntityId; var coords = xform.Coordinates; var grid = _mapManager.GetGrid(gridId); @@ -100,15 +100,15 @@ namespace Content.Server.Atmos.EntitySystems { if (!Resolve(airtight.Owner, ref xform)) return; - if (!xform.Anchored || !xform.GridID.IsValid()) + if (!xform.Anchored || !xform.GridEntityId.IsValid()) return; - var grid = _mapManager.GetGrid(xform.GridID); - airtight.LastPosition = (xform.GridID, grid.TileIndicesFor(xform.Coordinates)); + var grid = _mapManager.GetGrid(xform.GridEntityId); + airtight.LastPosition = (xform.GridEntityId, grid.TileIndicesFor(xform.Coordinates)); InvalidatePosition(airtight.LastPosition.Item1, airtight.LastPosition.Item2, airtight.FixVacuum && !airtight.AirBlocked); } - public void InvalidatePosition(GridId gridId, Vector2i pos, bool fixVacuum = false) + public void InvalidatePosition(EntityUid gridId, Vector2i pos, bool fixVacuum = false) { if (!gridId.IsValid()) return; diff --git a/Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs b/Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs index a0d8918398..db302b80b1 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs @@ -157,7 +157,7 @@ namespace Content.Server.Atmos.EntitySystems } } - RaiseNetworkEvent(new AtmosDebugOverlayMessage(grid.Index, baseTile, debugOverlayContent), session.ConnectedClient); + RaiseNetworkEvent(new AtmosDebugOverlayMessage(grid.GridEntityId, baseTile, debugOverlayContent), session.ConnectedClient); } } } diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Commands.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Commands.cs index 63a0b3efca..f176d352a1 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Commands.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Commands.cs @@ -57,26 +57,25 @@ public sealed partial class AtmosphereSystem mixtures[5].AdjustMoles(Gas.Plasma, Atmospherics.MolesCellGasMiner); mixtures[5].Temperature = 5000f; + var entMan = IoCManager.Resolve(); + foreach (var gid in args) { - // I like offering detailed error messages, that's why I don't use one of the extension methods. - if (!int.TryParse(gid, out var i) || i <= 0) + if(EntityUid.TryParse(gid, out var euid)) { - shell.WriteError($"Invalid grid ID \"{gid}\"."); - continue; + shell.WriteError($"Failed to parse euid '{gid}'."); + return; } - var gridId = new GridId(i); - - if (!_mapManager.TryGetGrid(gridId, out var mapGrid)) + if (!TryComp(euid, out IMapGridComponent? gridComp)) { - shell.WriteError($"Grid \"{i}\" doesn't exist."); - continue; + shell.WriteError($"Euid '{euid}' does not exist or is not a grid."); + return; } - if (!TryComp(mapGrid.GridEntityId, out GridAtmosphereComponent? gridAtmosphere)) + if (!TryComp(euid, out GridAtmosphereComponent? gridAtmosphere)) { - shell.WriteError($"Grid \"{i}\" has no atmosphere component, try addatmos."); + shell.WriteError($"Grid \"{euid}\" has no atmosphere component, try addatmos."); continue; } @@ -88,7 +87,7 @@ public sealed partial class AtmosphereSystem tile.Clear(); var mixtureId = 0; - foreach (var entUid in mapGrid.GetAnchoredEntities(indices)) + foreach (var entUid in gridComp.Grid.GetAnchoredEntities(indices)) { if (!TryComp(entUid, out AtmosFixMarkerComponent? afm)) continue; diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Grid.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Grid.cs index 26d4bcc0d8..0dc23e8a13 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Grid.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Grid.cs @@ -40,7 +40,7 @@ namespace Content.Server.Atmos.EntitySystems { try { - gridAtmosphere.Tiles.Add(indices, new TileAtmosphere(mapGrid.GridIndex, indices, (GasMixture) gridAtmosphere.UniqueMixes![mix].Clone())); + gridAtmosphere.Tiles.Add(indices, new TileAtmosphere(mapGrid.Owner, indices, (GasMixture) gridAtmosphere.UniqueMixes![mix].Clone())); } catch (ArgumentOutOfRangeException) { @@ -125,7 +125,7 @@ namespace Content.Server.Atmos.EntitySystems /// /// Grid to be checked. /// Whether the grid has a simulated atmosphere. - public bool IsSimulatedGrid(GridId grid) + public bool IsSimulatedGrid(EntityUid grid) { if (!_mapManager.TryGetGrid(grid, out var mapGrid)) return false; @@ -160,7 +160,7 @@ namespace Content.Server.Atmos.EntitySystems /// Grid where to get all tile mixtures from. /// Whether to invalidate all tiles. /// All tile mixtures in a grid. - public IEnumerable GetAllTileMixtures(GridId grid, bool invalidate = false) + public IEnumerable GetAllTileMixtures(EntityUid grid, bool invalidate = false) { // Return an array with a single space gas mixture for invalid grids. if (!grid.IsValid()) @@ -207,7 +207,7 @@ namespace Content.Server.Atmos.EntitySystems /// The grid in question. /// The amount of tiles. /// The volume in liters that the tiles occupy. - public float GetVolumeForTiles(GridId grid, int tiles = 1) + public float GetVolumeForTiles(EntityUid grid, int tiles = 1) { if (!_mapManager.TryGetGrid(grid, out var mapGrid)) return Atmospherics.CellVolume * tiles; @@ -289,7 +289,7 @@ namespace Content.Server.Atmos.EntitySystems foreach (var tile in mapGrid.GetAllTiles()) { if(!gridAtmosphere.Tiles.ContainsKey(tile.GridIndices)) - gridAtmosphere.Tiles[tile.GridIndices] = new TileAtmosphere(tile.GridIndex, tile.GridIndices, new GasMixture(volume){Temperature = Atmospherics.T20C}); + gridAtmosphere.Tiles[tile.GridIndices] = new TileAtmosphere(tile.GridUid, tile.GridIndices, new GasMixture(volume){Temperature = Atmospherics.T20C}); InvalidateTile(gridAtmosphere, tile.GridIndices); } @@ -297,7 +297,7 @@ namespace Content.Server.Atmos.EntitySystems foreach (var (position, tile) in gridAtmosphere.Tiles.ToArray()) { UpdateAdjacent(mapGrid, gridAtmosphere, tile); - InvalidateVisuals(mapGrid.Index, position); + InvalidateVisuals(mapGrid.GridEntityId, position); } } @@ -337,7 +337,7 @@ namespace Content.Server.Atmos.EntitySystems /// /// Grid where to invalidate the tile. /// The indices of the tile. - public void InvalidateTile(GridId grid, Vector2i tile) + public void InvalidateTile(EntityUid grid, Vector2i tile) { if (!_mapManager.TryGetGrid(grid, out var mapGrid)) return; @@ -371,7 +371,7 @@ namespace Content.Server.Atmos.EntitySystems } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void InvalidateVisuals(GridId grid, Vector2i tile) + public void InvalidateVisuals(EntityUid grid, Vector2i tile) { _gasTileOverlaySystem.Invalidate(grid, tile); } @@ -401,7 +401,7 @@ namespace Content.Server.Atmos.EntitySystems /// Indices of the tile. /// Do NOT use this outside of atmos internals. /// The Tile Atmosphere in the position, or null. - public TileAtmosphere? GetTileAtmosphere(GridId grid, Vector2i tile) + public TileAtmosphere? GetTileAtmosphere(EntityUid grid, Vector2i tile) { if (!_mapManager.TryGetGrid(grid, out var mapGrid)) return null; @@ -450,7 +450,7 @@ namespace Content.Server.Atmos.EntitySystems /// Indices of the tile. /// Do NOT use this outside of atmos internals. /// The tile atmosphere of a specific position in a grid, a space tile atmosphere if the tile is space or null if the grid doesn't exist. - public TileAtmosphere? GetTileAtmosphereOrCreateSpace(GridId grid, Vector2i tile) + public TileAtmosphere? GetTileAtmosphereOrCreateSpace(EntityUid grid, Vector2i tile) { if (!_mapManager.TryGetGrid(grid, out var mapGrid)) return null; @@ -480,7 +480,7 @@ namespace Content.Server.Atmos.EntitySystems // attempts to get the tile atmosphere for it before it has been revalidated by atmos. // The tile atmosphere will get revalidated on the next atmos tick, however. - return tileAtmosphere ?? new TileAtmosphere(mapGrid.Index, tile, new GasMixture(Atmospherics.CellVolume) {Temperature = Atmospherics.TCMB}, true); + return tileAtmosphere ?? new TileAtmosphere(mapGrid.GridEntityId, tile, new GasMixture(Atmospherics.CellVolume) {Temperature = Atmospherics.TCMB}, true); } #endregion @@ -502,7 +502,7 @@ namespace Content.Server.Atmos.EntitySystems /// /// Grid where to get the tile. /// Indices of the tile to be activated. - public void AddActiveTile(GridId grid, Vector2i tile) + public void AddActiveTile(EntityUid grid, Vector2i tile) { if (!_mapManager.TryGetGrid(grid, out var mapGrid)) return; @@ -563,7 +563,7 @@ namespace Content.Server.Atmos.EntitySystems /// Grid where to get the tile. /// Indices of the tile to be deactivated. /// Whether to dispose of the tile's - public void RemoveActiveTile(GridId grid, Vector2i tile, bool disposeExcitedGroup = true) + public void RemoveActiveTile(EntityUid grid, Vector2i tile, bool disposeExcitedGroup = true) { if (!_mapManager.TryGetGrid(grid, out var mapGrid)) return; @@ -632,7 +632,7 @@ namespace Content.Server.Atmos.EntitySystems /// Indices of the tile. /// Whether to invalidate the tile. /// The tile mixture, or null - public GasMixture? GetTileMixture(GridId grid, Vector2i tile, bool invalidate = false) + public GasMixture? GetTileMixture(EntityUid grid, Vector2i tile, bool invalidate = false) { // Always return space gas mixtures for invalid grids (grid 0) if (!grid.IsValid()) @@ -699,7 +699,7 @@ namespace Content.Server.Atmos.EntitySystems /// Grid where to get the tile. /// Indices of the tile. /// Reaction results. - public ReactionResult React(GridId grid, Vector2i tile) + public ReactionResult React(EntityUid grid, Vector2i tile) { if (!_mapManager.TryGetGrid(grid, out var mapGrid)) return ReactionResult.NoReaction; @@ -755,7 +755,7 @@ namespace Content.Server.Atmos.EntitySystems /// Indices of the tile. /// Directions to check. /// Whether the tile is blocked in the directions specified. - public bool IsTileAirBlocked(GridId grid, Vector2i tile, AtmosDirection direction = AtmosDirection.All) + public bool IsTileAirBlocked(EntityUid grid, Vector2i tile, AtmosDirection direction = AtmosDirection.All) { if (!_mapManager.TryGetGrid(grid, out var mapGrid)) return false; @@ -816,7 +816,7 @@ namespace Content.Server.Atmos.EntitySystems /// Grid where to check the tile. /// Indices of the tile. /// Whether the tile is space or not. - public bool IsTileSpace(GridId grid, Vector2i tile) + public bool IsTileSpace(EntityUid grid, Vector2i tile) { return !_mapManager.TryGetGrid(grid, out var mapGrid) || IsTileSpace(mapGrid, tile); } @@ -847,7 +847,7 @@ namespace Content.Server.Atmos.EntitySystems /// /// Get a tile's heat capacity, based on the tile type, tile contents and tile gas mixture. /// - public float GetTileHeatCapacity(GridId grid, Vector2i tile) + public float GetTileHeatCapacity(EntityUid grid, Vector2i tile) { // Always return space gas mixtures for invalid grids (grid 0) if (!grid.IsValid()) @@ -913,7 +913,7 @@ namespace Content.Server.Atmos.EntitySystems /// Indices of the tile. /// Whether to include tiles in directions the tile is air-blocked in. /// The positions adjacent to the tile. - public IEnumerable GetAdjacentTiles(GridId grid, Vector2i tile, bool includeBlocked = false) + public IEnumerable GetAdjacentTiles(EntityUid grid, Vector2i tile, bool includeBlocked = false) { if (!_mapManager.TryGetGrid(grid, out var mapGrid)) return Enumerable.Empty(); @@ -986,7 +986,7 @@ namespace Content.Server.Atmos.EntitySystems /// Whether to include tiles in directions the tile is air-blocked in. /// Whether to invalidate all adjacent tiles. /// All adjacent tile gas mixtures to the tile in question - public IEnumerable GetAdjacentTileMixtures(GridId grid, Vector2i tile, bool includeBlocked = false, bool invalidate = false) + public IEnumerable GetAdjacentTileMixtures(EntityUid grid, Vector2i tile, bool includeBlocked = false, bool invalidate = false) { // For invalid grids, return an array with a single space gas mixture in it. if (!grid.IsValid()) @@ -1073,7 +1073,7 @@ namespace Content.Server.Atmos.EntitySystems /// /// Grid where to get the tile. /// Indices of the tile. - public void UpdateAdjacent(GridId grid, Vector2i tile) + public void UpdateAdjacent(EntityUid grid, Vector2i tile) { if (!_mapManager.TryGetGrid(grid, out var mapGrid)) return; @@ -1149,7 +1149,7 @@ namespace Content.Server.Atmos.EntitySystems /// Grid where to get the tile. /// Indices of the tile. /// Direction to be updated. - public void UpdateAdjacent(GridId grid, Vector2i tile, AtmosDirection direction) + public void UpdateAdjacent(EntityUid grid, Vector2i tile, AtmosDirection direction) { if (!_mapManager.TryGetGrid(grid, out var mapGrid)) return; @@ -1227,7 +1227,7 @@ namespace Content.Server.Atmos.EntitySystems /// Temperature to expose to the tile. /// Volume of the exposed temperature. /// If true, the existing hotspot values will be set to the exposed values, but only if they're smaller. - public void HotspotExpose(GridId grid, Vector2i tile, float exposedTemperature, float exposedVolume, bool soh = false) + public void HotspotExpose(EntityUid grid, Vector2i tile, float exposedTemperature, float exposedVolume, bool soh = false) { if (!_mapManager.TryGetGrid(grid, out var mapGrid)) return; @@ -1264,7 +1264,7 @@ namespace Content.Server.Atmos.EntitySystems /// /// Grid where to get the tile. /// Indices of the tile. - public void HotspotExtinguish(GridId grid, Vector2i tile) + public void HotspotExtinguish(EntityUid grid, Vector2i tile) { if (!_mapManager.TryGetGrid(grid, out var mapGrid)) return; @@ -1313,7 +1313,7 @@ namespace Content.Server.Atmos.EntitySystems /// Grid where to get the tile /// Indices for the tile /// Whether the hotspot is active or not. - public bool IsHotspotActive(GridId grid, Vector2i tile) + public bool IsHotspotActive(EntityUid grid, Vector2i tile) { 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(atmosDevice.Owner).GridID; + var grid = Comp(atmosDevice.Owner).GridEntityId; if (!_mapManager.TryGetGrid(grid, out var mapGrid)) return false; @@ -1438,7 +1438,7 @@ namespace Content.Server.Atmos.EntitySystems /// Grid where to get the tile. /// Indices of the tile. /// Whether the tile's gas mixture is probably safe. - public bool IsTileMixtureProbablySafe(GridId grid, Vector2i tile) + public bool IsTileMixtureProbablySafe(EntityUid grid, Vector2i tile) { return IsMixtureProbablySafe(GetTileMixture(grid, tile)); } @@ -1491,7 +1491,7 @@ namespace Content.Server.Atmos.EntitySystems /// /// Grid where to get the tile. /// Indices of the tile. - public void FixVacuum(GridId grid, Vector2i tile) + public void FixVacuum(EntityUid grid, Vector2i tile) { if (!_mapManager.TryGetGrid(grid, out var mapGrid)) return; @@ -1558,7 +1558,7 @@ namespace Content.Server.Atmos.EntitySystems return tile.GridIndices.GetTileRef(tile.GridIndex, _mapManager); } - public bool TryGetGridAndTile(MapCoordinates coordinates, [NotNullWhen(true)] out (GridId Grid, Vector2i Tile)? tuple) + public bool TryGetGridAndTile(MapCoordinates coordinates, [NotNullWhen(true)] out (EntityUid Grid, Vector2i Tile)? tuple) { if (!_mapManager.TryFindGridAt(coordinates, out var grid)) { @@ -1566,11 +1566,11 @@ namespace Content.Server.Atmos.EntitySystems return false; } - tuple = (grid.Index, grid.TileIndicesFor(coordinates)); + tuple = (grid.GridEntityId, grid.TileIndicesFor(coordinates)); return true; } - public bool TryGetGridAndTile(EntityCoordinates coordinates, [NotNullWhen(true)] out (GridId Grid, Vector2i Tile)? tuple) + public bool TryGetGridAndTile(EntityCoordinates coordinates, [NotNullWhen(true)] out (EntityUid Grid, Vector2i Tile)? tuple) { if (!coordinates.IsValid(EntityManager)) { @@ -1578,7 +1578,7 @@ namespace Content.Server.Atmos.EntitySystems return false; } - var gridId = coordinates.GetGridId(EntityManager); + var gridId = coordinates.GetGridEntityId(EntityManager); if (!_mapManager.TryGetGrid(gridId, out var grid)) { diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Processing.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Processing.cs index 4c74ff98be..b2dba53c6f 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Processing.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Processing.cs @@ -54,7 +54,7 @@ namespace Content.Server.Atmos.EntitySystems if (tile == null) { - tile = new TileAtmosphere(mapGrid.Index, indices, new GasMixture(volume){Temperature = Atmospherics.T20C}); + tile = new TileAtmosphere(mapGrid.GridEntityId, indices, new GasMixture(volume){Temperature = Atmospherics.T20C}); atmosphere.Tiles[indices] = tile; } @@ -110,7 +110,7 @@ namespace Content.Server.Atmos.EntitySystems var tileDef = GetTile(tile)?.Tile.GetContentTileDefinition(_tileDefinitionManager); tile.ThermalConductivity = tileDef?.ThermalConductivity ?? 0.5f; tile.HeatCapacity = tileDef?.HeatCapacity ?? float.PositiveInfinity; - InvalidateVisuals(mapGrid.Index, indices); + InvalidateVisuals(mapGrid.GridEntityId, indices); for (var i = 0; i < Atmospherics.Directions; i++) { diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.cs index 5babbd230f..a775ca049b 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.cs @@ -58,7 +58,7 @@ namespace Content.Server.Atmos.EntitySystems return; } - InvalidateTile(ev.NewTile.GridIndex, ev.NewTile.GridIndices); + InvalidateTile(ev.NewTile.GridUid, ev.NewTile.GridIndices); } public override void Update(float frameTime) diff --git a/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs b/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs index ad49c13d6e..58a30c2417 100644 --- a/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs +++ b/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs @@ -29,7 +29,7 @@ namespace Content.Server.Atmos.EntitySystems /// /// The tiles that have had their atmos data updated since last tick /// - private readonly Dictionary> _invalidTiles = new(); + private readonly Dictionary> _invalidTiles = new(); private readonly Dictionary _knownPlayerChunks = new(); @@ -37,7 +37,7 @@ namespace Content.Server.Atmos.EntitySystems /// /// Gas data stored in chunks to make PVS / bubbling easier. /// - private readonly Dictionary> _overlay = + private readonly Dictionary> _overlay = new(); /// @@ -77,7 +77,7 @@ namespace Content.Server.Atmos.EntitySystems } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Invalidate(GridId gridIndex, Vector2i indices) + public void Invalidate(EntityUid gridIndex, Vector2i indices) { if (!_invalidTiles.TryGetValue(gridIndex, out var existing)) { @@ -88,7 +88,7 @@ namespace Content.Server.Atmos.EntitySystems existing.Add(indices); } - private GasOverlayChunk GetOrCreateChunk(GridId gridIndex, Vector2i indices) + private GasOverlayChunk GetOrCreateChunk(EntityUid gridIndex, Vector2i indices) { if (!_overlay.TryGetValue(gridIndex, out var chunks)) { @@ -204,7 +204,7 @@ namespace Content.Server.Atmos.EntitySystems foreach (var grid in _mapManager.FindGridsIntersecting(xform.MapID, worldBounds)) { - if (!_overlay.TryGetValue(grid.Index, out var chunks)) + if (!_overlay.TryGetValue(grid.GridEntityId, out var chunks)) { continue; } @@ -256,7 +256,7 @@ namespace Content.Server.Atmos.EntitySystems AccumulatedFrameTime -= _updateCooldown; - var gridAtmosComponents = new Dictionary(); + var gridAtmosComponents = new Dictionary(); var updatedTiles = new Dictionary>(); // So up to this point we've been caching the updated tiles for multiple ticks. @@ -351,7 +351,7 @@ namespace Content.Server.Atmos.EntitySystems overlay.RemoveChunk(chunk); } - var clientInvalids = new Dictionary>(); + var clientInvalids = new Dictionary>(); // Check for any dirty chunks in range and bundle the data to send to the client. foreach (var chunk in chunksInRange) @@ -378,13 +378,13 @@ namespace Content.Server.Atmos.EntitySystems } private sealed class PlayerGasOverlay { - private readonly Dictionary> _data = + private readonly Dictionary> _data = new(); private readonly Dictionary _lastSent = new(); - public GasOverlayMessage UpdateClient(GridId grid, List<(Vector2i, GasOverlayData)> data) + public GasOverlayMessage UpdateClient(EntityUid grid, List<(Vector2i, GasOverlayData)> data) { return new(grid, data); } diff --git a/Content.Server/Atmos/Piping/Components/AtmosDeviceComponent.cs b/Content.Server/Atmos/Piping/Components/AtmosDeviceComponent.cs index 1ba2ac0f87..5988245918 100644 --- a/Content.Server/Atmos/Piping/Components/AtmosDeviceComponent.cs +++ b/Content.Server/Atmos/Piping/Components/AtmosDeviceComponent.cs @@ -32,7 +32,7 @@ namespace Content.Server.Atmos.Piping.Components [ViewVariables] public TimeSpan LastProcess { get; set; } = TimeSpan.Zero; - public GridId? JoinedGrid { get; set; } + public EntityUid? JoinedGrid { get; set; } } public sealed class AtmosDeviceUpdateEvent : EntityEventArgs diff --git a/Content.Server/Atmos/Piping/EntitySystems/AtmosPipeAppearanceSystem.cs b/Content.Server/Atmos/Piping/EntitySystems/AtmosPipeAppearanceSystem.cs index 7ac264c618..0bcce94996 100644 --- a/Content.Server/Atmos/Piping/EntitySystems/AtmosPipeAppearanceSystem.cs +++ b/Content.Server/Atmos/Piping/EntitySystems/AtmosPipeAppearanceSystem.cs @@ -29,7 +29,7 @@ public sealed class AtmosPipeAppearanceSystem : EntitySystem if (!Resolve(uid, ref appearance, ref container, ref xform, false)) return; - if (!_mapManager.TryGetGrid(xform.GridID, out var grid)) + if (!_mapManager.TryGetGrid(xform.GridEntityId, out var grid)) return; // get connected entities diff --git a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasPortableSystem.cs b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasPortableSystem.cs index ced6be494b..d2e45051b8 100644 --- a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasPortableSystem.cs +++ b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasPortableSystem.cs @@ -30,7 +30,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems return; // If we can't find any ports, cancel the anchoring. - if(!FindGasPortIn(transform.GridID, transform.Coordinates, out _)) + if(!FindGasPortIn(transform.GridEntityId, transform.Coordinates, out _)) args.Cancel(); } @@ -50,7 +50,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems } } - private bool FindGasPortIn(GridId gridId, EntityCoordinates coordinates, [NotNullWhen(true)] out GasPortComponent? port) + private bool FindGasPortIn(EntityUid gridId, EntityCoordinates coordinates, [NotNullWhen(true)] out GasPortComponent? port) { port = null; diff --git a/Content.Server/Atmos/TileAtmosphere.cs b/Content.Server/Atmos/TileAtmosphere.cs index 17e09570d7..21cec7f262 100644 --- a/Content.Server/Atmos/TileAtmosphere.cs +++ b/Content.Server/Atmos/TileAtmosphere.cs @@ -62,7 +62,7 @@ namespace Content.Server.Atmos public AtmosDirection LastPressureDirection; [ViewVariables] - public GridId GridIndex { get; } + public EntityUid GridIndex { get; } [ViewVariables] public TileRef? Tile => GridIndices.GetTileRef(GridIndex); @@ -93,7 +93,7 @@ namespace Content.Server.Atmos [ViewVariables] public AtmosDirection BlockedAirflow { get; set; } = AtmosDirection.Invalid; - public TileAtmosphere(GridId gridIndex, Vector2i gridIndices, GasMixture? mixture = null, bool immutable = false) + public TileAtmosphere(EntityUid gridIndex, Vector2i gridIndices, GasMixture? mixture = null, bool immutable = false) { GridIndex = gridIndex; GridIndices = gridIndices; diff --git a/Content.Server/Chemistry/Components/SolutionAreaEffectComponent.cs b/Content.Server/Chemistry/Components/SolutionAreaEffectComponent.cs index 27c07fec6d..7fd670a2b0 100644 --- a/Content.Server/Chemistry/Components/SolutionAreaEffectComponent.cs +++ b/Content.Server/Chemistry/Components/SolutionAreaEffectComponent.cs @@ -69,7 +69,7 @@ namespace Content.Server.Chemistry.Components var xform = _entities.GetComponent(Owner); var solSys = _systems.GetEntitySystem(); - var grid = MapManager.GetGrid(xform.GridID); + var grid = MapManager.GetGrid(xform.GridEntityId); var origin = grid.TileIndicesFor(xform.Coordinates); DebugTools.Assert(xform.Anchored, "Area effect entity prototypes must be anchored."); @@ -146,7 +146,7 @@ namespace Content.Server.Chemistry.Components var chemistry = EntitySystem.Get(); var xform = _entities.GetComponent(Owner); - var mapGrid = MapManager.GetGrid(xform.GridID); + var mapGrid = MapManager.GetGrid(xform.GridEntityId); var tile = mapGrid.GetTileRef(xform.Coordinates.ToVector2i(_entities, MapManager)); var lookup = EntitySystem.Get(); diff --git a/Content.Server/Chemistry/EntitySystems/VaporSystem.cs b/Content.Server/Chemistry/EntitySystems/VaporSystem.cs index 587bec991d..f4faec5764 100644 --- a/Content.Server/Chemistry/EntitySystems/VaporSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/VaporSystem.cs @@ -1,4 +1,4 @@ -using Content.Server.Chemistry.Components; +using Content.Server.Chemistry.Components; using Content.Server.Chemistry.Components.SolutionManager; using Content.Shared.Chemistry.Components; using Content.Shared.Chemistry.Reagent; @@ -94,10 +94,10 @@ namespace Content.Server.Chemistry.EntitySystems vapor.Timer += frameTime; vapor.ReactTimer += frameTime; - if (vapor.ReactTimer >= ReactTime && EntityManager.GetComponent(vapor.Owner).GridID.IsValid()) + if (vapor.ReactTimer >= ReactTime && EntityManager.GetComponent(vapor.Owner).GridEntityId.IsValid()) { vapor.ReactTimer = 0; - var mapGrid = _mapManager.GetGrid(EntityManager.GetComponent(entity).GridID); + var mapGrid = _mapManager.GetGrid(EntityManager.GetComponent(entity).GridEntityId); var tile = mapGrid.GetTileRef(EntityManager.GetComponent(entity).Coordinates.ToVector2i(EntityManager, _mapManager)); foreach (var reagentQuantity in contents.Contents.ToArray()) diff --git a/Content.Server/Chemistry/TileReactions/CleanTileReaction.cs b/Content.Server/Chemistry/TileReactions/CleanTileReaction.cs index 9c0bfe8b96..bf3ab310ad 100644 --- a/Content.Server/Chemistry/TileReactions/CleanTileReaction.cs +++ b/Content.Server/Chemistry/TileReactions/CleanTileReaction.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using Content.Server.Cleanable; using Content.Server.Decals; using Content.Shared.Chemistry.Reaction; @@ -39,9 +39,9 @@ namespace Content.Server.Chemistry.TileReactions } var decalSystem = EntitySystem.Get(); - foreach (var (uid, _) in decalSystem.GetDecalsInRange(tile.GridIndex, tile.GridIndices+new Vector2(0.5f, 0.5f), validDelegate: x => x.Cleanable)) + foreach (var (uid, _) in decalSystem.GetDecalsInRange(tile.GridUid, tile.GridIndices+new Vector2(0.5f, 0.5f), validDelegate: x => x.Cleanable)) { - decalSystem.RemoveDecal(tile.GridIndex, uid); + decalSystem.RemoveDecal(tile.GridUid, uid); } return amount; diff --git a/Content.Server/Chemistry/TileReactions/ExtinguishTileReaction.cs b/Content.Server/Chemistry/TileReactions/ExtinguishTileReaction.cs index c9a27a951d..e3274a098e 100644 --- a/Content.Server/Chemistry/TileReactions/ExtinguishTileReaction.cs +++ b/Content.Server/Chemistry/TileReactions/ExtinguishTileReaction.cs @@ -1,4 +1,4 @@ -using Content.Server.Atmos.EntitySystems; +using Content.Server.Atmos.EntitySystems; using Content.Shared.Atmos; using Content.Shared.Chemistry.Reaction; using Content.Shared.Chemistry.Reagent; @@ -21,17 +21,17 @@ namespace Content.Server.Chemistry.TileReactions var atmosphereSystem = EntitySystem.Get(); - var environment = atmosphereSystem.GetTileMixture(tile.GridIndex, tile.GridIndices, true); + var environment = atmosphereSystem.GetTileMixture(tile.GridUid, tile.GridIndices, true); - if (environment == null || !atmosphereSystem.IsHotspotActive(tile.GridIndex, tile.GridIndices)) + if (environment == null || !atmosphereSystem.IsHotspotActive(tile.GridUid, tile.GridIndices)) return FixedPoint2.Zero; environment.Temperature = MathF.Max(MathF.Min(environment.Temperature - (_coolingTemperature * 1000f), environment.Temperature / _coolingTemperature), Atmospherics.TCMB); - atmosphereSystem.React(tile.GridIndex, tile.GridIndices); - atmosphereSystem.HotspotExtinguish(tile.GridIndex, tile.GridIndices); + atmosphereSystem.React(tile.GridUid, tile.GridIndices); + atmosphereSystem.HotspotExtinguish(tile.GridUid, tile.GridIndices); return FixedPoint2.Zero; } diff --git a/Content.Server/Chemistry/TileReactions/FlammableTileReaction.cs b/Content.Server/Chemistry/TileReactions/FlammableTileReaction.cs index f6aa74a13a..753321aa30 100644 --- a/Content.Server/Chemistry/TileReactions/FlammableTileReaction.cs +++ b/Content.Server/Chemistry/TileReactions/FlammableTileReaction.cs @@ -1,4 +1,4 @@ -using Content.Server.Atmos.EntitySystems; +using Content.Server.Atmos.EntitySystems; using Content.Shared.Chemistry.Reaction; using Content.Shared.Chemistry.Reagent; using Content.Shared.FixedPoint; @@ -20,12 +20,12 @@ namespace Content.Server.Chemistry.TileReactions var atmosphereSystem = EntitySystem.Get(); - var environment = atmosphereSystem.GetTileMixture(tile.GridIndex, tile.GridIndices, true); - if (environment == null || !atmosphereSystem.IsHotspotActive(tile.GridIndex, tile.GridIndices)) + var environment = atmosphereSystem.GetTileMixture(tile.GridUid, tile.GridIndices, true); + if (environment == null || !atmosphereSystem.IsHotspotActive(tile.GridUid, tile.GridIndices)) return FixedPoint2.Zero; environment.Temperature *= MathF.Max(_temperatureMultiplier * reactVolume.Float(), 1f); - atmosphereSystem.React(tile.GridIndex, tile.GridIndices); + atmosphereSystem.React(tile.GridUid, tile.GridIndices); return reactVolume; } diff --git a/Content.Server/Construction/Commands/FixRotationsCommand.cs b/Content.Server/Construction/Commands/FixRotationsCommand.cs index 2c14943e66..dceda7d23a 100644 --- a/Content.Server/Construction/Commands/FixRotationsCommand.cs +++ b/Content.Server/Construction/Commands/FixRotationsCommand.cs @@ -21,7 +21,7 @@ namespace Content.Server.Construction.Commands { var player = shell.Player as IPlayerSession; var entityManager = IoCManager.Resolve(); - GridId gridId; + EntityUid gridId; var xformQuery = entityManager.GetEntityQuery(); switch (args.Length) @@ -33,16 +33,16 @@ namespace Content.Server.Construction.Commands return; } - gridId = xformQuery.GetComponent(playerEntity).GridID; + gridId = xformQuery.GetComponent(playerEntity).GridEntityId; break; case 1: - if (!int.TryParse(args[0], out var id)) + if (!EntityUid.TryParse(args[0], out var id)) { - shell.WriteError($"{args[0]} is not a valid integer."); + shell.WriteError($"{args[0]} is not a valid entity."); return; } - gridId = new GridId(id); + gridId = id; break; default: shell.WriteLine(Help); diff --git a/Content.Server/Construction/Commands/TileReplaceCommand.cs b/Content.Server/Construction/Commands/TileReplaceCommand.cs index 8a3ec6ca74..6995475fc4 100644 --- a/Content.Server/Construction/Commands/TileReplaceCommand.cs +++ b/Content.Server/Construction/Commands/TileReplaceCommand.cs @@ -21,7 +21,7 @@ sealed class TileReplaceCommand : IConsoleCommand { var player = shell.Player as IPlayerSession; var entityManager = IoCManager.Resolve(); - GridId gridId; + EntityUid gridId; string tileIdA = ""; string tileIdB = ""; @@ -34,18 +34,18 @@ sealed class TileReplaceCommand : IConsoleCommand return; } - gridId = entityManager.GetComponent(playerEntity).GridID; + gridId = entityManager.GetComponent(playerEntity).GridEntityId; tileIdA = args[0]; tileIdB = args[1]; break; case 3: - if (!int.TryParse(args[0], out var id)) + if (!EntityUid.TryParse(args[0], out var id)) { - shell.WriteLine($"{args[0]} is not a valid integer."); + shell.WriteLine($"{args[0]} is not a valid entity."); return; } - gridId = new GridId(id); + gridId = id; tileIdA = args[1]; tileIdB = args[2]; break; diff --git a/Content.Server/Construction/Commands/TileWallsCommand.cs b/Content.Server/Construction/Commands/TileWallsCommand.cs index 7f8ae1f610..57a23aa569 100644 --- a/Content.Server/Construction/Commands/TileWallsCommand.cs +++ b/Content.Server/Construction/Commands/TileWallsCommand.cs @@ -24,7 +24,7 @@ namespace Content.Server.Construction.Commands { var player = shell.Player as IPlayerSession; var entityManager = IoCManager.Resolve(); - GridId gridId; + EntityUid gridId; switch (args.Length) { @@ -35,16 +35,16 @@ namespace Content.Server.Construction.Commands return; } - gridId = entityManager.GetComponent(playerEntity).GridID; + gridId = entityManager.GetComponent(playerEntity).GridEntityId; break; case 1: - if (!int.TryParse(args[0], out var id)) + if (!EntityUid.TryParse(args[0], out var id)) { - shell.WriteLine($"{args[0]} is not a valid integer."); + shell.WriteLine($"{args[0]} is not a valid entity."); return; } - gridId = new GridId(id); + gridId = id; break; default: shell.WriteLine(Help); diff --git a/Content.Server/Construction/Conditions/ComponentInTile.cs b/Content.Server/Construction/Conditions/ComponentInTile.cs index 9260abc327..3b4010f69f 100644 --- a/Content.Server/Construction/Conditions/ComponentInTile.cs +++ b/Content.Server/Construction/Conditions/ComponentInTile.cs @@ -1,4 +1,4 @@ -using Content.Shared.Construction; +using Content.Shared.Construction; using Content.Shared.Examine; using Content.Shared.Maps; using JetBrains.Annotations; @@ -44,7 +44,7 @@ namespace Content.Server.Construction.Conditions var transform = entityManager.GetComponent(uid); var indices = transform.Coordinates.ToVector2i(entityManager, IoCManager.Resolve()); - var entities = indices.GetEntitiesInTile(transform.GridID, LookupFlags.Approximate | LookupFlags.Anchored, EntitySystem.Get()); + var entities = indices.GetEntitiesInTile(transform.GridEntityId, LookupFlags.Approximate | LookupFlags.Anchored, EntitySystem.Get()); foreach (var ent in entities) { diff --git a/Content.Server/Coordinates/Helpers/SnapgridHelper.cs b/Content.Server/Coordinates/Helpers/SnapgridHelper.cs index 7790794d9f..520af9ba20 100644 --- a/Content.Server/Coordinates/Helpers/SnapgridHelper.cs +++ b/Content.Server/Coordinates/Helpers/SnapgridHelper.cs @@ -15,7 +15,7 @@ namespace Content.Server.Coordinates.Helpers { IoCManager.Resolve(ref entMan, ref mapManager); - var gridId = coordinates.GetGridId(entMan); + var gridId = coordinates.GetGridEntityId(entMan); var tileSize = 1f; diff --git a/Content.Server/Decals/Commands/AddDecalCommand.cs b/Content.Server/Decals/Commands/AddDecalCommand.cs index ecc63bb322..9ed0e43327 100644 --- a/Content.Server/Decals/Commands/AddDecalCommand.cs +++ b/Content.Server/Decals/Commands/AddDecalCommand.cs @@ -40,7 +40,7 @@ namespace Content.Server.Decals.Commands } var mapManager = IoCManager.Resolve(); - if (!int.TryParse(args[3], out var gridIdRaw) || !mapManager.TryGetGrid(new GridId(gridIdRaw), out var grid)) + if (!EntityUid.TryParse(args[3], out var gridIdRaw) || !mapManager.TryGetGrid(gridIdRaw, out var grid)) { shell.WriteError($"Failed parsing gridId '{args[3]}'."); return; diff --git a/Content.Server/Decals/Commands/EditDecalCommand.cs b/Content.Server/Decals/Commands/EditDecalCommand.cs index a9e6f2498d..934443672b 100644 --- a/Content.Server/Decals/Commands/EditDecalCommand.cs +++ b/Content.Server/Decals/Commands/EditDecalCommand.cs @@ -1,4 +1,4 @@ -using Content.Server.Administration; +using Content.Server.Administration; using Content.Shared.Administration; using Robust.Shared.Console; using Robust.Shared.Map; @@ -27,7 +27,7 @@ Possible modes are:\n return; } - if (!int.TryParse(args[0], out var gridIdRaw)) + if (!EntityUid.TryParse(args[0], out var gridId)) { shell.WriteError($"Failed parsing gridId '{args[3]}'."); return; @@ -39,7 +39,6 @@ Possible modes are:\n return; } - var gridId = new GridId(gridIdRaw); if (!IoCManager.Resolve().GridExists(gridId)) { shell.WriteError($"No grid with gridId {gridId} exists."); diff --git a/Content.Server/Decals/Commands/RemoveDecalCommand.cs b/Content.Server/Decals/Commands/RemoveDecalCommand.cs index 1d5e243940..3c7d44d5c4 100644 --- a/Content.Server/Decals/Commands/RemoveDecalCommand.cs +++ b/Content.Server/Decals/Commands/RemoveDecalCommand.cs @@ -25,14 +25,14 @@ namespace Content.Server.Decals.Commands return; } - if (!int.TryParse(args[1], out var rawGridId) || - !IoCManager.Resolve().GridExists(new GridId(rawGridId))) + if (!EntityUid.TryParse(args[1], out var rawGridId) || + !IoCManager.Resolve().GridExists(rawGridId)) { shell.WriteError("Failed parsing gridId."); } var decalSystem = EntitySystem.Get(); - if (decalSystem.RemoveDecal(new GridId(rawGridId), uid)) + if (decalSystem.RemoveDecal(rawGridId, uid)) { shell.WriteLine($"Successfully removed decal {uid}."); return; diff --git a/Content.Server/Decals/DecalSystem.cs b/Content.Server/Decals/DecalSystem.cs index 2763a4aa41..b0b9b8d61a 100644 --- a/Content.Server/Decals/DecalSystem.cs +++ b/Content.Server/Decals/DecalSystem.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using Content.Server.Administration.Managers; using Content.Shared.Administration; using Content.Shared.Decals; @@ -19,17 +19,17 @@ namespace Content.Server.Decals [Dependency] private readonly ITileDefinitionManager _tileDefMan = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; - private readonly Dictionary> _dirtyChunks = new(); - private readonly Dictionary>> _previousSentChunks = new(); + private readonly Dictionary> _dirtyChunks = new(); + private readonly Dictionary>> _previousSentChunks = new(); // If this ever gets parallelised then you'll want to increase the pooled count. private ObjectPool> _chunkIndexPool = new DefaultObjectPool>( new DefaultPooledObjectPolicy>(), 64); - private ObjectPool>> _chunkViewerPool = - new DefaultObjectPool>>( - new DefaultPooledObjectPolicy>>(), 64); + private ObjectPool>> _chunkViewerPool = + new DefaultObjectPool>>( + new DefaultPooledObjectPolicy>>(), 64); // Pool if we ever parallelise. private HashSet _viewers = new(64); @@ -122,10 +122,10 @@ namespace Content.Server.Decals foreach (var uid in toDelete) { - RemoveDecalInternal(args.NewTile.GridIndex, uid); + RemoveDecalInternal( args.NewTile.GridUid, uid); } - DirtyChunk(args.NewTile.GridIndex, indices); + DirtyChunk(args.NewTile.GridUid, indices); } private void OnPlayerStatusChanged(object? sender, SessionStatusEventArgs e) @@ -168,7 +168,7 @@ namespace Content.Server.Decals if (!ev.Coordinates.IsValid(EntityManager)) return; - var gridId = ev.Coordinates.GetGridId(EntityManager); + var gridId = ev.Coordinates.GetGridEntityId(EntityManager); if (!gridId.IsValid()) return; @@ -181,7 +181,7 @@ namespace Content.Server.Decals } } - protected override void DirtyChunk(GridId id, Vector2i chunkIndices) + protected override void DirtyChunk(EntityUid id, Vector2i chunkIndices) { if(!_dirtyChunks.ContainsKey(id)) _dirtyChunks[id] = new HashSet(); @@ -205,7 +205,7 @@ namespace Content.Server.Decals if (!PrototypeManager.HasIndex(decal.Id)) return false; - var gridId = coordinates.GetGridId(EntityManager); + var gridId = coordinates.GetGridEntityId(EntityManager); if (!MapManager.TryGetGrid(gridId, out var grid)) return false; @@ -224,9 +224,9 @@ namespace Content.Server.Decals return true; } - public bool RemoveDecal(GridId gridId, uint uid) => RemoveDecalInternal(gridId, uid); + public bool RemoveDecal(EntityUid gridId, uint uid) => RemoveDecalInternal(gridId, uid); - public HashSet<(uint Index, Decal Decal)> GetDecalsInRange(GridId gridId, Vector2 position, float distance = 0.75f, Func? validDelegate = null) + public HashSet<(uint Index, Decal Decal)> GetDecalsInRange(EntityUid gridId, Vector2 position, float distance = 0.75f, Func? validDelegate = null) { var uids = new HashSet<(uint, Decal)>(); var chunkCollection = ChunkCollection(gridId); @@ -248,12 +248,12 @@ namespace Content.Server.Decals return uids; } - public bool SetDecalPosition(GridId gridId, uint uid, EntityCoordinates coordinates) + public bool SetDecalPosition(EntityUid gridId, uint uid, EntityCoordinates coordinates) { - return SetDecalPosition(gridId, uid, coordinates.GetGridId(EntityManager), coordinates.Position); + return SetDecalPosition(gridId, uid, coordinates.GetGridEntityId(EntityManager), coordinates.Position); } - public bool SetDecalPosition(GridId gridId, uint uid, GridId newGridId, Vector2 position) + public bool SetDecalPosition(EntityUid gridId, uint uid, EntityUid newGridId, Vector2 position) { if (!ChunkIndex.TryGetValue(gridId, out var values) || !values.TryGetValue(uid, out var indices)) { @@ -281,7 +281,7 @@ namespace Content.Server.Decals return true; } - public bool SetDecalColor(GridId gridId, uint uid, Color? color) + public bool SetDecalColor(EntityUid gridId, uint uid, Color? color) { if (!ChunkIndex.TryGetValue(gridId, out var values) || !values.TryGetValue(uid, out var indices)) { @@ -295,7 +295,7 @@ namespace Content.Server.Decals return true; } - public bool SetDecalId(GridId gridId, uint uid, string id) + public bool SetDecalId(EntityUid gridId, uint uid, string id) { if (!ChunkIndex.TryGetValue(gridId, out var values) || !values.TryGetValue(uid, out var indices)) { @@ -312,7 +312,7 @@ namespace Content.Server.Decals return true; } - public bool SetDecalRotation(GridId gridId, uint uid, Angle angle) + public bool SetDecalRotation(EntityUid gridId, uint uid, Angle angle) { if (!ChunkIndex.TryGetValue(gridId, out var values) || !values.TryGetValue(uid, out var indices)) { @@ -326,7 +326,7 @@ namespace Content.Server.Decals return true; } - public bool SetDecalZIndex(GridId gridId, uint uid, int zIndex) + public bool SetDecalZIndex(EntityUid gridId, uint uid, int zIndex) { if (!ChunkIndex.TryGetValue(gridId, out var values) || !values.TryGetValue(uid, out var indices)) { @@ -340,7 +340,7 @@ namespace Content.Server.Decals return true; } - public bool SetDecalCleanable(GridId gridId, uint uid, bool cleanable) + public bool SetDecalCleanable(EntityUid gridId, uint uid, bool cleanable) { if (!ChunkIndex.TryGetValue(gridId, out var values) || !values.TryGetValue(uid, out var indices)) { @@ -364,12 +364,12 @@ namespace Content.Server.Decals continue; var chunksInRange = GetChunksForSession(playerSession); - var staleChunks = new Dictionary>(); + var staleChunks = new Dictionary>(); // Get any chunks not in range anymore // Then, remove them from previousSentChunks (for stuff like grids out of range) // and also mark them as stale for networking. - var toRemoveGrids = new RemQueue(); + var toRemoveGrids = new RemQueue(); // Store the chunks for later to remove. foreach (var (gridId, oldIndices) in _previousSentChunks[playerSession]) @@ -455,7 +455,7 @@ namespace Content.Server.Decals _dirtyChunks.Clear(); } - private void ReturnToPool(Dictionary> chunks) + private void ReturnToPool(Dictionary> chunks) { foreach (var (_, previous) in chunks) { @@ -469,10 +469,10 @@ namespace Content.Server.Decals private void SendChunkUpdates( IPlayerSession session, - Dictionary> updatedChunks, - Dictionary> staleChunks) + Dictionary> updatedChunks, + Dictionary> staleChunks) { - var updatedDecals = new Dictionary>>(); + var updatedDecals = new Dictionary>>(); foreach (var (gridId, chunks) in updatedChunks) { var gridChunks = new Dictionary>(); @@ -505,7 +505,7 @@ namespace Content.Server.Decals return viewers; } - private Dictionary> GetChunksForSession(IPlayerSession session) + private Dictionary> GetChunksForSession(IPlayerSession session) { var viewers = GetSessionViewers(session); var chunks = GetChunksForViewers(viewers); @@ -513,7 +513,7 @@ namespace Content.Server.Decals return chunks; } - private Dictionary> GetChunksForViewers(HashSet viewers) + private Dictionary> GetChunksForViewers(HashSet viewers) { var chunks = _chunkViewerPool.Get(); var xformQuery = GetEntityQuery(); @@ -524,14 +524,14 @@ namespace Content.Server.Decals foreach (var grid in MapManager.FindGridsIntersecting(mapId, bounds)) { - if (!chunks.ContainsKey(grid.Index)) - chunks[grid.Index] = _chunkIndexPool.Get(); + if (!chunks.ContainsKey(grid.GridEntityId)) + chunks[grid.GridEntityId] = _chunkIndexPool.Get(); var enumerator = new ChunkIndicesEnumerator(_transform.GetInvWorldMatrix(grid.GridEntityId, xformQuery).TransformBox(bounds), ChunkSize); while (enumerator.MoveNext(out var indices)) { - chunks[grid.Index].Add(indices.Value); + chunks[grid.GridEntityId].Add(indices.Value); } } } diff --git a/Content.Server/DeviceNetwork/Systems/WiredNetworkSystem.cs b/Content.Server/DeviceNetwork/Systems/WiredNetworkSystem.cs index 41cb9c1412..15e127717c 100644 --- a/Content.Server/DeviceNetwork/Systems/WiredNetworkSystem.cs +++ b/Content.Server/DeviceNetwork/Systems/WiredNetworkSystem.cs @@ -17,7 +17,7 @@ namespace Content.Server.DeviceNetwork.Systems /// private void OnBeforePacketSent(EntityUid uid, WiredNetworkComponent component, BeforePacketSentEvent args) { - if (EntityManager.GetComponent(uid).GridID != args.SenderTransform.GridID) + if (EntityManager.GetComponent(uid).GridEntityId != args.SenderTransform.GridEntityId) { args.Cancel(); } diff --git a/Content.Server/Disposal/Tube/DisposalTubeSystem.cs b/Content.Server/Disposal/Tube/DisposalTubeSystem.cs index bb9509af1b..9533b1db9e 100644 --- a/Content.Server/Disposal/Tube/DisposalTubeSystem.cs +++ b/Content.Server/Disposal/Tube/DisposalTubeSystem.cs @@ -125,7 +125,7 @@ namespace Content.Server.Disposal.Tube return null; var oppositeDirection = nextDirection.GetOpposite(); - var grid = _mapManager.GetGrid(EntityManager.GetComponent(targetTube.Owner).GridID); + var grid = _mapManager.GetGrid(EntityManager.GetComponent(targetTube.Owner).GridEntityId); var position = EntityManager.GetComponent(targetTube.Owner).Coordinates; foreach (var entity in grid.GetInDir(position, nextDirection)) { diff --git a/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs b/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs index 2d926bb23f..9ee06d17cd 100644 --- a/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs +++ b/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs @@ -34,7 +34,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems // *This is on purpose.* DisposalUnitComponent? duc = null; - if (_mapManager.TryGetGrid(holderTransform.GridID, out var grid)) + if (_mapManager.TryGetGrid(holderTransform.GridEntityId, out var grid)) { foreach (var contentUid in grid.GetLocal(holderTransform.Coordinates)) { diff --git a/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs b/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs index 4a68c63ce7..9dc857c6df 100644 --- a/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs +++ b/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs @@ -477,7 +477,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems return false; } - var grid = _mapManager.GetGrid(EntityManager.GetComponent(component.Owner).GridID); + var grid = _mapManager.GetGrid(EntityManager.GetComponent(component.Owner).GridEntityId); var coords = EntityManager.GetComponent(component.Owner).Coordinates; var entry = grid.GetLocal(coords) .FirstOrDefault(entity => EntityManager.HasComponent(entity)); diff --git a/Content.Server/Engineering/EntitySystems/SpawnAfterInteractSystem.cs b/Content.Server/Engineering/EntitySystems/SpawnAfterInteractSystem.cs index 7e839265cc..6c7b5f1cd5 100644 --- a/Content.Server/Engineering/EntitySystems/SpawnAfterInteractSystem.cs +++ b/Content.Server/Engineering/EntitySystems/SpawnAfterInteractSystem.cs @@ -30,7 +30,7 @@ namespace Content.Server.Engineering.EntitySystems return; if (string.IsNullOrEmpty(component.Prototype)) return; - if (!_mapManager.TryGetGrid(args.ClickLocation.GetGridId(EntityManager), out var grid)) + if (!_mapManager.TryGetGrid(args.ClickLocation.GetGridEntityId(EntityManager), out var grid)) return; if (!grid.TryGetTileRef(args.ClickLocation, out var tileRef)) return; diff --git a/Content.Server/Explosion/EntitySystems/ExplosionGridTileFlood.cs b/Content.Server/Explosion/EntitySystems/ExplosionGridTileFlood.cs index 65e361438a..fa36858ad5 100644 --- a/Content.Server/Explosion/EntitySystems/ExplosionGridTileFlood.cs +++ b/Content.Server/Explosion/EntitySystems/ExplosionGridTileFlood.cs @@ -41,7 +41,7 @@ public sealed class ExplosionGridTileFlood : ExplosionTileFlood float intensityStepSize, int typeIndex, Dictionary edgeTiles, - GridId? referenceGrid, + EntityUid? referenceGrid, Matrix3 spaceMatrix, Angle spaceAngle) { @@ -63,7 +63,7 @@ public sealed class ExplosionGridTileFlood : ExplosionTileFlood } } - if (referenceGrid == Grid.Index) + if (referenceGrid == Grid.GridEntityId) return; _needToTransform = true; diff --git a/Content.Server/Explosion/EntitySystems/ExplosionSpaceTileFlood.cs b/Content.Server/Explosion/EntitySystems/ExplosionSpaceTileFlood.cs index 241455bcaa..f8c917c1cd 100644 --- a/Content.Server/Explosion/EntitySystems/ExplosionSpaceTileFlood.cs +++ b/Content.Server/Explosion/EntitySystems/ExplosionSpaceTileFlood.cs @@ -19,11 +19,11 @@ public sealed class ExplosionSpaceTileFlood : ExplosionTileFlood /// After every iteration, this data set will store all the grid-tiles that were reached as a result of the /// explosion expanding in space. /// - public Dictionary> GridJump = new(); + public Dictionary> GridJump = new(); public ushort TileSize = ExplosionSystem.DefaultTileSize; - public ExplosionSpaceTileFlood(ExplosionSystem system, MapCoordinates epicentre, GridId? referenceGrid, List localGrids, float maxDistance) + public ExplosionSpaceTileFlood(ExplosionSystem system, MapCoordinates epicentre, EntityUid? referenceGrid, List localGrids, float maxDistance) { (_gridBlockMap, TileSize) = system.TransformGridEdges(epicentre, referenceGrid, localGrids, maxDistance); system.GetUnblockedDirections(_gridBlockMap, TileSize); diff --git a/Content.Server/Explosion/EntitySystems/ExplosionSystem.Airtight.cs b/Content.Server/Explosion/EntitySystems/ExplosionSystem.Airtight.cs index 2bcd30b67f..2df8362762 100644 --- a/Content.Server/Explosion/EntitySystems/ExplosionSystem.Airtight.cs +++ b/Content.Server/Explosion/EntitySystems/ExplosionSystem.Airtight.cs @@ -39,9 +39,9 @@ public sealed partial class ExplosionSystem : EntitySystem // // We then need this data for every tile on a grid. So this mess of a variable maps the Grid ID and Vector2i grid // indices to this tile-data struct. - private Dictionary> _airtightMap = new(); + private Dictionary> _airtightMap = new(); - public void UpdateAirtightMap(GridId gridId, Vector2i tile, EntityQuery? query = null) + public void UpdateAirtightMap(EntityUid gridId, Vector2i tile, EntityQuery? query = null) { if (_mapManager.TryGetGrid(gridId, out var grid)) UpdateAirtightMap(grid, tile, query); @@ -62,8 +62,8 @@ public sealed partial class ExplosionSystem : EntitySystem var tolerance = new float[_explosionTypes.Count]; var blockedDirections = AtmosDirection.Invalid; - if (!_airtightMap.ContainsKey(grid.Index)) - _airtightMap[grid.Index] = new(); + if (!_airtightMap.ContainsKey(grid.GridEntityId)) + _airtightMap[grid.GridEntityId] = new(); query ??= EntityManager.GetEntityQuery(); var damageQuery = EntityManager.GetEntityQuery(); @@ -83,9 +83,9 @@ public sealed partial class ExplosionSystem : EntitySystem } if (blockedDirections != AtmosDirection.Invalid) - _airtightMap[grid.Index][tile] = new(tolerance, blockedDirections); + _airtightMap[grid.GridEntityId][tile] = new(tolerance, blockedDirections); else - _airtightMap[grid.Index].Remove(tile); + _airtightMap[grid.GridEntityId].Remove(tile); } /// @@ -100,7 +100,7 @@ public sealed partial class ExplosionSystem : EntitySystem if (!EntityManager.TryGetComponent(uid, out TransformComponent? transform) || !transform.Anchored) return; - if (!_mapManager.TryGetGrid(transform.GridID, out var grid)) + if (!_mapManager.TryGetGrid(transform.GridEntityId, out var grid)) return; UpdateAirtightMap(grid, grid.CoordinatesToTile(transform.Coordinates)); diff --git a/Content.Server/Explosion/EntitySystems/ExplosionSystem.GridMap.cs b/Content.Server/Explosion/EntitySystems/ExplosionSystem.GridMap.cs index 26c8d2cae2..dd53c1bd23 100644 --- a/Content.Server/Explosion/EntitySystems/ExplosionSystem.GridMap.cs +++ b/Content.Server/Explosion/EntitySystems/ExplosionSystem.GridMap.cs @@ -11,7 +11,7 @@ public sealed partial class ExplosionSystem : EntitySystem /// /// Set of tiles of each grid that are directly adjacent to space, along with the directions that face space. /// - private Dictionary> _gridEdges = new(); + private Dictionary> _gridEdges = new(); /// /// On grid startup, prepare a map of grid edges. @@ -42,8 +42,8 @@ public sealed partial class ExplosionSystem : EntitySystem /// public (Dictionary, ushort) TransformGridEdges( MapCoordinates epicentre, - GridId? referenceGrid, - List localGrids, + EntityUid? referenceGrid, + List localGrids, float maxDistance) { Dictionary transformedEdges = new(); @@ -230,10 +230,10 @@ public sealed partial class ExplosionSystem : EntitySystem var tileRef = ev.NewTile; - if (!_gridEdges.TryGetValue(tileRef.GridIndex, out var edges)) + if (!_gridEdges.TryGetValue(tileRef.GridUid, out var edges)) { edges = new(); - _gridEdges[tileRef.GridIndex] = edges; + _gridEdges[tileRef.GridUid] = edges; } if (tileRef.Tile.IsEmpty) @@ -373,10 +373,10 @@ public sealed class BlockedSpaceTile public sealed class GridEdgeData { public Vector2i Tile; - public GridId? Grid; + public EntityUid? Grid; public Box2Rotated Box; - public GridEdgeData(Vector2i tile, GridId? grid, Vector2 center, Angle angle, float size) + public GridEdgeData(Vector2i tile, EntityUid? grid, Vector2 center, Angle angle, float size) { Tile = tile; Grid = grid; diff --git a/Content.Server/Explosion/EntitySystems/ExplosionSystem.TileFill.cs b/Content.Server/Explosion/EntitySystems/ExplosionSystem.TileFill.cs index b82b0e20b0..cd3d037efd 100644 --- a/Content.Server/Explosion/EntitySystems/ExplosionSystem.TileFill.cs +++ b/Content.Server/Explosion/EntitySystems/ExplosionSystem.TileFill.cs @@ -22,7 +22,7 @@ public sealed partial class ExplosionSystem : EntitySystem /// The maximum intensity that the explosion can have at any given tile. This /// effectively caps the damage that this explosion can do. /// A list of tile-sets and a list of intensity values which describe the explosion. - private (int, List, ExplosionSpaceTileFlood?, Dictionary, Matrix3)? GetExplosionTiles( + private (int, List, ExplosionSpaceTileFlood?, Dictionary, Matrix3)? GetExplosionTiles( MapCoordinates epicenter, string typeID, float totalIntensity, @@ -39,7 +39,7 @@ public sealed partial class ExplosionSystem : EntitySystem } Vector2i initialTile; - GridId? epicentreGrid = null; + EntityUid? epicentreGrid = null; var (localGrids, referenceGrid, maxDistance) = GetLocalGrids(epicenter, totalIntensity, slope, maxIntensity); // get the epicenter tile indices @@ -47,7 +47,7 @@ public sealed partial class ExplosionSystem : EntitySystem candidateGrid.TryGetTileRef(candidateGrid.WorldToTile(epicenter.Position), out var tileRef) && !tileRef.Tile.IsEmpty) { - epicentreGrid = candidateGrid.Index; + epicentreGrid = candidateGrid.GridEntityId; initialTile = tileRef.GridIndices; } else if (referenceGrid != null) @@ -64,7 +64,7 @@ public sealed partial class ExplosionSystem : EntitySystem } // Main data for the exploding tiles in space and on various grids - Dictionary gridData = new(); + Dictionary gridData = new(); ExplosionSpaceTileFlood? spaceData = null; // The intensity slope is how much the intensity drop over a one-tile distance. The actual algorithm step-size is half of thhat. @@ -76,8 +76,8 @@ public sealed partial class ExplosionSystem : EntitySystem HashSet previousSpaceJump; // As above, but for space-based explosion propagating from space onto grids. - HashSet encounteredGrids = new(); - Dictionary>? previousGridJump; + HashSet encounteredGrids = new(); + Dictionary>? previousGridJump; // variables for transforming between grid and space-coordiantes var spaceMatrix = Matrix3.Identity; @@ -256,7 +256,7 @@ public sealed partial class ExplosionSystem : EntitySystem /// match a separate grid. This is done so that if you have something like a tiny suicide-bomb shuttle exploding /// near a large station, the explosion will still orient to match the station, not the tiny shuttle. /// - public (List, GridId?, float) GetLocalGrids(MapCoordinates epicenter, float totalIntensity, float slope, float maxIntensity) + public (List, EntityUid?, float) GetLocalGrids(MapCoordinates epicenter, float totalIntensity, float slope, float maxIntensity) { // Get the explosion radius (approx radius if it were in open-space). Note that if the explosion is confined in // some directions but not in others, the actual explosion may reach further than this distance from the @@ -266,7 +266,7 @@ public sealed partial class ExplosionSystem : EntitySystem // to avoid a silly lookup for silly input numbers, cap the radius to half of the theoretical maximum (lookup area gets doubled later on). radius = Math.Min(radius, MaxIterations / 4); - GridId? referenceGrid = null; + EntityUid? referenceGrid = null; float mass = 0; // First attempt to find a grid that is relatively close to the explosion's center. Instead of looking in a @@ -278,7 +278,7 @@ public sealed partial class ExplosionSystem : EntitySystem if (TryComp(grid.GridEntityId, out PhysicsComponent? physics) && physics.Mass > mass) { mass = physics.Mass; - referenceGrid = grid.Index; + referenceGrid = grid.GridEntityId; } } @@ -294,7 +294,7 @@ public sealed partial class ExplosionSystem : EntitySystem radius *= 4; box = Box2.CenteredAround(epicenter.Position, (radius, radius)); var mapGrids = _mapManager.FindGridsIntersecting(epicenter.MapId, box).ToList(); - var grids = mapGrids.Select(x => x.Index).ToList(); + var grids = mapGrids.Select(x => x.GridEntityId).ToList(); if (referenceGrid != null) return (grids, referenceGrid, radius); @@ -305,7 +305,7 @@ public sealed partial class ExplosionSystem : EntitySystem if (TryComp(grid.GridEntityId, out PhysicsComponent? physics) && physics.Mass > mass) { mass = physics.Mass; - referenceGrid = grid.Index; + referenceGrid = grid.GridEntityId; } } diff --git a/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs b/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs index 6213bd7961..0585bda8ba 100644 --- a/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs +++ b/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs @@ -308,10 +308,10 @@ public sealed partial class ExplosionSystem : EntitySystem { var spaceTiles = spaceData?.TileLists; - Dictionary>> tileLists = new(); + Dictionary>> tileLists = new(); foreach (var grid in gridData) { - tileLists.Add(grid.Grid.Index, grid.TileLists); + tileLists.Add(grid.Grid.GridEntityId, grid.TileLists); } return new ExplosionEvent(_explosionCounter, epicenter, id, iterationIntensity, spaceTiles, tileLists, spaceMatrix, spaceData?.TileSize ?? DefaultTileSize); diff --git a/Content.Server/Fluids/EntitySystems/FluidSpreaderSystem.cs b/Content.Server/Fluids/EntitySystems/FluidSpreaderSystem.cs index 31b81a5855..5f3ca56753 100644 --- a/Content.Server/Fluids/EntitySystems/FluidSpreaderSystem.cs +++ b/Content.Server/Fluids/EntitySystems/FluidSpreaderSystem.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using System.Linq; using Content.Server.Chemistry.EntitySystems; using Content.Server.Fluids.Components; @@ -103,7 +103,7 @@ public sealed class FluidSpreaderSystem : EntitySystem var prototypeName = metadataOriginal.EntityPrototype!.ID; var visitedTiles = new HashSet(); - if (!_mapManager.TryGetGrid(transformOrig.GridID, out var mapGrid)) + if (!_mapManager.TryGetGrid(transformOrig.GridEntityId, out var mapGrid)) return; // skip origin puddle diff --git a/Content.Server/Fluids/EntitySystems/MoppingSystem.cs b/Content.Server/Fluids/EntitySystems/MoppingSystem.cs index c9b93dae1f..0ce8831fff 100644 --- a/Content.Server/Fluids/EntitySystems/MoppingSystem.cs +++ b/Content.Server/Fluids/EntitySystems/MoppingSystem.cs @@ -76,7 +76,7 @@ public sealed class MoppingSystem : EntitySystem private void ReleaseToFloor(EntityCoordinates clickLocation, AbsorbentComponent absorbent, Solution? absorbedSolution) { - if ((_mapManager.TryGetGrid(clickLocation.GetGridId(EntityManager), out var mapGrid)) // needs valid grid + if ((_mapManager.TryGetGrid(clickLocation.GetGridEntityId(EntityManager), out var mapGrid)) // needs valid grid && absorbedSolution is not null) // needs a solution to place on the tile { TileRef tile = mapGrid.GetTileRef(clickLocation); diff --git a/Content.Server/Fluids/EntitySystems/SpillableSystem.cs b/Content.Server/Fluids/EntitySystems/SpillableSystem.cs index 502ba4ca30..76e5082990 100644 --- a/Content.Server/Fluids/EntitySystems/SpillableSystem.cs +++ b/Content.Server/Fluids/EntitySystems/SpillableSystem.cs @@ -132,7 +132,7 @@ public sealed class SpillableSystem : EntitySystem if (solution.TotalVolume == 0) return null; - if (!_mapManager.TryGetGrid(coordinates.GetGridId(EntityManager), out var mapGrid)) + if (!_mapManager.TryGetGrid(coordinates.GetGridEntityId(EntityManager), out var mapGrid)) return null; // Let's not spill to space. return SpillAt(mapGrid.GetTileRef(coordinates), solution, prototype, overflow, sound, @@ -162,7 +162,7 @@ public sealed class SpillableSystem : EntitySystem // If space return early, let that spill go out into the void if (tileRef.Tile.IsEmpty) return null; - var gridId = tileRef.GridIndex; + var gridId = tileRef.GridUid; if (!_mapManager.TryGetGrid(gridId, out var mapGrid)) return null; // Let's not spill to invalid grids. if (!noTileReact) diff --git a/Content.Server/Fluids/EntitySystems/SpraySystem.cs b/Content.Server/Fluids/EntitySystems/SpraySystem.cs index 75a1476a31..9e93257d7a 100644 --- a/Content.Server/Fluids/EntitySystems/SpraySystem.cs +++ b/Content.Server/Fluids/EntitySystems/SpraySystem.cs @@ -1,4 +1,4 @@ -using Content.Server.Chemistry.Components; +using Content.Server.Chemistry.Components; using Content.Server.Chemistry.EntitySystems; using Content.Server.Cooldown; using Content.Server.Extinguisher; @@ -10,6 +10,7 @@ using Content.Shared.FixedPoint; using Content.Shared.Interaction; using Content.Shared.Vapor; using Robust.Shared.Audio; +using Robust.Shared.Map; using Robust.Shared.Player; using Robust.Shared.Timing; @@ -58,7 +59,7 @@ public sealed class SpraySystem : EntitySystem var playerPos = Transform(args.User).Coordinates; - if (args.ClickLocation.GetGridId(EntityManager) != playerPos.GetGridId(EntityManager)) + if (args.ClickLocation.GetGridEntityId(EntityManager) != playerPos.GetGridEntityId(EntityManager)) return; var direction = (args.ClickLocation.Position - playerPos.Position).Normalized; diff --git a/Content.Server/GameTicking/GameTicker.RoundFlow.cs b/Content.Server/GameTicking/GameTicker.RoundFlow.cs index 0e90bd097f..6a1b22bd40 100644 --- a/Content.Server/GameTicking/GameTicker.RoundFlow.cs +++ b/Content.Server/GameTicking/GameTicker.RoundFlow.cs @@ -112,7 +112,7 @@ namespace Content.Server.GameTicking /// Map loading options, includes offset. /// Name to assign to the loaded station. /// All loaded entities and grids. - public (IReadOnlyList, IReadOnlyList) LoadGameMap(GameMapPrototype map, MapId targetMapId, MapLoadOptions? loadOptions, string? stationName = null) + public (IReadOnlyList, IReadOnlyList) LoadGameMap(GameMapPrototype map, MapId targetMapId, MapLoadOptions? loadOptions, string? stationName = null) { var loadOpts = loadOptions ?? new MapLoadOptions(); @@ -121,10 +121,11 @@ namespace Content.Server.GameTicking var (entities, gridIds) = _mapLoader.LoadMap(targetMapId, ev.GameMap.MapPath.ToString(), ev.Options); - RaiseLocalEvent(new PostGameMapLoad(map, targetMapId, entities, gridIds, stationName)); + var gridUids = gridIds.Select(g => (EntityUid)g).ToList(); + RaiseLocalEvent(new PostGameMapLoad(map, targetMapId, entities, gridUids, stationName)); _spawnPoint = _mapManager.GetGrid(gridIds[0]).ToCoordinates(); - return (entities, gridIds); + return (entities, gridUids); } public void StartRound(bool force = false) @@ -557,10 +558,10 @@ namespace Content.Server.GameTicking public readonly GameMapPrototype GameMap; public readonly MapId Map; public readonly IReadOnlyList Entities; - public readonly IReadOnlyList Grids; + public readonly IReadOnlyList Grids; public readonly string? StationName; - public PostGameMapLoad(GameMapPrototype gameMap, MapId map, IReadOnlyList entities, IReadOnlyList grids, string? stationName) + public PostGameMapLoad(GameMapPrototype gameMap, MapId map, IReadOnlyList entities, IReadOnlyList grids, string? stationName) { GameMap = gameMap; Map = map; diff --git a/Content.Server/Gravity/EntitySystems/GravityGeneratorSystem.cs b/Content.Server/Gravity/EntitySystems/GravityGeneratorSystem.cs index d1167d8375..4eb8caa909 100644 --- a/Content.Server/Gravity/EntitySystems/GravityGeneratorSystem.cs +++ b/Content.Server/Gravity/EntitySystems/GravityGeneratorSystem.cs @@ -1,4 +1,4 @@ -using Content.Server.Audio; +using Content.Server.Audio; using Content.Server.Power.Components; using Content.Shared.Gravity; using Content.Shared.Interaction; @@ -187,8 +187,8 @@ namespace Content.Server.Gravity.EntitySystems private void UpdateGravityActive(GravityGeneratorComponent grav, bool shake) { - var gridId = EntityManager.GetComponent(grav.Owner).GridID; - if (gridId == GridId.Invalid) + var gridId = EntityManager.GetComponent(grav.Owner).GridEntityId; + if (gridId == EntityUid.Invalid) return; var grid = _mapManager.GetGrid(gridId); diff --git a/Content.Server/Gravity/EntitySystems/GravityShakeSystem.cs b/Content.Server/Gravity/EntitySystems/GravityShakeSystem.cs index 7ad060ffc5..d2e157b1e8 100644 --- a/Content.Server/Gravity/EntitySystems/GravityShakeSystem.cs +++ b/Content.Server/Gravity/EntitySystems/GravityShakeSystem.cs @@ -18,7 +18,7 @@ namespace Content.Server.Gravity.EntitySystems [Dependency] private readonly CameraRecoilSystem _cameraRecoil = default!; - private Dictionary _gridsToShake = new(); + private Dictionary _gridsToShake = new(); private const float GravityKick = 100.0f; private const uint ShakeTimes = 10; @@ -44,7 +44,7 @@ namespace Content.Server.Gravity.EntitySystems } } - public void ShakeGrid(GridId gridId, GravityComponent comp) + public void ShakeGrid(EntityUid gridId, GravityComponent comp) { _gridsToShake[gridId] = ShakeTimes; @@ -58,7 +58,7 @@ namespace Content.Server.Gravity.EntitySystems { // I have to copy this because C# doesn't allow changing collections while they're // getting enumerated. - var gridsToShake = new Dictionary(_gridsToShake); + var gridsToShake = new Dictionary(_gridsToShake); foreach (var gridId in _gridsToShake.Keys) { if (_gridsToShake[gridId] == 0) @@ -73,12 +73,12 @@ namespace Content.Server.Gravity.EntitySystems _gridsToShake = gridsToShake; } - private void ShakeGrid(GridId gridId) + private void ShakeGrid(EntityUid gridId) { foreach (var player in _playerManager.Sessions) { if (player.AttachedEntity is not {Valid: true} attached - || EntityManager.GetComponent(attached).GridID != gridId + || EntityManager.GetComponent(attached).GridEntityId != gridId || !EntityManager.HasComponent(attached)) { continue; diff --git a/Content.Server/Gravity/EntitySystems/GravitySystem.cs b/Content.Server/Gravity/EntitySystems/GravitySystem.cs index 251fffda98..c1d9e6f604 100644 --- a/Content.Server/Gravity/EntitySystems/GravitySystem.cs +++ b/Content.Server/Gravity/EntitySystems/GravitySystem.cs @@ -16,12 +16,12 @@ namespace Content.Server.Gravity.EntitySystems private void HandleGravityInitialize(EntityUid uid, GravityComponent component, ComponentInit args) { // Incase there's already a generator on the grid we'll just set it now. - var gridId = EntityManager.GetComponent(component.Owner).GridID; + var gridId = EntityManager.GetComponent(component.Owner).GridEntityId; GravityChangedMessage message; foreach (var generator in EntityManager.EntityQuery()) { - if (EntityManager.GetComponent(generator.Owner).GridID == gridId && generator.GravityActive) + if (EntityManager.GetComponent(generator.Owner).GridEntityId == gridId && generator.GravityActive) { component.Enabled = true; message = new GravityChangedMessage(gridId, true); @@ -45,7 +45,7 @@ namespace Content.Server.Gravity.EntitySystems if (comp.Enabled) return; comp.Enabled = true; - var gridId = EntityManager.GetComponent(comp.Owner).GridID; + var gridId = EntityManager.GetComponent(comp.Owner).GridEntityId; var message = new GravityChangedMessage(gridId, true); RaiseLocalEvent(message); } @@ -55,7 +55,7 @@ namespace Content.Server.Gravity.EntitySystems if (!comp.Enabled) return; comp.Enabled = false; - var gridId = EntityManager.GetComponent(comp.Owner).GridID; + var gridId = EntityManager.GetComponent(comp.Owner).GridEntityId; var message = new GravityChangedMessage(gridId, false); RaiseLocalEvent(message); } diff --git a/Content.Server/Gravity/EntitySystems/WeightlessSystem.cs b/Content.Server/Gravity/EntitySystems/WeightlessSystem.cs index 4c670b0844..eae135be62 100644 --- a/Content.Server/Gravity/EntitySystems/WeightlessSystem.cs +++ b/Content.Server/Gravity/EntitySystems/WeightlessSystem.cs @@ -14,7 +14,7 @@ namespace Content.Server.Gravity.EntitySystems [Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly AlertsSystem _alertsSystem = default!; - private readonly Dictionary> _alerts = new(); + private readonly Dictionary> _alerts = new(); public override void Initialize() { @@ -34,11 +34,11 @@ namespace Content.Server.Gravity.EntitySystems public void AddAlert(AlertsComponent status) { var xform = Transform(status.Owner); - var alerts = _alerts.GetOrNew(xform.GridID); + var alerts = _alerts.GetOrNew(xform.GridEntityId); alerts.Add(status); - if (_mapManager.TryGetGrid(xform.GridID, out var grid)) + if (_mapManager.TryGetGrid(xform.GridEntityId, out var grid)) { if (EntityManager.GetComponent(grid.GridEntityId).Enabled) { @@ -53,7 +53,7 @@ namespace Content.Server.Gravity.EntitySystems public void RemoveAlert(AlertsComponent status) { - var grid = EntityManager.GetComponent(status.Owner).GridID; + var grid = EntityManager.GetComponent(status.Owner).GridEntityId; if (!_alerts.TryGetValue(grid, out var statuses)) { return; @@ -101,7 +101,7 @@ namespace Content.Server.Gravity.EntitySystems if (ev.OldParent is {Valid: true} old && EntityManager.TryGetComponent(old, out IMapGridComponent? mapGrid)) { - var oldGrid = mapGrid.GridIndex; + var oldGrid = mapGrid.Owner; if (_alerts.TryGetValue(oldGrid, out var oldStatuses)) { @@ -109,7 +109,7 @@ namespace Content.Server.Gravity.EntitySystems } } - var newGrid = ev.Transform.GridID; + var newGrid = ev.Transform.GridEntityId; var newStatuses = _alerts.GetOrNew(newGrid); newStatuses.Add(status); diff --git a/Content.Server/Interaction/TilePryCommand.cs b/Content.Server/Interaction/TilePryCommand.cs index c7b245b20a..186c1bdadd 100644 --- a/Content.Server/Interaction/TilePryCommand.cs +++ b/Content.Server/Interaction/TilePryCommand.cs @@ -47,7 +47,7 @@ namespace Content.Server.Interaction } var mapManager = IoCManager.Resolve(); - var playerGrid = _entities.GetComponent(attached).GridID; + var playerGrid = _entities.GetComponent(attached).GridEntityId; var mapGrid = mapManager.GetGrid(playerGrid); var playerPosition = _entities.GetComponent(attached).Coordinates; var tileDefinitionManager = IoCManager.Resolve(); diff --git a/Content.Server/Kudzu/SpreaderSystem.cs b/Content.Server/Kudzu/SpreaderSystem.cs index bb14eab42b..786db00cec 100644 --- a/Content.Server/Kudzu/SpreaderSystem.cs +++ b/Content.Server/Kudzu/SpreaderSystem.cs @@ -44,7 +44,7 @@ public sealed class SpreaderSystem : EntitySystem if (!EntityManager.TryGetComponent(blocker, out var transform)) return; // how did we get here? - if (!_mapManager.TryGetGrid(transform.GridID, out var grid)) return; + if (!_mapManager.TryGetGrid(transform.GridEntityId, out var grid)) return; for (var i = 0; i < Atmospherics.Directions; i++) { @@ -89,7 +89,7 @@ public sealed class SpreaderSystem : EntitySystem if (spreader.Enabled == false) return false; - if (!_mapManager.TryGetGrid(transform.GridID, out var grid)) return false; + if (!_mapManager.TryGetGrid(transform.GridEntityId, out var grid)) return false; var didGrow = false; diff --git a/Content.Server/Medical/CrewMonitoring/CrewMonitoringConsoleSystem.cs b/Content.Server/Medical/CrewMonitoring/CrewMonitoringConsoleSystem.cs index c99892f5b6..4ae9df6836 100644 --- a/Content.Server/Medical/CrewMonitoring/CrewMonitoringConsoleSystem.cs +++ b/Content.Server/Medical/CrewMonitoring/CrewMonitoringConsoleSystem.cs @@ -77,7 +77,7 @@ namespace Content.Server.Medical.CrewMonitoring // should work well enough? if (TryComp(uid, out IMoverComponent? mover)) worldRot = mover.LastGridAngle; - else if (_mapManager.TryGetGrid(xform.GridID, out var grid)) + else if (_mapManager.TryGetGrid(xform.GridEntityId, out var grid)) worldRot = grid.WorldRotation; // update all sensors info diff --git a/Content.Server/Mind/MindSystem.cs b/Content.Server/Mind/MindSystem.cs index daf2c4a9c5..f2f3fcbed1 100644 --- a/Content.Server/Mind/MindSystem.cs +++ b/Content.Server/Mind/MindSystem.cs @@ -90,8 +90,8 @@ public sealed class MindSystem : EntitySystem return; // Async this so that we don't throw if the grid we're on is being deleted. - var gridId = spawnPosition.GetGridId(EntityManager); - if (!spawnPosition.IsValid(EntityManager) || gridId == GridId.Invalid || !_mapManager.GridExists(gridId)) + var gridId = spawnPosition.GetGridEntityId(EntityManager); + if (!spawnPosition.IsValid(EntityManager) || gridId == EntityUid.Invalid || !_mapManager.GridExists(gridId)) { spawnPosition = _gameTicker.GetObserverSpawnPoint(); } diff --git a/Content.Server/NodeContainer/EntitySystems/NodeGroupSystem.cs b/Content.Server/NodeContainer/EntitySystems/NodeGroupSystem.cs index 9e5a9e09e2..ec3c431aa0 100644 --- a/Content.Server/NodeContainer/EntitySystems/NodeGroupSystem.cs +++ b/Content.Server/NodeContainer/EntitySystems/NodeGroupSystem.cs @@ -335,7 +335,7 @@ namespace Content.Server.NodeContainer.EntitySystems private IEnumerable GetCompatibleNodes(Node node, EntityQuery xformQuery, EntityQuery nodeQuery) { var xform = xformQuery.GetComponent(node.Owner); - _mapManager.TryGetGrid(xform.GridID, out var grid); + _mapManager.TryGetGrid(xform.GridEntityId, out var grid); if (!node.Connectable(EntityManager, xform)) yield break; diff --git a/Content.Server/NodeContainer/NodeGroups/BaseNodeGroup.cs b/Content.Server/NodeContainer/NodeGroups/BaseNodeGroup.cs index e560e4be40..076dae9a00 100644 --- a/Content.Server/NodeContainer/NodeGroups/BaseNodeGroup.cs +++ b/Content.Server/NodeContainer/NodeGroups/BaseNodeGroup.cs @@ -56,7 +56,7 @@ namespace Content.Server.NodeContainer.NodeGroups public bool Removed { get; set; } = false; [ViewVariables] - protected GridId GridId { get; private set; } + protected EntityUid GridId { get; private set; } /// /// Network ID of this group for client-side debug visualization of nodes. @@ -75,7 +75,7 @@ namespace Content.Server.NodeContainer.NodeGroups public virtual void Initialize(Node sourceNode) { // TODO: Can we get rid of this GridId? - GridId = IoCManager.Resolve().GetComponent(sourceNode.Owner).GridID; + GridId = IoCManager.Resolve().GetComponent(sourceNode.Owner).GridEntityId; } /// diff --git a/Content.Server/NodeContainer/NodeGroups/PipeNet.cs b/Content.Server/NodeContainer/NodeGroups/PipeNet.cs index 04b0e97754..4931923240 100644 --- a/Content.Server/NodeContainer/NodeGroups/PipeNet.cs +++ b/Content.Server/NodeContainer/NodeGroups/PipeNet.cs @@ -3,7 +3,6 @@ using Content.Server.Atmos; using Content.Server.Atmos.EntitySystems; using Content.Server.NodeContainer.Nodes; using Content.Shared.Atmos; -using Robust.Shared.Map; using Robust.Shared.Utility; namespace Content.Server.NodeContainer.NodeGroups @@ -23,7 +22,7 @@ namespace Content.Server.NodeContainer.NodeGroups [ViewVariables] private AtmosphereSystem? _atmosphereSystem; - public GridId Grid => GridId; + public EntityUid Grid => GridId; public override void Initialize(Node sourceNode) { diff --git a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs index 0476060101..bfbff3fe11 100644 --- a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs +++ b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs @@ -329,7 +329,7 @@ namespace Content.Server.ParticleAccelerator.Components // Find fuel chamber first by scanning cardinals. if (_entMan.GetComponent(Owner).Anchored) { - var grid = _mapManager.GetGrid(_entMan.GetComponent(Owner).GridID); + var grid = _mapManager.GetGrid(_entMan.GetComponent(Owner).GridEntityId); var coords = _entMan.GetComponent(Owner).Coordinates; foreach (var maybeFuel in grid.GetCardinalNeighborCells(coords)) { @@ -403,7 +403,7 @@ namespace Content.Server.ParticleAccelerator.Components private bool ScanPart(Vector2i offset, [NotNullWhen(true)] out T? part) where T : ParticleAcceleratorPartComponent { - var grid = _mapManager.GetGrid(_entMan.GetComponent(Owner).GridID); + var grid = _mapManager.GetGrid(_entMan.GetComponent(Owner).GridEntityId); var coords = _entMan.GetComponent(Owner).Coordinates; foreach (var ent in grid.GetOffset(coords, offset)) { diff --git a/Content.Server/Physics/Controllers/ConveyorController.cs b/Content.Server/Physics/Controllers/ConveyorController.cs index 114b07df34..29374f010d 100644 --- a/Content.Server/Physics/Controllers/ConveyorController.cs +++ b/Content.Server/Physics/Controllers/ConveyorController.cs @@ -104,7 +104,7 @@ namespace Content.Server.Physics.Controllers public IEnumerable<(EntityUid, TransformComponent)> GetEntitiesToMove(ConveyorComponent comp, TransformComponent xform) { - if (!_mapManager.TryGetGrid(xform.GridID, out var grid) || + if (!_mapManager.TryGetGrid(xform.GridEntityId, out var grid) || !grid.TryGetTileRef(xform.Coordinates, out var tile)) yield break; var tileAABB = _lookup.GetLocalBounds(tile, grid.TileSize).Enlarged(0.01f); diff --git a/Content.Server/Physics/Controllers/MoverController.cs b/Content.Server/Physics/Controllers/MoverController.cs index b2f905ed95..cd24fcf4b9 100644 --- a/Content.Server/Physics/Controllers/MoverController.cs +++ b/Content.Server/Physics/Controllers/MoverController.cs @@ -66,7 +66,7 @@ namespace Content.Server.Physics.Controllers if (pilot.Console == null) continue; _excludedMobs.Add(mover.Owner); - var gridId = xform.GridID; + var gridId = xform.GridEntityId; // This tries to see if the grid is a shuttle if (!_mapManager.TryGetGrid(gridId, out var grid) || !EntityManager.TryGetComponent(grid.GridEntityId, out ShuttleComponent? shuttleComponent)) continue; diff --git a/Content.Server/Power/EntitySystems/CableSystem.Placer.cs b/Content.Server/Power/EntitySystems/CableSystem.Placer.cs index c0d01783be..36d685892d 100644 --- a/Content.Server/Power/EntitySystems/CableSystem.Placer.cs +++ b/Content.Server/Power/EntitySystems/CableSystem.Placer.cs @@ -2,6 +2,7 @@ using Content.Server.Power.Components; using Content.Server.Stack; using Content.Shared.Interaction; using Content.Shared.Maps; +using Robust.Shared.Map; namespace Content.Server.Power.EntitySystems; @@ -18,7 +19,7 @@ public sealed partial class CableSystem if (component.CablePrototypeId == null) return; - if(!_mapManager.TryGetGrid(args.ClickLocation.GetGridId(EntityManager), out var grid)) + if(!_mapManager.TryGetGrid(args.ClickLocation.GetGridEntityId(EntityManager), out var grid)) return; var snapPos = grid.TileIndicesFor(args.ClickLocation); diff --git a/Content.Server/Power/EntitySystems/CableVisSystem.cs b/Content.Server/Power/EntitySystems/CableVisSystem.cs index ea231ba238..4d5e109bec 100644 --- a/Content.Server/Power/EntitySystems/CableVisSystem.cs +++ b/Content.Server/Power/EntitySystems/CableVisSystem.cs @@ -29,7 +29,7 @@ namespace Content.Server.Power.EntitySystems return; var transform = Transform(uid); - if (!_mapManager.TryGetGrid(transform.GridID, out var grid)) + if (!_mapManager.TryGetGrid(transform.GridEntityId, out var grid)) return; var mask = WireVisDirFlags.None; diff --git a/Content.Server/Power/EntitySystems/ExtensionCableSystem.cs b/Content.Server/Power/EntitySystems/ExtensionCableSystem.cs index 5bd563b27e..3235ebd48f 100644 --- a/Content.Server/Power/EntitySystems/ExtensionCableSystem.cs +++ b/Content.Server/Power/EntitySystems/ExtensionCableSystem.cs @@ -48,7 +48,7 @@ namespace Content.Server.Power.EntitySystems var xform = Transform(uid); // If grid deleting no need to update power. - if (_mapManager.TryGetGrid(xform.GridID, out var grid)) + if (_mapManager.TryGetGrid(xform.GridEntityId, out var grid)) { if (MetaData(grid.GridEntityId).EntityLifeStage > EntityLifeStage.MapInitialized) return; } @@ -120,7 +120,7 @@ namespace Content.Server.Power.EntitySystems var xform = Transform(owner); var coordinates = xform.Coordinates; - if (!_mapManager.TryGetGrid(xform.GridID, out var grid)) + if (!_mapManager.TryGetGrid(xform.GridEntityId, out var grid)) yield break; var nearbyEntities = grid.GetCellsInSquareArea(coordinates, (int) Math.Ceiling(range / grid.TileSize)); @@ -238,7 +238,7 @@ namespace Content.Server.Power.EntitySystems private bool TryFindAvailableProvider(EntityUid owner, float range, [NotNullWhen(true)] out ExtensionCableProviderComponent? foundProvider, TransformComponent? xform = null) { - if (!Resolve(owner, ref xform) || !_mapManager.TryGetGrid(xform.GridID, out var grid)) + if (!Resolve(owner, ref xform) || !_mapManager.TryGetGrid(xform.GridEntityId, out var grid)) { foundProvider = null; return false; diff --git a/Content.Server/Power/NodeGroups/ApcNet.cs b/Content.Server/Power/NodeGroups/ApcNet.cs index 2e7c0476fa..ef2cadaf16 100644 --- a/Content.Server/Power/NodeGroups/ApcNet.cs +++ b/Content.Server/Power/NodeGroups/ApcNet.cs @@ -21,7 +21,7 @@ namespace Content.Server.Power.NodeGroups void QueueNetworkReconnect(); - GridId? GridId { get; } + EntityUid? GridId { get; } } [NodeGroup(NodeGroupID.Apc)] @@ -41,7 +41,7 @@ namespace Content.Server.Power.NodeGroups private IEnumerable AllReceivers => Providers.SelectMany(provider => provider.LinkedReceivers); - GridId? IApcNet.GridId => GridId; + EntityUid? IApcNet.GridId => GridId; [ViewVariables] public PowerState.Network NetworkNode { get; } = new(); diff --git a/Content.Server/Shuttles/EntitySystems/DockingSystem.cs b/Content.Server/Shuttles/EntitySystems/DockingSystem.cs index 6fcfdaae4d..ef06cf58ca 100644 --- a/Content.Server/Shuttles/EntitySystems/DockingSystem.cs +++ b/Content.Server/Shuttles/EntitySystems/DockingSystem.cs @@ -99,7 +99,7 @@ namespace Content.Server.Shuttles.EntitySystems // Assume the docking port itself (and its body) is valid - if (!_mapManager.TryGetGrid(dockingXform.GridID, out var grid) || + if (!_mapManager.TryGetGrid(dockingXform.GridEntityId, out var grid) || !HasComp(grid.GridEntityId)) return null; var transform = body.GetTransform(); @@ -128,7 +128,7 @@ namespace Content.Server.Shuttles.EntitySystems while (enumerator.MoveNext(out var otherGrid)) { - if (otherGrid.Index == dockingXform.GridID) continue; + if (otherGrid.GridEntityId == dockingXform.GridEntityId) continue; foreach (var ent in otherGrid.GetAnchoredEntities(enlargedAABB)) { @@ -200,8 +200,8 @@ namespace Content.Server.Shuttles.EntitySystems dockA.DockedWith = null; // If these grids are ever invalid then need to look at fixing ordering for unanchored events elsewhere. - var gridAUid = _mapManager.GetGrid(EntityManager.GetComponent(dockA.Owner).GridID).GridEntityId; - var gridBUid = _mapManager.GetGrid(EntityManager.GetComponent(dockB.Owner).GridID).GridEntityId; + var gridAUid = _mapManager.GetGrid(EntityManager.GetComponent(dockA.Owner).GridEntityId).GridEntityId; + var gridBUid = _mapManager.GetGrid(EntityManager.GetComponent(dockB.Owner).GridEntityId).GridEntityId; var msg = new UndockEvent { @@ -338,8 +338,8 @@ namespace Content.Server.Shuttles.EntitySystems var dockAXform = EntityManager.GetComponent(dockA.Owner); var dockBXform = EntityManager.GetComponent(dockB.Owner); - var gridA = _mapManager.GetGrid(dockAXform.GridID).GridEntityId; - var gridB = _mapManager.GetGrid(dockBXform.GridID).GridEntityId; + var gridA = _mapManager.GetGrid(dockAXform.GridEntityId).GridEntityId; + var gridB = _mapManager.GetGrid(dockBXform.GridEntityId).GridEntityId; SharedJointSystem.LinearStiffness( 2f, diff --git a/Content.Server/Shuttles/EntitySystems/ShuttleConsoleSystem.cs b/Content.Server/Shuttles/EntitySystems/ShuttleConsoleSystem.cs index b6c6ab55b1..3f3b186b0f 100644 --- a/Content.Server/Shuttles/EntitySystems/ShuttleConsoleSystem.cs +++ b/Content.Server/Shuttles/EntitySystems/ShuttleConsoleSystem.cs @@ -45,7 +45,7 @@ namespace Content.Server.Shuttles.EntitySystems var xform = EntityManager.GetComponent(uid); // Maybe move mode onto the console instead? - if (!_mapManager.TryGetGrid(xform.GridID, out var grid) || + if (!_mapManager.TryGetGrid(xform.GridEntityId, out var grid) || !EntityManager.TryGetComponent(grid.GridEntityId, out ShuttleComponent? shuttle)) return; InteractionVerb verb = new() @@ -65,7 +65,7 @@ namespace Content.Server.Shuttles.EntitySystems if (!Resolve(consoleComponent.Owner, ref consoleXform)) return; - if (!consoleXform.Anchored || consoleXform.GridID != EntityManager.GetComponent(shuttleComponent.Owner).GridID) return; + if (!consoleXform.Anchored || consoleXform.GridEntityId != EntityManager.GetComponent(shuttleComponent.Owner).GridEntityId) return; switch (shuttleComponent.Mode) { diff --git a/Content.Server/Shuttles/EntitySystems/SpaceGarbageSystem.cs b/Content.Server/Shuttles/EntitySystems/SpaceGarbageSystem.cs index 96429ccf41..59518b6a94 100644 --- a/Content.Server/Shuttles/EntitySystems/SpaceGarbageSystem.cs +++ b/Content.Server/Shuttles/EntitySystems/SpaceGarbageSystem.cs @@ -20,7 +20,7 @@ public sealed class SpaceGarbageSystem : EntitySystem var ourXform = Transform(args.OurFixture.Body.Owner); var otherXform = Transform(args.OtherFixture.Body.Owner); - if (ourXform.GridID == otherXform.GridID || + if (ourXform.GridEntityId == otherXform.GridEntityId || args.OtherFixture.Body.BodyType != BodyType.Static) return; QueueDel(uid); diff --git a/Content.Server/Shuttles/EntitySystems/ThrusterSystem.cs b/Content.Server/Shuttles/EntitySystems/ThrusterSystem.cs index 48de1666c9..fda51ecd39 100644 --- a/Content.Server/Shuttles/EntitySystems/ThrusterSystem.cs +++ b/Content.Server/Shuttles/EntitySystems/ThrusterSystem.cs @@ -103,7 +103,7 @@ namespace Content.Server.Shuttles.EntitySystems if (e.NewTile.IsSpace(_tileDefManager) || !e.OldTile.IsSpace(_tileDefManager)) return; var tilePos = e.NewTile.GridIndices; - var grid = _mapManager.GetGrid(e.NewTile.GridIndex); + var grid = _mapManager.GetGrid(e.NewTile.GridUid); var xformQuery = GetEntityQuery(); var thrusterQuery = GetEntityQuery(); @@ -126,7 +126,7 @@ namespace Content.Server.Shuttles.EntitySystems if (new Vector2i((int) direction.X, (int) direction.Y) != new Vector2i(x, y)) continue; - DisableThruster(ent.Value, thruster, xform.GridID); + DisableThruster(ent.Value, thruster, xform.GridEntityId); } } } @@ -147,7 +147,7 @@ namespace Content.Server.Shuttles.EntitySystems if (!component.Enabled || component.Type != ThrusterType.Linear || !EntityManager.TryGetComponent(uid, out TransformComponent? xform) || - !_mapManager.TryGetGrid(xform.GridID, out var grid) || + !_mapManager.TryGetGrid(xform.GridEntityId, out var grid) || !EntityManager.TryGetComponent(grid.GridEntityId, out ShuttleComponent? shuttleComponent)) { return; @@ -243,7 +243,7 @@ namespace Content.Server.Shuttles.EntitySystems { if (component.IsOn || !Resolve(uid, ref xform) || - !_mapManager.TryGetGrid(xform.GridID, out var grid)) return; + !_mapManager.TryGetGrid(xform.GridEntityId, out var grid)) return; component.IsOn = true; @@ -304,13 +304,13 @@ namespace Content.Server.Shuttles.EntitySystems public void DisableThruster(EntityUid uid, ThrusterComponent component, TransformComponent? xform = null, Angle? angle = null) { if (!Resolve(uid, ref xform)) return; - DisableThruster(uid, component, xform.GridID, xform); + DisableThruster(uid, component, xform.GridEntityId, xform); } /// /// Tries to disable the thruster. /// - public void DisableThruster(EntityUid uid, ThrusterComponent component, GridId gridId, TransformComponent? xform = null, Angle? angle = null) + public void DisableThruster(EntityUid uid, ThrusterComponent component, EntityUid gridId, TransformComponent? xform = null, Angle? angle = null) { if (!component.IsOn || !Resolve(uid, ref xform) || @@ -383,7 +383,7 @@ namespace Content.Server.Shuttles.EntitySystems private bool NozzleExposed(TransformComponent xform) { var (x, y) = xform.LocalPosition + xform.LocalRotation.Opposite().ToWorldVec(); - var tile = _mapManager.GetGrid(xform.GridID).GetTileRef(new Vector2i((int) Math.Floor(x), (int) Math.Floor(y))); + var tile = _mapManager.GetGrid(xform.GridEntityId).GetTileRef(new Vector2i((int) Math.Floor(x), (int) Math.Floor(y))); return tile.Tile.IsSpace(); } diff --git a/Content.Server/Sound/EmitSoundSystem.cs b/Content.Server/Sound/EmitSoundSystem.cs index 7a9461b736..901a1f76e1 100644 --- a/Content.Server/Sound/EmitSoundSystem.cs +++ b/Content.Server/Sound/EmitSoundSystem.cs @@ -46,7 +46,7 @@ namespace Content.Server.Sound private void HandleEmitSoundOnLand(EntityUid eUI, BaseEmitSoundComponent component, LandEvent arg) { if (!TryComp(eUI, out var xform) || - !_mapManager.TryGetGrid(xform.GridID, out var grid)) return; + !_mapManager.TryGetGrid(xform.GridEntityId, out var grid)) return; var tile = grid.GetTileRef(xform.Coordinates); diff --git a/Content.Server/Station/Systems/StationSystem.cs b/Content.Server/Station/Systems/StationSystem.cs index 7635e6a27b..0bd3fcab66 100644 --- a/Content.Server/Station/Systems/StationSystem.cs +++ b/Content.Server/Station/Systems/StationSystem.cs @@ -86,9 +86,9 @@ public sealed class StationSystem : EntitySystem private void OnPostGameMapLoad(PostGameMapLoad ev) { - var dict = new Dictionary>(); + var dict = new Dictionary>(); - void AddGrid(string station, GridId grid) + void AddGrid(string station, EntityUid grid) { if (dict.ContainsKey(station)) { @@ -96,7 +96,7 @@ public sealed class StationSystem : EntitySystem } else { - dict[station] = new List {grid}; + dict[station] = new List {grid}; } } @@ -104,7 +104,7 @@ public sealed class StationSystem : EntitySystem foreach (var grid in ev.Grids) { // We still setup the grid - if (!TryComp(_mapManager.GetGridEuid(grid), out var becomesStation)) + if (!TryComp(grid, out var becomesStation)) continue; AddGrid(becomesStation.Id, grid); @@ -123,7 +123,7 @@ public sealed class StationSystem : EntitySystem // Iterate over all PartOfStation foreach (var grid in ev.Grids) { - if (!TryComp(_mapManager.GetGridEuid(grid), out var partOfStation)) + if (!TryComp(grid, out var partOfStation)) continue; AddGrid(partOfStation.Id, grid); @@ -136,7 +136,7 @@ public sealed class StationSystem : EntitySystem stationConfig = ev.GameMap.Stations[id]; else _sawmill.Error($"The station {id} in map {ev.GameMap.ID} does not have an associated station config!"); - InitializeNewStation(stationConfig, gridIds.Select(x => _mapManager.GetGridEuid(x)), ev.StationName); + InitializeNewStation(stationConfig, gridIds, ev.StationName); } } @@ -222,11 +222,11 @@ public sealed class StationSystem : EntitySystem var stationMember = AddComp(mapGrid); stationMember.Station = station; - stationData.Grids.Add(gridComponent.GridIndex); + stationData.Grids.Add(gridComponent.Owner); - RaiseLocalEvent(station, new StationGridAddedEvent(gridComponent.GridIndex, false)); + RaiseLocalEvent(station, new StationGridAddedEvent(gridComponent.Owner, false)); - _sawmill.Info($"Adding grid {mapGrid}:{gridComponent.GridIndex} to station {Name(station)} ({station})"); + _sawmill.Info($"Adding grid {mapGrid}:{gridComponent.Owner} to station {Name(station)} ({station})"); } /// @@ -245,10 +245,10 @@ public sealed class StationSystem : EntitySystem throw new ArgumentException("Tried to use a non-station entity as a station!", nameof(station)); RemComp(mapGrid); - stationData.Grids.Remove(gridComponent.GridIndex); + stationData.Grids.Remove(gridComponent.Owner); - RaiseLocalEvent(station, new StationGridRemovedEvent(gridComponent.GridIndex)); - _sawmill.Info($"Removing grid {mapGrid}:{gridComponent.GridIndex} from station {Name(station)} ({station})"); + RaiseLocalEvent(station, new StationGridRemovedEvent(gridComponent.Owner)); + _sawmill.Info($"Removing grid {mapGrid}:{gridComponent.Owner} from station {Name(station)} ({station})"); } /// @@ -317,15 +317,13 @@ public sealed class StationSystem : EntitySystem return CompOrNull(entity)?.Station; } - if (xform.GridID == GridId.Invalid) + if (xform.GridEntityId == EntityUid.Invalid) { Logger.Debug("A"); return null; } - var grid = _mapManager.GetGridEuid(xform.GridID); - - return CompOrNull(grid)?.Station; + return CompOrNull(xform.GridEntityId)?.Station; } } @@ -356,7 +354,7 @@ public sealed class StationGridAddedEvent : EntityEventArgs /// /// ID of the grid added to the station. /// - public GridId GridId; + public EntityUid GridId; /// /// Indicates that the event was fired during station setup, @@ -364,7 +362,7 @@ public sealed class StationGridAddedEvent : EntityEventArgs /// public bool IsSetup; - public StationGridAddedEvent(GridId gridId, bool isSetup) + public StationGridAddedEvent(EntityUid gridId, bool isSetup) { GridId = gridId; IsSetup = isSetup; @@ -380,9 +378,9 @@ public sealed class StationGridRemovedEvent : EntityEventArgs /// /// ID of the grid removed from the station. /// - public GridId GridId; + public EntityUid GridId; - public StationGridRemovedEvent(GridId gridId) + public StationGridRemovedEvent(EntityUid gridId) { GridId = gridId; } diff --git a/Content.Server/StationEvents/Events/GasLeak.cs b/Content.Server/StationEvents/Events/GasLeak.cs index e033425b47..fa5984fdc1 100644 --- a/Content.Server/StationEvents/Events/GasLeak.cs +++ b/Content.Server/StationEvents/Events/GasLeak.cs @@ -118,13 +118,13 @@ namespace Content.Server.StationEvents.Events if (!_foundTile || _targetGrid == default || _entityManager.Deleted(_targetGrid) || - !atmosphereSystem.IsSimulatedGrid(_entityManager.GetComponent(_targetGrid).GridID)) + !atmosphereSystem.IsSimulatedGrid(_entityManager.GetComponent(_targetGrid).GridEntityId)) { Running = false; return; } - var environment = atmosphereSystem.GetTileMixture(_entityManager.GetComponent(_targetGrid).GridID, _targetTile, true); + var environment = atmosphereSystem.GetTileMixture(_entityManager.GetComponent(_targetGrid).GridEntityId, _targetTile, true); environment?.AdjustMoles(_leakGas, LeakCooldown * _molesPerSecond); } @@ -151,14 +151,14 @@ namespace Content.Server.StationEvents.Events if (!_foundTile || _targetGrid == default || (!_entityManager.EntityExists(_targetGrid) ? EntityLifeStage.Deleted : _entityManager.GetComponent(_targetGrid).EntityLifeStage) >= EntityLifeStage.Deleted || - !atmosphereSystem.IsSimulatedGrid(_entityManager.GetComponent(_targetGrid).GridID)) + !atmosphereSystem.IsSimulatedGrid(_entityManager.GetComponent(_targetGrid).GridEntityId)) { return; } // Don't want it to be so obnoxious as to instantly murder anyone in the area but enough that // it COULD start potentially start a bigger fire. - atmosphereSystem.HotspotExpose(_entityManager.GetComponent(_targetGrid).GridID, _targetTile, 700f, 50f, true); + atmosphereSystem.HotspotExpose(_entityManager.GetComponent(_targetGrid).GridEntityId, _targetTile, 700f, 50f, true); SoundSystem.Play(Filter.Pvs(_targetCoords), "/Audio/Effects/sparks4.ogg", _targetCoords); } } diff --git a/Content.Server/StationEvents/Events/RadiationStorm.cs b/Content.Server/StationEvents/Events/RadiationStorm.cs index a89a6ce851..a573ca0f56 100644 --- a/Content.Server/StationEvents/Events/RadiationStorm.cs +++ b/Content.Server/StationEvents/Events/RadiationStorm.cs @@ -86,7 +86,7 @@ namespace Content.Server.StationEvents.Events if (!_entityManager.TryGetComponent(stationEnt, out var grid)) return; - if (mapManager.IsGridPaused(grid.GridIndex)) + if (mapManager.IsGridPaused(grid.Owner)) return; SpawnPulse(grid.Grid); @@ -112,7 +112,7 @@ namespace Content.Server.StationEvents.Events private bool TryFindRandomGrid(IMapGrid mapGrid, out EntityCoordinates coordinates) { - if (!mapGrid.Index.IsValid()) + if (!(mapGrid.GridEntityId).IsValid()) { coordinates = default; return false; diff --git a/Content.Server/SubFloor/SubFloorHideSystem.cs b/Content.Server/SubFloor/SubFloorHideSystem.cs index 6c6faeb133..00162d6698 100644 --- a/Content.Server/SubFloor/SubFloorHideSystem.cs +++ b/Content.Server/SubFloor/SubFloorHideSystem.cs @@ -17,7 +17,7 @@ public sealed class SubFloorHideSystem : SharedSubFloorHideSystem // No teleporting entities through floor tiles when anchoring them. var xform = Transform(uid); - if (MapManager.TryGetGrid(xform.GridID, out var grid) + if (MapManager.TryGetGrid(xform.GridEntityId, out var grid) && HasFloorCover(grid, grid.TileIndicesFor(xform.Coordinates))) { args.Cancel(); diff --git a/Content.Server/Tools/ToolSystem.TilePrying.cs b/Content.Server/Tools/ToolSystem.TilePrying.cs index 4e9aee14ef..7e939125f9 100644 --- a/Content.Server/Tools/ToolSystem.TilePrying.cs +++ b/Content.Server/Tools/ToolSystem.TilePrying.cs @@ -47,7 +47,7 @@ public sealed partial class ToolSystem if (!TryComp(component.Owner, out var tool) && component.ToolComponentNeeded) return false; - if (!_mapManager.TryGetGrid(clickLocation.GetGridId(EntityManager), out var mapGrid)) + if (!_mapManager.TryGetGrid(clickLocation.GetGridEntityId(EntityManager), out var mapGrid)) return false; var tile = mapGrid.GetTileRef(clickLocation); diff --git a/Content.Shared/AI/SharedAiDebug.cs b/Content.Shared/AI/SharedAiDebug.cs index add5f7da58..7297ed1e84 100644 --- a/Content.Shared/AI/SharedAiDebug.cs +++ b/Content.Shared/AI/SharedAiDebug.cs @@ -140,10 +140,10 @@ namespace Content.Shared.AI [Serializable, NetSerializable] public sealed class ReachableChunkRegionsDebugMessage : EntityEventArgs { - public GridId GridId { get; } + public EntityUid GridId { get; } public Dictionary>> Regions { get; } - public ReachableChunkRegionsDebugMessage(GridId gridId, Dictionary>> regions) + public ReachableChunkRegionsDebugMessage(EntityUid gridId, Dictionary>> regions) { GridId = gridId; Regions = regions; @@ -153,11 +153,11 @@ namespace Content.Shared.AI [Serializable, NetSerializable] public sealed class ReachableCacheDebugMessage : EntityEventArgs { - public GridId GridId { get; } + public EntityUid GridId { get; } public Dictionary> Regions { get; } public bool Cached { get; } - public ReachableCacheDebugMessage(GridId gridId, Dictionary> regions, bool cached) + public ReachableCacheDebugMessage(EntityUid gridId, Dictionary> regions, bool cached) { GridId = gridId; Regions = regions; diff --git a/Content.Shared/Atmos/EntitySystems/SharedAtmosDebugOverlaySystem.cs b/Content.Shared/Atmos/EntitySystems/SharedAtmosDebugOverlaySystem.cs index cc955000a9..21394f7ab5 100644 --- a/Content.Shared/Atmos/EntitySystems/SharedAtmosDebugOverlaySystem.cs +++ b/Content.Shared/Atmos/EntitySystems/SharedAtmosDebugOverlaySystem.cs @@ -1,4 +1,4 @@ -using Robust.Shared.Map; +using Robust.Shared.Map; using Robust.Shared.Serialization; namespace Content.Shared.Atmos.EntitySystems @@ -37,13 +37,13 @@ namespace Content.Shared.Atmos.EntitySystems [Serializable, NetSerializable] public sealed class AtmosDebugOverlayMessage : EntityEventArgs { - public GridId GridId { get; } + public EntityUid GridId { get; } public Vector2i BaseIdx { get; } // LocalViewRange*LocalViewRange public AtmosDebugOverlayData[] OverlayData { get; } - public AtmosDebugOverlayMessage(GridId gridIndices, Vector2i baseIdx, AtmosDebugOverlayData[] overlayData) + public AtmosDebugOverlayMessage(EntityUid gridIndices, Vector2i baseIdx, AtmosDebugOverlayData[] overlayData) { GridId = gridIndices; BaseIdx = baseIdx; diff --git a/Content.Shared/Atmos/EntitySystems/SharedGasTileOverlaySystem.cs b/Content.Shared/Atmos/EntitySystems/SharedGasTileOverlaySystem.cs index b4d7c0aa8b..b79fef0534 100644 --- a/Content.Shared/Atmos/EntitySystems/SharedGasTileOverlaySystem.cs +++ b/Content.Shared/Atmos/EntitySystems/SharedGasTileOverlaySystem.cs @@ -1,4 +1,4 @@ -using Robust.Shared.Map; +using Robust.Shared.Map; using Robust.Shared.Serialization; namespace Content.Shared.Atmos.EntitySystems @@ -84,11 +84,11 @@ namespace Content.Shared.Atmos.EntitySystems [Serializable, NetSerializable] public sealed class GasOverlayMessage : EntityEventArgs { - public GridId GridId { get; } + public EntityUid GridId { get; } public List<(Vector2i, GasOverlayData)> OverlayData { get; } - public GasOverlayMessage(GridId gridIndices, List<(Vector2i,GasOverlayData)> overlayData) + public GasOverlayMessage(EntityUid gridIndices, List<(Vector2i,GasOverlayData)> overlayData) { GridId = gridIndices; OverlayData = overlayData; diff --git a/Content.Shared/Atmos/GasOverlayChunk.cs b/Content.Shared/Atmos/GasOverlayChunk.cs index 453cf26304..6dbbdc26af 100644 --- a/Content.Shared/Atmos/GasOverlayChunk.cs +++ b/Content.Shared/Atmos/GasOverlayChunk.cs @@ -10,7 +10,7 @@ namespace Content.Shared.Atmos /// /// Grid for this chunk /// - public GridId GridIndices { get; } + public EntityUid GridIndices { get; } /// /// Origin of this chunk @@ -21,7 +21,7 @@ namespace Content.Shared.Atmos public GameTick LastUpdate { get; private set; } - public GasOverlayChunk(GridId gridIndices, Vector2i vector2i) + public GasOverlayChunk(EntityUid gridIndices, Vector2i vector2i) { GridIndices = gridIndices; Vector2i = vector2i; diff --git a/Content.Shared/Decals/DecalChunkUpdateEvent.cs b/Content.Shared/Decals/DecalChunkUpdateEvent.cs index 53877192a6..ada0a3cb43 100644 --- a/Content.Shared/Decals/DecalChunkUpdateEvent.cs +++ b/Content.Shared/Decals/DecalChunkUpdateEvent.cs @@ -6,7 +6,7 @@ namespace Content.Shared.Decals [Serializable, NetSerializable] public sealed class DecalChunkUpdateEvent : EntityEventArgs { - public Dictionary>> Data = new(); - public Dictionary> RemovedChunks = new(); + public Dictionary>> Data = new(); + public Dictionary> RemovedChunks = new(); } } diff --git a/Content.Shared/Decals/SharedDecalSystem.cs b/Content.Shared/Decals/SharedDecalSystem.cs index b67767758a..cf3b406442 100644 --- a/Content.Shared/Decals/SharedDecalSystem.cs +++ b/Content.Shared/Decals/SharedDecalSystem.cs @@ -13,7 +13,7 @@ namespace Content.Shared.Decals [Dependency] private readonly IConfigurationManager _configurationManager = default!; [Dependency] protected readonly IMapManager MapManager = default!; - protected readonly Dictionary> ChunkIndex = new(); + protected readonly Dictionary> ChunkIndex = new(); public const int ChunkSize = 32; public static Vector2i GetChunkIndices(Vector2 coordinates) => new ((int) Math.Floor(coordinates.X / ChunkSize), (int) Math.Floor(coordinates.Y / ChunkSize)); @@ -54,14 +54,11 @@ namespace Content.Shared.Decals protected DecalGridComponent.DecalGridChunkCollection DecalGridChunkCollection(EntityUid gridEuid) => Comp(gridEuid).ChunkCollection; - protected DecalGridComponent.DecalGridChunkCollection DecalGridChunkCollection(GridId gridId) => - Comp(MapManager.GetGridEuid(gridId)).ChunkCollection; protected Dictionary> ChunkCollection(EntityUid gridEuid) => DecalGridChunkCollection(gridEuid).ChunkCollection; - protected Dictionary> ChunkCollection(GridId gridId) => DecalGridChunkCollection(gridId).ChunkCollection; - protected virtual void DirtyChunk(GridId id, Vector2i chunkIndices) {} + protected virtual void DirtyChunk(EntityUid id, Vector2i chunkIndices) {} - protected bool RemoveDecalInternal(GridId gridId, uint uid) + protected bool RemoveDecalInternal(EntityUid gridId, uint uid) { if (!RemoveDecalHook(gridId, uid)) return false; @@ -84,7 +81,7 @@ namespace Content.Shared.Decals return true; } - protected virtual bool RemoveDecalHook(GridId gridId, uint uid) => true; + protected virtual bool RemoveDecalHook(EntityUid gridId, uint uid) => true; protected (Box2 view, MapId mapId) CalcViewBounds(in EntityUid euid, TransformComponent xform) { diff --git a/Content.Shared/Explosion/ExplosionEvents.cs b/Content.Shared/Explosion/ExplosionEvents.cs index aef746d391..24ca038894 100644 --- a/Content.Shared/Explosion/ExplosionEvents.cs +++ b/Content.Shared/Explosion/ExplosionEvents.cs @@ -35,7 +35,7 @@ public sealed class ExplosionEvent : EntityEventArgs public MapCoordinates Epicenter; public Dictionary>? SpaceTiles; - public Dictionary>> Tiles; + public Dictionary>> Tiles; public List Intensity; @@ -53,7 +53,7 @@ public sealed class ExplosionEvent : EntityEventArgs string typeID, List intensity, Dictionary>? spaceTiles, - Dictionary>> tiles, + Dictionary>> tiles, Matrix3 spaceMatrix, ushort spaceTileSize) { diff --git a/Content.Shared/Friction/SharedTileFrictionController.cs b/Content.Shared/Friction/SharedTileFrictionController.cs index 42f6505ee8..44bf49bd28 100644 --- a/Content.Shared/Friction/SharedTileFrictionController.cs +++ b/Content.Shared/Friction/SharedTileFrictionController.cs @@ -161,7 +161,7 @@ namespace Content.Shared.Friction // TODO: Make IsWeightless event-based; we already have grid traversals tracked so just raise events if (body.Owner.IsWeightless(body, coords, _mapManager) || - !_mapManager.TryGetGrid(xform.GridID, out var grid)) + !_mapManager.TryGetGrid(xform.GridEntityId, out var grid)) return 0.0f; if (!coords.IsValid(EntityManager)) return 0.0f; diff --git a/Content.Shared/Gravity/GravityChangedMessage.cs b/Content.Shared/Gravity/GravityChangedMessage.cs index 0437af98d8..6ecd9473a4 100644 --- a/Content.Shared/Gravity/GravityChangedMessage.cs +++ b/Content.Shared/Gravity/GravityChangedMessage.cs @@ -4,13 +4,13 @@ namespace Content.Shared.Gravity { public sealed class GravityChangedMessage : EntityEventArgs { - public GravityChangedMessage(GridId changedGridIndex, bool newGravityState) + public GravityChangedMessage(EntityUid changedGridIndex, bool newGravityState) { HasGravity = newGravityState; ChangedGridIndex = changedGridIndex; } - public GridId ChangedGridIndex { get; } + public EntityUid ChangedGridIndex { get; } public bool HasGravity { get; } } diff --git a/Content.Shared/Maps/TurfHelpers.cs b/Content.Shared/Maps/TurfHelpers.cs index c54555735a..cd1c45e2ea 100644 --- a/Content.Shared/Maps/TurfHelpers.cs +++ b/Content.Shared/Maps/TurfHelpers.cs @@ -12,7 +12,7 @@ namespace Content.Shared.Maps /// /// Attempts to get the turf at map indices with grid id or null if no such turf is found. /// - public static TileRef GetTileRef(this Vector2i vector2i, GridId gridId, IMapManager? mapManager = null) + public static TileRef GetTileRef(this Vector2i vector2i, EntityUid gridId, IMapManager? mapManager = null) { if (!gridId.IsValid()) return default; @@ -41,7 +41,7 @@ namespace Content.Shared.Maps mapManager ??= IoCManager.Resolve(); - if (!mapManager.TryGetGrid(coordinates.GetGridId(entityManager), out var grid)) + if (!mapManager.TryGetGrid(coordinates.GetGridEntityId(entityManager), out var grid)) return null; @@ -95,10 +95,10 @@ namespace Content.Shared.Maps entityManager ??= IoCManager.Resolve(); mapManager ??= IoCManager.Resolve(); - return coordinates.ToVector2i(entityManager, mapManager).PryTile(coordinates.GetGridId(entityManager)); + return coordinates.ToVector2i(entityManager, mapManager).PryTile(coordinates.GetGridEntityId(entityManager)); } - public static bool PryTile(this Vector2i indices, GridId gridId, + public static bool PryTile(this Vector2i indices, EntityUid gridId, IMapManager? mapManager = null, ITileDefinitionManager? tileDefinitionManager = null, IEntityManager? entityManager = null) { mapManager ??= IoCManager.Resolve(); @@ -128,7 +128,7 @@ namespace Content.Shared.Maps if (!tileDef.CanCrowbar) return false; - var mapGrid = mapManager.GetGrid(tileRef.GridIndex); + var mapGrid = mapManager.GetGrid(tileRef.GridUid); var plating = tileDefinitionManager[tileDef.BaseTurfs[^1]]; @@ -139,7 +139,7 @@ namespace Content.Shared.Maps var (x, y) = ((mapGrid.TileSize - 2 * margin) * robustRandom.NextFloat() + margin, (mapGrid.TileSize - 2 * margin) * robustRandom.NextFloat() + margin); //Actually spawn the relevant tile item at the right position and give it some random offset. - var tileItem = entityManager.SpawnEntity(tileDef.ItemDropPrototypeName, indices.ToEntityCoordinates(tileRef.GridIndex, mapManager).Offset(new Vector2(x, y))); + var tileItem = entityManager.SpawnEntity(tileDef.ItemDropPrototypeName, indices.ToEntityCoordinates(tileRef.GridUid, mapManager).Offset(new Vector2(x, y))); entityManager.GetComponent(tileItem).LocalRotation = robustRandom.NextDouble() * Math.Tau; return true; @@ -156,7 +156,7 @@ namespace Content.Shared.Maps if (!GetWorldTileBox(turf, out var worldBox)) return Enumerable.Empty(); - return lookupSystem.GetEntitiesIntersecting(turf.GridIndex, worldBox, flags); + return lookupSystem.GetEntitiesIntersecting(turf.GridUid, worldBox, flags); } /// @@ -175,7 +175,7 @@ namespace Content.Shared.Maps /// /// Helper that returns all entities in a turf. /// - public static IEnumerable GetEntitiesInTile(this Vector2i indices, GridId gridId, LookupFlags flags = LookupFlags.Anchored, EntityLookupSystem? lookupSystem = null) + public static IEnumerable GetEntitiesInTile(this Vector2i indices, EntityUid gridId, LookupFlags flags = LookupFlags.Anchored, EntityLookupSystem? lookupSystem = null) { return GetEntitiesInTile(indices.GetTileRef(gridId), flags, lookupSystem); } @@ -196,7 +196,7 @@ namespace Content.Shared.Maps return false; var entManager = IoCManager.Resolve(); - var query = physics.GetEntitiesIntersecting(turf.GridIndex, worldBox); + var query = physics.GetEntitiesIntersecting(turf.GridUid, worldBox); foreach (var ent in query) { @@ -218,7 +218,7 @@ namespace Content.Shared.Maps { mapManager ??= IoCManager.Resolve(); - return turf.GridIndices.ToEntityCoordinates(turf.GridIndex, mapManager); + return turf.GridIndices.ToEntityCoordinates(turf.GridUid, mapManager); } /// @@ -228,7 +228,7 @@ namespace Content.Shared.Maps { var map = IoCManager.Resolve(); - if (map.TryGetGrid(turf.GridIndex, out var tileGrid)) + if (map.TryGetGrid(turf.GridUid, out var tileGrid)) { // This is scaled to 90 % so it doesn't encompass walls on other tiles. var tileBox = Box2.UnitCentered.Scale(0.9f); diff --git a/Content.Shared/Movement/Components/MovementIgnoreGravityComponent.cs b/Content.Shared/Movement/Components/MovementIgnoreGravityComponent.cs index 0ff9abf896..1c40b0a90f 100644 --- a/Content.Shared/Movement/Components/MovementIgnoreGravityComponent.cs +++ b/Content.Shared/Movement/Components/MovementIgnoreGravityComponent.cs @@ -45,7 +45,7 @@ namespace Content.Shared.Movement.Components return ignoreGravityComponent.Weightless; var transform = entityManager.GetComponent(entity); - var gridId = transform.GridID; + var gridId = transform.GridEntityId; if (!gridId.IsValid()) { diff --git a/Content.Shared/Movement/SharedMoverController.cs b/Content.Shared/Movement/SharedMoverController.cs index af2a214e33..36423ae8c9 100644 --- a/Content.Shared/Movement/SharedMoverController.cs +++ b/Content.Shared/Movement/SharedMoverController.cs @@ -68,7 +68,7 @@ namespace Content.Shared.Movement protected Angle GetParentGridAngle(TransformComponent xform, IMoverComponent mover) { - if (xform.GridID == GridId.Invalid || !_mapManager.TryGetGrid(xform.GridID, out var grid)) + if (xform.GridEntityId == EntityUid.Invalid || !_mapManager.TryGetGrid(xform.GridEntityId, out var grid)) return mover.LastGridAngle; return grid.WorldRotation; @@ -90,11 +90,11 @@ namespace Content.Shared.Movement var worldTotal = _relativeMovement ? parentRotation.RotateVec(total) : total; - if (transform.GridID != GridId.Invalid) + if (transform.GridEntityId == EntityUid.Invalid) mover.LastGridAngle = parentRotation; if (worldTotal != Vector2.Zero) - transform.LocalRotation = transform.GridID != GridId.Invalid + transform.LocalRotation = transform.GridEntityId == EntityUid.Invalid ? total.ToWorldAngle() : worldTotal.ToWorldAngle(); @@ -130,7 +130,7 @@ namespace Content.Shared.Movement if (!touching) { - if (xform.GridID != GridId.Invalid) + if (xform.GridEntityId != EntityUid.Invalid) mover.LastGridAngle = GetParentGridAngle(xform, mover); xform.WorldRotation = physicsComponent.LinearVelocity.GetDir().ToAngle(); @@ -152,14 +152,14 @@ namespace Content.Shared.Movement if (weightless) worldTotal *= mobMover.WeightlessStrength; - if (xform.GridID != GridId.Invalid) + if (xform.GridEntityId != EntityUid.Invalid) mover.LastGridAngle = parentRotation; if (worldTotal != Vector2.Zero) { // This should have its event run during island solver soooo xform.DeferUpdates = true; - xform.LocalRotation = xform.GridID != GridId.Invalid + xform.LocalRotation = xform.GridEntityId != EntityUid.Invalid ? total.ToWorldAngle() : worldTotal.ToWorldAngle(); xform.DeferUpdates = false; @@ -231,7 +231,7 @@ namespace Content.Shared.Movement if (!CanSound() || !_tags.HasTag(mover.Owner, "FootstepSound")) return false; var coordinates = xform.Coordinates; - var gridId = coordinates.GetGridId(EntityManager); + var gridId = coordinates.GetGridEntityId(EntityManager); var distanceNeeded = mover.Sprinting ? StepSoundMoveDistanceRunning : StepSoundMoveDistanceWalking; // Handle footsteps. @@ -254,7 +254,7 @@ namespace Content.Shared.Movement return false; } - DebugTools.Assert(gridId != GridId.Invalid); + DebugTools.Assert(gridId != EntityUid.Invalid); mobMover.LastPosition = coordinates; if (mobMover.StepSoundDistance < distanceNeeded) return false; @@ -272,7 +272,7 @@ namespace Content.Shared.Movement return TryGetFootstepSound(gridId, coordinates, out variation, out sound); } - private bool TryGetFootstepSound(GridId gridId, EntityCoordinates coordinates, out float variation, [NotNullWhen(true)] out string? sound) + private bool TryGetFootstepSound(EntityUid gridId, EntityCoordinates coordinates, out float variation, [NotNullWhen(true)] out string? sound) { variation = 0f; sound = null; diff --git a/Content.Shared/SubFloor/SharedSubFloorHideSystem.cs b/Content.Shared/SubFloor/SharedSubFloorHideSystem.cs index 4640d47bf7..40bfdc6b3c 100644 --- a/Content.Shared/SubFloor/SharedSubFloorHideSystem.cs +++ b/Content.Shared/SubFloor/SharedSubFloorHideSystem.cs @@ -79,7 +79,7 @@ namespace Content.Shared.SubFloor if (args.NewTile.Tile.IsEmpty) return; // Anything that was here will be unanchored anyways. - UpdateTile(MapManager.GetGrid(args.NewTile.GridIndex), args.NewTile.GridIndices); + UpdateTile(MapManager.GetGrid(args.NewTile.GridUid), args.NewTile.GridIndices); } private void OnGridChanged(GridModifiedEvent args) @@ -98,7 +98,7 @@ namespace Content.Shared.SubFloor if (!Resolve(uid, ref component, ref xform)) return; - if (xform.Anchored && MapManager.TryGetGrid(xform.GridID, out var grid)) + if (xform.Anchored && MapManager.TryGetGrid(xform.GridEntityId, out var grid)) component.IsUnderCover = HasFloorCover(grid, grid.TileIndicesFor(xform.Coordinates)); else component.IsUnderCover = false; diff --git a/Content.Shared/SubFloor/TrayScannerSystem.cs b/Content.Shared/SubFloor/TrayScannerSystem.cs index c54ca958f2..c9441f3662 100644 --- a/Content.Shared/SubFloor/TrayScannerSystem.cs +++ b/Content.Shared/SubFloor/TrayScannerSystem.cs @@ -208,7 +208,7 @@ public sealed class TrayScannerSystem : EntitySystem // For now, limiting to the scanner's own grid. We could do a grid-lookup, but then what do we do if one grid // flies away, while the scanner's local-position remains unchanged? - if (_mapManager.TryGetGrid(transform.GridID, out var grid)) + if (_mapManager.TryGetGrid(transform.GridEntityId, out var grid)) { foreach (var entity in grid.GetAnchoredEntities(worldBox)) {