Files
tbd-station-14/Content.Client/Overlays/ShowThirstIconsSystem.cs
PrPleGoo 1a13884961 Task/food hud (#19312)
* security HUD now shows a job icon on entities with a body

* thirst goggles

* set starting hud gear

* fix build

* remove from starting gear

* remove

* replace

* fix thirst and hunger icons

* update icons

* space

* space

* ]

* ]

* fix build

* fix comments

* fix

* spacing

* field

* move more namespaces

* use AutoGenerateComponentState

* comments

* fix build

* not all fields

* comments

* unpaused

* fix Dirty warning

---------

Co-authored-by: Slava0135 <super.novalskiy_0135@inbox.ru>
2023-09-23 16:14:06 +03:00

59 lines
1.9 KiB
C#

using Content.Shared.Nutrition.Components;
using Content.Shared.Overlays;
using Content.Shared.StatusIcon;
using Content.Shared.StatusIcon.Components;
using Robust.Shared.Prototypes;
namespace Content.Client.Overlays;
public sealed class ShowThirstIconsSystem : EquipmentHudSystem<ShowThirstIconsComponent>
{
[Dependency] private readonly IPrototypeManager _prototypeMan = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ThirstComponent, GetStatusIconsEvent>(OnGetStatusIconsEvent);
}
private void OnGetStatusIconsEvent(EntityUid uid, ThirstComponent thirstComponent, ref GetStatusIconsEvent args)
{
if (!IsActive || args.InContainer)
return;
var healthIcons = DecideThirstIcon(uid, thirstComponent);
args.StatusIcons.AddRange(healthIcons);
}
private IReadOnlyList<StatusIconPrototype> DecideThirstIcon(EntityUid uid, ThirstComponent thirstComponent)
{
var result = new List<StatusIconPrototype>();
switch (thirstComponent.CurrentThirstThreshold)
{
case ThirstThreshold.OverHydrated:
if (_prototypeMan.TryIndex<StatusIconPrototype>("ThirstIconOverhydrated", out var overhydrated))
{
result.Add(overhydrated);
}
break;
case ThirstThreshold.Thirsty:
if (_prototypeMan.TryIndex<StatusIconPrototype>("ThirstIconThirsty", out var thirsty))
{
result.Add(thirsty);
}
break;
case ThirstThreshold.Parched:
if (_prototypeMan.TryIndex<StatusIconPrototype>("ThirstIconParched", out var parched))
{
result.Add(parched);
}
break;
}
return result;
}
}