Update maploader to support loading onto an existing map (#10748)
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
using System.Linq;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Maps;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Server.Maps;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.ContentPack;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
@@ -15,7 +17,7 @@ namespace Content.Server.Administration.Commands
|
||||
|
||||
public string Description => "Loads the given game map at the given coordinates.";
|
||||
|
||||
public string Help => "loadgamemap <gamemap> <mapid> [<x> <y> [<name>]] ";
|
||||
public string Help => "loadgamemap <mapid> <gamemap> [<x> <y> [<name>]] ";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
@@ -29,11 +31,16 @@ namespace Content.Server.Administration.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (prototypeManager.TryIndex<GameMapPrototype>(args[0], out var gameMap))
|
||||
if (prototypeManager.TryIndex<GameMapPrototype>(args[1], out var gameMap))
|
||||
{
|
||||
if (!int.TryParse(args[1], out var mapId)) return;
|
||||
if (!int.TryParse(args[0], out var mapId))
|
||||
return;
|
||||
|
||||
var loadOptions = new MapLoadOptions()
|
||||
{
|
||||
LoadMap = false,
|
||||
};
|
||||
|
||||
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))
|
||||
@@ -48,6 +55,28 @@ namespace Content.Server.Administration.Commands
|
||||
shell.WriteError($"The given map prototype {args[0]} is invalid.");
|
||||
}
|
||||
}
|
||||
|
||||
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
||||
{
|
||||
switch (args.Length)
|
||||
{
|
||||
case 1:
|
||||
return CompletionResult.FromHint(Loc.GetString("cmd-hint-savemap-id"));
|
||||
case 2:
|
||||
var opts = CompletionHelper.PrototypeIDs<GameMapPrototype>();
|
||||
return CompletionResult.FromHintOptions(opts, Loc.GetString("cmd-hint-savemap-path"));
|
||||
case 3:
|
||||
return CompletionResult.FromHint(Loc.GetString("cmd-hint-loadmap-x-position"));
|
||||
case 4:
|
||||
return CompletionResult.FromHint(Loc.GetString("cmd-hint-loadmap-y-position"));
|
||||
case 5:
|
||||
return CompletionResult.FromHint(Loc.GetString("cmd-hint-loadmap-rotation"));
|
||||
case 6:
|
||||
return CompletionResult.FromHint(Loc.GetString("cmd-hint-loadmap-uids"));
|
||||
}
|
||||
|
||||
return CompletionResult.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
[AdminCommand(AdminFlags.Round | AdminFlags.Spawn)]
|
||||
|
||||
@@ -114,6 +114,8 @@ namespace Content.Server.GameTicking
|
||||
/// <returns>All loaded entities and grids.</returns>
|
||||
public (IReadOnlyList<EntityUid>, IReadOnlyList<EntityUid>) LoadGameMap(GameMapPrototype map, MapId targetMapId, MapLoadOptions? loadOptions, string? stationName = null)
|
||||
{
|
||||
// Okay I specifically didn't set LoadMap here because this is typically called onto a new map.
|
||||
// whereas the command can also be used on an existing map.
|
||||
var loadOpts = loadOptions ?? new MapLoadOptions();
|
||||
|
||||
var ev = new PreGameMapLoad(targetMapId, map, loadOpts);
|
||||
|
||||
Reference in New Issue
Block a user