Client LuaCsForBarotrauma
CharacterAbilityModifyStatToLevel.cs
1 using Microsoft.Xna.Framework;
2 
3 namespace Barotrauma.Abilities
4 {
6  {
7  private readonly StatTypes statType;
8  private readonly float statPerLevel;
9  private readonly int maxLevel;
10  private float lastValue = 0f;
11  public override bool AllowClientSimulation => true;
12 
13  public CharacterAbilityModifyStatToLevel(CharacterAbilityGroup characterAbilityGroup, ContentXElement abilityElement) : base(characterAbilityGroup, abilityElement)
14  {
15  statType = CharacterAbilityGroup.ParseStatType(abilityElement.GetAttributeString("stattype", ""), CharacterTalent.DebugIdentifier);
16  statPerLevel = abilityElement.GetAttributeFloat("statperlevel", 0f);
17  maxLevel = abilityElement.GetAttributeInt("maxlevel", int.MaxValue);
18  }
19 
20  protected override void VerifyState(bool conditionsMatched, float timeSinceLastUpdate)
21  {
22  Character.ChangeStat(statType, -lastValue);
23  if (conditionsMatched)
24  {
25  int level = MathHelper.Min(Character?.Info.GetCurrentLevel() ?? 0, maxLevel);
26  lastValue = statPerLevel * level;
27  Character.ChangeStat(statType, lastValue);
28  }
29  else
30  {
31  lastValue = 0f;
32  }
33  }
34  }
35 }
static StatTypes ParseStatType(string statTypeString, string debugIdentifier)
CharacterAbilityModifyStatToLevel(CharacterAbilityGroup characterAbilityGroup, ContentXElement abilityElement)
override void VerifyState(bool conditionsMatched, float timeSinceLastUpdate)
void ChangeStat(StatTypes statType, float value)
string? GetAttributeString(string key, string? def)
float GetAttributeFloat(string key, float def)
int GetAttributeInt(string key, int def)
StatTypes
StatTypes are used to alter several traits of a character. They are mostly used by talents.
Definition: Enums.cs:180