Editor/Tool/ArchRoadTool.cs
using System;
using System.Collections.Generic;
using Editor;
using Sandbox;

namespace Sunless.Architecture;

[EditorTool( "sunless.roads" )]
[Title( "Roads" )]
[Icon( "add_road" )]
[Alias( "roads" )]
public sealed class ArchRoadTool : ArchTool {
	public override string Shell => ArchShells.Roads;

	// A road belongs to the map, not a storey - the run itself is the target.
	public override void BuildTargets( Layout header, Action refresh ) {
		if ( Plan.Roads().Count == 0 ) {
			header.Add( new Label( "No roads yet - lay a centreline with the Road tool." ) );
			return;
		}

		var roads = new ComboBox();

		foreach ( var road in Plan.Roads() ) {
			var picked = road;
			var label = $"{picked.Name}  ({Resolved( picked.Id, picked.Curve ).Length / 12f:0} ft, {picked.Crossings.Count} crossings, {picked.Bridges.Count} bridges, {picked.Tunnels.Count} tunnels)";

			roads.AddItem( label, "add_road", () => { Picked = new ArchSelection { Item = picked }; refresh(); },
				selected: Picked?.Targets( picked ) == true );
		}

		header.Add( roads );
	}
}