36 lines
1.3 KiB
C#
36 lines
1.3 KiB
C#
using System.Linq;
|
|
using System.Xml.Linq;
|
|
|
|
namespace Barotrauma.Abilities
|
|
{
|
|
class CharacterAbilityModifyStatToFlooding : CharacterAbility
|
|
{
|
|
private readonly StatTypes statType;
|
|
private readonly float maxValue;
|
|
private float lastValue = 0f;
|
|
public override bool AllowClientSimulation => true;
|
|
|
|
public CharacterAbilityModifyStatToFlooding(CharacterAbilityGroup characterAbilityGroup, XElement abilityElement) : base(characterAbilityGroup, abilityElement)
|
|
{
|
|
statType = CharacterAbilityGroup.ParseStatType(abilityElement.GetAttributeString("stattype", ""), CharacterTalent.DebugIdentifier);
|
|
maxValue = abilityElement.GetAttributeFloat("maxvalue", 0f);
|
|
}
|
|
|
|
protected override void VerifyState(bool conditionsMatched, float timeSinceLastUpdate)
|
|
{
|
|
Character.ChangeStat(statType, -lastValue);
|
|
|
|
if (conditionsMatched && Character.IsInFriendlySub)
|
|
{
|
|
float currentFloodPercentage = Character.Submarine.GetHulls(false).Average(h => h.WaterPercentage);
|
|
lastValue = currentFloodPercentage / 100f * maxValue;
|
|
Character.ChangeStat(statType, lastValue);
|
|
}
|
|
else
|
|
{
|
|
lastValue = 0f;
|
|
}
|
|
}
|
|
}
|
|
}
|