Editor/Data/ArchProfile.cs
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;
		}
	}
}