66 lines
2.1 KiB
C#
66 lines
2.1 KiB
C#
using Engine.Core;
|
|
|
|
namespace Engine.Physics2D;
|
|
|
|
/// <summary>
|
|
/// Represents a 2D collider.
|
|
/// </summary>
|
|
public interface ICollider2D : IBehaviour
|
|
{
|
|
/// <summary>
|
|
/// Event triggered when the collider is recalculated.
|
|
/// </summary>
|
|
Event<ICollider2D> OnRecalculated { get; }
|
|
|
|
/// <summary>
|
|
/// Event triggered when a collision is detected.
|
|
/// </summary>
|
|
Event<ICollider2D, CollisionDetectionInformation> OnCollisionDetected { get; }
|
|
|
|
/// <summary>
|
|
/// Event triggered when a collision is resolved.
|
|
/// </summary>
|
|
Event<ICollider2D, CollisionDetectionInformation> OnCollisionResolved { get; }
|
|
|
|
/// <summary>
|
|
/// Event triggered when another <see cref="ICollider2D"/> triggers this <see cref="ICollider2D"/>.
|
|
/// </summary>
|
|
Event<ICollider2D, ICollider2D> OnTriggered { get; }
|
|
|
|
/// <inheritdoc cref="ITransform2D" />
|
|
ITransform2D Transform { get; }
|
|
|
|
/// <summary>
|
|
/// The <see cref="IRigidBody2D"/> associated with the <see cref="ICollider2D"/>.
|
|
/// </summary>
|
|
IRigidBody2D? RigidBody2D { get; }
|
|
|
|
/// <summary>
|
|
/// The area of the <see cref="ICollider2D"/>.
|
|
/// </summary>
|
|
float Area { get; }
|
|
|
|
/// <summary>
|
|
/// The geometric inertia of the <see cref="ICollider2D"/>.
|
|
/// </summary>
|
|
float GeometricInertia { get; }
|
|
|
|
/// <summary>
|
|
/// The value indicating whether the <see cref="ICollider2D"/> is a trigger.
|
|
/// </summary>
|
|
bool IsTrigger { get; set; }
|
|
|
|
/// <summary>
|
|
/// Recalculates <see cref="ICollider2D"/> properties.
|
|
/// </summary>
|
|
void Recalculate();
|
|
|
|
void Detect(CollisionDetectionInformation collisionDetectionInformation);
|
|
void Resolve(CollisionDetectionInformation collisionDetectionInformation);
|
|
void Trigger(ICollider2D initiator);
|
|
|
|
readonly record struct CollisionDetectedArguments(ICollider2D Sender, CollisionDetectionInformation CollisionDetectionInformation);
|
|
readonly record struct CollisionResolvedArguments(ICollider2D Sender, CollisionDetectionInformation CollisionDetectionInformation);
|
|
readonly record struct TriggeredArguments(ICollider2D Sender, ICollider2D InitiatorCollider);
|
|
}
|