using System.Collections.Generic;

namespace CounterDrone.Core.Simulation
{
    public enum SimulationState { Idle, Running, Paused, Stopped, Completed }

    public class SimEvent
    {
        public Models.SimEventType Type { get; set; }
        public float OccurredAt { get; set; }
        public string SourceId { get; set; } = string.Empty;
        public string TargetId { get; set; } = string.Empty;
        public string DataJson { get; set; } = "{}";
        public string Description { get; set; } = string.Empty;
    }

    public class SimulationFrameResult
    {
        public List<EntitySnapshot> EntitySnapshots { get; set; } = new();
        public List<SimEvent> NewEvents { get; set; } = new();
        public SimulationState State { get; set; }
        public int FrameIndex { get; set; }
        public float SimulationTime { get; set; }
    }

    public class EntitySnapshot
    {
        public string EntityId { get; set; } = string.Empty;
        public Models.EntityType EntityType { get; set; }
        public float PosX, PosY, PosZ, RotX, RotY, RotZ;

        // ── 原始状态字段（引擎直接填充，前端直接读取，无需 JSON）──
        public int DamageStage;
        public float Hp;
        public string? PlatformStateStr;
        public float CloudRadius;
        public float CloudOpacity;
        public int CloudPhase;
        public float CloudElapsed;

        public float VelX, VelY, VelZ;

        public string? ModelId;

        /// <summary>仅 Flush 入库时使用，仿真期间保持 null</summary>
        public string? StateData;
    }

    public enum DroneStatus { Flying, Destroyed, ReachedTarget, ZoneIntruded }
}
