Client LuaCsForBarotrauma
CharacterAbilityAtmosMachine.cs
1 using System;
2 using System.Linq;
3 
4 namespace Barotrauma.Abilities
5 {
7  {
8  private readonly float addedValue;
9  private readonly Identifier[] tags;
10  private readonly int maxMultiplyCount;
11 
12  public CharacterAbilityAtmosMachine(CharacterAbilityGroup characterAbilityGroup, ContentXElement abilityElement) : base(characterAbilityGroup, abilityElement)
13  {
14  addedValue = abilityElement.GetAttributeFloat("addedvalue", 0f);
15  tags = abilityElement.GetAttributeIdentifierArray("tags", Array.Empty<Identifier>());
16  maxMultiplyCount = abilityElement.GetAttributeInt("maxmultiplycount", int.MaxValue);
17  }
18 
19  protected override void ApplyEffect(AbilityObject abilityObject)
20  {
21  if (abilityObject is IAbilityValue abilityValue)
22  {
23  int multiplyCount = 0;
24 
25  foreach (Item item in Item.ItemList)
26  {
27  if (item.Prefab.Tags.Any(t => tags.Contains(t)))
28  {
29  multiplyCount++;
30  if (multiplyCount == maxMultiplyCount)
31  {
32  break;
33  }
34  }
35  }
36  abilityValue.Value += addedValue * multiplyCount;
37  }
38  }
39  }
40 }
CharacterAbilityAtmosMachine(CharacterAbilityGroup characterAbilityGroup, ContentXElement abilityElement)
override void ApplyEffect(AbilityObject abilityObject)
Identifier[] GetAttributeIdentifierArray(Identifier[] def, params string[] keys)
float GetAttributeFloat(string key, float def)
int GetAttributeInt(string key, int def)
static readonly List< Item > ItemList
override ImmutableHashSet< Identifier > Tags