CuffableSystem.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using Content.Shared.Cuffs;
  2. using Content.Shared.Cuffs.Components;
  3. using JetBrains.Annotations;
  4. using Robust.Shared.GameStates;
  5. namespace Content.Server.Cuffs
  6. {
  7. [UsedImplicitly]
  8. public sealed class CuffableSystem : SharedCuffableSystem
  9. {
  10. public override void Initialize()
  11. {
  12. base.Initialize();
  13. SubscribeLocalEvent<CuffableComponent, ComponentGetState>(OnCuffableGetState);
  14. }
  15. private void OnCuffableGetState(EntityUid uid, CuffableComponent component, ref ComponentGetState args)
  16. {
  17. // there are 2 approaches i can think of to handle the handcuff overlay on players
  18. // 1 - make the current RSI the handcuff type that's currently active. all handcuffs on the player will appear the same.
  19. // 2 - allow for several different player overlays for each different cuff type.
  20. // approach #2 would be more difficult/time consuming to do and the payoff doesn't make it worth it.
  21. // right now we're doing approach #1.
  22. HandcuffComponent? cuffs = null;
  23. if (component.CuffedHandCount > 0)
  24. TryComp(component.LastAddedCuffs, out cuffs);
  25. args.State = new CuffableComponentState(component.CuffedHandCount,
  26. component.CanStillInteract,
  27. cuffs?.CuffedRSI,
  28. $"{cuffs?.BodyIconState}-{component.CuffedHandCount}",
  29. cuffs?.Color);
  30. // the iconstate is formatted as blah-2, blah-4, blah-6, etc.
  31. // the number corresponds to how many hands are cuffed.
  32. }
  33. }
  34. }