1 using Microsoft.Xna.Framework;
3 using System.Collections.Generic;
4 using System.Collections.Immutable;
6 using System.Reflection;
12 [RequiredByCorePackage]
15 private readonly
static ImmutableHashSet<Type> afflictionTypes;
18 afflictionTypes = ReflectionUtils.GetDerivedNonAbstract<
Affliction>()
19 .ToImmutableHashSet();
29 element.
Elements().ForEach(s => ParseElement(s, overriding:
true));
31 else if (elementName ==
"Afflictions")
33 element.
Elements().ForEach(s => ParseElement(s, overriding: overriding));
35 else if (elementName ==
"cprsettings")
37 var cprSettings =
new CPRSettings(element,
this);
38 CPRSettings.Prefabs.Add(cprSettings, overriding);
40 else if (elementName ==
"damageoverlay")
43 var damageOverlay =
new CharacterHealth.DamageOverlayPrefab(element,
this);
44 CharacterHealth.DamageOverlayPrefab.Prefabs.Add(damageOverlay, overriding);
50 if (identifier.IsEmpty)
52 DebugConsole.ThrowError(
53 $
"No identifier defined for the affliction '{elementName}' in file '{Path}'",
58 if (AfflictionPrefab.Prefabs.ContainsKey(identifier))
62 DebugConsole.NewMessage(
63 $
"Overriding an affliction or a buff with the identifier '{identifier}' using the file '{Path}'",
68 DebugConsole.ThrowError(
69 $
"Duplicate affliction: '{identifier}' defined in {elementName} of '{Path}'",
75 var type = afflictionTypes.FirstOrDefault(t =>
77 || t.Name == $
"Affliction{elementName}".ToIdentifier())
78 ?? typeof(Affliction);
79 var prefab = CreatePrefab(element, type);
80 AfflictionPrefab.Prefabs.Add(prefab, overriding);
86 XDocument doc = XMLExtensions.TryLoadXml(Path);
87 if (doc?.Root is
null) {
return; }
88 ParseElement(doc.Root.FromPackage(
ContentPackage), overriding:
false);
94 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)