Client LuaCsForBarotrauma
CharacterAbilityGiveItemStat.cs
1 #nullable enable
2 
3 namespace Barotrauma.Abilities
4 {
5  internal sealed class CharacterAbilityGiveItemStat : CharacterAbility
6  {
7  private readonly ItemTalentStats stat;
8  private readonly float value;
9  private readonly bool stackable;
10  private readonly bool save;
11 
12  public CharacterAbilityGiveItemStat(CharacterAbilityGroup characterAbilityGroup, ContentXElement abilityElement) : base(characterAbilityGroup, abilityElement)
13  {
14  stat = abilityElement.GetAttributeEnum("stattype", ItemTalentStats.None);
15  value = abilityElement.GetAttributeFloat("value", 0f);
16  stackable = abilityElement.GetAttributeBool("stackable", true);
17  save = abilityElement.GetAttributeBool("save", false);
18  }
19 
20  protected override void VerifyState(bool conditionsMatched, float timeSinceLastUpdate)
21  {
22  if (conditionsMatched)
23  {
24  ApplyEffect();
25  }
26  }
27 
28  protected override void ApplyEffect(AbilityObject abilityObject)
29  {
30  if (abilityObject is not IAbilityItem ability) { return; }
31 
32  ability.Item.StatManager.ApplyStat(stat, stackable, save, value, CharacterTalent);
33  }
34  }
35 }