1
0

CaptureAreaComponent.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. namespace Content.Server.GameTicking.Rules.Components;
  2. [RegisterComponent, Access(typeof(CaptureAreaSystem))]
  3. public sealed partial class CaptureAreaRuleComponent : Component
  4. {
  5. /// <summary>
  6. /// The type of captures possible
  7. /// - King of the Hill: All factions try to capture a specific area.
  8. /// - Asymmetric: One faction attacks, another defends. Only the attacker can capture.
  9. /// There is a timer for the defender.
  10. /// - Symmetric: Factions have to capture each other's bases.
  11. /// </summary>
  12. [DataField("mode")]
  13. public string Mode { get; set; } = "King of the Hill";
  14. /// <summary>
  15. /// The timer before the defender wins, in minutes. Only applies if Mode is Asymmetric.
  16. /// </summary>
  17. [DataField("timer")]
  18. public float Timer { get; set; } = 40f;
  19. /// <summary>
  20. /// The faction that is defending on this map.
  21. /// </summary>
  22. [DataField("defenderFactionName")]
  23. public string DefenderFactionName { get; set; } = "Defender";
  24. /// <summary>
  25. /// How much time has elapsed in an Asymmetric mode game.
  26. /// </summary>
  27. [DataField("asymmetricGameTimeElapsed"), ViewVariables(VVAccess.ReadWrite)]
  28. public float AsymmetricGameTimeElapsed { get; set; } = 0f;
  29. }
  30. [RegisterComponent]
  31. public sealed partial class CaptureAreaComponent : Component
  32. {
  33. /// <summary>
  34. /// The name for this capturable area
  35. /// </summary>
  36. [DataField("name")]
  37. public string Name { get; set; } = "Objective Area";
  38. /// <summary>
  39. /// How long does the area need to be held for, in seconds
  40. /// </summary>
  41. [DataField("captureDuration")]
  42. public float CaptureDuration { get; set; } = 300f;
  43. /// <summary>
  44. /// How far entities need to be to count towards capture
  45. /// </summary>
  46. [DataField("captureRadius")]
  47. public float CaptureRadius { get; set; } = 4f;
  48. /// <summary>
  49. /// What the capture timer is currently at
  50. /// </summary>
  51. [DataField("captureTimer")]
  52. public float CaptureTimer { get; set; } = 0f;
  53. /// <summary>
  54. /// Has 1 minute left been announced?
  55. /// </summary>
  56. [DataField("captureTimerAnnouncement1")]
  57. public bool CaptureTimerAnnouncement1 { get; set; } = false;
  58. /// <summary>
  59. /// Has 2 minute left been announced?
  60. /// </summary>
  61. [DataField("captureTimerAnnouncement2")]
  62. public bool CaptureTimerAnnouncement2 { get; set; } = false;
  63. /// <summary>
  64. /// Is the area currently occupied?
  65. /// </summary>
  66. [DataField("occupied")]
  67. public bool Occupied { get; set; } = false;
  68. /// <summary>
  69. /// Which faction is occupying the area?
  70. /// </summary>
  71. [DataField("controller")]
  72. public string Controller { get; set; } = "";
  73. /// <summary>
  74. /// The previous controller (for announcements when controller changes)
  75. /// </summary>
  76. [DataField("previousController")]
  77. public string PreviousController { get; set; } = "";
  78. /// <summary>
  79. /// Which factions can occupy this area?
  80. /// </summary>
  81. [DataField("capturableFactions")]
  82. public List<string> CapturableFactions { get; set; } = [];
  83. /// <summary>
  84. /// How long the area needs to be contested or lost before the capture timer resets
  85. /// </summary>
  86. [DataField("contestedResetTime")]
  87. public float ContestedResetTime { get; set; } = 10f;
  88. /// <summary>
  89. /// Current timer tracking how long the area has been contested or lost
  90. /// </summary>
  91. [DataField("contestedTimer")]
  92. public float ContestedTimer { get; set; } = 0f;
  93. /// <summary>
  94. /// The last controller before the area became contested or lost
  95. /// </summary>
  96. [DataField("lastController")]
  97. public string LastController { get; set; } = "";
  98. }