mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* Scope creep my ass * why was this shit not pushed???? * gone... * fix that * review plus buildd * asfsafsafsafsafas * grug * burber * I'll fix this later * shrimply die * also this * it's snerf or snuthin * assaads * round snend * aaaa * fix this shit for real * actually, don't start GameRules until MapInit now that I think aboot it. * forgot u * don't actually need this part nullable * Deffer comp removal * one liner * do that too * chungus * Honestly makes more sense here, plus WHY are we doing all that shit on "GameRuleAdded" rather than GameRuleStarted(?) * deferred removal :V * aaaaaaaaaaaaaaa * whhop * Whoop * better * landmine that I placed for myself then forgot about lmao * cleanup * FUCKING `!` * gotovo * amogus * please don't check by metadata I beg * waawsasfdfsasfa * sfafsasfafsas * fdsaasffsasfa * code * fix * fasasffasfasfsad * chungaas * I may be stupid * gra * graaaaaaaaaaaaaaaaa * comment * gra * clearing is not predicted and would require major refactors, so don't cache on client. * lame shit :P * last holes * nukeopsfsafsasafsfafsa * why was that shit public bruh * bubrbgwahrghfaka * dynamic * revert change that did nothing lmao
95 lines
3.5 KiB
C#
95 lines
3.5 KiB
C#
using System.Numerics;
|
|
using Content.Server.GameTicking;
|
|
using Content.Shared.Administration;
|
|
using Content.Shared.Maps;
|
|
using Robust.Shared.Console;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Server.Administration.Commands
|
|
{
|
|
[AdminCommand(AdminFlags.Round | AdminFlags.Spawn)]
|
|
public sealed partial class LoadGameMapCommand : LocalizedEntityCommands
|
|
{
|
|
[Dependency] private IPrototypeManager _prototypeManager = default!;
|
|
[Dependency] private ServerGameTicker _gameTicker = default!;
|
|
[Dependency] private SharedMapSystem _mapSystem = default!;
|
|
|
|
public override string Command => "loadgamemap";
|
|
|
|
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
{
|
|
if (args.Length is not (2 or 4 or 5))
|
|
{
|
|
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
|
|
return;
|
|
}
|
|
|
|
if (!_prototypeManager.TryIndex<GameMapPrototype>(args[1], out var gameMap))
|
|
{
|
|
shell.WriteError($"The given map prototype {args[0]} is invalid.");
|
|
return;
|
|
}
|
|
|
|
if (!int.TryParse(args[0], out var mapId))
|
|
return;
|
|
|
|
var stationName = args.Length == 5 ? args[4] : null;
|
|
|
|
Vector2? offset = null;
|
|
if (args.Length >= 4)
|
|
offset = new Vector2(int.Parse(args[2]), int.Parse(args[3]));
|
|
|
|
var id = new MapId(mapId);
|
|
|
|
var grids = _mapSystem.MapExists(id)
|
|
? _gameTicker.MergeGameMap(gameMap, id, stationName: stationName, offset: offset)
|
|
: _gameTicker.LoadGameMapWithId(gameMap, id, stationName: stationName, offset: offset);
|
|
|
|
shell.WriteLine($"Loaded {grids.Count} grids.");
|
|
}
|
|
|
|
public override 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)]
|
|
public sealed partial class ListGameMaps : LocalizedCommands
|
|
{
|
|
[Dependency] private IPrototypeManager _prototypeManager = default!;
|
|
|
|
public override string Command => "listgamemaps";
|
|
|
|
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
{
|
|
if (args.Length != 0)
|
|
{
|
|
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
|
|
return;
|
|
}
|
|
foreach (var prototype in _prototypeManager.EnumeratePrototypes<GameMapPrototype>())
|
|
{
|
|
shell.WriteLine($"{prototype.ID} - {prototype.MapName}");
|
|
}
|
|
}
|
|
}
|
|
}
|