Editor manifest describing the carved stair ArchKind. It declares metadata (kind, slot, label, glyph, subtool), where it can be hosted, naming and rename behavior, and filing/unfiling logic to platform parts.
using System;
using System.Collections.Generic;
using System.Linq;
namespace Sunless.Architecture;
public sealed class ArchCarvedStairManifest : ArchKindManifest
{
public override ArchKind Kind => ArchKind.CarvedStair;
// A carved flight IS an ArchStairPart: the Stair manifest claims the type, and only the platform it is filed on
// tells the two kinds apart, so claiming it twice would collide.
public override Type Payload => null;
public override string Slot => "Stairs";
public override IEnumerable<Type> Hosts => new[] { typeof( ArchPlatformPart ) };
public override string Label => "Carved stair";
public override string Glyph => "stairs";
public override string Subtool => ArchSubtools.Stair;
public override ArchLayerStage Stage( object payload ) => ArchLayerStage.Void;
public override string NameOf( object payload, int id )
{
return payload is ArchStairPart stair ? stair.Name : base.NameOf( payload, id );
}
public override bool TryRename( object payload, string name )
{
if ( string.IsNullOrWhiteSpace( name ) || payload is not ArchStairPart stair )
{
return false;
}
stair.Name = name;
return true;
}
public override IEnumerable<object> Filed( ArchPlan plan, object host )
{
return host is ArchPlatformPart platform ? platform.Stairs : Array.Empty<object>();
}
public override bool File( object host, object payload )
{
if ( host is not ArchPlatformPart platform || payload is not ArchStairPart stair )
{
return false;
}
platform.Stairs.Add( stair );
return true;
}
public override bool Unfile( ArchPlan plan, object payload )
{
return plan is not null && payload is ArchStairPart stair
&& plan.Buildings.SelectMany( building => building.Platforms ).Any( platform => platform.Stairs.Remove( stair ) );
}
}