StrippableSystem.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using Content.Client.Inventory;
  2. using Content.Shared.Cuffs.Components;
  3. using Content.Shared.Ensnaring.Components;
  4. using Content.Shared.Hands;
  5. using Content.Shared.Inventory.Events;
  6. using Content.Shared.Strip;
  7. using Content.Shared.Strip.Components;
  8. namespace Content.Client.Strip;
  9. /// <summary>
  10. /// This is the client-side stripping system, which just triggers UI updates on events.
  11. /// </summary>
  12. public sealed class StrippableSystem : SharedStrippableSystem
  13. {
  14. public override void Initialize()
  15. {
  16. base.Initialize();
  17. SubscribeLocalEvent<StrippableComponent, CuffedStateChangeEvent>(OnCuffStateChange);
  18. SubscribeLocalEvent<StrippableComponent, DidEquipEvent>(UpdateUi);
  19. SubscribeLocalEvent<StrippableComponent, DidUnequipEvent>(UpdateUi);
  20. SubscribeLocalEvent<StrippableComponent, DidEquipHandEvent>(UpdateUi);
  21. SubscribeLocalEvent<StrippableComponent, DidUnequipHandEvent>(UpdateUi);
  22. SubscribeLocalEvent<StrippableComponent, EnsnaredChangedEvent>(UpdateUi);
  23. }
  24. private void OnCuffStateChange(EntityUid uid, StrippableComponent component, ref CuffedStateChangeEvent args)
  25. {
  26. UpdateUi(uid, component);
  27. }
  28. public void UpdateUi(EntityUid uid, StrippableComponent? component = null, EntityEventArgs? args = null)
  29. {
  30. if (!TryComp(uid, out UserInterfaceComponent? uiComp))
  31. return;
  32. foreach (var ui in uiComp.ClientOpenInterfaces.Values)
  33. {
  34. if (ui is StrippableBoundUserInterface stripUi)
  35. stripUi.DirtyMenu();
  36. }
  37. }
  38. }