using System;
using Chernobyl.Mathematics.Geometry;
namespace Chernobyl.Mathematics.Collision
{
///
/// An interface for types that can collide with 2D objects.
///
public interface ICollidable2D
: IExtendedCollidable, IExtendedCollidable,
IExtendedCollidable
{ }
///
/// Utility and extension methods for .
///
public static class Collidable2D
{
///
/// Tests for a collision between this and
/// by doing a type check on to determine the method of collision
/// check.
///
public static bool IsColliding(this ICollidable2D collidable, IShape shape)
{
switch (shape)
{
case Circle circle: return collidable.IsColliding(circle);
case Rectangle rect: return collidable.IsColliding(rect);
case Point2D point: return collidable.IsColliding(point);
default: throw new ArgumentException(
$"Unable to perform collision check. Unknown {nameof(IShape)} type.", nameof(shape));
}
}
}
}