Editor helper that constructs a staged preview of a single wall treatment. It builds an ArchWall with a door and a window opening, wraps it in a room and building, and returns an ArchStaged containing the plan, camera pivot and radius. Also provides an Identity string for the wall preset.
using System;
using System.Collections.Generic;
using Sandbox;
namespace Sunless.Architecture;
// One staging of a wall treatment, shared by the designer's turntable and the browser's card art. A band
// is judged where it crosses a jamb and passes under a sill, so the elevation carries a door and a window.
public static class ArchWallStage
{
public const float Span = 264f;
public static ArchStaged Of( ArchWallPreset unit, ArchKit kit )
{
var height = unit.Height > 1f ? unit.Height : kit.WallHeight;
var wall = unit.Spawn( 2, Vector2.Zero, new Vector2( Span, 0f ) );
wall.Openings.Add( new ArchOpening
{
Id = 3,
Preset = "door",
Kind = OpeningKind.Door,
Offset = Span * 0.28f,
Width = 48f,
Height = height * 0.75f,
SillHeight = 0f
} );
wall.Openings.Add( new ArchOpening
{
Id = 4,
Preset = "window",
Kind = OpeningKind.Window,
Offset = Span * 0.72f,
Width = 64f,
Height = height * 0.3f,
SillHeight = height * 0.36f,
HasSill = true,
Glazed = true,
Leaf = false
} );
var room = new ArchRoom
{
Id = 1,
WallHeight = height,
HasFloor = false,
RaisedFoundation = false,
Walls = new List<ArchWall> { wall }
};
var building = new ArchBuilding
{
Id = 1,
Rooms = new List<ArchRoom> { room },
StoreyHeight = height
};
return new ArchStaged(
new ArchPlan { Units = new List<ArchUnit> { building } },
new Vector3( Span * 0.5f, 0f, height * 0.5f ),
MathF.Max( 300f, MathF.Max( Span, height ) * 1.55f ) );
}
// Serialised rather than a typed-out field list: a treatment carries nested band and trim lists, and a
// key that forgot one would show yesterday's elevation for today's brick line.
public static string Identity( ArchWallPreset unit ) => ArchStageKey.Of( "wall", unit.Name, unit );
}