Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions Content.Server/GameTicking/Rules/ZombieRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public sealed class ZombieRuleSystem : GameRuleSystem<ZombieRuleComponent>
[Dependency] private readonly AntagSelectionSystem _antagSelection = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly AnnouncerSystem _announcer = default!;
[Dependency] private readonly GameTicker _gameTicker = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -89,7 +90,7 @@ private void OnRoundEndText(RoundEndTextAppendEvent ev)
("username", player.Value)));
}

var healthy = GetHealthyHumans();
var healthy = GetHealthyHumans(true);
// 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 * zombie.InitialInfectedNames.Count)
Expand Down Expand Up @@ -185,7 +186,7 @@ private void OnZombifySelf(EntityUid uid, PendingZombieComponent component, Zomb
/// <param name="includeOffStation">Include healthy players that are not on the station grid</param>
/// <param name="includeDead">Should dead zombies be included in the count</param>
/// <returns></returns>
private float GetInfectedFraction(bool includeOffStation = true, bool includeDead = false)
private float GetInfectedFraction(bool includeOffStation = false, bool includeDead = true)
{
var players = GetHealthyHumans(includeOffStation);
var zombieCount = 0;
Expand All @@ -205,14 +206,14 @@ private float GetInfectedFraction(bool includeOffStation = true, bool includeDea
/// Flying off via a shuttle disqualifies you.
/// </summary>
/// <returns></returns>
private List<EntityUid> GetHealthyHumans(bool includeOffStation = true)
private List<EntityUid> GetHealthyHumans(bool includeOffStation = false)
{
var healthy = new List<EntityUid>();

var stationGrids = new HashSet<EntityUid>();
if (!includeOffStation)
{
foreach (var station in _station.GetStationsSet())
foreach (var station in _gameTicker.GetSpawnableStations())
{
if (TryComp<StationDataComponent>(station, out var data) && _station.GetLargestGrid(data) is { } grid)
stationGrids.Add(grid);
Expand All @@ -223,13 +224,11 @@ private List<EntityUid> GetHealthyHumans(bool includeOffStation = true)
var zombers = GetEntityQuery<ZombieComponent>();
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))
if (!_mobState.IsAlive(uid, mob)
|| HasComp<PendingZombieComponent>(uid) //Do not include infected players in the "Healthy players" list.
|| HasComp<ZombifyOnDeathComponent>(uid)
|| zombers.HasComponent(uid)
|| !includeOffStation && !stationGrids.Contains(xform.GridUid ?? EntityUid.Invalid))
continue;

healthy.Add(uid);
Expand Down