Files
tbd-station-14/Content.Server/Commands/MachineLinking/SignalLinkerCommand.cs
Acruid 8b5d66050a Console Unify API Changes (#3059)
* Remove unused IChatCommand.

* Lots of refactoring into a shared context.

* Removed ICommonSession from server concmd Execute.

* Added argStr parameter to concmd execute.

* The execute function of client concmds now returns void, use the new shell.RemoteExecuteCommand function to forward commands.

* Finally move shells and commands into shared.

* Console commands can now be registered directly without a class in a shared context.

* Engine API Changes.

* Repair rebase damage.

* Update Submodule.
2021-02-01 16:49:43 -08:00

51 lines
1.7 KiB
C#

using Content.Server.Administration;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.Administration;
using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Commands.MachineLinking
{
[AdminCommand(AdminFlags.Debug)]
public class SignalLinkerCommand : IConsoleCommand
{
public string Command => "signallink";
public string Description => "Turns on signal linker mode. Click a transmitter to tune that signal and then click on each receiver to tune them to the transmitter signal.";
public string Help => "signallink (on/off)";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
bool? enable = null;
if (args.Length > 0)
{
if (args[0] == "on")
enable = true;
else if (args[0] == "off")
enable = false;
else if (bool.TryParse(args[0], out var boolean))
enable = boolean;
else if (int.TryParse(args[0], out var num))
{
if (num == 1)
enable = true;
else if (num == 0)
enable = false;
}
}
if (!IoCManager.Resolve<IEntitySystemManager>().TryGetEntitySystem<SignalLinkerSystem>(out var system))
{
return;
}
var ret = system.SignalLinkerKeybind(player.UserId, enable);
shell.WriteLine(ret ? "Enabled" : "Disabled");
}
}
}