Client LuaCsForBarotrauma
CharacterAbilityModifyAffliction.cs
1 namespace Barotrauma.Abilities
2 {
4  {
5  private readonly Identifier[] afflictionIdentifiers;
6 
7  private readonly Identifier replaceWith;
8 
9  private readonly float addedMultiplier;
10 
11  public CharacterAbilityModifyAffliction(CharacterAbilityGroup characterAbilityGroup, ContentXElement abilityElement) : base(characterAbilityGroup, abilityElement)
12  {
13  afflictionIdentifiers = abilityElement.GetAttributeIdentifierArray("afflictionidentifiers", System.Array.Empty<Identifier>());
14  replaceWith = abilityElement.GetAttributeIdentifier("replacewith", Identifier.Empty);
15  addedMultiplier = abilityElement.GetAttributeFloat("addedmultiplier", 0f);
16  }
17 
18  protected override void ApplyEffect(AbilityObject abilityObject)
19  {
20  var abilityAffliction = abilityObject as IAbilityAffliction;
21  if (abilityAffliction?.Affliction is Affliction affliction)
22  {
23  foreach (Identifier afflictionIdentifier in afflictionIdentifiers)
24  {
25  if (affliction.Identifier != afflictionIdentifier) { continue; }
26  AfflictionPrefab afflictionPrefab = affliction.Prefab;
27  if (!replaceWith.IsEmpty)
28  {
29  AfflictionPrefab.Prefabs.TryGet(replaceWith, out afflictionPrefab);
30  }
31  abilityAffliction.Affliction = new Affliction(afflictionPrefab, affliction.Strength * (1 + addedMultiplier));
32  }
33  }
34  else
35  {
37  }
38  }
39  }
40 }
CharacterAbilityModifyAffliction(CharacterAbilityGroup characterAbilityGroup, ContentXElement abilityElement)
AfflictionPrefab is a prefab that defines a type of affliction that can be applied to a character....
static readonly PrefabCollection< AfflictionPrefab > Prefabs
Identifier[] GetAttributeIdentifierArray(Identifier[] def, params string[] keys)
float GetAttributeFloat(string key, float def)
Identifier GetAttributeIdentifier(string key, string def)
Prefab(ContentFile file, Identifier identifier)
Definition: Prefab.cs:40