1 using Microsoft.Xna.Framework;
4 using System.Collections.Generic;
5 using System.Collections.Immutable;
12 public string Name =>
"Damage Modifier";
51 return rawAfflictionIdentifierString;
55 rawAfflictionIdentifierString = value;
56 parsedAfflictionIdentifiers = rawAfflictionIdentifierString.ToIdentifiers().ToImmutableArray();
65 return rawAfflictionTypeString;
69 rawAfflictionTypeString = value;
70 parsedAfflictionTypes = rawAfflictionTypeString.ToIdentifiers().ToImmutableArray();
74 private string rawAfflictionIdentifierString;
75 private string rawAfflictionTypeString;
76 private ImmutableArray<Identifier> parsedAfflictionIdentifiers;
77 private ImmutableArray<Identifier> parsedAfflictionTypes;
87 DebugConsole.ThrowError(
"Error in DamageModifier config (" + parentDebugName +
") - define afflictions using identifiers or types instead of names.",
92 foreach (var afflictionType
in parsedAfflictionTypes)
96 createWarningOrError($
"Potentially invalid damage modifier in \"{parentDebugName}\". Could not find any afflictions of the type \"{afflictionType}\". Did you mean to use an affliction identifier instead?");
99 foreach (var afflictionIdentifier
in parsedAfflictionIdentifiers)
103 createWarningOrError($
"Potentially invalid damage modifier in \"{parentDebugName}\". Could not find any afflictions with the identifier \"{afflictionIdentifier}\". Did you mean to use an affliction type instead?");
106 if (!parsedAfflictionTypes.Any() && !parsedAfflictionIdentifiers.Any())
108 createWarningOrError($
"Potentially invalid damage modifier in \"{parentDebugName}\". Neither affliction types of identifiers defined.");
112 void createWarningOrError(
string msg)
115 DebugConsole.ThrowError(msg, contentPackage: element.
ContentPackage);
117 DebugConsole.AddWarning(msg, contentPackage: element.
ContentPackage);
129 return parsedAfflictionIdentifiers.Any(
id =>
id == identifier);
139 return parsedAfflictionTypes.Any(t => t == type);
152 return parsedAfflictionIdentifiers.Any(
id =>
id == identifier)
153 || parsedAfflictionTypes.Any(t => t == type);
160 if (element ==
null) {
return; }
166 if (element ==
null) {
return; }
AfflictionPrefab is a prefab that defines a type of affliction that can be applied to a character....
static readonly PrefabCollection< AfflictionPrefab > Prefabs
ContentPackage? ContentPackage
XAttribute? GetAttribute(string name)
bool MatchesAfflictionType(string type)
void Serialize(XElement element)
bool MatchesAfflictionIdentifier(string identifier)
void Deserialize(XElement element)
Dictionary< Identifier, SerializableProperty > SerializableProperties
DamageModifier(ContentXElement element, string parentDebugName, bool checkErrors=true)
bool MatchesAfflictionIdentifier(Identifier identifier)
bool MatchesAffliction(Affliction affliction)
bool MatchesAffliction(string identifier, string type)
Returns true if the type or the identifier matches the defined types/identifiers.
bool MatchesAfflictionType(Identifier type)
Vector2 ArmorSectorInRadians
ref readonly ImmutableArray< Identifier > ParsedAfflictionIdentifiers
ref readonly ImmutableArray< Identifier > ParsedAfflictionTypes
bool MatchesAffliction(Identifier identifier, Identifier type)
string AfflictionIdentifiers
float ProbabilityMultiplier
static Dictionary< Identifier, SerializableProperty > DeserializeProperties(object obj, XElement element=null)
static void SerializeProperties(ISerializableEntity obj, XElement element, bool saveIfDefault=false, bool ignoreEditable=false)