Client LuaCsForBarotrauma
AbilityConditionHasItem.cs
2 using System;
3 
4 namespace Barotrauma.Abilities
5 {
7  {
8  private readonly Identifier[] tags;
9  readonly bool requireAll;
10 
11  public AbilityConditionHasItem(CharacterTalent characterTalent, ContentXElement conditionElement) : base(characterTalent, conditionElement)
12  {
13  tags = conditionElement.GetAttributeIdentifierArray("tags", Array.Empty<Identifier>());
14  requireAll = conditionElement.GetAttributeBool("requireall", false);
15  }
16 
17  protected override bool MatchesConditionSpecific()
18  {
19  if (tags.None())
20  {
21  return character.GetEquippedItem(Identifier.Empty) != null;
22  }
23 
24  if (requireAll)
25  {
26  foreach (Identifier tag in tags)
27  {
28  if (character.GetEquippedItem(tag) == null) { return false; }
29  }
30  return true;
31  }
32  else
33  {
34  foreach (Identifier tag in tags)
35  {
36  if (character.GetEquippedItem(tag) != null) { return true; }
37  }
38  return false;
39  }
40  }
41  }
42 }
AbilityConditionHasItem(CharacterTalent characterTalent, ContentXElement conditionElement)
Item GetEquippedItem(Identifier tagOrIdentifier=default, InvSlotType? slotType=null)
Identifier[] GetAttributeIdentifierArray(Identifier[] def, params string[] keys)
bool GetAttributeBool(string key, bool def)