Track/PathHint.cs

Defines PathHintFlags enum and a PathHint record struct used by the racing AI. The enum encodes surface conditions (LowGrip, Airborne, Narrow, SlowZone, Corner) as bitflags. PathHint stores a friction float and combined flags and provides a Default instance with full grip and no flags.

namespace Machines.Race;

/// <summary>
/// Flags describing notable surface conditions at a point, queried by AI for anticipatory driving.
/// </summary>
[Flags]
public enum PathHintFlags
{
	None = 0,

	/// <summary>
	/// Surface friction is below the low-grip threshold.
	/// </summary>
	LowGrip = 1 << 0,

	/// <summary>
	/// No ground below this point (jump or gap section).
	/// </summary>
	Airborne = 1 << 1,

	/// <summary>
	/// Track is narrower than normal at this point.
	/// </summary>
	Narrow = 1 << 2,

	/// <summary>
	/// Designer-placed slow-down hint (e.g. hazard zone).
	/// </summary>
	SlowZone = 1 << 3,

	/// <summary>
	/// Curvature exceeds the corner threshold (significant turn).
	/// </summary>
	Corner = 1 << 4,
}

/// <summary>
/// Per-sample surface annotation baked alongside curvature data in <see cref="RacingLine"/>.
/// </summary>
[Serializable]
public record struct PathHint
{
	/// <summary>
	/// Surface friction at this sample (0-1, 1 = full grip).
	/// </summary>
	public float Friction { get; set; }

	/// <summary>
	/// Combinable condition flags for this sample point.
	/// </summary>
	public PathHintFlags Flags { get; set; }

	/// <summary>
	/// Default hint: full grip, no flags.
	/// </summary>
	public static PathHint Default => new() { Friction = 1f, Flags = PathHintFlags.None };
}