Client LuaCsForBarotrauma
AbilityConditionReduceAffliction.cs
1 using System;
2 
3 namespace Barotrauma.Abilities
4 {
6  {
7  private readonly string[] allowedTypes;
8  private readonly string identifier;
9 
11  {
12  allowedTypes = conditionElement.GetAttributeStringArray("allowedtypes", Array.Empty<string>(), convertToLowerInvariant: true);
13  identifier = conditionElement.GetAttributeString("identifier", "");
14  }
15 
16  protected override bool MatchesConditionSpecific(AbilityObject abilityObject)
17  {
18  if ((abilityObject as IAbilityAffliction)?.Affliction is Affliction affliction)
19  {
20  if (allowedTypes.Find(c => c == affliction.Prefab.AfflictionType) == null) { return false; }
21 
22  if (!string.IsNullOrEmpty(identifier) && affliction.Prefab.Identifier != identifier) { return false; }
23 
24  return true;
25  }
26  else
27  {
28  LogAbilityConditionError(abilityObject, typeof(IAbilityAffliction));
29  return false;
30  }
31  }
32  }
33 }
void LogAbilityConditionError(AbilityObject abilityObject, Type expectedData)
AbilityConditionReduceAffliction(CharacterTalent characterTalent, ContentXElement conditionElement)
override bool MatchesConditionSpecific(AbilityObject abilityObject)
string? GetAttributeString(string key, string? def)
string?[] GetAttributeStringArray(string key, string[]? def, bool convertToLowerInvariant=false)