Editor-side class representing an architectural profile. Stores a name, a list of 2D points and flags for closed/capped/mapping, and exposes convenience properties for usability, bounding min/max and outward-winding point order.
using System;
using System.Collections.Generic;
using System.Linq;
using Sandbox;
namespace Sunless.Architecture;
public sealed class ArchProfile
{
public string Name { get; set; } = "trim";
public List<Vector2> Points { get; set; } = new();
public bool Closed { get; set; } = true;
public bool Capped { get; set; } = true;
public bool MapAlongPath { get; set; } = true;
public bool IsUsable => Points is { Count: >= 3 };
public Vector2 Min => new( Points.Min( point => point.x ), Points.Min( point => point.y ) );
public Vector2 Max => new( Points.Max( point => point.x ), Points.Max( point => point.y ) );
// A CCW section extrudes inside-out, so normalise the winding here.
public IReadOnlyList<Vector2> Outward
{
get
{
if ( ArchFootprint.SignedArea( Points ) <= 0f )
{
return Points;
}
var reversed = new List<Vector2>( Points );
reversed.Reverse();
return reversed;
}
}
}