Editor-side generator for exterior stairs. It resolves an ArchExteriorStair shape and builds stair flights, landings (slabs) and optional rails by delegating to ArchStairGen, ArchPlatformGen and ArchFixtureGuard, grouping mesh output into Parts on the provided ArchMesh.
using System.Collections.Generic;
namespace Sunless.Architecture;
// The routing filed as named pieces: the legs come out of the stair engine, the landings out of the platform
// engine and the rails out of the barrier engine, so nothing about a tread, a slab or a baluster lives here.
public static class ArchExteriorStairGen
{
public static void Build(
ArchMesh canvas,
ArchExteriorStairPart part,
ArchBuilding building,
ArchPlan plan,
ArchKit kit,
ArchStyle style,
List<ArchDoorRequest> doors )
{
var shape = ArchExteriorStair.Resolve( part, building, kit );
if ( !shape.IsUsable )
{
return;
}
using ( canvas.Part( ArchPieces.Flight ) )
{
foreach ( var flight in shape.Flights )
{
ArchStairGen.Build( canvas, flight.Stair, shape.Host, building, kit, style, doors, plan );
}
}
using ( canvas.Part( ArchPieces.Landings ) )
{
foreach ( var landing in shape.Landings )
{
ArchPlatformGen.Build( canvas, ArchExteriorStair.Slab( part, landing ), building, plan, kit, style );
}
}
if ( !part.Rail )
{
return;
}
using ( canvas.Part( ArchPieces.Rails ) )
{
Rails( canvas, shape, kit, ArchBarrierBrushes.Of( style, part.Palette, building.Palette ) );
}
}
// Follow on the rake, Level on a landing: the same engine, told which of the two the ground under it does.
static void Rails( ArchMesh canvas, ArchExteriorStairShape shape, ArchKit kit, ArchBarrierBrushes brushes )
{
foreach ( var flight in shape.Flights )
{
ArchFixtureGuard.Build( canvas, flight.Edge, kit, kit.HandrailHeight, BarrierGround.Follow, brushes );
}
foreach ( var landing in shape.Landings )
{
ArchFixtureGuard.Build( canvas, landing.Edge, kit, kit.HandrailHeight, BarrierGround.Level, brushes );
}
}
}