1
0

CuffableComponent.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using Content.Shared.Alert;
  2. using Content.Shared.Damage;
  3. using Robust.Shared.Containers;
  4. using Robust.Shared.GameStates;
  5. using Robust.Shared.Prototypes;
  6. using Robust.Shared.Serialization;
  7. using Robust.Shared.Utility;
  8. namespace Content.Shared.Cuffs.Components;
  9. [RegisterComponent, NetworkedComponent]
  10. [Access(typeof(SharedCuffableSystem))]
  11. public sealed partial class CuffableComponent : Component
  12. {
  13. /// <summary>
  14. /// The current RSI for the handcuff layer
  15. /// </summary>
  16. [DataField("currentRSI"), ViewVariables(VVAccess.ReadWrite)]
  17. public string? CurrentRSI;
  18. /// <summary>
  19. /// How many of this entity's hands are currently cuffed.
  20. /// </summary>
  21. [ViewVariables]
  22. public int CuffedHandCount => Container.ContainedEntities.Count * 2;
  23. /// <summary>
  24. /// The last pair of cuffs that was added to this entity.
  25. /// </summary>
  26. [ViewVariables]
  27. public EntityUid LastAddedCuffs => Container.ContainedEntities[^1];
  28. /// <summary>
  29. /// Container of various handcuffs currently applied to the entity.
  30. /// </summary>
  31. [ViewVariables(VVAccess.ReadOnly)]
  32. public Container Container = default!;
  33. /// <summary>
  34. /// Whether or not the entity can still interact (is not cuffed)
  35. /// </summary>
  36. [DataField("canStillInteract"), ViewVariables(VVAccess.ReadWrite)]
  37. public bool CanStillInteract = true;
  38. [DataField]
  39. public ProtoId<AlertPrototype> CuffedAlert = "Handcuffed";
  40. }
  41. public sealed partial class RemoveCuffsAlertEvent : BaseAlertEvent;
  42. [Serializable, NetSerializable]
  43. public sealed class CuffableComponentState : ComponentState
  44. {
  45. public readonly bool CanStillInteract;
  46. public readonly int NumHandsCuffed;
  47. public readonly string? RSI;
  48. public readonly string? IconState;
  49. public readonly Color? Color;
  50. public CuffableComponentState(int numHandsCuffed, bool canStillInteract, string? rsiPath, string? iconState, Color? color)
  51. {
  52. NumHandsCuffed = numHandsCuffed;
  53. CanStillInteract = canStillInteract;
  54. RSI = rsiPath;
  55. IconState = iconState;
  56. Color = color;
  57. }
  58. }
  59. [ByRefEvent]
  60. public readonly record struct CuffedStateChangeEvent;