ShowFactionIconsSystem.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using Content.Shared.Access.Components;
  2. using Content.Shared.Access.Systems;
  3. using Content.Shared.NPC.Components;
  4. using Content.Shared.Overlays;
  5. using System.Linq;
  6. using Content.Shared.StatusIcon;
  7. using Content.Shared.StatusIcon.Components;
  8. using Robust.Shared.Prototypes;
  9. namespace Content.Client.Overlays;
  10. public sealed class ShowFactionIconsSystem : EquipmentHudSystem<ShowFactionIconsComponent>
  11. {
  12. [Dependency] private readonly IPrototypeManager _prototype = default!;
  13. public override void Initialize()
  14. {
  15. base.Initialize();
  16. SubscribeLocalEvent<ShowFactionIconsComponent, GetStatusIconsEvent>(OnGetStatusIconsEvent);
  17. }
  18. private void OnGetStatusIconsEvent(EntityUid uid, ShowFactionIconsComponent component, ref GetStatusIconsEvent ev)
  19. {
  20. if (!IsActive)
  21. return;
  22. if (_prototype.TryIndex<FactionIconPrototype>(component.FactionIcon, out var iconPrototype))
  23. ev.StatusIcons.Add(iconPrototype);
  24. }
  25. }
  26. public sealed class ShowFrenchFactionIconsSystem : EquipmentHudSystem<ShowFrenchFactionIconsComponent>
  27. {
  28. [Dependency] private readonly IPrototypeManager _prototype = default!;
  29. public override void Initialize()
  30. {
  31. base.Initialize();
  32. SubscribeLocalEvent<ShowFrenchFactionIconsComponent, GetStatusIconsEvent>(OnGetStatusIconsEvent);
  33. }
  34. private void OnGetStatusIconsEvent(EntityUid uid, ShowFrenchFactionIconsComponent component, ref GetStatusIconsEvent ev)
  35. {
  36. if (!IsActive)
  37. return;
  38. if (_prototype.TryIndex<FactionIconPrototype>(component.FactionIcon, out var iconPrototype))
  39. ev.StatusIcons.Add(iconPrototype);
  40. }
  41. }
  42. public sealed class ShowEnglishFactionIconsSystem : EquipmentHudSystem<ShowEnglishFactionIconsComponent>
  43. {
  44. [Dependency] private readonly IPrototypeManager _prototype = default!;
  45. public override void Initialize()
  46. {
  47. base.Initialize();
  48. SubscribeLocalEvent<ShowEnglishFactionIconsComponent, GetStatusIconsEvent>(OnGetStatusIconsEvent);
  49. }
  50. private void OnGetStatusIconsEvent(EntityUid uid, ShowEnglishFactionIconsComponent component, ref GetStatusIconsEvent ev)
  51. {
  52. if (!IsActive)
  53. return;
  54. if (_prototype.TryIndex<FactionIconPrototype>(component.FactionIcon, out var iconPrototype))
  55. ev.StatusIcons.Add(iconPrototype);
  56. }
  57. }