Editor-side types for foundation mouths. Defines a request record, an interface IArchFoundationMouth exposing a Kind and an Open method returning mouth openings as Vector2 list, and a registry ArchFoundationMouths that holds implementations, validates keys, reports collisions and provides lookup/Open by ArchKind.
namespace Sunless.Architecture;
public readonly record struct ArchFoundationMouthRequest( object Payload, ArchKit Kit, float Reach );
public interface IArchFoundationMouth
{
ArchKind Kind { get; }
IReadOnlyList<Vector2> Open( ArchFoundationMouthRequest request );
}
public sealed class ArchFoundationMouths : ArchTable<ArchFoundationMouths, ArchKind, IArchFoundationMouth>
{
protected override IEnumerable<IArchFoundationMouth> Standing()
{
yield return new ArchApproachFoundationMouth();
}
protected override ArchKind KeyOf( IArchFoundationMouth mouth ) => mouth.Kind;
protected override bool Accepts( IArchFoundationMouth mouth ) => mouth.Kind.Known;
protected override string Collision( IArchFoundationMouth standing, IArchFoundationMouth mouth )
{
return $"{mouth.Kind.Ident} foundation mouth is claimed by both {standing.GetType().Name} and {mouth.GetType().Name}";
}
public IArchFoundationMouth For( ArchKind kind ) => Held( kind );
public IReadOnlyList<Vector2> Open( ArchKind kind, ArchFoundationMouthRequest request )
{
return For( kind )?.Open( request ) ?? Array.Empty<Vector2>();
}
}