Files
OldThink/Content.Client/Commands/ToggleHealthBarsCommand.cs
Aviu00 64f8083539 Hud fix (#278)
* Fix huds

* No unshaded
2024-01-20 06:13:30 +03:00

45 lines
1.5 KiB
C#

using Robust.Client.Player;
using Robust.Shared.Console;
using Content.Shared.White.EntityHealthBar;
namespace Content.Client.Commands
{
public sealed class ToggleHealthBarsCommand : IConsoleCommand
{
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
public string Command => "togglehealthbars";
public string Description => "Toggles a health bar above mobs.";
public string Help => $"Usage: {Command}";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = _playerManager.LocalPlayer;
if (player == null)
{
shell.WriteLine("You aren't a player.");
return;
}
var playerEntity = player?.ControlledEntity;
if (playerEntity == null)
{
shell.WriteLine("You do not have an attached entity.");
return;
}
if (!_entityManager.TryGetComponent<ShowWhiteHealthBarsComponent>(playerEntity, out var glassComp))
{
_entityManager.AddComponent<ShowWhiteHealthBarsComponent>((EntityUid) playerEntity);
shell.WriteLine("Enabled health overlay.");
return;
}
_entityManager.RemoveComponent<ShowWhiteHealthBarsComponent>((EntityUid) playerEntity);
shell.WriteLine("Disabled health overlay.");
return;
}
}
}