]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
UnlockNode command to LEC. (#38751)
authorKyle Tyo <36606155+VerinSenpai@users.noreply.github.com>
Fri, 4 Jul 2025 23:14:12 +0000 (19:14 -0400)
committerGitHub <noreply@github.com>
Fri, 4 Jul 2025 23:14:12 +0000 (01:14 +0200)
* commit

* Update UnlockNodeCommand.cs

* commit

* move command locale to its own file.

* Update Content.Server/Xenoarchaeology/Artifact/UnlockNodeCommand.cs

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Content.Server/Xenoarchaeology/Artifact/UnlockNodeCommand.cs [new file with mode: 0644]
Content.Server/Xenoarchaeology/Artifact/XenoArtifactUnlockNodeCommand.cs [deleted file]
Resources/Locale/en-US/commands/unlocknode-command.ftl [new file with mode: 0644]
Resources/Locale/en-US/xenoarchaeology/artifact-component.ftl

diff --git a/Content.Server/Xenoarchaeology/Artifact/UnlockNodeCommand.cs b/Content.Server/Xenoarchaeology/Artifact/UnlockNodeCommand.cs
new file mode 100644 (file)
index 0000000..ea86186
--- /dev/null
@@ -0,0 +1,68 @@
+using Content.Server.Administration;
+using Content.Shared.Administration;
+using Content.Shared.Xenoarchaeology.Artifact.Components;
+using Robust.Shared.Console;
+
+namespace Content.Server.Xenoarchaeology.Artifact;
+
+/// <summary> Command for unlocking a specific node of a xeno artifact. </summary>
+[AdminCommand(AdminFlags.Debug)]
+public sealed class UnlockNodeCommand : LocalizedEntityCommands
+{
+    [Dependency] private readonly XenoArtifactSystem _artiSystem = default!;
+
+    public override string Command => "unlocknode";
+
+    public override void Execute(IConsoleShell shell, string argStr, string[] args)
+    {
+        if (args.Length != 2)
+        {
+            shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
+            return;
+        }
+
+        if (!NetEntity.TryParse(args[1], out var netNode) || !EntityManager.TryGetEntity(netNode, out var entityUid))
+        {
+            shell.WriteError(Loc.GetString("shell-could-not-find-entity-with-uid", ("uid", args[1])));
+            return;
+        }
+
+        _artiSystem.SetNodeUnlocked(entityUid.Value);
+    }
+
+    public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
+    {
+        switch (args.Length)
+        {
+            case 1:
+            {
+                var query = EntityManager.EntityQueryEnumerator<XenoArtifactComponent>();
+                var completionOptions = new List<CompletionOption>();
+                while (query.MoveNext(out var uid, out _))
+                {
+                    completionOptions.Add(new CompletionOption(uid.ToString()));
+                }
+
+                return CompletionResult.FromHintOptions(completionOptions, Loc.GetString("cmd-unlocknode-artifact-hint"));
+            }
+            case 2 when
+                NetEntity.TryParse(args[0], out var netEnt) &&
+                EntityManager.TryGetEntity(netEnt, out var artifactUid) &&
+                EntityManager.TryGetComponent<XenoArtifactComponent>(artifactUid, out var comp):
+            {
+                var result = new List<CompletionOption>();
+                foreach (var node in _artiSystem.GetAllNodes((artifactUid.Value, comp)))
+                {
+                    var metaData = EntityManager.MetaQuery.Comp(artifactUid.Value);
+                    var entityUidStr = EntityManager.GetNetEntity(node).ToString();
+                    var completionOption = new CompletionOption(entityUidStr, metaData.EntityName);
+                    result.Add(completionOption);
+                }
+
+                return CompletionResult.FromHintOptions(result, Loc.GetString("cmd-unlocknode-node-hint"));
+            }
+            default:
+                return CompletionResult.Empty;
+        }
+    }
+}
diff --git a/Content.Server/Xenoarchaeology/Artifact/XenoArtifactUnlockNodeCommand.cs b/Content.Server/Xenoarchaeology/Artifact/XenoArtifactUnlockNodeCommand.cs
deleted file mode 100644 (file)
index 1782619..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-using Content.Server.Administration;
-using Content.Shared.Administration;
-using Content.Shared.Xenoarchaeology.Artifact.Components;
-using Robust.Shared.Console;
-
-namespace Content.Server.Xenoarchaeology.Artifact;
-
-/// <summary> Command for unlocking specific node of xeno artifact. </summary>
-[AdminCommand(AdminFlags.Debug)]
-public sealed class XenoArtifactUnlockNodeCommand : LocalizedCommands
-{
-    [Dependency] private readonly EntityManager _entities = default!;
-
-    /// <inheritdoc />
-    public override string Command => "unlocknode";
-
-    /// <inheritdoc />
-    public override string Description => Loc.GetString("cmd-unlocknode-desc");
-
-    /// <inheritdoc />
-    public override string Help => Loc.GetString("cmd-unlocknode-help");
-
-    /// <inheritdoc />
-    public override void Execute(IConsoleShell shell, string argStr, string[] args)
-    {
-        if (args.Length != 2)
-        {
-            shell.WriteError(Loc.GetString("cmd-parse-failure-unlocknode-arg-num"));
-            return;
-        }
-
-        if (!NetEntity.TryParse(args[1], out var netNode))
-        {
-            shell.WriteError(Loc.GetString("cmd-parse-failure-unlocknode-invalid-entity"));
-            return;
-        }
-
-        if (!_entities.TryGetEntity(netNode, out var entityUid))
-        {
-            shell.WriteError(Loc.GetString("cmd-parse-failure-unlocknode-invalid-entity"));
-            return;
-        }
-        _entities.System<XenoArtifactSystem>()
-                 .SetNodeUnlocked(entityUid.Value);
-    }
-
-    /// <inheritdoc />
-    public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
-    {
-        if (args.Length == 1)
-        {
-            var query = _entities.EntityQueryEnumerator<XenoArtifactComponent>();
-            var completionOptions = new List<CompletionOption>();
-            while (query.MoveNext(out var uid, out _))
-            {
-                completionOptions.Add(new CompletionOption(uid.ToString()));
-            }
-
-            return CompletionResult.FromHintOptions(completionOptions, "<artifact uid>");
-        }
-
-        if (args.Length == 2 &&
-            NetEntity.TryParse(args[0], out var netEnt) &&
-            _entities.TryGetEntity(netEnt, out var artifactUid) &&
-            _entities.TryGetComponent<XenoArtifactComponent>(artifactUid, out var comp))
-        {
-            var artifactSystem = _entities.System<XenoArtifactSystem>();
-
-            var result = new List<CompletionOption>();
-            foreach (var node in artifactSystem.GetAllNodes((artifactUid.Value, comp)))
-            {
-                var metaData = _entities.MetaQuery.Comp(artifactUid.Value);
-                var entityUidStr = _entities.GetNetEntity(node)
-                                            .ToString();
-                var completionOption = new CompletionOption(entityUidStr, metaData.EntityName);
-                result.Add(completionOption);
-            }
-
-            return CompletionResult.FromHintOptions(result, "<node uid>");
-        }
-
-        return CompletionResult.Empty;
-    }
-}
diff --git a/Resources/Locale/en-US/commands/unlocknode-command.ftl b/Resources/Locale/en-US/commands/unlocknode-command.ftl
new file mode 100644 (file)
index 0000000..5a3b825
--- /dev/null
@@ -0,0 +1,4 @@
+cmd-unlocknode-desc = Unlocks a node on a given artifact
+cmd-unlocknode-help = unlocknode <artifact uid> <node uid>
+cmd-unlocknode-artifact-hint = <artifact uid>
+cmd-unlocknode-node-hint = <node uid>
index 50fa136928afb25c14ee103f95bb003335979ce5..90029b282c486acbccda48df810787b4978ef121 100644 (file)
@@ -1,10 +1,4 @@
-### Commands
-cmd-unlocknode-desc = Unlocks a node on a given artifact
-cmd-unlocknode-help = unlocknode <artifact uid> <node uid>
-cmd-parse-failure-unlocknode-arg-num = Incorrect number of args
-cmd-parse-failure-unlocknode-invalid-entity = Provided netEntity is not valid node
-
-### Verbs
+### Verbs
 artifact-verb-make-always-active = Make artifact always active
 artifact-verb-activate = Activate artifact