Syntriax.Engine/Engine.Physics2D/Abstract/IRaycastResolver2D.cs

24 lines
1.0 KiB
C#

using Syntriax.Engine.Core;
namespace Syntriax.Engine.Physics2D;
/// <summary>
/// Represents a 2D raycast resolver.
/// </summary>
public interface IRaycastResolver2D
{
/// <summary>
/// Casts a <see cref="Ray2D"/> against a specific <see cref="ICollider2D"/> shape and returns the first hit, if any.
/// </summary>
/// <typeparam name="T">The type of the <see cref="ICollider2D"/>, which must implement <see cref="ICollider2D"/>.</typeparam>
/// <param name="shape">The <see cref="ICollider2D"/> shape to test against.</param>
/// <param name="ray">The <see cref="Ray2D"/> to cast.</param>
/// <param name="length">
/// The maximum distance to check along the <see cref="Ray2D"/>. Defaults to <see cref="float.MaxValue"/>.
/// </param>
/// <returns>
/// A <see cref="RaycastResult"/> containing information about the intersection, or <see cref="null"/> if there was no hit.
/// </returns>
RaycastResult? RaycastAgainst<T>(T shape, Ray2D ray, float length = float.MaxValue) where T : ICollider2D;
}