ShowThirstIconsSystem.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 ShowThirstIconsSystem : EquipmentHudSystem<ShowThirstIconsComponent>
  7. {
  8. [Dependency] private readonly ThirstSystem _thirst = default!;
  9. public override void Initialize()
  10. {
  11. base.Initialize();
  12. SubscribeLocalEvent<ThirstComponent, GetStatusIconsEvent>(OnGetStatusIconsEvent);
  13. }
  14. private void OnGetStatusIconsEvent(EntityUid uid, ThirstComponent component, ref GetStatusIconsEvent ev)
  15. {
  16. if (!IsActive)
  17. return;
  18. if (_thirst.TryGetStatusIconPrototype(component, out var iconPrototype))
  19. ev.StatusIcons.Add(iconPrototype);
  20. }
  21. }