2 using System.Collections.Immutable;
7 internal class NPCSet : Prefab
9 public readonly
static PrefabCollection<NPCSet> Sets =
new PrefabCollection<NPCSet>();
11 private readonly ImmutableArray<HumanPrefab> Humans;
13 public NPCSet(ContentXElement element, NPCSetsFile file) : base(file, element.GetAttributeIdentifier(
"identifier",
""))
15 Humans = element.Elements().Select(npcElement =>
new HumanPrefab(npcElement, file, Identifier)).ToImmutableArray();
18 public static HumanPrefab? Get(Identifier setIdentifier, Identifier npcidentifier,
bool logError =
true)
20 HumanPrefab? prefab = Sets.Where(
set =>
set.Identifier == setIdentifier).SelectMany(npcSet => npcSet.Humans.Where(npcSetHuman => npcSetHuman.Identifier == npcidentifier)).FirstOrDefault();
26 DebugConsole.ThrowError($
"Could not find human prefab \"{npcidentifier}\" from \"{setIdentifier}\".");
33 public override void Dispose() { }