1
0

CivFactionsEvents.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. using Robust.Shared.Serialization;
  2. using Robust.Shared.Network; // Required for NetUserId
  3. namespace Content.Shared.Civ14.CivFactions;
  4. /// <summary>
  5. /// Base class for faction-related network events for easier subscription if needed.
  6. /// </summary>
  7. [Serializable, NetSerializable]
  8. public abstract class BaseFactionRequestEvent : EntityEventArgs
  9. {
  10. // Can add common fields here if necessary later
  11. }
  12. /// <summary>
  13. /// Sent from Client -> Server when a player wants to create a new faction.
  14. /// </summary>
  15. [Serializable, NetSerializable]
  16. public sealed class CreateFactionRequestEvent : BaseFactionRequestEvent
  17. {
  18. public string FactionName { get; }
  19. /// <summary>
  20. /// Initialises a new request to create a faction with the specified name.
  21. /// </summary>
  22. /// <param name="factionName">The desired name for the new faction.</param>
  23. public CreateFactionRequestEvent(string factionName)
  24. {
  25. FactionName = factionName;
  26. }
  27. }
  28. /// <summary>
  29. /// Sent from Client -> Server when a player wants to leave their current faction.
  30. /// </summary>
  31. [Serializable, NetSerializable]
  32. public sealed class LeaveFactionRequestEvent : BaseFactionRequestEvent
  33. {
  34. // No extra data needed, server knows sender.
  35. }
  36. /// <summary>
  37. /// Sent from Client -> Server when a player wants to invite another player.
  38. /// </summary>
  39. [Serializable, NetSerializable]
  40. public sealed class InviteFactionRequestEvent : BaseFactionRequestEvent
  41. {
  42. /// <summary>
  43. /// The NetUserId of the player being invited.
  44. /// </summary>
  45. public NetUserId TargetPlayerUserId { get; }
  46. /// <summary>
  47. /// Initialises a new invitation request event targeting the specified player for faction invitation.
  48. /// </summary>
  49. /// <param name="targetPlayerUserId">The user ID of the player to invite to the faction.</param>
  50. public InviteFactionRequestEvent(NetUserId targetPlayerUserId)
  51. {
  52. TargetPlayerUserId = targetPlayerUserId;
  53. }
  54. }
  55. /// <summary>
  56. /// Sent from Server -> Client (Target) to notify them of a faction invitation.
  57. /// </summary>
  58. [Serializable, NetSerializable]
  59. public sealed class FactionInviteOfferEvent : EntityEventArgs // Not inheriting BaseFactionRequestEvent
  60. {
  61. public string InviterName { get; }
  62. public string FactionName { get; }
  63. public NetUserId InviterUserId { get; } /// <summary>
  64. /// Initialises a new faction invitation offer with the inviter's name, faction name, and inviter's user ID.
  65. /// </summary>
  66. /// <param name="inviterName">The display name of the player sending the invitation.</param>
  67. /// <param name="factionName">The name of the faction the invitation is for.</param>
  68. /// <param name="inviterUserId">The user ID of the player sending the invitation.</param>
  69. public FactionInviteOfferEvent(string inviterName, string factionName, NetUserId inviterUserId)
  70. {
  71. InviterName = inviterName;
  72. FactionName = factionName;
  73. InviterUserId = inviterUserId;
  74. }
  75. }
  76. /// <summary>
  77. /// Sent from Client (Target) -> Server when a player accepts a faction invitation.
  78. /// </summary>
  79. [Serializable, NetSerializable]
  80. public sealed class AcceptFactionInviteEvent : BaseFactionRequestEvent
  81. {
  82. /// <summary>
  83. /// The name of the faction being joined.
  84. /// </summary>
  85. public string FactionName { get; }
  86. /// <summary>
  87. /// The NetUserId of the player who originally sent the invite.
  88. /// </summary>
  89. public NetUserId InviterUserId { get; } /// <summary>
  90. /// Initialises a new event indicating that a player has accepted a faction invitation.
  91. /// </summary>
  92. /// <param name="factionName">The name of the faction being joined.</param>
  93. /// <param name="inviterUserId">The user ID of the player who sent the invitation.</param>
  94. public AcceptFactionInviteEvent(string factionName, NetUserId inviterUserId)
  95. {
  96. FactionName = factionName;
  97. InviterUserId = inviterUserId;
  98. }
  99. }
  100. // Optional: Decline event if explicit decline handling is needed beyond timeout/ignoring.
  101. // [Serializable, NetSerializable]
  102. // public sealed class DeclineFactionInviteEvent : BaseFactionRequestEvent { ... }
  103. /// <summary>
  104. /// Sent from Server -> Client (specific player) when their faction membership status changes.
  105. /// </summary>
  106. [Serializable, NetSerializable]
  107. public sealed class PlayerFactionStatusChangedEvent : EntityEventArgs
  108. {
  109. public bool IsInFaction { get; }
  110. public string? FactionName { get; } /// <summary>
  111. /// Initialises a new event indicating a player's faction membership status and, if applicable, the faction's name.
  112. /// </summary>
  113. /// <param name="isInFaction">Whether the player is currently in a faction.</param>
  114. /// <param name="factionName">The name of the faction if the player is a member; otherwise, null.</param>
  115. public PlayerFactionStatusChangedEvent(bool isInFaction, string? factionName)
  116. {
  117. IsInFaction = isInFaction;
  118. FactionName = factionName;
  119. }
  120. }