2 using Microsoft.Xna.Framework;
4 using System.Collections.Immutable;
10 [RequiredByCorePackage]
13 private readonly
static ImmutableHashSet<Type> afflictionTypes;
16 afflictionTypes = ReflectionUtils.GetDerivedNonAbstract<
Affliction>()
17 .ToImmutableHashSet();
27 element.
Elements().ForEach(s => ParseElement(s, overriding:
true));
29 else if (elementName ==
"Afflictions")
31 element.
Elements().ForEach(s => ParseElement(s, overriding: overriding));
33 else if (elementName ==
"cprsettings")
35 var cprSettings =
new CPRSettings(element,
this);
36 CPRSettings.Prefabs.Add(cprSettings, overriding);
38 else if (elementName ==
"damageoverlay")
41 var damageOverlay =
new CharacterHealth.DamageOverlayPrefab(element,
this);
42 CharacterHealth.DamageOverlayPrefab.Prefabs.Add(damageOverlay, overriding);
48 if (identifier.IsEmpty)
50 DebugConsole.ThrowError(
51 $
"No identifier defined for the affliction '{elementName}' in file '{Path}'",
56 if (AfflictionPrefab.Prefabs.TryGet(identifier, out var existingAffliction))
60 DebugConsole.NewMessage(
61 $
"Overriding an affliction or a buff with the identifier '{identifier}' using the version in '{element.ContentPackage.Name}'",
66 DebugConsole.ThrowError(
67 $
"Duplicate affliction: '{identifier}' defined in {element.ContentPackage.Name} is already defined in the previously loaded content package {existingAffliction.ContentPackage.Name}."+
68 $
" You may need to adjust the mod load order to make sure {element.ContentPackage.Name} is loaded first.",
74 var type = afflictionTypes.FirstOrDefault(t =>
76 || t.Name == $
"Affliction{elementName}".ToIdentifier())
77 ?? typeof(Affliction);
78 var prefab = CreatePrefab(element, type);
79 AfflictionPrefab.Prefabs.Add(prefab, overriding);
85 XDocument doc = XMLExtensions.TryLoadXml(Path);
86 if (doc?.Root is
null) {
return; }
87 ParseElement(doc.Root.FromPackage(
ContentPackage), overriding:
false);
93 return new AfflictionPrefab(element,
this, type);
A special affliction type that gradually makes the character turn into another type of character....
AfflictionPrefab is a prefab that defines a type of affliction that can be applied to a character....
static readonly PrefabCollection< AfflictionPrefab > Prefabs
AfflictionPrefabHusk is a special type of affliction that has added functionality for husk infection.
override void UnloadFile()
AfflictionsFile(ContentPackage contentPackage, ContentPath path)
static readonly PrefabSelector< CPRSettings > Prefabs
static readonly PrefabSelector< DamageOverlayPrefab > Prefabs
Base class for content file types, which are loaded from filelist.xml via reflection....
readonly ContentPackage ContentPackage
Identifier NameAsIdentifier()
IEnumerable< ContentXElement > Elements()
Identifier GetAttributeIdentifier(string key, string def)