using System.Collections.Generic;

namespace CounterDrone.Core
{
    public static class DefaultFireUnits
    {
        private static List<FireUnitTemplate> _cache;

        public static List<FireUnitTemplate> GetAll()
        {
            if (_cache != null) return _cache;
            _cache = new List<FireUnitTemplate>
            {
                new FireUnitTemplate
                {
                    Id = "ground-light",
                    Name = "轻型地基火力单元",
                    PlatformType = 1,
                    GunCount = 4,
                    ChannelsPerGun = 4,
                    ChannelInterval = 0.1,
                    Cooldown = 5.0,
                    AmmoChangeTime = 30.0,
                    MuzzleVelocity = 800.0,
                    AmmoTypes = new() { 0, 1 },
                    RadarRange = 10000.0,
                    EORange = 6000.0,
                    IRRange = 3000.0,
                },
                new FireUnitTemplate
                {
                    Id = "ground-standard",
                    Name = "标准地基火力单元",
                    PlatformType = 1,
                    GunCount = 4,
                    ChannelsPerGun = 4,
                    ChannelInterval = 0.1,
                    Cooldown = 5.0,
                    AmmoChangeTime = 30.0,
                    MuzzleVelocity = 800.0,
                    AmmoTypes = new() { 0, 1 },
                    RadarRange = 15000.0,
                    EORange = 8000.0,
                    IRRange = 5000.0,
                },
                new FireUnitTemplate
                {
                    Id = "ground-heavy",
                    Name = "重型地基火力单元",
                    PlatformType = 1,
                    GunCount = 6,
                    ChannelsPerGun = 4,
                    ChannelInterval = 1.0,
                    Cooldown = 5.0,
                    AmmoChangeTime = 30.0,
                    MuzzleVelocity = 600.0,
                    AmmoTypes = new() { 0, 1, 2 },
                    RadarRange = 20000.0,
                    EORange = 10000.0,
                    IRRange = 6000.0,
                },
                new FireUnitTemplate
                {
                    Id = "air-standard",
                    Name = "标准空基火力单元",
                    PlatformType = 0,
                    GunCount = 1,
                    ChannelsPerGun = 8,
                    ChannelInterval = 1.0,
                    Cooldown = 5.0,
                    AmmoChangeTime = 30.0,
                    CruiseSpeed = 55.0,
                    ReleaseAltitude = 1500.0,
                    AmmoTypes = new() { 0, 1 },
                    EORange = 12000.0,
                    IRRange = 8000.0,
                },
            };
            return _cache;
        }

        public static FireUnitTemplate GetById(string id) => GetAll().Find(t => t.Id == id);
    }

    public class FireUnitTemplate
    {
        public string Id { get; set; } = "";
        public string Name { get; set; } = "";
        public int PlatformType { get; set; }
        public int GunCount { get; set; } = 1;
        public int ChannelsPerGun { get; set; } = 1;
        public double ChannelInterval { get; set; } = 1.0;
        public double Cooldown { get; set; } = 5.0;
        public double AmmoChangeTime { get; set; } = 30.0;
        public double MuzzleVelocity { get; set; }
        public double CruiseSpeed { get; set; }
        public double ReleaseAltitude { get; set; }
        public List<int> AmmoTypes { get; set; } = new();
        public double RadarRange { get; set; }
        public double EORange { get; set; }
        public double IRRange { get; set; }
    }
}
