Client LuaCsForBarotrauma
AbilityConditionAttackResult.cs
1 using System;
3 using System.Collections.Generic;
4 using System.Linq;
5 using System.Xml.Linq;
6 
7 namespace Barotrauma.Abilities
8 {
10  {
11  private readonly List<TargetType> targetTypes;
12  private readonly Identifier[] afflictions;
14  {
15  targetTypes = ParseTargetTypes(conditionElement.GetAttributeStringArray("targettypes", Array.Empty<string>()));
16  afflictions = conditionElement.GetAttributeIdentifierArray("afflictions", Array.Empty<Identifier>());
17  }
18 
19  protected override bool MatchesConditionSpecific(AbilityObject abilityObject)
20  {
21  if ((abilityObject as IAbilityAttackResult)?.AttackResult is AttackResult attackResult)
22  {
23  if (!IsViableTarget(targetTypes, attackResult.HitLimb?.character)) { return false; }
24 
25  if (afflictions.Any())
26  {
27  if (attackResult.Afflictions == null || !afflictions.Any(a => attackResult.Afflictions.Select(c => c.Identifier).Contains(a))) { return false; }
28  }
29 
30  return true;
31  }
32  else
33  {
34  LogAbilityConditionError(abilityObject, typeof(IAbilityAttackResult));
35  return false;
36  }
37  }
38  }
39 }
override bool MatchesConditionSpecific(AbilityObject abilityObject)
AbilityConditionAttackResult(CharacterTalent characterTalent, ContentXElement conditionElement)
void LogAbilityConditionError(AbilityObject abilityObject, Type expectedData)
List< TargetType > ParseTargetTypes(string[] targetTypeStrings)
bool IsViableTarget(IEnumerable< TargetType > targetTypes, Character targetCharacter)
Identifier[] GetAttributeIdentifierArray(Identifier[] def, params string[] keys)
string?[] GetAttributeStringArray(string key, string[]? def, bool convertToLowerInvariant=false)