Files
tbd-station-14/Content.Client/GameObjects/Components/Mobs/CombatModeComponent.cs
ike709 1d052d0410 Improves the HUD (#3655)
* All good except the combat doll

* Makes the HUD inventory less terrible

* Cleanup, nuke the Combat Mode button

* Harm icon

* Switch the icon

* Basic goon hud

* Toggleable

* Nuke the popup, properly centers it

* Fix clicking the button

* Nuke some old code

* missed a comment

* Remove defaults

* Localization

* Nuke some old yaml

* New sprites

Co-authored-by: ike709 <sparebytes@protonmail.com>
2021-03-27 02:23:12 +11:00

65 lines
1.7 KiB
C#

using Content.Client.UserInterface;
using Content.Shared.GameObjects.Components.Mobs;
using Robust.Client.GameObjects;
using Robust.Client.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Client.GameObjects.Components.Mobs
{
[RegisterComponent]
[ComponentReference(typeof(SharedCombatModeComponent))]
public sealed class CombatModeComponent : SharedCombatModeComponent
{
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IGameHud _gameHud = default!;
public override bool IsInCombatMode
{
get => base.IsInCombatMode;
set
{
base.IsInCombatMode = value;
UpdateHud();
}
}
public override TargetingZone ActiveZone
{
get => base.ActiveZone;
set
{
base.ActiveZone = value;
UpdateHud();
}
}
public override void HandleMessage(ComponentMessage message, IComponent? component)
{
base.HandleMessage(message, component);
switch (message)
{
case PlayerAttachedMsg _:
_gameHud.CombatPanelVisible = true;
UpdateHud();
break;
case PlayerDetachedMsg _:
_gameHud.CombatPanelVisible = false;
break;
}
}
private void UpdateHud()
{
if (Owner != _playerManager.LocalPlayer?.ControlledEntity)
{
return;
}
_gameHud.TargetingZone = ActiveZone;
}
}
}