Editor/Designers/ArchOpeningKinds.cs
using System;
using System.Collections.Generic;
using System.Linq;
namespace Sunless.Architecture;
// The one table: generators, designer and property sheet ask here, so no control lies.
public static class ArchOpeningKinds {
public static bool Glazes( this OpeningKind kind ) => kind == OpeningKind.Window;
public static bool Sills( this OpeningKind kind ) => kind == OpeningKind.Window;
public static bool Hangs( this OpeningKind kind ) => kind is OpeningKind.Door or OpeningKind.DoubleDoor or OpeningKind.Garage;
// Furniture is fixed to the frame the hole wears, so an archway carries none of it: its jambs are the wall's
// own finish carried through the thickness and there is nothing there to bolt a grille to.
public static bool Carries( this OpeningKind kind, OpeningFurniture furniture ) => furniture switch {
OpeningFurniture.Bars => kind is OpeningKind.Window or OpeningKind.Hatch,
OpeningFurniture.Boarded => kind is OpeningKind.Window or OpeningKind.Door or OpeningKind.DoubleDoor or OpeningKind.Hatch,
OpeningFurniture.Shutter => kind is OpeningKind.Garage or OpeningKind.Window,
OpeningFurniture.Gate => kind is OpeningKind.Door or OpeningKind.DoubleDoor,
OpeningFurniture.Leaves => kind == OpeningKind.Window,
_ => false
};
// A hood stands on the wall over the head, so it wants a hole with a frame under it to look bolted to. An
// archway has none, a hatch is too small to carry one and a garage's head is where the door stacks.
public static bool Wears( this OpeningKind kind, OpeningHood hood ) {
return hood != OpeningHood.None && kind is OpeningKind.Window or OpeningKind.Door or OpeningKind.DoubleDoor;
}
public static IEnumerable<OpeningHood> Hoods( this OpeningKind kind ) {
return Enum.GetValues<OpeningHood>().Where( hood => kind.Wears( hood ) );
}
// What a picker may offer, read off the same rows the generator builds from - so a form and a wall cannot
// disagree about what a kind has.
public static IEnumerable<OpeningFurniture> Furnishings( this OpeningKind kind ) {
return Enum.GetValues<OpeningFurniture>().Where( furniture => kind.Carries( furniture ) );
}
public static bool Furnishes( this OpeningKind kind ) => kind.Furnishings().Any();
}