using Theriapolis.Core.Util;
namespace Theriapolis.Core.World;
///
/// A bridge where a road or rail polyline crosses a river.
/// Endpoints are in world-pixel space and follow the actual road polyline,
/// so the deck visually matches the road at the crossing regardless of meander.
///
public readonly struct Bridge
{
public readonly Vec2 Start;
public readonly Vec2 End;
public readonly int RoadId;
public Bridge(Vec2 start, Vec2 end, int roadId)
{
Start = start;
End = end;
RoadId = roadId;
}
/// Center of the deck (midpoint of Start–End).
public float WorldPixelX => (Start.X + End.X) * 0.5f;
public float WorldPixelY => (Start.Y + End.Y) * 0.5f;
/// Road direction angle (radians) from Start to End.
public float RoadAngle => MathF.Atan2(End.Y - Start.Y, End.X - Start.X);
}