Track/PathSegmentInfo.cs

Data class describing a contiguous arc segment of a racing path. Stores start/end distances, surface type, whether it is an auto-generated gap, a source label, and convenience helpers for length and containment.

File Access
namespace Machines.Race;

/// <summary>
/// Distance-range metadata for a contiguous section of a baked <see cref="RacingLine"/>.
/// </summary>
[Serializable]
public sealed class PathSegmentInfo
{
	/// <summary>
	/// Arc distance where this segment starts.
	/// </summary>
	public float StartDistance { get; set; }

	/// <summary>
	/// Arc distance where this segment ends.
	/// </summary>
	public float EndDistance { get; set; }

	/// <summary>
	/// Surface type of this segment (<see cref="SplineType.Custom"/> + <see cref="IsGap"/> = bridge section).
	/// </summary>
	public SplineType Type { get; set; } = SplineType.Road;

	/// <summary>
	/// True if this is an auto-generated bridge between two splines.
	/// </summary>
	public bool IsGap { get; set; }

	/// <summary>
	/// Source spline label from <see cref="SplineInfo.Label"/> or GameObject name.
	/// </summary>
	public string SourceLabel { get; set; } = "";

	/// <summary>
	/// Length of this segment in world units.
	/// </summary>
	public float Length => EndDistance - StartDistance;

	/// <summary>
	/// True if the given distance falls within this segment's range.
	/// </summary>
	public bool Contains( float distance ) => distance >= StartDistance && distance < EndDistance;
}