Editor/Floor/ArchFoundationMouths.cs
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>();
}
}