From 20b175d9975b1a0cd461753e22f523ad1ed36e15 Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Sun, 19 Jul 2020 18:43:16 +0200 Subject: [PATCH] Add mapping command (#1411) Co-authored-by: Pieter-Jan Briers Co-authored-by: Pieter-Jan Briers --- Content.Client/Commands/DebugCommands.cs | 22 +++++++++++++ .../GameTicking/GameTickerCommands.cs | 32 +++++++++++++++++-- Resources/Groups/groups.yml | 2 ++ 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/Content.Client/Commands/DebugCommands.cs b/Content.Client/Commands/DebugCommands.cs index 30a844fdba..8dc1354b65 100644 --- a/Content.Client/Commands/DebugCommands.cs +++ b/Content.Client/Commands/DebugCommands.cs @@ -1,6 +1,7 @@ using Content.Client.GameObjects.EntitySystems; using Content.Client.Interfaces; using Content.Shared.GameObjects.Components.Markers; +using Robust.Client.Console.Commands; using Robust.Client.Interfaces.Console; using Robust.Client.Interfaces.GameObjects.Components; using Robust.Shared.GameObjects; @@ -59,4 +60,25 @@ namespace Content.Client.Commands return false; } } + + internal sealed class MappingCommand : IConsoleCommand + { + public string Command => "mapping"; + public string Description => "Creates and teleports you to a new uninitialized map for mapping."; + public string Help => $"Usage: {Command} "; + + public bool Execute(IDebugConsole console, params string[] args) + { + if (args.Length != 2) + { + console.AddLine(Help); + return false; + } + + console.Commands["togglelight"].Execute(console); + console.Commands["showwires"].Execute(console); + + return true; + } + } } diff --git a/Content.Server/GameTicking/GameTickerCommands.cs b/Content.Server/GameTicking/GameTickerCommands.cs index cb15158cf9..7d45bb1370 100644 --- a/Content.Server/GameTicking/GameTickerCommands.cs +++ b/Content.Server/GameTicking/GameTickerCommands.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using Content.Server.GameTicking; using Content.Server.Interfaces.GameTicking; using Content.Server.Players; using Content.Shared.Jobs; @@ -9,7 +8,7 @@ using Robust.Server.Interfaces.Player; using Robust.Shared.IoC; using Robust.Shared.Network; using Robust.Shared.Prototypes; -using Robust.Shared.Log; +using Robust.Shared.Utility; namespace Content.Server.GameTicking { @@ -293,4 +292,33 @@ namespace Content.Server.GameTicking shell.SendText(player, $"Forced the game to start with preset {name}."); } } + + class MappingCommand : IClientCommand + { + public string Command => "mapping"; + public string Description => "Creates and teleports you to a new uninitialized map for mapping."; + public string Help => $"Usage: {Command} "; + + public void Execute(IConsoleShell shell, IPlayerSession player, string[] args) + { + if (player == null) + { + shell.SendText(player, "Only players can use this command"); + return; + } + + if (args.Length != 2) + { + shell.SendText(player, Help); + return; + } + + shell.ExecuteCommand(player, $"addmap {args[0]} false"); + shell.ExecuteCommand(player, $"loadbp {args[0]} \"{CommandParsing.Escape(args[1])}\""); + shell.ExecuteCommand(player, $"aghost"); + shell.ExecuteCommand(player, $"tp 0 0 {args[0]}"); + + shell.SendText(player, $"Created unloaded map from file {args[1]} with id {args[0]}. Use \"savebp 4 foo.yml\" to save it."); + } + } } diff --git a/Resources/Groups/groups.yml b/Resources/Groups/groups.yml index 97efbcf5d3..53c2f38ae9 100644 --- a/Resources/Groups/groups.yml +++ b/Resources/Groups/groups.yml @@ -85,6 +85,7 @@ - hostlogin - deleteewc - asay + - mapping CanViewVar: true CanAdminPlace: true @@ -157,6 +158,7 @@ - deleteewc - sudo - asay + - mapping CanViewVar: true CanAdminPlace: true CanScript: true