Editor/Tool/ArchSheets.cs

Editor UI registry for architecture sheets. Defines IArchSheet interface and ArchSheets collection that yields concrete sheet instances and maps them by their Payload Type for lookup and exclusions.

Reflection
namespace Sunless.Architecture;

public interface IArchSheet
{
	Type Payload { get; }

	void Build( ToolSidebarWidget panel, ArchTool tool, ArchSelection picked, Action refresh, Action changed );
}

public sealed class ArchSheets : ArchTable<ArchSheets, Type, IArchSheet>
{
	protected override IEnumerable<IArchSheet> Standing()
	{
		yield return new ArchWallSheet();
		yield return new ArchWallModSheet();
		yield return new ArchRoofSheet();
		yield return new ArchRoofLightSheet();
		yield return new ArchStairSheet();
		yield return new ArchStairStepSheet();
		yield return new ArchStairGuardSheet();
		yield return new ArchApproachSheet();
		yield return new ArchPillarSheet();
		yield return new ArchSpanSheet();
		yield return new ArchPlatformSheet();
		yield return new ArchBeamSheet();
		yield return new ArchCutSheet();
		yield return new ArchPipeSheet();
		yield return new ArchPipeBracketSheet();
		yield return new ArchPorchSheet();
		yield return new ArchRoadPartSheet();
		yield return new ArchCrossingSheet();
		yield return new ArchBridgeSheet();
		yield return new ArchTunnelSheet();
	}

	protected override Type KeyOf( IArchSheet sheet ) => sheet.Payload;

	protected override bool Accepts( IArchSheet sheet ) => sheet.Payload is not null;

	protected override string Collision( IArchSheet standing, IArchSheet sheet )
	{
		return $"{sheet.Payload.Name} is claimed by both {standing.GetType().Name} and {sheet.GetType().Name}";
	}

	public IArchSheet For( Type payload ) => Held( payload );

	public IArchSheet For( object payload ) => payload is null ? null : For( payload.GetType() );

	public ArchSheets Without<T>() => Without( typeof( T ) );

	public ArchSheets Except( Type payload ) => Without( payload );

	public ArchSheets Except<T>() => Without<T>();
}