30 lines
1.1 KiB
C#
30 lines
1.1 KiB
C#
using Content.Server.GameTicking.Rules.VariationPass.Components;
|
|
using Content.Shared.Storage;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Server.GameTicking.Rules.VariationPass;
|
|
|
|
/// <inheritdoc cref="EntitySpawnVariationPassComponent"/>
|
|
public sealed class EntitySpawnVariationPassSystem : VariationPassSystem<EntitySpawnVariationPassComponent>
|
|
{
|
|
protected override void ApplyVariation(Entity<EntitySpawnVariationPassComponent> ent, ref StationVariationPassEvent args)
|
|
{
|
|
var totalTiles = Stations.GetTileCount(args.Station.AsNullable());
|
|
|
|
var dirtyMod = Random.NextGaussian(ent.Comp.TilesPerEntityAverage, ent.Comp.TilesPerEntityStdDev);
|
|
var trashTiles = Math.Max((int) (totalTiles * (1 / dirtyMod)), 0);
|
|
|
|
for (var i = 0; i < trashTiles; i++)
|
|
{
|
|
if (!TryFindRandomTileOnStation(args.Station, out _, out _, out var coords))
|
|
continue;
|
|
|
|
var ents = EntitySpawnCollection.GetSpawns(ent.Comp.Entities, Random);
|
|
foreach (var spawn in ents)
|
|
{
|
|
SpawnAtPosition(spawn, coords);
|
|
}
|
|
}
|
|
}
|
|
}
|