2024-04-17 23:20:44 -04:00
|
|
|
using Content.Shared.Nutrition.EntitySystems;
|
2023-09-23 15:14:06 +02:00
|
|
|
using Content.Shared.Nutrition.Components;
|
|
|
|
|
using Content.Shared.Overlays;
|
|
|
|
|
using Content.Shared.StatusIcon.Components;
|
|
|
|
|
|
|
|
|
|
namespace Content.Client.Overlays;
|
|
|
|
|
|
|
|
|
|
public sealed class ShowHungerIconsSystem : EquipmentHudSystem<ShowHungerIconsComponent>
|
|
|
|
|
{
|
2024-04-17 23:20:44 -04:00
|
|
|
[Dependency] private readonly HungerSystem _hunger = default!;
|
2023-09-23 15:14:06 +02:00
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<HungerComponent, GetStatusIconsEvent>(OnGetStatusIconsEvent);
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-17 23:20:44 -04:00
|
|
|
private void OnGetStatusIconsEvent(EntityUid uid, HungerComponent component, ref GetStatusIconsEvent ev)
|
2023-09-23 15:14:06 +02:00
|
|
|
{
|
2024-04-17 23:20:44 -04:00
|
|
|
if (!IsActive || ev.InContainer)
|
2023-09-23 15:14:06 +02:00
|
|
|
return;
|
|
|
|
|
|
2024-04-17 23:20:44 -04:00
|
|
|
if (_hunger.TryGetStatusIconPrototype(component, out var iconPrototype))
|
|
|
|
|
ev.StatusIcons.Add(iconPrototype);
|
2023-09-23 15:14:06 +02:00
|
|
|
}
|
|
|
|
|
}
|