Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anomaly commands #16179

Merged
merged 1 commit into from
May 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions Content.Server/Anomaly/AnomalySystem.Commands.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using Content.Server.Administration;
using Content.Shared.Administration;
using Content.Shared.Anomaly.Components;
using Robust.Shared.Console;

namespace Content.Server.Anomaly;

public sealed partial class AnomalySystem
{
[Dependency] private readonly IConsoleHost _consoleHost = default!;

public void InitializeCommands()
{
_consoleHost.RegisterCommand("pulseanomaly", Loc.GetString("anomaly-command-pulse"), "pulseanomaly <uid>",
PulseAnomalyCommand,
GetAnomalyCompletion);

_consoleHost.RegisterCommand("supercriticalanomaly", Loc.GetString("anomaly-command-supercritical"), "supercriticalanomaly <uid>",
SupercriticalAnomalyCommand,
GetAnomalyCompletion);
}

[AdminCommand(AdminFlags.Fun)]
private void PulseAnomalyCommand(IConsoleShell shell, string argstr, string[] args)
{
if (args.Length != 1)
shell.WriteError("Argument length must be 1");

if (!EntityUid.TryParse(args[0], out var uid))
return;

if (!TryComp<AnomalyComponent>(uid, out var anomaly))
return;

DoAnomalyPulse(uid, anomaly);
}

[AdminCommand(AdminFlags.Fun)]
private void SupercriticalAnomalyCommand(IConsoleShell shell, string argstr, string[] args)
{
if (args.Length != 1)
shell.WriteError("Argument length must be 1");

if (!EntityUid.TryParse(args[0], out var uid))
return;

if (!HasComp<AnomalyComponent>(uid))
return;

StartSupercriticalEvent(uid);
}

private CompletionResult GetAnomalyCompletion(IConsoleShell shell, string[] args)
{
return args.Length != 1
? CompletionResult.Empty
: CompletionResult.FromHintOptions(CompletionHelper.Components<AnomalyComponent>(args[0]), "<uid>");
}
}
3 changes: 2 additions & 1 deletion Content.Server/Anomaly/AnomalySystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Server.Anomaly.Components;
using Content.Server.Anomaly.Components;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Audio;
using Content.Server.Explosion.EntitySystems;
Expand Down Expand Up @@ -44,6 +44,7 @@ public override void Initialize()
InitializeGenerator();
InitializeScanner();
InitializeVessel();
InitializeCommands();
}

private void OnMapInit(EntityUid uid, AnomalyComponent component, MapInitEvent args)
Expand Down
2 changes: 2 additions & 0 deletions Resources/Locale/en-US/anomaly/anomaly.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ anomaly-generator-charges = {$charges ->
}
anomaly-generator-announcement = An anomaly has been generated!
anomaly-command-pulse = Pulses a target anomaly
anomaly-command-supercritical = Makes a target anomaly go supercritical
# Flavor text on the footer
anomaly-generator-flavor-left = Anomaly may spawn inside the operator.
Expand Down