1 using Microsoft.Xna.Framework;
3 using System.Collections.Generic;
4 using System.Collections.Immutable;
8 partial class MissionPrefab : PrefabWithUintIdentifier
10 private ImmutableArray<Sprite> portraits =
new ImmutableArray<Sprite>();
42 return hudIcon ??
Icon;
55 private Color? hudIconColor;
57 private ImmutableDictionary<int, Identifier> overrideMusicOnState;
63 Dictionary<int, Identifier> overrideMusic =
new Dictionary<int, Identifier>();
64 List<Sprite> portraits =
new List<Sprite>();
65 foreach (var subElement
in element.
Elements())
67 switch (subElement.Name.ToString().ToLowerInvariant())
71 IconColor = subElement.GetAttributeColor(
"color", Color.White);
74 hudIcon =
new Sprite(subElement);
75 hudIconColor = subElement.GetAttributeColor(
"color");
79 subElement.GetAttributeInt(
"state", 0),
80 subElement.GetAttributeIdentifier(
"type",
Identifier.Empty));
83 var portrait =
new Sprite(subElement, lazyLoad:
true);
86 portraits.Add(portrait);
91 this.portraits = portraits.ToImmutableArray();
92 overrideMusicOnState = overrideMusic.ToImmutableDictionary();
97 if (overrideMusicOnState.TryGetValue(state, out
Identifier id))
106 if (portraits.Length == 0) {
return null; }
107 return portraits[Math.Abs(randomSeed) % portraits.Length];
110 partial
void DisposeProjectSpecific()
float GetAttributeFloat(string key, float def)
IEnumerable< ContentXElement > Elements()
bool GetAttributeBool(string key, bool def)
bool DisplayTargetHudIcons
Identifier GetOverrideMusicType(int state)
Sprite GetPortrait(int randomSeed)
readonly Identifier Identifier