Editor/Road/ArchFenceGen.cs
using Sandbox;

namespace Sunless.Architecture;

// A fence is a barrier on its own spline: everything lives in the barrier layer. A retaining wall is the one
// style that is no barrier at all - it holds fill - so the same spline stands ArchWing instead of posts.
public static class ArchFenceGen {
	public static void Build( ArchMesh canvas, ArchFencePart fence, ArchBuilding building, ArchKit kit, ArchStyle style, ArchGround ground = default ) {
		var brushes = ArchBarrierBrushes.Of( style, fence.Palette, building.Palette );

		if ( fence.Barrier.Style == BarrierStyle.Retaining ) {
			ArchRetainingGen.Build( canvas, Retains( fence, kit, ground ), kit, brushes );

			return;
		}

		ArchBarrierGen.Build( canvas, Shape( fence, kit ), fence.Barrier, kit, brushes );
	}

	public static ArchBarrierShape Shape( ArchFencePart fence, ArchKit kit = null ) {
		return ArchBarrierShape.Resolve( fence.Curve(), fence.Barrier, 0f, 0f, kit );
	}

	public static ArchRetainingShape Retains( ArchFencePart fence, ArchKit kit, ArchGround ground ) {
		return ArchRetainingShape.Resolve( Shape( fence, kit ), kit, ground );
	}
}