1
0

SSDIndicatorSystem.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using Content.Shared.CCVar;
  2. using Content.Shared.Mind.Components;
  3. using Content.Shared.Mobs.Systems;
  4. using Content.Shared.NPC;
  5. using Content.Shared.SSDIndicator;
  6. using Content.Shared.StatusIcon;
  7. using Content.Shared.StatusIcon.Components;
  8. using Robust.Shared.Configuration;
  9. using Robust.Shared.Prototypes;
  10. namespace Content.Client.SSDIndicator;
  11. /// <summary>
  12. /// Handles displaying SSD indicator as status icon
  13. /// </summary>
  14. public sealed class SSDIndicatorSystem : EntitySystem
  15. {
  16. [Dependency] private readonly IPrototypeManager _prototype = default!;
  17. [Dependency] private readonly IConfigurationManager _cfg = default!;
  18. [Dependency] private readonly MobStateSystem _mobState = default!;
  19. public override void Initialize()
  20. {
  21. base.Initialize();
  22. SubscribeLocalEvent<SSDIndicatorComponent, GetStatusIconsEvent>(OnGetStatusIcon);
  23. }
  24. private void OnGetStatusIcon(EntityUid uid, SSDIndicatorComponent component, ref GetStatusIconsEvent args)
  25. {
  26. if (component.IsSSD &&
  27. _cfg.GetCVar(CCVars.ICShowSSDIndicator) &&
  28. !_mobState.IsDead(uid) &&
  29. !HasComp<ActiveNPCComponent>(uid) &&
  30. TryComp<MindContainerComponent>(uid, out var mindContainer) &&
  31. mindContainer.ShowExamineInfo)
  32. {
  33. args.StatusIcons.Add(_prototype.Index(component.Icon));
  34. }
  35. }
  36. }