Files
tbd-station-14/Content.Server/StationEvents/Events/SpiderSpawn.cs
2023-01-22 18:50:05 -04:00

33 lines
985 B
C#

using Content.Server.StationEvents.Components;
using Content.Shared.Actions;
using Robust.Shared.Random;
using System.Linq;
namespace Content.Server.StationEvents.Events;
public sealed class SpiderSpawn : StationEventSystem
{
public override string Prototype => "SpiderSpawn";
public override void Started()
{
base.Started();
var spawnLocations = EntityManager.EntityQuery<VentCritterSpawnLocationComponent>().ToList();
RobustRandom.Shuffle(spawnLocations);
var mod = Math.Sqrt(GetSeverityModifier());
var spawnAmount = (int) (RobustRandom.Next(4, 8) * mod);
Sawmill.Info($"Spawning {spawnAmount} of spiders");
foreach (var location in spawnLocations)
{
if (spawnAmount-- == 0)
break;
var coords = EntityManager.GetComponent<TransformComponent>(location.Owner);
EntityManager.SpawnEntity("MobGiantSpiderAngry", coords.Coordinates);
}
}
}