Utility that classifies a 2D loop as either a Box or a Circle form. It defines an enum ArchBoolForm and a static method Of that returns Circle when the loop has at least a minimum number of segments and is not rectilinear, otherwise Box.
using System.Collections.Generic;
using Sandbox;
namespace Sunless.Architecture;
// The shape a drag stands. A box, or a circle authored as the box it is inscribed in plus a segment count - so both
// are the same gesture and the same loop, and everything downstream stops caring which.
public enum ArchBoolForm
{
Box,
Circle
}
// Read back off a loop rather than stored, so an edited outline reports what it now IS.
public static class ArchOutlineForm
{
public static ArchBoolForm Of( IReadOnlyList<Vector2> loop )
{
return loop is { Count: >= ArchFootprint.LeastSegments } && !ArchFootprint.IsRectilinear( loop )
? ArchBoolForm.Circle
: ArchBoolForm.Box;
}
}