Editor/Services/ArchGenerationServices.cs

Editor-side helper that bundles services used to generate architecture. It stores references to an ArchPlan, ArchKit, computed ArchStyle, an ArchConnectionService and ArchGround, and provides ResolveConnections to normalize the plan and resolve connection/road boundaries.

using System;
using Sandbox;

namespace Sunless.Architecture;

public sealed class ArchGenerationServices
{
	public ArchPlan Plan { get; }
	public ArchKit Kit { get; }
	public ArchStyle Style { get; }
	public ArchConnectionService Connections { get; }
	public ArchGround Ground { get; }

	public ArchGenerationServices( ArchPlan plan, ArchKit kit, Scene scene )
	{
		Plan = plan ?? throw new ArgumentNullException( nameof( plan ) );
		Kit = kit ?? throw new ArgumentNullException( nameof( kit ) );
		Style = new ArchStyle( kit );
		Connections = new ArchConnectionService( plan, kit );
		Ground = new ArchGround( scene );
	}

	public bool ConnectionsResolved { get; private set; }

	public ArchGenerationServices ResolveConnections()
	{
		if ( ConnectionsResolved )
		{
			return this;
		}

		Plan.Normalize();
		Connections.NormalizeBoundaries();
		Connections.ResolveRoads();
		ConnectionsResolved = true;

		return this;
	}
}