Editor/Roof/ArchRoofLightExtentProvider.cs

Editor-side extent provider for roof light parts. It calculates a 3D bounding extent for an ArchRoofLightPart by sampling each outline corner, computing deck seat and stack/top offsets, then expanding the result by a margin based on curb width.

ReflectionFile Access
using System;
using Sandbox;

namespace Sunless.Architecture;

public sealed class ArchRoofLightExtentProvider : IArchExtentProvider
{
	public ArchKind Kind => ArchKind.RoofLight;

	// Corner by corner off the deck plane, because a light or a plant item on a raked deck stands at a different
	// height at each end and a box drawn off the eave alone selects thin air above a shed's high side.
	public ArchExtent Measure( object payload, ArchExtentContext context )
	{
		var extent = new ArchExtent();

		if ( payload is not ArchRoofLightPart light || context.Host is not ArchRoofPart roof )
		{
			return extent;
		}

		var kit = context.Kit;
		var top = ArchRoofGen.Stack( light, kit ).Top;

		foreach ( var corner in light.Outline() )
		{
			var deck = ArchRoofGen.Seat( roof, kit, corner );

			extent.Add( corner, deck - ArchRoofPlane.Thickness( roof, kit ), deck + top );
		}

		return extent.Grown( MathF.Max( 6f, light.CurbWidth ) );
	}
}