CatStation/Content.Server/GameTicking/Rules/VariationPass/EntitySpawnVariationPassSystem.cs
DrSmugleaf 65f5f67cd5
Make every EntitySystem partial (#45220)
* Make every EntitySystem partial

* Oobs thats for a diff PR

* Also oops on that one

* Test systems

* git are we fr

* Update file templates

* cleanup empty classes while we are here

* forgor

---------

Co-authored-by: AJCM-git <ajcm_mail@disroot.org>
2026-08-14 18:24:47 +00:00

29 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 partial 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);
}
}
}
}