Events.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. using Content.Shared.DoAfter;
  2. using Content.Shared.Interaction;
  3. using Robust.Shared.Map;
  4. using Robust.Shared.Serialization;
  5. namespace Content.Shared.Construction;
  6. /// <summary>
  7. /// Sent client -> server to to tell the server that we started building
  8. /// a structure-construction.
  9. /// </summary>
  10. [Serializable, NetSerializable]
  11. public sealed class TryStartStructureConstructionMessage : EntityEventArgs
  12. {
  13. /// <summary>
  14. /// Position to start building.
  15. /// </summary>
  16. public readonly NetCoordinates Location;
  17. /// <summary>
  18. /// The construction prototype to start building.
  19. /// </summary>
  20. public readonly string PrototypeName;
  21. public readonly Angle Angle;
  22. /// <summary>
  23. /// Identifier to be sent back in the acknowledgement so that the client can clean up its ghost.
  24. /// </summary>
  25. /// <remarks>
  26. /// So essentially the client is sending its own entity to the server so it knows to delete it when it gets server
  27. /// response back.
  28. /// </remarks>
  29. public readonly int Ack;
  30. public TryStartStructureConstructionMessage(NetCoordinates loc, string prototypeName, Angle angle, int ack)
  31. {
  32. Location = loc;
  33. PrototypeName = prototypeName;
  34. Angle = angle;
  35. Ack = ack;
  36. }
  37. }
  38. /// <summary>
  39. /// Sent client -> server to to tell the server that we started building
  40. /// an item-construction.
  41. /// </summary>
  42. [Serializable, NetSerializable]
  43. public sealed class TryStartItemConstructionMessage : EntityEventArgs
  44. {
  45. /// <summary>
  46. /// The construction prototype to start building.
  47. /// </summary>
  48. public readonly string PrototypeName;
  49. public TryStartItemConstructionMessage(string prototypeName)
  50. {
  51. PrototypeName = prototypeName;
  52. }
  53. }
  54. /// <summary>
  55. /// Sent server -> client to tell the client that a ghost has started to be constructed.
  56. /// </summary>
  57. [Serializable, NetSerializable]
  58. public sealed class AckStructureConstructionMessage : EntityEventArgs
  59. {
  60. public readonly int GhostId;
  61. /// <summary>
  62. /// The entity that is now being constructed, if any.
  63. /// </summary>
  64. public readonly NetEntity? Uid;
  65. public AckStructureConstructionMessage(int ghostId, NetEntity? uid = null)
  66. {
  67. GhostId = ghostId;
  68. Uid = uid;
  69. }
  70. }
  71. /// <summary>
  72. /// Sent client -> server to request a specific construction guide.
  73. /// </summary>
  74. [Serializable, NetSerializable]
  75. public sealed class RequestConstructionGuide : EntityEventArgs
  76. {
  77. public readonly string ConstructionId;
  78. public RequestConstructionGuide(string constructionId)
  79. {
  80. ConstructionId = constructionId;
  81. }
  82. }
  83. /// <summary>
  84. /// Sent server -> client as a response to a <see cref="RequestConstructionGuide"/> net message.
  85. /// </summary>
  86. [Serializable, NetSerializable]
  87. public sealed class ResponseConstructionGuide : EntityEventArgs
  88. {
  89. public readonly string ConstructionId;
  90. public readonly ConstructionGuide Guide;
  91. public ResponseConstructionGuide(string constructionId, ConstructionGuide guide)
  92. {
  93. ConstructionId = constructionId;
  94. Guide = guide;
  95. }
  96. }
  97. [Serializable, NetSerializable]
  98. public sealed partial class ConstructionInteractDoAfterEvent : DoAfterEvent
  99. {
  100. [DataField("clickLocation")]
  101. public NetCoordinates ClickLocation;
  102. private ConstructionInteractDoAfterEvent()
  103. {
  104. }
  105. public ConstructionInteractDoAfterEvent(IEntityManager entManager, InteractUsingEvent ev)
  106. {
  107. ClickLocation = entManager.GetNetCoordinates(ev.ClickLocation);
  108. }
  109. public override DoAfterEvent Clone() => this;
  110. }
  111. [Serializable, NetSerializable]
  112. public sealed partial class WelderRefineDoAfterEvent : SimpleDoAfterEvent
  113. {
  114. }