ShowHungerIconsSystem.cs 824 B

123456789101112131415161718192021222324252627
  1. using Content.Shared.Nutrition.EntitySystems;
  2. using Content.Shared.Nutrition.Components;
  3. using Content.Shared.Overlays;
  4. using Content.Shared.StatusIcon.Components;
  5. namespace Content.Client.Overlays;
  6. public sealed class ShowHungerIconsSystem : EquipmentHudSystem<ShowHungerIconsComponent>
  7. {
  8. [Dependency] private readonly HungerSystem _hunger = default!;
  9. public override void Initialize()
  10. {
  11. base.Initialize();
  12. SubscribeLocalEvent<HungerComponent, GetStatusIconsEvent>(OnGetStatusIconsEvent);
  13. }
  14. private void OnGetStatusIconsEvent(EntityUid uid, HungerComponent component, ref GetStatusIconsEvent ev)
  15. {
  16. if (!IsActive)
  17. return;
  18. if (_hunger.TryGetStatusIconPrototype(component, out var iconPrototype))
  19. ev.StatusIcons.Add(iconPrototype);
  20. }
  21. }