Fix maploading once and for all. (#7501)
This commit is contained in:
@@ -1,14 +1,9 @@
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Maps;
|
||||
using Content.Server.Roles;
|
||||
using Content.Server.Station;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Server.Maps;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.Administration.Commands
|
||||
@@ -25,9 +20,8 @@ namespace Content.Server.Administration.Commands
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||
var mapLoader = IoCManager.Resolve<IMapLoader>();
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var stationSystem = entityManager.EntitySysManager.GetEntitySystem<StationSystem>();
|
||||
var gameTicker = entityManager.EntitySysManager.GetEntitySystem<GameTicker>();
|
||||
|
||||
if (args.Length is not (2 or 4 or 5))
|
||||
{
|
||||
@@ -37,25 +31,17 @@ namespace Content.Server.Administration.Commands
|
||||
|
||||
if (prototypeManager.TryIndex<GameMapPrototype>(args[0], out var gameMap))
|
||||
{
|
||||
if (int.TryParse(args[1], out var mapId))
|
||||
if (!int.TryParse(args[1], out var mapId)) return;
|
||||
|
||||
var loadOptions = new MapLoadOptions();
|
||||
var stationName = args.Length == 5 ? args[4] : null;
|
||||
|
||||
if (args.Length >= 4 && int.TryParse(args[2], out var x) && int.TryParse(args[3], out var y))
|
||||
{
|
||||
var gameMapEnt = mapLoader.LoadBlueprint(new MapId(mapId), gameMap.MapPath.ToString());
|
||||
if (gameMapEnt is null)
|
||||
{
|
||||
shell.WriteError($"Failed to create the given game map, is the path {gameMap.MapPath} correct?");
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Length >= 4 && int.TryParse(args[2], out var x) && int.TryParse(args[3], out var y))
|
||||
{
|
||||
var transform = entityManager.GetComponent<TransformComponent>(gameMapEnt.GridEntityId);
|
||||
transform.WorldPosition = new Vector2(x, y);
|
||||
}
|
||||
|
||||
var stationName = args.Length == 5 ? args[4] : null;
|
||||
|
||||
stationSystem.InitialSetupStationGrid(gameMapEnt.GridEntityId, gameMap, stationName);
|
||||
loadOptions.Offset = new Vector2(x, y);
|
||||
}
|
||||
var (ents, grids) = gameTicker.LoadGameMap(gameMap, new MapId(mapId), loadOptions, stationName);
|
||||
shell.WriteLine($"Loaded {ents.Count} entities and {grids.Count} grids.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user