using Robust.Shared.Prototypes; using Robust.Shared.Random; namespace Content.Shared.EntityTable.EntitySelectors; /// /// Gets the spawns from the entity table prototype specified. /// Can be used to reuse common tables. /// public sealed partial class NestedSelector : EntityTableSelectorWithNestedBase { /// /// The prototype from which to draw random items. /// [DataField(required: true)] public ProtoId TableId; /// > public override bool CheckConditions(IEntityManager entMan, IPrototypeManager proto, EntityTableContext ctx) { using var scoped = ScopedConditions(ctx); return base.CheckConditions(entMan, proto, ctx) && proto.Index(TableId).Table.CheckConditions(entMan, proto, ctx); } /// > protected override IEnumerable GetSpawnsImplementation(IRobustRandom rand, IEntityManager entMan, IPrototypeManager proto, EntityTableContext ctx) { using var scoped = ScopedConditions(ctx); foreach (var spawn in proto.Index(TableId).Table.GetSpawns(rand, entMan, proto, ctx)) { yield return spawn; } } /// > protected override IEnumerable<(EntProtoId spawn, double)> ListSpawnsImplementation(IEntityManager entMan, IPrototypeManager proto, EntityTableContext ctx) { return proto.Index(TableId).Table.ListSpawns(entMan, proto, ctx); } /// > protected override IEnumerable<(EntProtoId spawn, double)> AverageSpawnsImplementation(IEntityManager entMan, IPrototypeManager proto, EntityTableContext ctx) { return proto.Index(TableId).Table.AverageSpawns(entMan, proto, ctx); } /// public override string ToString() { return $"Nested({TableId})"; } }