Editor manifest for the ArchRoom kind. It defines metadata for rooms (kind, slot, hosts, label, glyph, child kinds, rank) and implements methods to enumerate filed rooms from a building, produce outline loops from a room footprint, and supply room height.
using System;
using System.Collections.Generic;
using System.Linq;
using Sandbox;
namespace Sunless.Architecture;
public sealed class ArchRoomManifest : ArchKindManifest<ArchRoom>
{
public override ArchKind Kind => ArchKind.Room;
public override string Slot => "Rooms";
public override IEnumerable<Type> Hosts => new[] { typeof( ArchBuilding ) };
public override string Label => "Room";
public override string Glyph => ArchIcons.Get( "subtool_room", "crop_square" );
public override string HostOutput => "Room footprint or boundary";
public override IEnumerable<ArchKind> Children => new[]
{
ArchKind.Wall, ArchKind.Stair, ArchKind.Trim, ArchKind.Pillar, ArchKind.Span,
ArchKind.Beam, ArchKind.Porch, ArchKind.Approach
};
public override int IndirectRank => 200;
public override IEnumerable<object> Filed( ArchPlan plan, object host )
{
if ( host is not ArchBuilding building )
{
return Array.Empty<object>();
}
return building.Rooms.Where( room => !room.Spans );
}
public override IReadOnlyList<List<Vector2>> Loops( object payload )
{
if ( payload is not ArchRoom room )
{
return Array.Empty<List<Vector2>>();
}
var footprint = ArchFloorGen.Footprint( room );
if ( footprint.Count < 3 )
{
return Array.Empty<List<Vector2>>();
}
return new List<List<Vector2>> { footprint };
}
public override float Height( object payload, float fallback )
{
return payload is ArchRoom room ? room.BaseHeight : fallback;
}
}