using System.Collections.Generic;
using CounterDrone.Core.Models;
using SQLite;

namespace CounterDrone.Core.Models
{
    /// <summary>搭载/发射平台规格（基础数据模板）</summary>
    [Table("LaunchPlatformSpec")]
    public class LaunchPlatformSpec
    {
        [PrimaryKey]
        public string Id { get; set; } = "";
        public string Name { get; set; } = "";
        public string Description { 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 string ModelId { get; set; } = "";
        [Ignore]
        public List<int> AmmoTypes { get; set; } = new();

        public ScenarioUnit ToScenarioUnit(AerosolType ammoType, int quantity,
            double posX, double posY, double posZ)
        {
            return new ScenarioUnit
            {
                LaunchPlatformSpecId = Id,
                EquipmentRole = (int)Models.EquipmentRole.LaunchPlatform,
                Quantity = quantity,
                PositionX = posX,
                PositionY = posY,
                PositionZ = posZ,
                AerosolType = (int)ammoType,
                MunitionCount = GunCount * ChannelsPerGun * quantity,
            };
        }
    }
}
