All delegate events are refactored to use the Event<TSender> and Event<TSender, TArgument> for performance issues regarding delegate events creating garbage, also this gives us better control on event invocation since C# Delegates did also create unnecessary garbage during Delegate.DynamicInvoke
51 lines
1.8 KiB
C#
51 lines
1.8 KiB
C#
using Syntriax.Engine.Core;
|
|
|
|
namespace Syntriax.Engine.Physics2D;
|
|
|
|
/// <summary>
|
|
/// Represents a 2D collider.
|
|
/// </summary>
|
|
public interface ICollider2D : IBehaviour
|
|
{
|
|
/// <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 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);
|
|
}
|