Editor/Roof/ArchRoofManifest.cs
using System;
using System.Collections.Generic;
using System.Linq;
using Sandbox;
namespace Sunless.Architecture;
public sealed class ArchRoofManifest : ArchKindManifest<ArchRoofPart> {
public override ArchKind Kind => ArchKind.Roof;
public override string Slot => "Roofs";
public override IEnumerable<Type> Hosts => new[] { typeof( ArchBuilding ) };
public override string Label => "Roof";
public override string Glyph => ArchIcons.Get( "subtool_roof", "roofing" );
public override string Subtool => ArchSubtools.Roof;
public override string HostOutput => "Roof deck or eave run";
// A wall standing on the deck is a parapet, so the deck it stands on is what owns it.
public override IEnumerable<ArchKind> Children => new[]
{
ArchKind.RoofLight, ArchKind.Downpipe, ArchKind.Wall
};
// Ranks BEHIND the building on purpose: a roofed shell reads as all roof from above, and a roof that won the
// click would leave the building unpickable.
public override int DirectRank => 120;
public override ArchLayerStage Stage( object payload ) => ArchLayerStage.Structure;
public override IReadOnlyList<List<Vector2>> Loops( object payload ) {
if ( payload is not ArchRoofPart roof ) {
return Array.Empty<List<Vector2>>();
}
var outline = roof.Outline();
return outline.Count >= 3 ? new List<List<Vector2>> { outline } : Array.Empty<List<Vector2>>();
}
public override float Height( object payload, float fallback ) {
return payload is ArchRoofPart roof ? roof.BaseHeight : fallback;
}
}