2024-01-30 22:52:35 -07:00
|
|
|
|
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)
|
|
|
|
|
|
{
|
2025-08-08 11:22:34 -04:00
|
|
|
|
var totalTiles = Stations.GetTileCount(args.Station.AsNullable());
|
2024-01-30 22:52:35 -07:00
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|