feat: ICollider2D Action Calls
This commit is contained in:
parent
0ba6913a61
commit
309c8db6e1
|
@ -6,8 +6,8 @@ namespace Syntriax.Engine.Physics2D.Abstract;
|
|||
|
||||
public interface ICollider2D : IBehaviour, IAssignableTransform
|
||||
{
|
||||
Action<ICollider2D, ICollider2D>? OnCollisionPreResolve { get; set; }
|
||||
Action<ICollider2D, ICollider2D>? OnCollisionResolved { get; set; }
|
||||
Action<ICollider2D, CollisionDetectionInformation>? OnCollisionPreResolve { get; set; }
|
||||
Action<ICollider2D, CollisionDetectionInformation>? OnCollisionResolved { get; set; }
|
||||
|
||||
IRigidBody2D? RigidBody2D { get; }
|
||||
|
||||
|
|
|
@ -62,6 +62,9 @@ public class PhysicsEngine2D : IPhysicsEngine2D
|
|||
|
||||
if (collisionDetector.TryDetect(colliderX, colliderY, out CollisionDetectionInformation information))
|
||||
{
|
||||
colliderX.OnCollisionPreResolve?.Invoke(colliderX, information);
|
||||
colliderY.OnCollisionPreResolve?.Invoke(colliderY, information);
|
||||
|
||||
Vector2D displacementVector = information.Normal * information.Penetration;
|
||||
|
||||
|
||||
|
@ -89,6 +92,9 @@ public class PhysicsEngine2D : IPhysicsEngine2D
|
|||
|
||||
information.Left.Recalculate();
|
||||
information.Right.Recalculate();
|
||||
|
||||
colliderX.OnCollisionResolved?.Invoke(colliderX, information);
|
||||
colliderY.OnCollisionResolved?.Invoke(colliderY, information);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue