1
0

ValleyPointsSystem.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. using System.Linq;
  2. using Content.Server.GameTicking.Rules.Components;
  3. using Content.Server.Chat.Managers;
  4. using Content.Server.Popups;
  5. using Content.Shared.GameTicking.Components;
  6. using Content.Shared.Mobs;
  7. using Content.Shared.Mobs.Components;
  8. using Content.Shared.NPC.Components;
  9. using Content.Shared.Interaction;
  10. using Content.Shared.Hands.EntitySystems;
  11. using Robust.Shared.Timing;
  12. using Content.Server.KillTracking;
  13. using Content.Shared.NPC.Systems;
  14. using Content.Server.RoundEnd;
  15. namespace Content.Server.GameTicking.Rules;
  16. /// <summary>
  17. /// Handles the Valley gamemode points system for Blugoslavia vs Insurgents
  18. /// </summary>
  19. public sealed class ValleyPointsRuleSystem : GameRuleSystem<ValleyPointsComponent>
  20. {
  21. [Dependency] private readonly ILogManager _logManager = default!;
  22. [Dependency] private readonly IGameTiming _timing = default!;
  23. [Dependency] private readonly IChatManager _chatManager = default!;
  24. [Dependency] private readonly PopupSystem _popup = default!;
  25. [Dependency] private readonly EntityLookupSystem _lookup = default!;
  26. [Dependency] private readonly SharedTransformSystem _transform = default!;
  27. [Dependency] private readonly SharedHandsSystem _hands = default!;
  28. [Dependency] private readonly RoundEndSystem _roundEndSystem = default!;
  29. [Dependency] private readonly NpcFactionSystem _factionSystem = default!; // Added dependency
  30. private ISawmill _sawmill = default!;
  31. private TimeSpan _lastSupplyBoxCheck = TimeSpan.Zero;
  32. private const float SupplyBoxCheckInterval = 30f; // Check every 30 seconds
  33. public override void Initialize()
  34. {
  35. base.Initialize();
  36. _sawmill = _logManager.GetSawmill("valley-points");
  37. SubscribeLocalEvent<MobStateChangedEvent>(OnMobStateChanged);
  38. SubscribeLocalEvent<CaptureAreaComponent, ComponentStartup>(OnCaptureAreaStartup);
  39. SubscribeLocalEvent<KillReportedEvent>(OnKillReported);
  40. }
  41. protected override void Started(EntityUid uid, ValleyPointsComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
  42. {
  43. component.GameStartTime = _timing.CurTime;
  44. component.LastCheckpointBonusTime = _timing.CurTime;
  45. component.LastScoreAnnouncementTime = _timing.CurTime;
  46. _lastSupplyBoxCheck = _timing.CurTime;
  47. // Initialize checkpoints immediately
  48. InitializeCheckpoints(component);
  49. // Delay civilian count initialization to allow spawning
  50. Timer.Spawn(TimeSpan.FromSeconds(5), () => InitializeCivilianCount(component));
  51. _sawmill.Info("Valley gamemode started - 50 minute timer begins now");
  52. AnnounceToAll("Valley conflict has begun! Blugoslavia and Insurgents fight for control.");
  53. }
  54. private void OnCaptureAreaStartup(EntityUid uid, CaptureAreaComponent component, ComponentStartup args)
  55. {
  56. if (HasComp<ValleyCheckpointComponent>(uid))
  57. {
  58. component.CapturableFactions.Clear();
  59. component.CapturableFactions.Add("Blugoslavia");
  60. component.CapturableFactions.Add("Insurgents");
  61. }
  62. }
  63. private void OnMobStateChanged(MobStateChangedEvent args)
  64. {
  65. if (args.NewMobState == MobState.Dead && args.OldMobState == MobState.Alive)
  66. {
  67. if (TryComp<NpcFactionMemberComponent>(args.Target, out var factionMember) &&
  68. factionMember.Factions.Any(f => f == "Blugoslavia"))
  69. {
  70. var ruleQuery = EntityQueryEnumerator<ValleyPointsComponent>();
  71. if (ruleQuery.MoveNext(out var ruleEntity, out _))
  72. {
  73. AwardInsurgentKill(ruleEntity);
  74. }
  75. }
  76. }
  77. }
  78. private void InitializeCivilianCount(ValleyPointsComponent component)
  79. {
  80. // Count civilian NPCs on the map
  81. var civilianCount = 0;
  82. var query = EntityQueryEnumerator<NpcFactionMemberComponent>();
  83. while (query.MoveNext(out _, out var faction))
  84. {
  85. if (faction.Factions.Any(f => f == "Civilian"))
  86. civilianCount++;
  87. }
  88. component.InitialCivilianCount = civilianCount;
  89. component.TotalCivilianNPCs = civilianCount;
  90. _sawmill.Info($"Initialized with {civilianCount} civilian NPCs");
  91. }
  92. private void InitializeCheckpoints(ValleyPointsComponent valley)
  93. {
  94. var checkpointQuery = EntityQueryEnumerator<ValleyCheckpointComponent, CaptureAreaComponent>();
  95. while (checkpointQuery.MoveNext(out var uid, out var checkpoint, out var area))
  96. {
  97. area.CapturableFactions.Clear();
  98. area.CapturableFactions.Add("Blugoslavia");
  99. area.CapturableFactions.Add("Insurgents");
  100. _sawmill.Info($"Initialized Valley checkpoint: {area.Name}");
  101. }
  102. }
  103. public override void Update(float frameTime)
  104. {
  105. base.Update(frameTime);
  106. var query = EntityQueryEnumerator<ValleyPointsComponent, GameRuleComponent>();
  107. while (query.MoveNext(out var uid, out var valley, out var gameRule))
  108. {
  109. if (!GameTicker.IsGameRuleAdded(uid, gameRule))
  110. continue;
  111. if (valley.GameEnded)
  112. continue;
  113. UpdateCheckpointHolding(valley);
  114. UpdateSupplyBoxSecuring(valley);
  115. CheckCaptureAreaControl(valley);
  116. CheckSupplyBoxDeliveries(valley);
  117. CheckScoreAnnouncement(valley);
  118. CheckWinConditions(uid, valley);
  119. CheckTimeLimit(uid, valley);
  120. }
  121. }
  122. private void CheckSupplyBoxDeliveries(ValleyPointsComponent valley)
  123. {
  124. var currentTime = _timing.CurTime;
  125. // Only check every 30 seconds
  126. if ((currentTime - _lastSupplyBoxCheck).TotalSeconds < SupplyBoxCheckInterval)
  127. return;
  128. _lastSupplyBoxCheck = currentTime;
  129. // Check all capture areas for nearby supply boxes
  130. var areaQuery = EntityQueryEnumerator<CaptureAreaComponent>();
  131. while (areaQuery.MoveNext(out var areaUid, out var area))
  132. {
  133. var areaPos = _transform.GetMapCoordinates(areaUid);
  134. var nearbyEntities = _lookup.GetEntitiesInRange(areaPos, 3f);
  135. foreach (var entity in nearbyEntities)
  136. {
  137. if (TryComp<ValleySupplyBoxComponent>(entity, out var supplyBox) && !supplyBox.Delivered)
  138. {
  139. // Check if this is a checkpoint controlled by Blugoslavia
  140. if (HasComp<ValleyCheckpointComponent>(areaUid) && area.Controller == "Blugoslavia")
  141. {
  142. ProcessBlugoslavianSupplyDelivery(valley, entity, areaUid, area);
  143. }
  144. // Check if this is the Insurgent base
  145. else if (IsInsurgentBase(areaUid, area))
  146. {
  147. ProcessInsurgentSupplyTheft(valley, entity, areaUid, area);
  148. }
  149. }
  150. }
  151. }
  152. }
  153. private bool IsInsurgentBase(EntityUid areaUid, CaptureAreaComponent area)
  154. {
  155. // Check if this area is marked as insurgent base
  156. return area.Name.ToLower().Contains("insurgent");
  157. }
  158. private void ProcessBlugoslavianSupplyDelivery(ValleyPointsComponent valley, EntityUid supplyBox, EntityUid checkpoint, CaptureAreaComponent area)
  159. {
  160. if (!TryComp<ValleySupplyBoxComponent>(supplyBox, out var boxComp))
  161. return;
  162. boxComp.Delivered = true;
  163. boxComp.SecuringAtCheckpoint = checkpoint;
  164. // Start securing timer
  165. valley.SecuringSupplyBoxes[supplyBox] = _timing.CurTime;
  166. if (TryComp<ValleyCheckpointComponent>(checkpoint, out var checkpointComp))
  167. {
  168. checkpointComp.SecuringBoxes.Add(supplyBox);
  169. }
  170. _sawmill.Info($"Supply box delivery started at {area.Name}, securing for {valley.SupplyBoxSecureTime} seconds");
  171. }
  172. private void ProcessInsurgentSupplyTheft(ValleyPointsComponent valley, EntityUid supplyBox, EntityUid baseArea, CaptureAreaComponent area)
  173. {
  174. if (!TryComp<ValleySupplyBoxComponent>(supplyBox, out var boxComp))
  175. return;
  176. boxComp.Delivered = true;
  177. // Award points immediately for insurgent theft
  178. valley.InsurgentPoints += valley.StolenSupplyBoxPoints;
  179. _sawmill.Info($"Insurgents awarded {valley.StolenSupplyBoxPoints} points for stolen supply box at {area.Name}. Total: {valley.InsurgentPoints}");
  180. AnnounceToAll($"Insurgents: +{valley.StolenSupplyBoxPoints} points (Supply Theft at {area.Name}) - Total: {valley.InsurgentPoints}");
  181. // Remove the supply box
  182. QueueDel(supplyBox);
  183. }
  184. private void CheckCaptureAreaControl(ValleyPointsComponent valley)
  185. {
  186. var checkpointQuery = EntityQueryEnumerator<ValleyCheckpointComponent, CaptureAreaComponent>();
  187. while (checkpointQuery.MoveNext(out var uid, out var checkpoint, out var area))
  188. {
  189. var blugoslaviaControlled = area.Controller == "Blugoslavia";
  190. if (checkpoint.BlugoslaviaControlled != blugoslaviaControlled)
  191. {
  192. checkpoint.BlugoslaviaControlled = blugoslaviaControlled;
  193. SetCheckpointControl(valley, uid, blugoslaviaControlled);
  194. }
  195. }
  196. }
  197. public void SetCheckpointControl(ValleyPointsComponent valley, EntityUid checkpoint, bool blugoslaviaControlled)
  198. {
  199. if (blugoslaviaControlled)
  200. {
  201. if (!valley.BlugoslaviaHeldCheckpoints.Contains(checkpoint))
  202. {
  203. valley.BlugoslaviaHeldCheckpoints.Add(checkpoint);
  204. valley.CheckpointHoldStartTimes[checkpoint] = _timing.CurTime;
  205. _sawmill.Info($"Blugoslavia gained control of checkpoint {checkpoint}");
  206. }
  207. }
  208. else
  209. {
  210. if (valley.BlugoslaviaHeldCheckpoints.Contains(checkpoint))
  211. {
  212. valley.BlugoslaviaHeldCheckpoints.Remove(checkpoint);
  213. valley.CheckpointHoldStartTimes.Remove(checkpoint);
  214. _sawmill.Info($"Blugoslavia lost control of checkpoint {checkpoint}");
  215. }
  216. }
  217. }
  218. private void UpdateCheckpointHolding(ValleyPointsComponent valley)
  219. {
  220. var currentTime = _timing.CurTime;
  221. var checkpointsToAward = new List<EntityUid>();
  222. // Check individual checkpoint holding - award points every minute (60 seconds)
  223. foreach (var kvp in valley.CheckpointHoldStartTimes.ToList())
  224. {
  225. var checkpoint = kvp.Key;
  226. var startTime = kvp.Value;
  227. if ((currentTime - startTime).TotalSeconds >= 60f) // 1 minute instead of 5
  228. {
  229. checkpointsToAward.Add(checkpoint);
  230. valley.CheckpointHoldStartTimes[checkpoint] = currentTime;
  231. }
  232. }
  233. if (checkpointsToAward.Count > 0)
  234. {
  235. var pointsAwarded = checkpointsToAward.Count * 5; // 5 points per minute instead of 25 per 5 minutes
  236. valley.BlugoslaviaPoints += pointsAwarded;
  237. _sawmill.Info($"Blugoslavia awarded {pointsAwarded} points for holding {checkpointsToAward.Count} checkpoints");
  238. AnnounceToAll($"Blugoslavia: +{pointsAwarded} points (Checkpoint Control) - Total: {valley.BlugoslaviaPoints}");
  239. }
  240. // Check for all checkpoints bonus - still every 5 minutes but reduced frequency
  241. if (valley.BlugoslaviaHeldCheckpoints.Count >= 4 && // Assuming 4 checkpoints total
  242. (currentTime - valley.LastCheckpointBonusTime).TotalSeconds >= valley.CheckpointBonusInterval)
  243. {
  244. valley.BlugoslaviaPoints += valley.AllCheckpointsBonusPoints;
  245. valley.LastCheckpointBonusTime = currentTime;
  246. _sawmill.Info($"Blugoslavia awarded {valley.AllCheckpointsBonusPoints} bonus points for controlling all checkpoints");
  247. AnnounceToAll($"Blugoslavia: +{valley.AllCheckpointsBonusPoints} points (All Checkpoints Bonus) - Total: {valley.BlugoslaviaPoints}");
  248. }
  249. }
  250. private void UpdateSupplyBoxSecuring(ValleyPointsComponent valley)
  251. {
  252. var currentTime = _timing.CurTime;
  253. var securedBoxes = new List<EntityUid>();
  254. // Check all checkpoints for securing boxes
  255. var checkpointQuery = EntityQueryEnumerator<ValleyCheckpointComponent>();
  256. while (checkpointQuery.MoveNext(out var checkpointUid, out var checkpoint))
  257. {
  258. var boxesToRemove = new List<EntityUid>();
  259. foreach (var boxUid in checkpoint.SecuringBoxes)
  260. {
  261. if (!TryComp<ValleySupplyBoxComponent>(boxUid, out var boxComp))
  262. {
  263. boxesToRemove.Add(boxUid);
  264. continue;
  265. }
  266. // Check if box is still near the checkpoint
  267. var boxPos = _transform.GetMapCoordinates(boxUid);
  268. var checkpointPos = _transform.GetMapCoordinates(checkpointUid);
  269. if ((boxPos.Position - checkpointPos.Position).Length() > 3f)
  270. {
  271. // Box moved away, cancel securing
  272. boxesToRemove.Add(boxUid);
  273. boxComp.Delivered = false;
  274. boxComp.SecuringAtCheckpoint = null;
  275. _sawmill.Info("Supply box moved away from checkpoint, delivery cancelled");
  276. continue;
  277. }
  278. // Check if securing time has elapsed
  279. if (valley.SecuringSupplyBoxes.TryGetValue(boxUid, out var startTime) &&
  280. (currentTime - startTime).TotalSeconds >= valley.SupplyBoxSecureTime)
  281. {
  282. securedBoxes.Add(boxUid);
  283. boxesToRemove.Add(boxUid);
  284. }
  285. }
  286. // Remove boxes that are no longer securing
  287. foreach (var box in boxesToRemove)
  288. {
  289. checkpoint.SecuringBoxes.Remove(box);
  290. }
  291. }
  292. // Award points for secured boxes
  293. foreach (var box in securedBoxes)
  294. {
  295. valley.SecuringSupplyBoxes.Remove(box);
  296. valley.BlugoslaviaPoints += valley.SupplyBoxDeliveryPoints;
  297. _sawmill.Info($"Blugoslavia awarded {valley.SupplyBoxDeliveryPoints} points for secured supply box delivery");
  298. AnnounceToAll($"Blugoslavia: +{valley.SupplyBoxDeliveryPoints} points (Supply Delivery) - Total: {valley.BlugoslaviaPoints}");
  299. // Delete the secured box
  300. QueueDel(box);
  301. }
  302. }
  303. /// <summary>
  304. /// Award points to insurgents for killing a Blugoslavian soldier.
  305. /// </summary>
  306. public void AwardInsurgentKill(EntityUid ruleEntity)
  307. {
  308. if (!TryComp<ValleyPointsComponent>(ruleEntity, out var valley))
  309. return;
  310. valley.InsurgentPoints += valley.KillPoints;
  311. _sawmill.Info($"Insurgents awarded {valley.KillPoints} points for kill. Total: {valley.InsurgentPoints}");
  312. AnnounceToAll($"Insurgents: +{valley.KillPoints} points (Kill) - Total: {valley.InsurgentPoints}");
  313. }
  314. /// <summary>
  315. /// Award points to Blugoslavia for successfully escorting a convoy.
  316. /// </summary>
  317. public void AwardConvoyEscort(EntityUid ruleEntity)
  318. {
  319. if (!TryComp<ValleyPointsComponent>(ruleEntity, out var valley))
  320. return;
  321. valley.BlugoslaviaPoints += valley.ConvoyEscortPoints;
  322. _sawmill.Info($"Blugoslavia awarded {valley.ConvoyEscortPoints} points for convoy escort. Total: {valley.BlugoslaviaPoints}");
  323. AnnounceToAll($"Blugoslavia: +{valley.ConvoyEscortPoints} points (Convoy Escort) - Total: {valley.BlugoslaviaPoints}");
  324. }
  325. private void CheckWinConditions(EntityUid uid, ValleyPointsComponent valley)
  326. {
  327. if (valley.BlugoslaviaPoints >= valley.PointsToWin)
  328. {
  329. EndGame(uid, valley, "Blugoslavia");
  330. }
  331. else if (valley.InsurgentPoints >= valley.PointsToWin)
  332. {
  333. EndGame(uid, valley, "Insurgents");
  334. }
  335. }
  336. private void CheckTimeLimit(EntityUid uid, ValleyPointsComponent valley)
  337. {
  338. var elapsed = (_timing.CurTime - valley.GameStartTime).TotalMinutes;
  339. if (elapsed >= valley.MatchDurationMinutes)
  340. {
  341. // Determine winner by points
  342. if (valley.BlugoslaviaPoints > valley.InsurgentPoints)
  343. {
  344. EndGame(uid, valley, "Blugoslavia");
  345. }
  346. else if (valley.InsurgentPoints > valley.BlugoslaviaPoints)
  347. {
  348. EndGame(uid, valley, "Insurgents");
  349. }
  350. else
  351. {
  352. EndGame(uid, valley, "Draw");
  353. }
  354. }
  355. }
  356. private void EndGame(EntityUid uid, ValleyPointsComponent valley, string winner)
  357. {
  358. valley.GameEnded = true;
  359. var finalMessage = winner switch
  360. {
  361. "Blugoslavia" => $"VICTORY: Blugoslavia wins with {valley.BlugoslaviaPoints} points!",
  362. "Insurgents" => $"VICTORY: Insurgents win with {valley.InsurgentPoints} points!",
  363. "Draw" => $"DRAW: Match ended in a tie! Blugoslavia: {valley.BlugoslaviaPoints}, Insurgents: {valley.InsurgentPoints}",
  364. _ => "Match ended."
  365. };
  366. _sawmill.Info($"Valley gamemode ended: {finalMessage}");
  367. AnnounceToAll(finalMessage);
  368. _roundEndSystem.EndRound();
  369. }
  370. private string CheckUNObjectives(ValleyPointsComponent valley)
  371. {
  372. var civilianSurvivalRate = valley.TotalCivilianNPCs > 0
  373. ? (float)valley.AliveCivilianNPCs / valley.TotalCivilianNPCs
  374. : 1.0f;
  375. var query = EntityQueryEnumerator<CaptureAreaComponent>();
  376. while (query.MoveNext(out var uid, out var area))
  377. {
  378. if (area.Name == "UN Hospital")
  379. {
  380. if (area.Occupied == true)
  381. {
  382. valley.UNHospitalZoneControlled = false;
  383. }
  384. else
  385. {
  386. valley.UNHospitalZoneControlled = true;
  387. }
  388. }
  389. }
  390. var unSuccess = civilianSurvivalRate >= valley.RequiredCivilianSurvivalRate &&
  391. valley.UNHospitalZoneControlled &&
  392. valley.UNNeutralityMaintained;
  393. var unMessage = unSuccess
  394. ? $"UN OBJECTIVES COMPLETED: {civilianSurvivalRate:P0} civilian survival rate maintained, hospital zone secured, neutrality preserved."
  395. : $"UN OBJECTIVES FAILED: {civilianSurvivalRate:P0} civilian survival rate, hospital zone: {(valley.UNHospitalZoneControlled ? "Secured" : "Lost")}, neutrality: {(valley.UNNeutralityMaintained ? "Maintained" : "Violated")}";
  396. _sawmill.Info(unMessage);
  397. return unMessage;
  398. }
  399. private void AnnounceToAll(string message)
  400. {
  401. _chatManager.DispatchServerAnnouncement(message);
  402. }
  403. protected override void AppendRoundEndText(EntityUid uid, ValleyPointsComponent component, GameRuleComponent gameRule, ref RoundEndTextAppendEvent args)
  404. {
  405. if (component.BlugoslaviaPoints > component.InsurgentPoints)
  406. {
  407. args.AddLine($"[color=lime]Blugoslavia[/color] has won!");
  408. }
  409. else if (component.BlugoslaviaPoints < component.InsurgentPoints)
  410. {
  411. args.AddLine($"[color=lime]Insurgents[/color] have won!");
  412. }
  413. else
  414. {
  415. args.AddLine("The round ended in a [color=yellow]draw[/color]!");
  416. }
  417. args.AddLine("");
  418. args.AddLine($"Blugoslavia: {component.BlugoslaviaPoints} points");
  419. args.AddLine($"Insurgents: {component.InsurgentPoints} points");
  420. args.AddLine("");
  421. args.AddLine($"UN Objectives:");
  422. args.AddLine(CheckUNObjectives(component));
  423. }
  424. private void OnKillReported(ref KillReportedEvent ev)
  425. {
  426. var query = EntityQueryEnumerator<ValleyPointsComponent, GameRuleComponent>();
  427. while (query.MoveNext(out var uid, out var valley, out var rule))
  428. {
  429. if (!GameTicker.IsGameRuleActive(uid, rule))
  430. continue;
  431. // Check if UN member was involved (either as killer or victim) TODO: Check killer
  432. bool unInvolved = false;
  433. // Check if victim is UN
  434. if (TryComp<NpcFactionMemberComponent>(ev.Entity, out var victimFaction))
  435. {
  436. if (_factionSystem.IsMember(ev.Entity, "UnitedNations"))
  437. {
  438. unInvolved = true;
  439. }
  440. // If UN was involved, set neutrality to false
  441. if (unInvolved && valley.UNNeutralityMaintained)
  442. {
  443. valley.UNNeutralityMaintained = false;
  444. _sawmill.Info("UN neutrality violated - UN member involved in combat");
  445. AnnounceToAll("UN neutrality has been violated!");
  446. }
  447. // Award points to Insurgents for killing Blugoslavian soldiers
  448. if (TryComp<NpcFactionMemberComponent>(ev.Entity, out var deadFaction) &&
  449. deadFaction.Factions.Any(f => f == "Blugoslavia"))
  450. {
  451. valley.InsurgentPoints += valley.KillPoints;
  452. _sawmill.Info($"Insurgents awarded {valley.KillPoints} points for Blugoslavian kill. Total: {valley.InsurgentPoints}");
  453. AnnounceToAll($"Insurgents: +{valley.KillPoints} points (Kill) - Total: {valley.InsurgentPoints}");
  454. }
  455. }
  456. }
  457. }
  458. private void CheckScoreAnnouncement(ValleyPointsComponent valley)
  459. {
  460. var currentTime = _timing.CurTime;
  461. // Announce scores every 5 minutes (300 seconds)
  462. if ((currentTime - valley.LastScoreAnnouncementTime).TotalSeconds >= 300f)
  463. {
  464. valley.LastScoreAnnouncementTime = currentTime;
  465. var elapsedMinutes = (currentTime - valley.GameStartTime).TotalMinutes;
  466. var remainingMinutes = valley.MatchDurationMinutes - elapsedMinutes;
  467. var scoreMessage = $"SCORE UPDATE ({remainingMinutes:F0} minutes remaining): " +
  468. $"Blugoslavia: {valley.BlugoslaviaPoints} points | " +
  469. $"Insurgents: {valley.InsurgentPoints} points";
  470. _sawmill.Info($"Score announcement: {scoreMessage}");
  471. AnnounceToAll(scoreMessage);
  472. }
  473. }
  474. }