mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-18 06:31:14 +03:00
* refactor: entity table condition injection and hierarhical condition checks * refactor: rename IsNotRepeatingCondition into ExcludeEntitiesFromContextCondition, simplify EntityTableSelectorWithChildrenBase.CheckConditions logic, + new test * refactor: fix test using old name of condition * refactor: renaming * refactor: fix no condition + RequireAll case and added test * refactor: GetSpawns no more virtual * refactor: more tests! * refactor: use ScopedConditionsRestore for child conditions in EntityTableSelectorWithChildrenBase, not for current type conditions
48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Shared.EntityTable.EntitySelectors;
|
|
|
|
/// <summary>
|
|
/// Gets spawns from all of the child selectors
|
|
/// </summary>
|
|
public sealed partial class AllSelector : EntityTableSelectorWithChildrenBase
|
|
{
|
|
protected override IEnumerable<EntProtoId> GetSpawnsImplementation(IRobustRandom rand,
|
|
IEntityManager entMan,
|
|
IPrototypeManager proto,
|
|
EntityTableContext ctx)
|
|
{
|
|
using var scoped = ScopedConditions(ctx);
|
|
|
|
foreach (var child in Children)
|
|
{
|
|
foreach (var spawn in child.GetSpawns(rand, entMan, proto, ctx))
|
|
{
|
|
yield return spawn;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override IEnumerable<(EntProtoId spawn, double)> ListSpawnsImplementation(IEntityManager entMan, IPrototypeManager proto, EntityTableContext ctx)
|
|
{
|
|
foreach (var child in Children)
|
|
{
|
|
foreach (var (spawn, prob) in child.ListSpawns(entMan, proto, ctx))
|
|
{
|
|
yield return (spawn, prob);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override IEnumerable<(EntProtoId spawn, double)> AverageSpawnsImplementation(IEntityManager entMan, IPrototypeManager proto, EntityTableContext ctx)
|
|
{
|
|
foreach (var child in Children)
|
|
{
|
|
foreach (var (spawn, prob) in child.AverageSpawns(entMan, proto, ctx))
|
|
{
|
|
yield return (spawn, prob);
|
|
}
|
|
}
|
|
}
|
|
}
|