ShowFactionIconsSystem.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. }
  58. public sealed class ShowGermanFactionIconsSystem : EquipmentHudSystem<ShowGermanFactionIconsComponent>
  59. {
  60. [Dependency] private readonly IPrototypeManager _prototype = default!;
  61. public override void Initialize()
  62. {
  63. base.Initialize();
  64. SubscribeLocalEvent<ShowGermanFactionIconsComponent, GetStatusIconsEvent>(OnGetStatusIconsEvent);
  65. }
  66. private void OnGetStatusIconsEvent(EntityUid uid, ShowGermanFactionIconsComponent component, ref GetStatusIconsEvent ev)
  67. {
  68. if (!IsActive)
  69. return;
  70. if (_prototype.TryIndex<FactionIconPrototype>(component.FactionIcon, out var iconPrototype))
  71. ev.StatusIcons.Add(iconPrototype);
  72. }
  73. }
  74. public sealed class ShowSovietFactionIconsSystem : EquipmentHudSystem<ShowSovietFactionIconsComponent>
  75. {
  76. [Dependency] private readonly IPrototypeManager _prototype = default!;
  77. public override void Initialize()
  78. {
  79. base.Initialize();
  80. SubscribeLocalEvent<ShowSovietFactionIconsComponent, GetStatusIconsEvent>(OnGetStatusIconsEvent);
  81. }
  82. private void OnGetStatusIconsEvent(EntityUid uid, ShowSovietFactionIconsComponent component, ref GetStatusIconsEvent ev)
  83. {
  84. if (!IsActive)
  85. return;
  86. if (_prototype.TryIndex<FactionIconPrototype>(component.FactionIcon, out var iconPrototype))
  87. ev.StatusIcons.Add(iconPrototype);
  88. }
  89. }
  90. public sealed class ShowUsFactionIconsSystem : EquipmentHudSystem<ShowUsFactionIconsComponent>
  91. {
  92. [Dependency] private readonly IPrototypeManager _prototype = default!;
  93. public override void Initialize()
  94. {
  95. base.Initialize();
  96. SubscribeLocalEvent<ShowUsFactionIconsComponent, GetStatusIconsEvent>(OnGetStatusIconsEvent);
  97. }
  98. private void OnGetStatusIconsEvent(EntityUid uid, ShowUsFactionIconsComponent component, ref GetStatusIconsEvent ev)
  99. {
  100. if (!IsActive)
  101. return;
  102. if (_prototype.TryIndex<FactionIconPrototype>(component.FactionIcon, out var iconPrototype))
  103. ev.StatusIcons.Add(iconPrototype);
  104. }
  105. }