Client LuaCsForBarotrauma
CharacterAbilityModifyStat.cs
1 namespace Barotrauma.Abilities
2 {
4  {
5  private readonly StatTypes statType;
6  private readonly float value;
7  bool lastState;
8  public override bool AllowClientSimulation => true;
9 
10  public CharacterAbilityModifyStat(CharacterAbilityGroup characterAbilityGroup, ContentXElement abilityElement) : base(characterAbilityGroup, abilityElement)
11  {
12  statType = CharacterAbilityGroup.ParseStatType(abilityElement.GetAttributeString("stattype", ""), CharacterTalent.DebugIdentifier);
13  value = abilityElement.GetAttributeFloat("value", 0f);
14  }
15 
16  public override void InitializeAbility(bool addingFirstTime)
17  {
18  VerifyState(conditionsMatched: true, timeSinceLastUpdate: 0.0f);
19  }
20 
21  protected override void VerifyState(bool conditionsMatched, float timeSinceLastUpdate)
22  {
23  if (conditionsMatched != lastState)
24  {
25  Character.ChangeStat(statType, conditionsMatched ? value : -value);
26  lastState = conditionsMatched;
27  }
28  }
29  }
30 }
static StatTypes ParseStatType(string statTypeString, string debugIdentifier)
override void InitializeAbility(bool addingFirstTime)
CharacterAbilityModifyStat(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)
StatTypes
StatTypes are used to alter several traits of a character. They are mostly used by talents.
Definition: Enums.cs:195