ShowMindShieldIconsSystem.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Content.Shared.Mindshield.Components;
  2. using Content.Shared.Overlays;
  3. using Content.Shared.StatusIcon;
  4. using Content.Shared.StatusIcon.Components;
  5. using Robust.Shared.Prototypes;
  6. namespace Content.Client.Overlays;
  7. public sealed class ShowMindShieldIconsSystem : EquipmentHudSystem<ShowMindShieldIconsComponent>
  8. {
  9. [Dependency] private readonly IPrototypeManager _prototype = default!;
  10. public override void Initialize()
  11. {
  12. base.Initialize();
  13. SubscribeLocalEvent<MindShieldComponent, GetStatusIconsEvent>(OnGetStatusIconsEvent);
  14. SubscribeLocalEvent<FakeMindShieldComponent, GetStatusIconsEvent>(OnGetStatusIconsEventFake);
  15. }
  16. // TODO: Probably need to get this OFF of client since this can be read by bad actors rather easily
  17. // ...imagine cheating in a game about silly paper dolls
  18. private void OnGetStatusIconsEventFake(EntityUid uid, FakeMindShieldComponent component, ref GetStatusIconsEvent ev)
  19. {
  20. if(!IsActive)
  21. return;
  22. if (component.IsEnabled && _prototype.TryIndex(component.MindShieldStatusIcon, out var fakeStatusIconPrototype))
  23. ev.StatusIcons.Add(fakeStatusIconPrototype);
  24. }
  25. private void OnGetStatusIconsEvent(EntityUid uid, MindShieldComponent component, ref GetStatusIconsEvent ev)
  26. {
  27. if (!IsActive)
  28. return;
  29. if (_prototype.TryIndex(component.MindShieldStatusIcon, out var iconPrototype))
  30. ev.StatusIcons.Add(iconPrototype);
  31. }
  32. }