CatStation/Content.Shared/EntityTable/EntitySelectors/NestedSelector.cs
Fildrance 8bf0961e5a
Feature/refactor xenoarch trigger to be entity table ed (#45608)
* refactor: rough strokes for initial implementation

* refactor: fix ada remarks

* refactor: fix XenoArtifactNodeParser not displaying trigger and effect properly in autocompletion

* refactor: more changes for IsNotRepeatingCondition

* refactor: update triggers declarations

* refactor: remove IsNotRepeatingCondition - duplicate

* refactor: fixup after merge with master

* refactor: properly handle creation of improper trigger set, all selectors gt ToString override!

* refactor: fix missing weight for some triggers, XenoArtifactCommand.UnlockAllNodes now accepts multiple entries

* refactor: fix trigger hints loc being name explicitly and failing tests

* yaml changes

* rename

* refactor: fix xml-doc copy-paste for XenoArtifactTriggerParser

---------

Co-authored-by: iaada <iaada@users.noreply.github.com>
2026-08-31 20:58:52 +00:00

56 lines
1.9 KiB
C#

using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Shared.EntityTable.EntitySelectors;
/// <summary>
/// Gets the spawns from the entity table prototype specified.
/// Can be used to reuse common tables.
/// </summary>
public sealed partial class NestedSelector : EntityTableSelectorWithNestedBase
{
/// <summary>
/// The prototype from which to draw random items.
/// </summary>
[DataField(required: true)]
public ProtoId<EntityTablePrototype> TableId;
/// <inheritdoc/>>
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);
}
/// <inheritdoc/>>
protected override IEnumerable<EntProtoId> 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;
}
}
/// <inheritdoc/>>
protected override IEnumerable<(EntProtoId spawn, double)> ListSpawnsImplementation(IEntityManager entMan, IPrototypeManager proto, EntityTableContext ctx)
{
return proto.Index(TableId).Table.ListSpawns(entMan, proto, ctx);
}
/// <inheritdoc/>>
protected override IEnumerable<(EntProtoId spawn, double)> AverageSpawnsImplementation(IEntityManager entMan, IPrototypeManager proto, EntityTableContext ctx)
{
return proto.Index(TableId).Table.AverageSpawns(entMan, proto, ctx);
}
/// <inheritdoc/>
public override string ToString()
{
return $"Nested({TableId})";
}
}