[feat]Med huds

This commit is contained in:
rhailrake
2023-04-27 23:54:17 +06:00
committed by Aviu00
parent 518b730864
commit cb5f49f2b3
14 changed files with 508 additions and 43 deletions

View File

@@ -0,0 +1,44 @@
using Robust.Client.Player;
using Robust.Shared.Console;
using Content.Shared.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<ShowHealthBarsComponent>(playerEntity, out var glassComp))
{
_entityManager.AddComponent<ShowHealthBarsComponent>((EntityUid) playerEntity);
shell.WriteLine("Enabled health overlay.");
return;
}
_entityManager.RemoveComponent<ShowHealthBarsComponent>((EntityUid) playerEntity);
shell.WriteLine("Disabled health overlay.");
return;
}
}
}