Editor/Stair/ArchStairGhost.cs

Editor utility that draws a gizmo/ghost visualization for arch stair geometry. It iterates stair runs, pads and level loops to draw step lines, rings and verticals at specified heights for preview in the editor.

File Access
namespace Sunless.Architecture;

public static class ArchStairGhost
{
	public static void Flight( ArchStairShape shape, float soffit, int? level = null )
	{
		foreach ( var run in shape.Runs )
		{
			if ( level is { } runLevel && run.Level != runLevel )
			{
				continue;
			}

			foreach ( var lane in new[] { 0f, run.Width } )
			{
				for ( var step = 0; step < run.Steps; step++ )
				{
					var nose = step * run.Going;
					var top = run.StepTop( step );

					Gizmo.Draw.Line( run.Axes.Point( nose, lane, top - run.Rise ), run.Axes.Point( nose, lane, top ) );
					Gizmo.Draw.Line( run.Axes.Point( nose, lane, top ), run.Axes.Point( nose + run.Going, lane, top ) );
				}
			}
		}

		Gizmo.Draw.Color = ArchGhost.Accent;

		foreach ( var pad in shape.Pads )
		{
			if ( level is { } padLevel && pad.Storey != padLevel )
			{
				continue;
			}

			ArchGhost.Ring( pad.Loop(), pad.Height );
		}

		Gizmo.Draw.Color = ArchGhost.Ground;

		foreach ( var well in shape.Levels )
		{
			if ( level is { } wellLevel && well.Level != wellLevel + 1 )
			{
				continue;
			}

			foreach ( var loop in well.Loops )
			{
				ArchGhost.Ring( loop, well.Height );
			}

			if ( well.Level == shape.TopLevel )
			{
				foreach ( var loop in well.Loops )
				{
					ArchGhost.Ring( loop, soffit );

					foreach ( var corner in loop )
					{
						Gizmo.Draw.Line( new Vector3( corner.x, corner.y, shape.BaseHeight ), new Vector3( corner.x, corner.y, soffit ) );
					}
				}
			}
		}

		Gizmo.Draw.Color = ArchGhost.Line;
	}
}