StrippableComponent.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using Content.Shared.DoAfter;
  2. using Content.Shared.Inventory;
  3. using Robust.Shared.GameStates;
  4. using Robust.Shared.Serialization;
  5. namespace Content.Shared.Strip.Components
  6. {
  7. [RegisterComponent, NetworkedComponent]
  8. public sealed partial class StrippableComponent : Component
  9. {
  10. /// <summary>
  11. /// The strip delay for hands.
  12. /// </summary>
  13. [ViewVariables(VVAccess.ReadWrite), DataField("handDelay")]
  14. public TimeSpan HandStripDelay = TimeSpan.FromSeconds(4f);
  15. }
  16. [NetSerializable, Serializable]
  17. public enum StrippingUiKey : byte
  18. {
  19. Key,
  20. }
  21. [NetSerializable, Serializable]
  22. public sealed class StrippingSlotButtonPressed(string slot, bool isHand) : BoundUserInterfaceMessage
  23. {
  24. public readonly string Slot = slot;
  25. public readonly bool IsHand = isHand;
  26. }
  27. [NetSerializable, Serializable]
  28. public sealed class StrippingEnsnareButtonPressed : BoundUserInterfaceMessage;
  29. [ByRefEvent]
  30. public abstract class BaseBeforeStripEvent(TimeSpan initialTime, bool stealth = false) : EntityEventArgs, IInventoryRelayEvent
  31. {
  32. public readonly TimeSpan InitialTime = initialTime;
  33. public float Multiplier = 1f;
  34. public TimeSpan Additive = TimeSpan.Zero;
  35. public bool Stealth = stealth;
  36. public TimeSpan Time => TimeSpan.FromSeconds(MathF.Max(InitialTime.Seconds * Multiplier + Additive.Seconds, 0f));
  37. public SlotFlags TargetSlots { get; } = SlotFlags.GLOVES;
  38. }
  39. /// <summary>
  40. /// Used to modify strip times. Raised directed at the item being stripped.
  41. /// </summary>
  42. /// <remarks>
  43. /// This is also used by some stripping related interactions, i.e., interactions with items that are currently equipped by another player.
  44. /// </remarks>
  45. [ByRefEvent]
  46. public sealed class BeforeItemStrippedEvent(TimeSpan initialTime, bool stealth = false) : BaseBeforeStripEvent(initialTime, stealth);
  47. /// <summary>
  48. /// Used to modify strip times. Raised directed at the user.
  49. /// </summary>
  50. /// <remarks>
  51. /// This is also used by some stripping related interactions, i.e., interactions with items that are currently equipped by another player.
  52. /// </remarks>
  53. [ByRefEvent]
  54. public sealed class BeforeStripEvent(TimeSpan initialTime, bool stealth = false) : BaseBeforeStripEvent(initialTime, stealth);
  55. /// <summary>
  56. /// Used to modify strip times. Raised directed at the target.
  57. /// </summary>
  58. /// <remarks>
  59. /// This is also used by some stripping related interactions, i.e., interactions with items that are currently equipped by another player.
  60. /// </remarks>
  61. [ByRefEvent]
  62. public sealed class BeforeGettingStrippedEvent(TimeSpan initialTime, bool stealth = false) : BaseBeforeStripEvent(initialTime, stealth);
  63. /// <summary>
  64. /// Organizes the behavior of DoAfters for <see cref="StrippableSystem">.
  65. /// </summary>
  66. [Serializable, NetSerializable]
  67. public sealed partial class StrippableDoAfterEvent : DoAfterEvent
  68. {
  69. public readonly bool InsertOrRemove;
  70. public readonly bool InventoryOrHand;
  71. public readonly string SlotOrHandName;
  72. public StrippableDoAfterEvent(bool insertOrRemove, bool inventoryOrHand, string slotOrHandName)
  73. {
  74. InsertOrRemove = insertOrRemove;
  75. InventoryOrHand = inventoryOrHand;
  76. SlotOrHandName = slotOrHandName;
  77. }
  78. public override DoAfterEvent Clone() => this;
  79. }
  80. }