Skip to content

Commit

Permalink
AddPsionicPower Command (#807)
Browse files Browse the repository at this point in the history
# 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 <[email protected]>
Co-authored-by: DEATHB4DEFEAT <[email protected]>
  • Loading branch information
VMSolidus and DEATHB4DEFEAT authored Sep 8, 2024
1 parent 7d0cbc6 commit 272ae47
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Content.Server/Psionics/PsionicsCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<IEntityManager>();
var psionicPowers = IoCManager.Resolve<PsionicAbilitiesSystem>();
var protoMan = IoCManager.Resolve<IPrototypeManager>();

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<PsionicPowerPrototype>(args[1], out var powerProto))
{
shell.WriteError(Loc.GetString("addpsionicpower-args-two-error"));
return;
}

entMan.EnsureComponent<PsionicComponent>(uid, out var psionic);
psionicPowers.InitializePsionicPower(uid, powerProto, psionic);
}
}
5 changes: 5 additions & 0 deletions Resources/Locale/en-US/psionics/psionic-commands.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 272ae47

Please sign in to comment.