Barotrauma Client Doc
AbilityConditionItemInSubmarine.cs
1 using System.Xml.Linq;
2 
3 namespace Barotrauma.Abilities
4 {
6  {
7  private readonly SubmarineType? submarineType;
8 
10  {
11  if (conditionElement.GetAttribute("submarinetype") != null)
12  {
13  submarineType = conditionElement.GetAttributeEnum<SubmarineType>("submarinetype", SubmarineType.Player);
14  }
15  }
16 
17  protected override bool MatchesConditionSpecific(AbilityObject abilityObject)
18  {
19  if ((abilityObject as IAbilityItem)?.Item is Item item)
20  {
21  if (item.Submarine == null) { return false; }
22  if (submarineType.HasValue)
23  {
24  return item.Submarine.Info?.Type == submarineType.Value;
25  }
26  else
27  {
28  return true;
29  }
30  }
31  else
32  {
33  LogAbilityConditionError(abilityObject, typeof(IAbilityItem));
34  return false;
35  }
36  }
37  }
38 }
void LogAbilityConditionError(AbilityObject abilityObject, Type expectedData)
override bool MatchesConditionSpecific(AbilityObject abilityObject)
AbilityConditionItemInSubmarine(CharacterTalent characterTalent, ContentXElement conditionElement)
XAttribute? GetAttribute(string name)