diff --git a/Content.Shared/Prototypes/EntityList/EntityListPrototype.cs b/Content.Shared/Prototypes/EntityList/EntityListPrototype.cs new file mode 100644 index 0000000000..26b8b4d581 --- /dev/null +++ b/Content.Shared/Prototypes/EntityList/EntityListPrototype.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using System.Collections.Immutable; +using Robust.Shared.IoC; +using Robust.Shared.Prototypes; +using Robust.Shared.Serialization.Manager.Attributes; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; +using Robust.Shared.ViewVariables; + +namespace Content.Shared.Prototypes.EntityList +{ + [Prototype("entityList")] + public class EntityListPrototype : IPrototype + { + [ViewVariables] + [field: DataField("id", required: true)] + public string ID { get; } = default!; + + [ViewVariables] + [field: DataField("entities", customTypeSerializer: typeof(PrototypeIdListSerializer))] + public ImmutableList EntityIds { get; } = ImmutableList.Empty; + + public IEnumerable Entities(IPrototypeManager? prototypeManager = null) + { + prototypeManager ??= IoCManager.Resolve(); + + foreach (var entityId in EntityIds) + { + yield return prototypeManager.Index(entityId); + } + } + } +}