2022-04-18 18:30:22 -04:00
|
|
|
using Content.Shared.MobState.Components;
|
2022-06-12 01:53:13 -04:00
|
|
|
using Content.Server.Zombies;
|
2022-04-18 18:30:22 -04:00
|
|
|
|
|
|
|
|
namespace Content.Server.StationEvents.Events
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Revives several dead entities as zombies
|
|
|
|
|
/// </summary>
|
2022-07-10 18:48:41 -07:00
|
|
|
public sealed class ZombieOutbreak : StationEventSystem
|
2022-04-18 18:30:22 -04:00
|
|
|
{
|
2022-07-10 18:48:41 -07:00
|
|
|
[Dependency] private readonly ZombifyOnDeathSystem _zombify = default!;
|
2022-04-18 18:30:22 -04:00
|
|
|
|
2022-07-10 18:48:41 -07:00
|
|
|
public override string Prototype => "ZombieOutbreak";
|
2022-04-18 18:30:22 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
2022-07-10 18:48:41 -07:00
|
|
|
/// Finds 1-3 random, dead entities across the station
|
2022-04-18 18:30:22 -04:00
|
|
|
/// and turns them into zombies.
|
|
|
|
|
/// </summary>
|
2022-07-10 18:48:41 -07:00
|
|
|
public override void Started()
|
2022-04-18 18:30:22 -04:00
|
|
|
{
|
2022-07-10 18:48:41 -07:00
|
|
|
base.Started();
|
2022-04-18 18:30:22 -04:00
|
|
|
List<MobStateComponent> deadList = new();
|
2022-07-10 18:48:41 -07:00
|
|
|
foreach (var mobState in EntityManager.EntityQuery<MobStateComponent>())
|
2022-04-18 18:30:22 -04:00
|
|
|
{
|
|
|
|
|
if (mobState.IsDead() || mobState.IsCritical())
|
|
|
|
|
deadList.Add(mobState);
|
|
|
|
|
}
|
2022-07-10 18:48:41 -07:00
|
|
|
RobustRandom.Shuffle(deadList);
|
2022-04-18 18:30:22 -04:00
|
|
|
|
2022-07-10 18:48:41 -07:00
|
|
|
var toInfect = RobustRandom.Next(1, 3);
|
2022-06-26 18:19:27 +10:00
|
|
|
|
2022-04-18 18:30:22 -04:00
|
|
|
foreach (var target in deadList)
|
|
|
|
|
{
|
|
|
|
|
if (toInfect-- == 0)
|
|
|
|
|
break;
|
2022-06-26 18:19:27 +10:00
|
|
|
|
2022-07-10 18:48:41 -07:00
|
|
|
_zombify.ZombifyEntity(target.Owner);
|
2022-04-18 18:30:22 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|