Editor/Geometry/ArchStoreyGeometry.cs

Utility class for storey geometry. Provides FloorAbove which finds the room directly above a given room by checking building rooms on floor+1, computes a midpoint between two points, generates the wall shell from the above room footprint using kit wall thickness, and returns the above room base height if the shell encloses the midpoint.

ReflectionFile AccessNetworkingProcess ExecutionNative InteropObfuscated CodeEncoded DataExternal DownloadCredential AccessSelf Modifying CodeHttp Calls
namespace Sunless.Architecture;

public static class ArchStoreyGeometry
{
	public static float FloorAbove( ArchRoom room, ArchBuilding building, ArchKit kit, Vector2 from, Vector2 to )
	{
		if ( building is null )
		{
			return 0f;
		}

		var midpoint = (from + to) * 0.5f;

		foreach ( var above in building.Rooms.Where( other => other.Floor == room.Floor + 1 ) )
		{
			var shell = ArchRegion.Shell( ArchRegion.Footprints( new[] { above } ), kit.WallThickness );

			if ( ArchFootprint.Encloses( shell, midpoint ) )
			{
				return above.BaseHeight;
			}
		}

		return 0f;
	}
}