A data container used by the Editor for an architectural opening preset (door/window). It defines properties like size, glazing, sills, furniture and provides helpers to copy itself and spawn an ArchOpening instance with the same values.
using System;
using System.Collections.Generic;
using System.Linq;
using Sandbox;
namespace Sunless.Architecture;
public sealed class ArchOpeningPreset
{
public string Name { get; set; } = "door";
public OpeningKind Kind { get; set; } = OpeningKind.Door;
public float Width { get; set; } = 48f;
public float Height { get; set; } = 96f;
public float SillHeight { get; set; }
public bool Cased { get; set; } = true;
public bool HasSill { get; set; }
public bool Leaf { get; set; } = true;
public bool StartOpen { get; set; }
public float CasingWidth { get; set; }
public bool Glazed { get; set; }
public bool AutoLayout { get; set; } = true;
public int Lights { get; set; } = 1;
public int Sashes { get; set; } = 2;
public int PanesAcross { get; set; } = 2;
public int PanesDown { get; set; } = 3;
public GlassState Glass { get; set; } = GlassState.Intact;
public bool Breakable { get; set; }
public OpeningFurniture Furniture { get; set; }
public bool IsGlazed => Glazed && Kind.Glazes();
public bool IsSilled => HasSill && Kind.Sills();
public bool IsHung => Leaf && Kind.Hangs();
public OpeningFurniture Fitted => Kind.Carries( Furniture ) ? Furniture : OpeningFurniture.None;
// Every member is a scalar, an enum or a string, so a shallow clone IS a copy - four hand-written
// twenty-field initialisers drifted apart before this.
public ArchOpeningPreset Copy() => (ArchOpeningPreset)MemberwiseClone();
public ArchOpening Spawn( int id, float offset )
{
return new ArchOpening
{
Id = id,
Preset = Name,
Kind = Kind,
Offset = offset,
Width = Width,
Height = Height,
SillHeight = SillHeight,
Cased = Cased,
HasSill = HasSill,
CasingWidth = CasingWidth,
Leaf = Leaf,
StartOpen = StartOpen,
Glazed = Glazed,
AutoLayout = AutoLayout,
Lights = Lights,
Sashes = Sashes,
PanesAcross = PanesAcross,
PanesDown = PanesDown,
Glass = Glass,
Breakable = Breakable,
Furniture = Furniture
};
}
}