From 272ae471bd8ec22a887b4cbf1168d23870e13e21 Mon Sep 17 00:00:00 2001 From: VMSolidus Date: Sun, 8 Sep 2024 11:16:29 -0400 Subject: [PATCH] AddPsionicPower Command (#807) # Description This PR adds a new console command for directly adding psionic powers to an entity. Should an entity not already be psionic, this command will additionally make them psionic. # Changelog :cl: - add: A new console command, AddPsionicPower has been added. --------- Signed-off-by: VMSolidus Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com> --- Content.Server/Psionics/PsionicsCommands.cs | 38 +++++++++++++++++++ .../en-US/psionics/psionic-commands.ftl | 5 +++ 2 files changed, 43 insertions(+) diff --git a/Content.Server/Psionics/PsionicsCommands.cs b/Content.Server/Psionics/PsionicsCommands.cs index 5c273461f1e..2894343c66b 100644 --- a/Content.Server/Psionics/PsionicsCommands.cs +++ b/Content.Server/Psionics/PsionicsCommands.cs @@ -3,6 +3,9 @@ using Content.Shared.Abilities.Psionics; using Robust.Shared.Console; using Robust.Shared.Player; +using Content.Server.Abilities.Psionics; +using Robust.Shared.Prototypes; +using Content.Shared.Psionics; namespace Content.Server.Psionics; @@ -25,3 +28,38 @@ public async void Execute(IConsoleShell shell, string argStr, string[] args) } } } + +[AdminCommand(AdminFlags.Fun)] +public sealed class AddPsionicPowerCommand : IConsoleCommand +{ + public string Command => "addpsionicpower"; + public string Description => Loc.GetString("command-addpsionicpower-description"); + public string Help => Loc.GetString("command-addpsionicpower-help"); + public async void Execute(IConsoleShell shell, string argStr, string[] args) + { + var entMan = IoCManager.Resolve(); + var psionicPowers = IoCManager.Resolve(); + var protoMan = IoCManager.Resolve(); + + if (args.Length != 2) + { + shell.WriteError(Loc.GetString("shell-need-exactly-one-argument")); + return; + } + + if (!EntityUid.TryParse(args[0], out var uid)) + { + shell.WriteError(Loc.GetString("addpsionicpower-args-one-error")); + return; + } + + if (!protoMan.TryIndex(args[1], out var powerProto)) + { + shell.WriteError(Loc.GetString("addpsionicpower-args-two-error")); + return; + } + + entMan.EnsureComponent(uid, out var psionic); + psionicPowers.InitializePsionicPower(uid, powerProto, psionic); + } +} diff --git a/Resources/Locale/en-US/psionics/psionic-commands.ftl b/Resources/Locale/en-US/psionics/psionic-commands.ftl index e1110ef285e..34d12981de4 100644 --- a/Resources/Locale/en-US/psionics/psionic-commands.ftl +++ b/Resources/Locale/en-US/psionics/psionic-commands.ftl @@ -6,3 +6,8 @@ command-glimmerset-help = glimmerset (integer) command-lspsionic-description = List psionics. command-lspsionic-help = No arguments. + +command-addpsionicpower-description = Initialize an entity as Psionic with a given PowerPrototype +command-addpsionicpower-help = Argument 1 must be an EntityUid, and argument 2 must be a string matching the PrototypeId of a PsionicPower. +addpsionicpower-args-one-error = Argument 1 must be an EntityUid +addpsionicpower-args-two-error = Argument 2 must match the PrototypeId of a PsionicPower