Editor partial for RoadSettings that adds per-direction lane widths and per-side sidewalk widths, used by the procedural road generator. Exposes computed lane widths, a lane center offset lookup and an expanded side descriptor.
namespace AdvancedMappingTools;
public sealed partial class RoadSettings
{
[Property, Group( "Directional Lanes" ), WideMode]
public bool CustomDirectionWidths { get; set; }
[Property, Group( "Directional Lanes" ), Title( "Forward Lane Width" ), Range( 48, 256, slider: false ), WideMode]
public float ForwardWidth { get; set; } = 108;
[Property, Group( "Directional Lanes" ), Title( "Reverse Lane Width" ), Range( 48, 256, slider: false ), WideMode]
public float ReverseWidth { get; set; } = 108;
[Property, Group( "Sidewalks" ), WideMode]
public bool SeparateSidewalkWidths { get; set; }
[Property, Group( "Sidewalks" ), Range( 8, 1024, slider: false ), WideMode]
public float LeftWalkWidth { get; set; } = 72;
[Property, Group( "Sidewalks" ), Range( 8, 1024, slider: false ), WideMode]
public float RightWalkWidth { get; set; } = 72;
public float RightLaneWidth => CustomDirectionWidths ? Math.Clamp( ForwardWidth, 48, 256 ) : LaneWidth;
public float LeftLaneWidth => CustomDirectionWidths ? Math.Clamp( ReverseWidth, 48, 256 ) : LaneWidth;
public int ForwardLanes => OneWay ? Lanes : (Lanes + 1) / 2;
public float DrivenWidth => ForwardLanes * RightLaneWidth + (Lanes - ForwardLanes) * LeftLaneWidth;
public float LaneCenter( int index )
{
var right = -(DrivenWidth + (Divider != RoadDivider.None ? DividerWidth : 0)) * .5f;
return index < ForwardLanes ? right + (index + .5f) * RightLaneWidth : right + ForwardLanes * RightLaneWidth + (Divider != RoadDivider.None ? DividerWidth : 0) + (index - ForwardLanes + .5f) * LeftLaneWidth;
}
RoadSide ExpandedSide( bool left )
{
var side = Side( left ? LeftCurb : RightCurb, left ? LeftSidewalk : RightSidewalk );
if ( SeparateSidewalkWidths && side.Sidewalk > 0 )
side.Sidewalk = Math.Clamp( left ? LeftWalkWidth : RightWalkWidth, 8, 1024 );
return side;
}
}