Builder class used in the editor to create a connection (ArchWallJoin) between a wall and a room. Stores references to ArchConnectionService, ArchWall and ArchRoom, allows setting thickness, and calls service.Resolve to create the join.
using System;
using System.Collections.Generic;
using System.Linq;
using Sandbox;
namespace Sunless.Architecture;
public sealed class ArchWallConnectionBuilder
{
readonly ArchConnectionService service;
readonly ArchWall wall;
readonly ArchRoom room;
float thickness;
public ArchWallConnectionBuilder( ArchConnectionService service, ArchWall wall, ArchRoom room )
{
this.service = service ?? throw new ArgumentNullException( nameof( service ) );
this.wall = wall ?? throw new ArgumentNullException( nameof( wall ) );
this.room = room ?? throw new ArgumentNullException( nameof( room ) );
}
public ArchWallConnectionBuilder WithThickness( float thickness )
{
this.thickness = thickness;
return this;
}
public ArchWallJoin Create()
{
return service.Resolve( wall, room, thickness );
}
}