Add a command to hide replay UI (#19956)

This commit is contained in:
ShadowCommander
2023-10-10 20:43:48 -07:00
committed by GitHub
parent d2665b6bba
commit c7d1fb80b5
4 changed files with 73 additions and 2 deletions

View File

@@ -0,0 +1,30 @@
using Content.Shared.Ghost;
using Robust.Client.GameObjects;
using Robust.Shared.Console;
namespace Content.Client.Ghost;
public sealed class GhostToggleSelfVisibility : IConsoleCommand
{
public string Command => "toggleselfghost";
public string Description => "Toggles seeing your own ghost.";
public string Help => "toggleselfghost";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var attachedEntity = shell.Player?.AttachedEntity;
if (!attachedEntity.HasValue)
return;
var entityManager = IoCManager.Resolve<IEntityManager>();
if (!entityManager.HasComponent<GhostComponent>(attachedEntity))
{
shell.WriteError("Entity must be a ghost.");
return;
}
if (!entityManager.TryGetComponent(attachedEntity, out SpriteComponent? spriteComponent))
return;
spriteComponent.Visible = !spriteComponent.Visible;
}
}