2020-12-03 03:40:47 +01:00
|
|
|
using Content.Server.Administration;
|
|
|
|
|
using Content.Shared.Administration;
|
2023-08-04 14:53:07 +10:00
|
|
|
using Content.Shared.Damage.Systems;
|
2021-02-01 16:49:43 -08:00
|
|
|
using Robust.Shared.Console;
|
2020-12-03 03:40:47 +01:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Damage.Commands
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
|
|
|
|
[AdminCommand(AdminFlags.Admin)]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class GodModeCommand : IConsoleCommand
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
2023-09-11 09:42:41 +10:00
|
|
|
[Dependency] private readonly IEntityManager _entManager = default!;
|
|
|
|
|
|
2020-12-03 03:40:47 +01:00
|
|
|
public string Command => "godmode";
|
|
|
|
|
public string Description => "Makes your entity or another invulnerable to almost anything. May have irreversible changes.";
|
|
|
|
|
public string Help => $"Usage: {Command} / {Command} <entityUid>";
|
|
|
|
|
|
2021-02-01 16:49:43 -08:00
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
2023-10-28 09:59:53 +11:00
|
|
|
var player = shell.Player;
|
2021-11-09 12:20:02 +01:00
|
|
|
EntityUid entity;
|
|
|
|
|
|
2020-12-03 03:40:47 +01:00
|
|
|
switch (args.Length)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
if (player == null)
|
|
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
shell.WriteLine("An entity needs to be specified when the command isn't used by a player.");
|
2020-12-03 03:40:47 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-06 15:34:46 +01:00
|
|
|
if (player.AttachedEntity == null)
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
shell.WriteLine("An entity needs to be specified when you aren't attached to an entity.");
|
2020-12-03 03:40:47 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-06 15:34:46 +01:00
|
|
|
entity = player.AttachedEntity.Value;
|
2020-12-03 03:40:47 +01:00
|
|
|
break;
|
|
|
|
|
case 1:
|
2023-09-11 09:42:41 +10:00
|
|
|
if (!NetEntity.TryParse(args[0], out var idNet) || !_entManager.TryGetEntity(idNet, out var id))
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
shell.WriteLine($"{args[0]} isn't a valid entity id.");
|
2020-12-03 03:40:47 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
if (!_entManager.EntityExists(id))
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
shell.WriteLine($"No entity found with id {id}.");
|
2020-12-03 03:40:47 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
entity = id.Value;
|
2020-12-03 03:40:47 +01:00
|
|
|
break;
|
|
|
|
|
default:
|
2021-02-01 16:49:43 -08:00
|
|
|
shell.WriteLine(Help);
|
2020-12-03 03:40:47 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
var godmodeSystem = _entManager.System<SharedGodmodeSystem>();
|
2020-12-03 03:40:47 +01:00
|
|
|
var enabled = godmodeSystem.ToggleGodmode(entity);
|
|
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
var name = _entManager.GetComponent<MetaDataComponent>(entity).EntityName;
|
2021-11-09 12:20:02 +01:00
|
|
|
|
2021-02-01 16:49:43 -08:00
|
|
|
shell.WriteLine(enabled
|
2021-11-09 12:20:02 +01:00
|
|
|
? $"Enabled godmode for entity {name} with id {entity}"
|
|
|
|
|
: $"Disabled godmode for entity {name} with id {entity}");
|
2020-12-03 03:40:47 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|