using System;
using CounterDrone.Core.Models;

namespace CounterDrone.Core.Algorithms
{
    /// <summary>吸入式灭火 — 阈值型：密度达标后线性累积</summary>
    public class InertGasDamageModel : IDamageModel
    {
        private const float EffectiveThreshold = 0.0001f;   // 对齐弹药的有效浓度
        private const float DamageRate = 0.15f;           // 每秒毁伤率

        public float CalculateDamage(TargetType droneType, PowerType powerType,
            AerosolType aerosolType, float cloudDensity, float exposureTime, float deltaTime)
        {
            if (aerosolType != AerosolType.InertGas) return 0f;
            if (cloudDensity < EffectiveThreshold) return 0f;

            // 活塞发动机对惰性气体最敏感
            var sensitivity = powerType == PowerType.Piston ? 1.5f : 1.0f;
            return DamageRate * sensitivity * deltaTime;
        }

        public DamageStage GetDamageStage(float accumulatedDamage)
        {
            if (accumulatedDamage >= 1.0f) return DamageStage.Destroyed;
            if (accumulatedDamage >= 0.6f) return DamageStage.AttitudeLoss;
            if (accumulatedDamage >= 0.25f) return DamageStage.EngineAnomaly;
            return DamageStage.Normal;
        }
    }
}
