CatStation/Content.Shared/EntityTable/EntitySelectors/EntSelector.cs
Whatstone f339f58945
Replace all uses of System.Random with IRobustRandom, resolve all System.Random warnings. (#32)
* Remove all uses of System.Random

* Use IRobustRandom in BinomialNumberSelector.Get

* Remove remaining ToolRefinableSystem S.Random inst
2026-06-16 23:38:37 +00:00

41 lines
1.3 KiB
C#

using Content.Shared.EntityTable.ValueSelector;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Shared.EntityTable.EntitySelectors;
/// <summary>
/// Gets the spawn for the entity prototype specified at whatever count specified.
/// </summary>
public sealed partial class EntSelector : EntityTableSelector
{
public const string IdDataFieldTag = "id";
[DataField(IdDataFieldTag, required: true)]
public EntProtoId Id;
[DataField]
public NumberSelector Amount = new ConstantNumberSelector(1);
protected override IEnumerable<EntProtoId> GetSpawnsImplementation(IRobustRandom rand,
IEntityManager entMan,
IPrototypeManager proto,
EntityTableContext ctx)
{
var num = Amount.Get(rand);
for (var i = 0; i < num; i++)
{
yield return Id;
}
}
protected override IEnumerable<(EntProtoId spawn, double)> ListSpawnsImplementation(IEntityManager entMan, IPrototypeManager proto, EntityTableContext ctx)
{
yield return (Id, 1f);
}
protected override IEnumerable<(EntProtoId spawn, double)> AverageSpawnsImplementation(IEntityManager entMan, IPrototypeManager proto, EntityTableContext ctx)
{
yield return (Id, Amount.Average());
}
}