Remove Explicit GridId References (#8315)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Acruid
2022-06-11 18:54:41 -07:00
committed by GitHub
parent 846321cebb
commit 4f9be42f40
131 changed files with 531 additions and 588 deletions

View File

@@ -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<IMapManager>();
var entMan = IoCManager.Resolve<IEntityManager>();
var random = IoCManager.Resolve<IRobustRandom>();
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);
}
}
}

View File

@@ -52,7 +52,7 @@ namespace Content.Server.Administration.Commands
var mapManager = IoCManager.Resolve<IMapManager>();
var currentMap = entMan.GetComponent<TransformComponent>(playerEntity).MapID;
var currentGrid = entMan.GetComponent<TransformComponent>(playerEntity).GridID;
var currentGrid = entMan.GetComponent<TransformComponent>(playerEntity).GridEntityId;
var found = entMan.EntityQuery<WarpPointComponent>(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<TransformComponent>(playerEntity).Coordinates = found;
if (entMan.TryGetComponent(playerEntity, out IPhysBody? physics))