Client LuaCsForBarotrauma
CharacterAbilityReduceAffliction.cs
1 #nullable enable
2 
3 namespace Barotrauma.Abilities
4 {
5  internal sealed class CharacterAbilityReduceAffliction : CharacterAbility
6  {
7  private readonly Identifier afflictionId;
8  private readonly float amount;
9 
10  public CharacterAbilityReduceAffliction(CharacterAbilityGroup characterAbilityGroup, ContentXElement abilityElement) : base(characterAbilityGroup, abilityElement)
11  {
12  afflictionId = abilityElement.GetAttributeIdentifier("afflictionid", abilityElement.GetAttributeIdentifier("affliction", Identifier.Empty));
13  amount = abilityElement.GetAttributeFloat("amount", 0);
14 
15  if (afflictionId.IsEmpty)
16  {
17  DebugConsole.ThrowError($"Error in {nameof(CharacterAbilityReduceAffliction)} - affliction identifier not set.",
18  contentPackage: abilityElement.ContentPackage);
19  }
20  }
21 
22  protected override void ApplyEffect(AbilityObject abilityObject)
23  {
24  if (abilityObject is not IAbilityCharacter character) { return; }
25  character.Character.CharacterHealth.ReduceAfflictionOnAllLimbs(afflictionId, amount, attacker: Character);
26  }
27  }
28 }