Editor/Layers/ArchAssemblyManifest.cs
using System;
using System.Collections.Generic;

namespace Sunless.Architecture;

public sealed class ArchAssemblyManifest : ArchKindManifest<ArchSiteAssembly> {
	public override ArchKind Kind => ArchKind.Assembly;

	public override string Slot => "Assemblies";

	public override ArchLayerDomain Domain => ArchLayerDomain.Connections;

	public override string Label => "Assembly";

	public override string Glyph => "hub";

	public override string HostOutput => "Group transform and members";

	// A folder is a scope, not an ownership claim: it takes the root kinds, other folders, and a walkway, because a
	// connection is filed with the houses it joins rather than under one of them.
	public override IEnumerable<ArchKind> Children => new[]
	{
		ArchKind.Building, ArchKind.Road, ArchKind.Walkway, ArchKind.Assembly
	};

	// ArchPick.Rank returns before it splits direct from indirect, so a group answers the same either way.
	public override int DirectRank => -1;

	public override int IndirectRank => -1;

	public override ArchLayerStage Stage( object payload ) => ArchLayerStage.Addition;

	// A folder stands at the plan root, so nothing hosts it and only a hostless ask reaches its list.
	public override IEnumerable<object> Filed( ArchPlan plan, object host ) {
		return plan is not null && host is null ? plan.Assemblies : Array.Empty<object>();
	}

	public override bool Unfile( ArchPlan plan, object payload ) {
		return plan is not null && payload is ArchSiteAssembly assembly && plan.Assemblies.Remove( assembly );
	}
}