Client LuaCsForBarotrauma
CharacterAbilityModifyValue.cs
1 namespace Barotrauma.Abilities
2 {
4  {
5  private readonly float addedValue;
6  private readonly float multiplyValue;
7 
8  public override bool AllowClientSimulation => true;
9 
10  public CharacterAbilityModifyValue(CharacterAbilityGroup characterAbilityGroup, ContentXElement abilityElement) : base(characterAbilityGroup, abilityElement)
11  {
12  addedValue = abilityElement.GetAttributeFloat("addedvalue", 0f);
13  multiplyValue = abilityElement.GetAttributeFloat("multiplyvalue", 1f);
14  if (MathUtils.NearlyEqual(addedValue, 0.0f) && MathUtils.NearlyEqual(multiplyValue, 1.0f))
15  {
16  DebugConsole.ThrowError($"Error in talent {CharacterTalent.DebugIdentifier}, {nameof(CharacterAbilityModifyValue)} - added value is 0 and multiplier is 1, the ability will do nothing.",
17  contentPackage: abilityElement.ContentPackage);
18  }
19  }
20 
21  protected override void ApplyEffect(AbilityObject abilityObject)
22  {
23  if (abilityObject is IAbilityValue abilityValue)
24  {
25  abilityValue.Value += addedValue;
26  abilityValue.Value *= multiplyValue;
27  }
28  }
29  }
30 }
override void ApplyEffect(AbilityObject abilityObject)
CharacterAbilityModifyValue(CharacterAbilityGroup characterAbilityGroup, ContentXElement abilityElement)
float GetAttributeFloat(string key, float def)
ContentPackage? ContentPackage