Client LuaCsForBarotrauma
AbilityConditionShipFlooded.cs
1 namespace Barotrauma.Abilities
2 {
4  {
5  private readonly float floodPercentage;
7  {
8  floodPercentage = conditionElement.GetAttributeFloat("floodpercentage", 0f);
9  }
10 
11  protected override bool MatchesConditionSpecific()
12  {
13  if (!character.IsInFriendlySub) { return false; }
14  float waterVolume = 0.0f, totalVolume = 0.0f;
15  foreach (Hull hull in Hull.HullList)
16  {
17  if (hull.Submarine is not { } hullSubmarine) { continue; }
18  if (hullSubmarine != character.Submarine || hullSubmarine.TeamID != character.TeamID) { continue; }
19  waterVolume += hull.WaterVolume;
20  totalVolume += hull.Volume;
21  }
22  return (waterVolume / totalVolume) > floodPercentage;
23  }
24  }
25 }
AbilityConditionShipFlooded(CharacterTalent characterTalent, ContentXElement conditionElement)
float GetAttributeFloat(string key, float def)
Submarine Submarine
Definition: Entity.cs:53
static readonly List< Hull > HullList