diff --git a/Content.Server/Cargo/Systems/PricingSystem.cs b/Content.Server/Cargo/Systems/PricingSystem.cs index 1aca4b9d8b..eed4b0e788 100644 --- a/Content.Server/Cargo/Systems/PricingSystem.cs +++ b/Content.Server/Cargo/Systems/PricingSystem.cs @@ -45,15 +45,17 @@ public sealed class PricingSystem : EntitySystem foreach (var gid in args) { - if (!EntityUid.TryParse(gid, out var gridId) || !gridId.IsValid()) + if (!int.TryParse(gid, out var i) || i <= 0) { shell.WriteError($"Invalid grid ID \"{gid}\"."); continue; } + var gridId = new GridId(i); + if (!_mapManager.TryGetGrid(gridId, out var mapGrid)) { - shell.WriteError($"Grid \"{gridId}\" doesn't exist."); + shell.WriteError($"Grid \"{i}\" doesn't exist."); continue; } diff --git a/Content.Server/Coordinates/Helpers/SnapgridHelper.cs b/Content.Server/Coordinates/Helpers/SnapgridHelper.cs index f643d33227..7790794d9f 100644 --- a/Content.Server/Coordinates/Helpers/SnapgridHelper.cs +++ b/Content.Server/Coordinates/Helpers/SnapgridHelper.cs @@ -15,11 +15,11 @@ namespace Content.Server.Coordinates.Helpers { IoCManager.Resolve(ref entMan, ref mapManager); - var gridIdOpt = coordinates.GetGridUid(entMan); + var gridId = coordinates.GetGridId(entMan); var tileSize = 1f; - if (gridIdOpt is EntityUid gridId && gridId.IsValid()) + if (gridId.IsValid()) { var grid = mapManager.GetGrid(gridId); tileSize = grid.TileSize; diff --git a/Content.Server/Explosion/EntitySystems/ExplosionSystem.GridMap.cs b/Content.Server/Explosion/EntitySystems/ExplosionSystem.GridMap.cs index 48ccf4bff7..48e19acd13 100644 --- a/Content.Server/Explosion/EntitySystems/ExplosionSystem.GridMap.cs +++ b/Content.Server/Explosion/EntitySystems/ExplosionSystem.GridMap.cs @@ -18,7 +18,7 @@ public sealed partial class ExplosionSystem : EntitySystem /// private void OnGridStartup(GridStartupEvent ev) { - var grid = _mapManager.GetGrid(ev.EntityUid); + var grid = _mapManager.GetGrid(ev.GridId); Dictionary edges = new(); _gridEdges[ev.EntityUid] = edges; diff --git a/Content.Server/ImmovableRod/ImmovableRodSystem.cs b/Content.Server/ImmovableRod/ImmovableRodSystem.cs index f980419de8..b1c2acbca6 100644 --- a/Content.Server/ImmovableRod/ImmovableRodSystem.cs +++ b/Content.Server/ImmovableRod/ImmovableRodSystem.cs @@ -27,7 +27,7 @@ public sealed class ImmovableRodSystem : EntitySystem { if (!rod.DestroyTiles) continue; - if (!_map.TryGetGrid(trans.GridUid, out var grid)) + if (!_map.TryGetGrid(trans.GridID, out var grid)) continue; grid.SetTile(trans.Coordinates, Tile.Empty); diff --git a/Content.Server/RCD/Systems/RCDSystem.cs b/Content.Server/RCD/Systems/RCDSystem.cs index 485737dfe5..885869b252 100644 --- a/Content.Server/RCD/Systems/RCDSystem.cs +++ b/Content.Server/RCD/Systems/RCDSystem.cs @@ -73,18 +73,17 @@ namespace Content.Server.RCD.Systems return; // Try to fix it (i.e. if clicking on space) // Note: Ideally there'd be a better way, but there isn't right now. - var gridIdOpt = clickLocationMod.GetGridUid(EntityManager); - if (!(gridIdOpt is EntityUid gridId) || !gridId.IsValid()) + var gridID = clickLocationMod.GetGridId(EntityManager); + if (!gridID.IsValid()) { clickLocationMod = clickLocationMod.AlignWithClosestGridTile(); - gridIdOpt = clickLocationMod.GetGridUid(EntityManager); - // Check if fixing it failed / get final grid ID - if (!(gridIdOpt is EntityUid gridId2) || !gridId2.IsValid()) - return; - gridId = gridId2; + gridID = clickLocationMod.GetGridId(EntityManager); } + // Check if fixing it failed / get final grid ID + if (!gridID.IsValid()) + return; - var mapGrid = _mapManager.GetGrid(gridId); + var mapGrid = _mapManager.GetGrid(gridID); var tile = mapGrid.GetTileRef(clickLocationMod); var snapPos = mapGrid.TileIndicesFor(clickLocationMod); @@ -115,14 +114,14 @@ namespace Content.Server.RCD.Systems //Floor mode just needs the tile to be a space tile (subFloor) case RcdMode.Floors: mapGrid.SetTile(snapPos, new Tile(_tileDefinitionManager["FloorSteel"].TileId)); - _adminLogger.Add(LogType.RCD, LogImpact.High, $"{ToPrettyString(args.User):user} used RCD to set grid: {tile.GridUid} {snapPos} to FloorSteel"); + _adminLogger.Add(LogType.RCD, LogImpact.High, $"{ToPrettyString(args.User):user} used RCD to set grid: {tile.GridIndex} {snapPos} to FloorSteel"); break; //We don't want to place a space tile on something that's already a space tile. Let's do the inverse of the last check. case RcdMode.Deconstruct: if (!tile.IsBlockedTurf(true)) //Delete the turf { mapGrid.SetTile(snapPos, Tile.Empty); - _adminLogger.Add(LogType.RCD, LogImpact.High, $"{ToPrettyString(args.User):user} used RCD to set grid: {tile.GridUid} tile: {snapPos} to space"); + _adminLogger.Add(LogType.RCD, LogImpact.High, $"{ToPrettyString(args.User):user} used RCD to set grid: {tile.GridIndex} tile: {snapPos} to space"); } else //Delete what the user targeted { @@ -138,12 +137,12 @@ namespace Content.Server.RCD.Systems case RcdMode.Walls: var ent = EntityManager.SpawnEntity("WallSolid", mapGrid.GridTileToLocal(snapPos)); Transform(ent).LocalRotation = Angle.Zero; // Walls always need to point south. - _adminLogger.Add(LogType.RCD, LogImpact.High, $"{ToPrettyString(args.User):user} used RCD to spawn {ToPrettyString(ent)} at {snapPos} on grid {mapGrid.GridEntityId}"); + _adminLogger.Add(LogType.RCD, LogImpact.High, $"{ToPrettyString(args.User):user} used RCD to spawn {ToPrettyString(ent)} at {snapPos} on grid {mapGrid.Index}"); break; case RcdMode.Airlock: var airlock = EntityManager.SpawnEntity("Airlock", mapGrid.GridTileToLocal(snapPos)); Transform(airlock).LocalRotation = Transform(rcd.Owner).LocalRotation; //Now apply icon smoothing. - _adminLogger.Add(LogType.RCD, LogImpact.High, $"{ToPrettyString(args.User):user} used RCD to spawn {ToPrettyString(airlock)} at {snapPos} on grid {mapGrid.GridEntityId}"); + _adminLogger.Add(LogType.RCD, LogImpact.High, $"{ToPrettyString(args.User):user} used RCD to spawn {ToPrettyString(airlock)} at {snapPos} on grid {mapGrid.Index}"); break; default: args.Handled = true; diff --git a/Content.Server/Salvage/SalvageSystem.cs b/Content.Server/Salvage/SalvageSystem.cs index 8d74d11fef..5d3cd11a1c 100644 --- a/Content.Server/Salvage/SalvageSystem.cs +++ b/Content.Server/Salvage/SalvageSystem.cs @@ -40,7 +40,7 @@ namespace Content.Server.Salvage private static readonly int SalvageLocationPlaceAttempts = 16; // TODO: This is probably not compatible with multi-station - private readonly Dictionary _salvageGridStates = new(); + private readonly Dictionary _salvageGridStates = new(); public override void Initialize() { @@ -66,9 +66,10 @@ namespace Content.Server.Salvage private void OnGridRemoval(GridRemovalEvent ev) { // If we ever want to give magnets names, and announce them individually, we would need to loop this, before removing it. - if (_salvageGridStates.Remove(ev.EntityUid)) + if (_salvageGridStates.Remove(ev.GridId)) { - if (EntityManager.TryGetComponent(ev.EntityUid, out var salvComp) && salvComp.SpawnerMagnet != null) + var gridUid = _mapManager.GetGridEuid(ev.GridId); + if (EntityManager.TryGetComponent(gridUid, out var salvComp) && salvComp.SpawnerMagnet != null) Report(salvComp.SpawnerMagnet.Owner, salvComp.SpawnerMagnet.SalvageChannel, "salvage-system-announcement-spawn-magnet-lost"); // For the very unlikely possibility that the salvage magnet was on a salvage, we will not return here } @@ -91,7 +92,7 @@ namespace Content.Server.Salvage if (component.MagnetState.StateType == MagnetStateType.Inactive) return; var magnetTranform = EntityManager.GetComponent(component.Owner); - if (!(magnetTranform.GridUid is EntityUid gridId) || !_salvageGridStates.TryGetValue(gridId, out var salvageGridState)) + if (!_salvageGridStates.TryGetValue(magnetTranform.GridID, out var salvageGridState)) { return; } @@ -129,8 +130,8 @@ namespace Content.Server.Salvage args.PushMarkup(Loc.GetString("salvage-system-magnet-examined-cooling-down")); break; case MagnetStateType.Holding: - var magnetTransform = EntityManager.GetComponent(component.Owner); - if (magnetTransform.GridUid is EntityUid gridId && _salvageGridStates.TryGetValue(gridId, out var salvageGridState)) + var magnetTranform = EntityManager.GetComponent(component.Owner); + if (_salvageGridStates.TryGetValue(magnetTranform.GridID, out var salvageGridState)) { var remainingTime = component.MagnetState.Until - salvageGridState.CurrentTime; args.PushMarkup(Loc.GetString("salvage-system-magnet-examined-active", ("timeLeft", Math.Ceiling(remainingTime.TotalSeconds)))); @@ -159,13 +160,12 @@ namespace Content.Server.Salvage { case MagnetStateType.Inactive: ShowPopup("salvage-system-report-activate-success", component, user); + var magnetTranform = EntityManager.GetComponent(component.Owner); SalvageGridState? gridState; - var magnetTransform = EntityManager.GetComponent(component.Owner); - EntityUid gridId = magnetTransform.GridUid ?? throw new InvalidOperationException("Magnet had no grid associated"); - if (!_salvageGridStates.TryGetValue(gridId, out gridState)) + if (!_salvageGridStates.TryGetValue(magnetTranform.GridID, out gridState)) { gridState = new SalvageGridState(); - _salvageGridStates[gridId] = gridState; + _salvageGridStates[magnetTranform.GridID] = gridState; } gridState.ActiveMagnets.Add(component); component.MagnetState = new MagnetState(MagnetStateType.Attaching, gridState.CurrentTime + AttachingTime); @@ -227,7 +227,8 @@ namespace Content.Server.Salvage angle = Angle.Zero; var tsc = Transform(component.Owner); coords = new EntityCoordinates(component.Owner, component.Offset).ToMap(EntityManager); - if (_mapManager.TryGetGrid(tsc.GridUid, out var magnetGrid)) + var grid = tsc.GridID; + if (_mapManager.TryGetGrid(grid, out var magnetGrid)) { angle = magnetGrid.WorldRotation; } diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs index 216139a4b0..1402dabf7c 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs @@ -97,7 +97,7 @@ public sealed partial class ShuttleSystem foreach (var other in _mapManager.FindGridsIntersecting(xform.MapID, bounds)) { - if (grid.Owner == other.GridEntityId || + if (grid.GridIndex == other.Index || !bodyQuery.TryGetComponent(other.GridEntityId, out var body) || body.Mass < ShuttleFTLMassThreshold) continue;