Editor/Tunnel/ArchTunnelShapeBuilder.cs

A small builder class in the editor that collects parameters for creating an ArchTunnelShape. It stores references to an ArchRoadPart, ArchTunnelPart, ArchCurve, frames list, ArchKit, ArchGround and an optional ArchPlan, and passes them to ArchTunnel.ResolveCore when Create is called.

using System;
using System.Collections.Generic;
using Sandbox;

namespace Sunless.Architecture;

public sealed class ArchTunnelShapeBuilder
{
	ArchRoadPart road;
	ArchTunnelPart part;
	ArchCurve curve;
	IReadOnlyList<ArchFrame> frames;
	ArchKit kit;
	ArchGround ground;
	ArchPlan plan;

	public ArchTunnelShapeBuilder On( ArchRoadPart road, ArchTunnelPart part )
	{
		this.road = road;
		this.part = part;

		return this;
	}

	public ArchTunnelShapeBuilder Along( ArchCurve curve )
	{
		this.curve = curve;

		return this;
	}

	public ArchTunnelShapeBuilder WithFrames( IReadOnlyList<ArchFrame> frames )
	{
		this.frames = frames;

		return this;
	}

	public ArchTunnelShapeBuilder WithKit( ArchKit kit )
	{
		this.kit = kit;

		return this;
	}

	public ArchTunnelShapeBuilder Under( ArchGround ground )
	{
		this.ground = ground;

		return this;
	}

	// Optional: handed no plan nothing is carved, which is what a designer stage and a bare test want.
	public ArchTunnelShapeBuilder In( ArchPlan plan )
	{
		this.plan = plan;

		return this;
	}

	public ArchTunnelShape Create()
	{
		return ArchTunnel.ResolveCore( road, part, curve, frames, kit, ground, plan );
	}
}