mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
30 lines
961 B
C#
30 lines
961 B
C#
using Content.Shared.Ghost.Components;
|
|
using Robust.Client.GameObjects;
|
|
using Robust.Shared.Console;
|
|
|
|
namespace Content.Client.Ghost;
|
|
|
|
public sealed partial class GhostToggleSelfVisibility : LocalizedEntityCommands
|
|
{
|
|
[Dependency] private SpriteSystem _sprite = default!;
|
|
|
|
public override string Command => "toggleselfghost";
|
|
|
|
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
{
|
|
var attachedEntity = shell.Player?.AttachedEntity;
|
|
if (!attachedEntity.HasValue)
|
|
return;
|
|
|
|
if (!EntityManager.HasComponent<GhostComponent>(attachedEntity))
|
|
{
|
|
shell.WriteError(Loc.GetString($"cmd-toggleselfghost-must-be-ghost"));
|
|
return;
|
|
}
|
|
|
|
if (!EntityManager.TryGetComponent(attachedEntity, out SpriteComponent? spriteComponent))
|
|
return;
|
|
|
|
_sprite.SetVisible((attachedEntity.Value, spriteComponent), !spriteComponent.Visible);
|
|
}
|
|
}
|