Disease Tweaks (#7136)

This commit is contained in:
Rane
2022-03-20 18:29:12 -04:00
committed by GitHub
parent 41f77e6889
commit 1759bf509b
6 changed files with 23 additions and 15 deletions

View File

@@ -3,6 +3,7 @@ using Content.Server.Chat.Managers;
using Content.Server.Disease.Components;
using Content.Server.Disease;
using Content.Shared.Disease;
using Content.Shared.MobState.Components;
using Robust.Shared.Random;
using Robust.Shared.Prototypes;
@@ -32,16 +33,21 @@ public sealed class DiseaseOutbreak : StationEvent
public override float Weight => WeightNormal;
protected override float EndAfter => 1.0f;
/// <summary>
/// Finds 2-5 random entities that can host diseases
/// Finds 2-5 random, alive entities that can host diseases
/// and gives them a randomly selected disease.
/// They all get the same disease.
/// </summary>
public override void Startup()
{
base.Startup();
var targetList = _entityManager.EntityQuery<DiseaseCarrierComponent>().ToList();
_random.Shuffle(targetList);
List<DiseaseCarrierComponent> aliveList = new();
foreach (var (carrier, mobState) in _entityManager.EntityQuery<DiseaseCarrierComponent, MobStateComponent>())
{
if (!mobState.IsDead())
aliveList.Add(carrier);
}
_random.Shuffle(aliveList);
/// We're going to filter the above out to only alive mobs. Might change after future mobstate rework
var toInfect = _random.Next(2, 5);
@@ -51,8 +57,8 @@ public sealed class DiseaseOutbreak : StationEvent
return;
var diseaseSystem = EntitySystem.Get<DiseaseSystem>();
foreach (var target in targetList)
/// Now we give it to people in the list of living disease carriers earlier
foreach (var target in aliveList)
{
if (toInfect-- == 0)
break;