1
0

GhostToggleSelfVisibility.cs 976 B

123456789101112131415161718192021222324252627282930
  1. using Content.Shared.Ghost;
  2. using Robust.Client.GameObjects;
  3. using Robust.Shared.Console;
  4. namespace Content.Client.Ghost;
  5. public sealed class GhostToggleSelfVisibility : IConsoleCommand
  6. {
  7. public string Command => "toggleselfghost";
  8. public string Description => "Toggles seeing your own ghost.";
  9. public string Help => "toggleselfghost";
  10. public void Execute(IConsoleShell shell, string argStr, string[] args)
  11. {
  12. var attachedEntity = shell.Player?.AttachedEntity;
  13. if (!attachedEntity.HasValue)
  14. return;
  15. var entityManager = IoCManager.Resolve<IEntityManager>();
  16. if (!entityManager.HasComponent<GhostComponent>(attachedEntity))
  17. {
  18. shell.WriteError("Entity must be a ghost.");
  19. return;
  20. }
  21. if (!entityManager.TryGetComponent(attachedEntity, out SpriteComponent? spriteComponent))
  22. return;
  23. spriteComponent.Visible = !spriteComponent.Visible;
  24. }
  25. }