PryingComponent.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using Robust.Shared.Audio;
  2. using Robust.Shared.GameStates;
  3. namespace Content.Shared.Prying.Components;
  4. [RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
  5. public sealed partial class PryingComponent : Component
  6. {
  7. /// <summary>
  8. /// Whether the entity can pry open powered doors
  9. /// </summary>
  10. [DataField, AutoNetworkedField]
  11. public bool PryPowered;
  12. /// <summary>
  13. /// Whether the tool can bypass certain restrictions when prying.
  14. /// For example door bolts.
  15. /// </summary>
  16. [DataField]
  17. public bool Force;
  18. /// <summary>
  19. /// Modifier on the prying time.
  20. /// Lower values result in more time.
  21. /// </summary>
  22. [DataField, AutoNetworkedField]
  23. public float SpeedModifier = 1.0f;
  24. /// <summary>
  25. /// What sound to play when prying is finished.
  26. /// </summary>
  27. [DataField]
  28. public SoundSpecifier UseSound = new SoundPathSpecifier("/Audio/Items/crowbar.ogg");
  29. /// <summary>
  30. /// Whether the entity can currently pry things.
  31. /// </summary>
  32. [DataField]
  33. public bool Enabled = true;
  34. }
  35. /// <summary>
  36. /// Raised directed on an entity before prying it.
  37. /// Cancel to stop the entity from being pried open.
  38. /// </summary>
  39. [ByRefEvent]
  40. public record struct BeforePryEvent(EntityUid User, bool PryPowered, bool Force, bool StrongPry)
  41. {
  42. public readonly EntityUid User = User;
  43. /// <summary>
  44. /// Whether prying should be allowed even if whatever is being pried is powered.
  45. /// </summary>
  46. public readonly bool PryPowered = PryPowered;
  47. /// <summary>
  48. /// Whether prying should be allowed to go through under most circumstances. (E.g. airlock is bolted).
  49. /// Systems may still wish to ignore this occasionally.
  50. /// </summary>
  51. public readonly bool Force = Force;
  52. /// <summary>
  53. /// Whether anything other than bare hands were used. This should only be false if prying is being performed without a prying comp.
  54. /// </summary>
  55. public readonly bool StrongPry = StrongPry;
  56. public string? Message;
  57. public bool Cancelled;
  58. }
  59. /// <summary>
  60. /// Raised directed on an entity that has been pried.
  61. /// </summary>
  62. [ByRefEvent]
  63. public readonly record struct PriedEvent(EntityUid User)
  64. {
  65. public readonly EntityUid User = User;
  66. }
  67. /// <summary>
  68. /// Raised to determine how long the door's pry time should be modified by.
  69. /// Multiply PryTimeModifier by the desired amount.
  70. /// </summary>
  71. [ByRefEvent]
  72. public record struct GetPryTimeModifierEvent
  73. {
  74. public readonly EntityUid User;
  75. public float PryTimeModifier = 1.0f;
  76. public float BaseTime = 5.0f;
  77. public GetPryTimeModifierEvent(EntityUid user)
  78. {
  79. User = user;
  80. }
  81. }