Client LuaCsForBarotrauma
CharacterAbilityPsychoClown.cs
1 namespace Barotrauma.Abilities
2 {
4  {
5  private readonly StatTypes statType;
6  private readonly float maxValue;
7  private readonly string afflictionIdentifier;
8  private float lastValue = 0f;
9  public override bool AllowClientSimulation => true;
10 
11  public CharacterAbilityPsychoClown(CharacterAbilityGroup characterAbilityGroup, ContentXElement abilityElement) : base(characterAbilityGroup, abilityElement)
12  {
13  statType = CharacterAbilityGroup.ParseStatType(abilityElement.GetAttributeString("stattype", ""), CharacterTalent.DebugIdentifier);
14  maxValue = abilityElement.GetAttributeFloat("maxvalue", 0f);
15  afflictionIdentifier = abilityElement.GetAttributeString("afflictionidentifier", "");
16  }
17 
18  protected override void VerifyState(bool conditionsMatched, float timeSinceLastUpdate)
19  {
20  // managing state this way seems liable to cause bugs, maybe instead create abstraction to reset these values more safely
21  // talents cannot be removed while in active play because of the lack of this, for example
22  Character.ChangeStat(statType, -lastValue);
23 
24  if (conditionsMatched)
25  {
26  var affliction = Character.CharacterHealth.GetAffliction(afflictionIdentifier);
27 
28  float afflictionStrength = 0f;
29  if (affliction != null)
30  {
31  afflictionStrength = affliction.Strength / affliction.Prefab.MaxStrength;
32  }
33 
34  lastValue = afflictionStrength * maxValue;
35  Character.ChangeStat(statType, lastValue);
36  }
37  else
38  {
39  lastValue = 0f;
40  }
41  }
42  }
43 }
static StatTypes ParseStatType(string statTypeString, string debugIdentifier)
CharacterAbilityPsychoClown(CharacterAbilityGroup characterAbilityGroup, ContentXElement abilityElement)
override void VerifyState(bool conditionsMatched, float timeSinceLastUpdate)
virtual float Strength
Definition: Affliction.cs:31
Affliction GetAffliction(string identifier, bool allowLimbAfflictions=true)
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:180