Electrocute Command
This commit is contained in:
58
Content.Server/Electrocution/ElectrocuteCommand.cs
Normal file
58
Content.Server/Electrocution/ElectrocuteCommand.cs
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
using System;
|
||||||
|
using Content.Server.Administration;
|
||||||
|
using Content.Shared.Administration;
|
||||||
|
using Content.Shared.StatusEffect;
|
||||||
|
using Robust.Shared.Console;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Localization;
|
||||||
|
|
||||||
|
namespace Content.Server.Electrocution
|
||||||
|
{
|
||||||
|
[AdminCommand(AdminFlags.Fun)]
|
||||||
|
public class ElectrocuteCommand : IConsoleCommand
|
||||||
|
{
|
||||||
|
public string Command => "electrocute";
|
||||||
|
public string Description => Loc.GetString("electrocute-command-description");
|
||||||
|
public string Help => $"{Command} <uid> <seconds> <damage>";
|
||||||
|
|
||||||
|
public const string ElectrocutionStatusEffect = "Electrocution";
|
||||||
|
|
||||||
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||||
|
{
|
||||||
|
if (args.Length < 1)
|
||||||
|
{
|
||||||
|
// TODO: Localize this.
|
||||||
|
shell.WriteError("Not enough arguments!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||||
|
|
||||||
|
if (!EntityUid.TryParse(args[0], out var uid) || !entityManager.EntityExists(uid))
|
||||||
|
{
|
||||||
|
shell.WriteError($"Invalid entity specified!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!entityManager.EntitySysManager.GetEntitySystem<StatusEffectsSystem>().CanApplyEffect(uid, ElectrocutionStatusEffect))
|
||||||
|
{
|
||||||
|
shell.WriteError(Loc.GetString("electrocute-command-entity-cannot-be-electrocuted"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.Length < 2 || !int.TryParse(args[1], out var seconds))
|
||||||
|
{
|
||||||
|
seconds = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.Length < 3 || !int.TryParse(args[2], out var damage))
|
||||||
|
{
|
||||||
|
damage = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
entityManager.EntitySysManager.GetEntitySystem<ElectrocutionSystem>()
|
||||||
|
.TryDoElectrocution(uid, null, damage, TimeSpan.FromSeconds(seconds));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,6 +21,7 @@ using Content.Shared.Speech.EntitySystems;
|
|||||||
using Content.Shared.StatusEffect;
|
using Content.Shared.StatusEffect;
|
||||||
using Content.Shared.Stunnable;
|
using Content.Shared.Stunnable;
|
||||||
using Content.Shared.Weapons.Melee;
|
using Content.Shared.Weapons.Melee;
|
||||||
|
using Robust.Shared.Console;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
@@ -38,6 +39,7 @@ namespace Content.Server.Electrocution
|
|||||||
[Dependency] private readonly IEntityLookup _entityLookup = default!;
|
[Dependency] private readonly IEntityLookup _entityLookup = default!;
|
||||||
[Dependency] private readonly IRobustRandom _random = default!;
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
|
[Dependency] private readonly IConsoleHost _consoleHost = default!;
|
||||||
[Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!;
|
[Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!;
|
||||||
[Dependency] private readonly SharedJitteringSystem _jitteringSystem = default!;
|
[Dependency] private readonly SharedJitteringSystem _jitteringSystem = default!;
|
||||||
[Dependency] private readonly SharedStunSystem _stunSystem = default!;
|
[Dependency] private readonly SharedStunSystem _stunSystem = default!;
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
electrocute-command-description = Electrocutes the specified entity, defaults to 10 seconds and 10 damage. Shocking!
|
||||||
|
electrocute-command-entity-cannot-be-electrocuted = You cannot electrocute that entity!
|
||||||
Reference in New Issue
Block a user