Client LuaCsForBarotrauma
CharacterAbilityAlienHoarder.cs
1 using System;
2 using System.Linq;
3 
4 namespace Barotrauma.Abilities
5 {
7  {
8  private readonly float addedDamageMultiplierPerItem;
9  private readonly float maxAddedDamageMultiplier;
10  private readonly string[] tags;
11 
12  public CharacterAbilityAlienHoarder(CharacterAbilityGroup characterAbilityGroup, ContentXElement abilityElement) : base(characterAbilityGroup, abilityElement)
13  {
14  addedDamageMultiplierPerItem = abilityElement.GetAttributeFloat("addeddamagemultiplierperitem", 0f);
15  maxAddedDamageMultiplier = abilityElement.GetAttributeFloat("maxaddedddamagemultiplier", float.MaxValue);
16  tags = abilityElement.GetAttributeStringArray("tags", Array.Empty<string>(), convertToLowerInvariant: true);
17  }
18 
19  protected override void ApplyEffect(AbilityObject abilityObject)
20  {
21  if (abilityObject is AbilityAttackData attackData)
22  {
23  float totalAddedDamageMultiplier = 0f;
24  foreach (Item item in Character.Inventory.AllItems)
25  {
26  if (tags.Any(t => item.Prefab.Tags.Any(p => t == p)))
27  {
28  totalAddedDamageMultiplier += addedDamageMultiplierPerItem;
29  }
30  }
31  attackData.DamageMultiplier += Math.Min(totalAddedDamageMultiplier, maxAddedDamageMultiplier);
32  }
33  else
34  {
36  }
37  }
38  }
39 }
override void ApplyEffect(AbilityObject abilityObject)
CharacterAbilityAlienHoarder(CharacterAbilityGroup characterAbilityGroup, ContentXElement abilityElement)
float GetAttributeFloat(string key, float def)
string?[] GetAttributeStringArray(string key, string[]? def, bool convertToLowerInvariant=false)
virtual IEnumerable< Item > AllItems
All items contained in the inventory. Stacked items are returned as individual instances....
override ImmutableHashSet< Identifier > Tags