From 70337cff156f0fa8fa13a1661ff86ecfc2195281 Mon Sep 17 00:00:00 2001 From: Kill_Me_I_Noobs <118206719+Vonsant@users.noreply.github.com> Date: Fri, 6 Dec 2024 01:44:41 +0300 Subject: [PATCH] Impro (#126) --- .../GameTicking/GameTicker.Spawning.cs | 2 +- .../GameTicking/Rules/ZombieRuleSystem.cs | 23 ++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Content.Server/GameTicking/GameTicker.Spawning.cs b/Content.Server/GameTicking/GameTicker.Spawning.cs index 15cf30d5259..f045084ed97 100644 --- a/Content.Server/GameTicking/GameTicker.Spawning.cs +++ b/Content.Server/GameTicking/GameTicker.Spawning.cs @@ -43,7 +43,7 @@ public sealed partial class GameTicker // Mainly to avoid allocations. private readonly List _possiblePositions = new(); - private List GetSpawnableStations() + public List GetSpawnableStations() // Corvax-Next { var spawnableStations = new List(); var query = EntityQueryEnumerator(); diff --git a/Content.Server/GameTicking/Rules/ZombieRuleSystem.cs b/Content.Server/GameTicking/Rules/ZombieRuleSystem.cs index bb76721340d..8b024a78dc2 100644 --- a/Content.Server/GameTicking/Rules/ZombieRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/ZombieRuleSystem.cs @@ -33,6 +33,7 @@ public sealed class ZombieRuleSystem : GameRuleSystem [Dependency] private readonly StationSystem _station = default!; [Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly ZombieSystem _zombie = default!; + [Dependency] private readonly GameTicker _gameTicker = default!; // Corvax-Next public override void Initialize() { @@ -84,7 +85,7 @@ protected override void AppendRoundEndText(EntityUid uid, ("username", data.UserName))); } - var healthy = GetHealthyHumans(); + var healthy = GetHealthyHumans(true); // Corvax-Next // Gets a bunch of the living players and displays them if they're under a threshold. // InitialInfected is used for the threshold because it scales with the player count well. if (healthy.Count <= 0 || healthy.Count > 2 * antags.Count) @@ -159,7 +160,7 @@ private void OnZombifySelf(EntityUid uid, IncurableZombieComponent component, Zo /// Include healthy players that are not on the station grid /// Should dead zombies be included in the count /// - private float GetInfectedFraction(bool includeOffStation = true, bool includeDead = false) + private float GetInfectedFraction(bool includeOffStation = false, bool includeDead = true) // Corvax-Next { var players = GetHealthyHumans(includeOffStation); var zombieCount = 0; @@ -179,14 +180,14 @@ private float GetInfectedFraction(bool includeOffStation = true, bool includeDea /// Flying off via a shuttle disqualifies you. /// /// - private List GetHealthyHumans(bool includeOffStation = true) + private List GetHealthyHumans(bool includeOffStation = false) // Corvax-Next { var healthy = new List(); var stationGrids = new HashSet(); if (!includeOffStation) { - foreach (var station in _station.GetStationsSet()) + foreach (var station in _gameTicker.GetSpawnableStations()) // Corvax-Next { if (TryComp(station, out var data) && _station.GetLargestGrid(data) is { } grid) stationGrids.Add(grid); @@ -197,13 +198,13 @@ private List GetHealthyHumans(bool includeOffStation = true) var zombers = GetEntityQuery(); while (players.MoveNext(out var uid, out _, out _, out var mob, out var xform)) { - if (!_mobState.IsAlive(uid, mob)) - continue; - - if (zombers.HasComponent(uid)) - continue; - - if (!includeOffStation && !stationGrids.Contains(xform.GridUid ?? EntityUid.Invalid)) + // Corvax-Next-Start + if (!_mobState.IsAlive(uid, mob) + || HasComp(uid) //Do not include infected players in the "Healthy players" list. + || HasComp(uid) + || zombers.HasComponent(uid) + || !includeOffStation && !stationGrids.Contains(xform.GridUid ?? EntityUid.Invalid)) + // Corvax-Next-End continue; healthy.Add(uid);