Editor/Porch/ArchPorchEffects.cs

Editor-side affector for porches. Implements IArchAffector for ArchKind.Porch, delegating resolution and closure logic to ArchPorchAffector and ArchPorchCover. Closes when payload is an ArchPorchPart and removes porch coverage when closed.

File Access
namespace Sunless.Architecture;

public sealed class ArchPorchEffects : IArchAffector
{
	public ArchKind Kind => ArchKind.Porch;

	public int Order => 30;

	public int Resolve( ArchPlan plan, ArchKit kit ) => ArchPorchAffector.Resolve( plan, kit );

	public bool Closes( object payload ) => payload is ArchPorchPart;

	public void Close( ArchPlan plan, object payload )
	{
		if ( plan is null || payload is not ArchPorchPart porch )
		{
			return;
		}

		var room = plan.AllRooms().FirstOrDefault( candidate => candidate.Porches.Contains( porch ) );
		var building = room is null ? null : plan.OwnerOf( room );

		if ( building is null )
		{
			return;
		}

		ArchPorchAffector.Close( building, porch );
		ArchPorchCover.Remove( plan, building, porch );
	}
}