using System;
using System.Collections.Generic;

namespace MultiWheelC.TrajectoryPlanning.Mapping;

/// <summary>障碍物来源的一次投影结果，包含状态、世界 mm 几何和可选诊断信息。</summary>
public sealed class ObstacleProjectionResult
{
    private ObstacleProjectionResult(ObstacleSourceStatus status, IReadOnlyList<IMapObstacle> obstacles, string diagnostic)
    {
        Status = status; Obstacles = obstacles ?? Array.Empty<IMapObstacle>(); Diagnostic = diagnostic ?? string.Empty;
    }
    /// <summary>投影状态。只有 <see cref="ObstacleSourceStatus.Applied"/> 的几何会被栅格化。</summary>
    public ObstacleSourceStatus Status { get; }
    /// <summary>世界 mm 坐标的障碍物列表。非 Applied 状态时为空列表，不为 null。</summary>
    public IReadOnlyList<IMapObstacle> Obstacles { get; }
    /// <summary>用于日志和诊断的说明文本；未提供时为空字符串。</summary>
    public string Diagnostic { get; }
    /// <summary>创建成功投影结果。参数 obstacles 为有效世界 mm 几何；diagnostic 为可选诊断文本。返回的状态为 Applied。</summary>
    public static ObstacleProjectionResult Applied(IReadOnlyList<IMapObstacle> obstacles, string diagnostic = null)
    {
        return new ObstacleProjectionResult(ObstacleSourceStatus.Applied, obstacles, diagnostic);
    }
    /// <summary>创建空投影结果。参数 diagnostic 为可选原因；返回状态为 Empty，障碍物列表为空。</summary>
    public static ObstacleProjectionResult Empty(string diagnostic = null) { return new ObstacleProjectionResult(ObstacleSourceStatus.Empty, null, diagnostic); }
    /// <summary>创建不可用投影结果。参数 diagnostic 应说明快照缺失原因；返回状态为 Unavailable。</summary>
    public static ObstacleProjectionResult Unavailable(string diagnostic) { return new ObstacleProjectionResult(ObstacleSourceStatus.Unavailable, null, diagnostic); }
    /// <summary>创建无效投影结果。参数 diagnostic 应说明数据或几何错误；返回状态为 Invalid。</summary>
    public static ObstacleProjectionResult Invalid(string diagnostic) { return new ObstacleProjectionResult(ObstacleSourceStatus.Invalid, null, diagnostic); }
}
