2023-10-10 20:43:48 -07:00
|
|
|
|
using Content.Shared.Ghost;
|
|
|
|
|
|
using Robust.Client.GameObjects;
|
|
|
|
|
|
using Robust.Shared.Console;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Content.Client.Ghost;
|
|
|
|
|
|
|
2025-06-17 14:08:12 -04:00
|
|
|
|
public sealed class GhostToggleSelfVisibility : LocalizedEntityCommands
|
2023-10-10 20:43:48 -07:00
|
|
|
|
{
|
2025-06-17 14:08:12 -04:00
|
|
|
|
[Dependency] private readonly SpriteSystem _sprite = default!;
|
|
|
|
|
|
|
|
|
|
|
|
public override string Command => "toggleselfghost";
|
|
|
|
|
|
|
|
|
|
|
|
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
2023-10-10 20:43:48 -07:00
|
|
|
|
{
|
|
|
|
|
|
var attachedEntity = shell.Player?.AttachedEntity;
|
|
|
|
|
|
if (!attachedEntity.HasValue)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2025-06-17 14:08:12 -04:00
|
|
|
|
if (!EntityManager.HasComponent<GhostComponent>(attachedEntity))
|
2023-10-10 20:43:48 -07:00
|
|
|
|
{
|
2025-06-17 14:08:12 -04:00
|
|
|
|
shell.WriteError(Loc.GetString($"cmd-toggleselfghost-must-be-ghost"));
|
2023-10-10 20:43:48 -07:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-17 14:08:12 -04:00
|
|
|
|
if (!EntityManager.TryGetComponent(attachedEntity, out SpriteComponent? spriteComponent))
|
2023-10-10 20:43:48 -07:00
|
|
|
|
return;
|
|
|
|
|
|
|
2025-06-17 14:08:12 -04:00
|
|
|
|
_sprite.SetVisible((attachedEntity.Value, spriteComponent), !spriteComponent.Visible);
|
2023-10-10 20:43:48 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|