namespace MultiWheelC.TrajectoryPlanning.Mapping;

/// <summary>将一个 <see cref="TwoLegProjectionInput"/> 快照包装为统一障碍物来源。</summary>
public sealed class TwoLegObstacleSource : IMapObstacleSource
{
    private readonly TwoLegProjectionInput _input;
    /// <summary>
    /// 创建 TwoLeg 障碍物来源。
    ///
    /// 参数：sourceId 为唯一标识；sourceVersion 为快照版本，输入内容改变时必须递增；isRequired 指示失败是否阻断建图；input 为检测时刻快照，可为空。
    /// </summary>
    public TwoLegObstacleSource(string sourceId, long sourceVersion, bool isRequired, TwoLegProjectionInput input)
    {
        SourceId = sourceId; SourceVersion = sourceVersion; IsRequired = isRequired; _input = input;
    }
    /// <summary>该快照来源的唯一标识。</summary>
    public string SourceId { get; }
    /// <summary>快照版本号；输入内容变化时必须递增。</summary>
    public long SourceVersion { get; }
    /// <summary>true 时投影不可用或无效会阻断建图。</summary>
    public bool IsRequired { get; }
    /// <summary>投影保存的 TwoLeg 快照。返回世界 mm 圆形障碍物，且不访问实时检测、定位、UI 或时钟。</summary>
    public ObstacleProjectionResult ProjectToWorld() { return TwoLegObstacleProjector.Project(_input); }
}
