Update maploader to support loading onto an existing map (#10748)

This commit is contained in:
metalgearsloth
2022-09-14 14:05:48 +10:00
committed by GitHub
parent 8d3ab125b8
commit b3581d11c6
2 changed files with 35 additions and 4 deletions

View File

@@ -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)]