CaptureAreaComponent.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. //for points-based
  30. /// <summary>
  31. /// The first faction that can get points from capture.
  32. /// </summary>
  33. [DataField("pointsFactionName1")]
  34. public string PointsFactionName1 { get; set; } = "";
  35. /// <summary>
  36. /// The first faction that can get points from capture.
  37. /// </summary>
  38. [DataField("pointsFactionName2")]
  39. public string PointsFactionName2 { get; set; } = "";
  40. /// <summary>
  41. /// How many points per minute
  42. /// </summary>
  43. [DataField("pointsPerMinute")]
  44. public int PointsPerMinute { get; set; } = 0;
  45. }
  46. [RegisterComponent]
  47. public sealed partial class CaptureAreaComponent : Component
  48. {
  49. /// <summary>
  50. /// The name for this capturable area
  51. /// </summary>
  52. [DataField("name")]
  53. public string Name { get; set; } = "Objective Area";
  54. /// <summary>
  55. /// How long does the area need to be held for, in seconds
  56. /// </summary>
  57. [DataField("captureDuration")]
  58. public float CaptureDuration { get; set; } = 300f;
  59. /// <summary>
  60. /// How far entities need to be to count towards capture
  61. /// </summary>
  62. [DataField("captureRadius")]
  63. public float CaptureRadius { get; set; } = 4f;
  64. /// <summary>
  65. /// What the capture timer is currently at
  66. /// </summary>
  67. [DataField("captureTimer")]
  68. public float CaptureTimer { get; set; } = 0f;
  69. /// <summary>
  70. /// Has 1 minute left been announced?
  71. /// </summary>
  72. [DataField("captureTimerAnnouncement1")]
  73. public bool CaptureTimerAnnouncement1 { get; set; } = false;
  74. /// <summary>
  75. /// Has 2 minute left been announced?
  76. /// </summary>
  77. [DataField("captureTimerAnnouncement2")]
  78. public bool CaptureTimerAnnouncement2 { get; set; } = false;
  79. /// <summary>
  80. /// Is the area currently occupied?
  81. /// </summary>
  82. [DataField("occupied")]
  83. public bool Occupied { get; set; } = false;
  84. /// <summary>
  85. /// Which faction is occupying the area?
  86. /// </summary>
  87. [DataField("controller")]
  88. public string Controller { get; set; } = "";
  89. /// <summary>
  90. /// The previous controller (for announcements when controller changes)
  91. /// </summary>
  92. [DataField("previousController")]
  93. public string PreviousController { get; set; } = "";
  94. /// <summary>
  95. /// Which factions can occupy this area?
  96. /// </summary>
  97. [DataField("capturableFactions")]
  98. public List<string> CapturableFactions { get; set; } = [];
  99. /// <summary>
  100. /// How long the area needs to be contested or lost before the capture timer resets
  101. /// </summary>
  102. [DataField("contestedResetTime")]
  103. public float ContestedResetTime { get; set; } = 10f;
  104. /// <summary>
  105. /// Current timer tracking how long the area has been contested or lost
  106. /// </summary>
  107. [DataField("contestedTimer")]
  108. public float ContestedTimer { get; set; } = 0f;
  109. /// <summary>
  110. /// The last controller before the area became contested or lost
  111. /// </summary>
  112. [DataField("lastController")]
  113. public string LastController { get; set; } = "";
  114. }