docs(physics2d): Abstract
This commit is contained in:
parent
2f4137dae2
commit
2b19b24a26
|
@ -2,8 +2,18 @@ using Syntriax.Engine.Physics2D.Primitives;
|
||||||
|
|
||||||
namespace Syntriax.Engine.Physics2D.Abstract;
|
namespace Syntriax.Engine.Physics2D.Abstract;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a <see cref="ICollider2D"/> with the shape of a <see cref="Circle"/>.
|
||||||
|
/// </summary>
|
||||||
public interface ICircleCollider2D : ICollider2D
|
public interface ICircleCollider2D : ICollider2D
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The local <see cref="Circle"/> shape of the <see cref="ICollider2D"/>.
|
||||||
|
/// </summary>
|
||||||
Circle CircleLocal { get; set; }
|
Circle CircleLocal { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The world space representation of the <see cref="Circle"/> shape.
|
||||||
|
/// </summary>
|
||||||
Circle CircleWorld { get; }
|
Circle CircleWorld { get; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,15 +4,38 @@ using Syntriax.Engine.Core.Abstract;
|
||||||
|
|
||||||
namespace Syntriax.Engine.Physics2D.Abstract;
|
namespace Syntriax.Engine.Physics2D.Abstract;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a 2D collider.
|
||||||
|
/// </summary>
|
||||||
public interface ICollider2D : IBehaviour, IAssignableTransform
|
public interface ICollider2D : IBehaviour, IAssignableTransform
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Event triggered when a collision is detected.
|
||||||
|
/// </summary>
|
||||||
Action<ICollider2D, CollisionDetectionInformation>? OnCollisionDetected { get; set; }
|
Action<ICollider2D, CollisionDetectionInformation>? OnCollisionDetected { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event triggered when a collision is resolved.
|
||||||
|
/// </summary>
|
||||||
Action<ICollider2D, CollisionDetectionInformation>? OnCollisionResolved { get; set; }
|
Action<ICollider2D, CollisionDetectionInformation>? OnCollisionResolved { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event triggered when another <see cref="ICollider2D"/> triggers this <see cref="ICollider2D"/>.
|
||||||
|
/// </summary>
|
||||||
Action<ICollider2D, ICollider2D>? OnTriggered { get; set; }
|
Action<ICollider2D, ICollider2D>? OnTriggered { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The <see cref="IRigidBody2D"/> associated with the <see cref="ICollider2D"/>.
|
||||||
|
/// </summary>
|
||||||
IRigidBody2D? RigidBody2D { get; }
|
IRigidBody2D? RigidBody2D { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The value indicating whether the <see cref="ICollider2D"/> is a trigger.
|
||||||
|
/// </summary>
|
||||||
bool IsTrigger { get; set; }
|
bool IsTrigger { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Recalculates <see cref="ICollider2D"/> properties.
|
||||||
|
/// </summary>
|
||||||
void Recalculate();
|
void Recalculate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,19 @@ using Syntriax.Engine.Physics2D.Abstract;
|
||||||
|
|
||||||
namespace Syntriax.Engine.Physics2D;
|
namespace Syntriax.Engine.Physics2D;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a 2D collision detector.
|
||||||
|
/// </summary>
|
||||||
public interface ICollisionDetector2D
|
public interface ICollisionDetector2D
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Attempts to detect a collision between two <see cref="ICollider2D"/>s.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T1">Type of the first <see cref="ICollider2D"/>.</typeparam>
|
||||||
|
/// <typeparam name="T2">Type of the second <see cref="ICollider2D"/>.</typeparam>
|
||||||
|
/// <param name="left">The first <see cref="ICollider2D"/>.</param>
|
||||||
|
/// <param name="right">The second <see cref="ICollider2D"/>.</param>
|
||||||
|
/// <param name="collisionInformation">Information about the collision.</param>
|
||||||
|
/// <returns><see cref="true"/> if a collision is detected, otherwise <see cref="false"/>.</returns>
|
||||||
bool TryDetect<T1, T2>(T1 left, T2 right, out CollisionDetectionInformation collisionInformation) where T1 : ICollider2D where T2 : ICollider2D;
|
bool TryDetect<T1, T2>(T1 left, T2 right, out CollisionDetectionInformation collisionInformation) where T1 : ICollider2D where T2 : ICollider2D;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,13 @@
|
||||||
namespace Syntriax.Engine.Physics2D.Abstract;
|
namespace Syntriax.Engine.Physics2D.Abstract;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a 2D collision resolver.
|
||||||
|
/// </summary>
|
||||||
public interface ICollisionResolver2D
|
public interface ICollisionResolver2D
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Resolves collisions based on collision detection information provided.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="collisionInformation">Information about the collision.</param>
|
||||||
void Resolve(CollisionDetectionInformation collisionInformation);
|
void Resolve(CollisionDetectionInformation collisionInformation);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,18 @@
|
||||||
namespace Syntriax.Engine.Physics2D.Abstract;
|
namespace Syntriax.Engine.Physics2D.Abstract;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a 2D physics engine.
|
||||||
|
/// </summary>
|
||||||
public interface IPhysicsEngine2D
|
public interface IPhysicsEngine2D
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The number of iterations the <see cref="IPhysicsEngine2D"/> performs per step.
|
||||||
|
/// </summary>
|
||||||
int IterationCount { get; set; }
|
int IterationCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Advances the physics simulation by the specified time.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="deltaTime">The time step.</param>
|
||||||
void Step(float deltaTime);
|
void Step(float deltaTime);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,17 @@
|
||||||
namespace Syntriax.Engine.Physics2D.Abstract;
|
namespace Syntriax.Engine.Physics2D.Abstract;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a 2D physics object's responsive attributes.
|
||||||
|
/// </summary>
|
||||||
public interface IPhysicsMaterial2D
|
public interface IPhysicsMaterial2D
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The friction coefficient of the physics object.
|
||||||
|
/// </summary>
|
||||||
float Friction { get; }
|
float Friction { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The restitution (bounciness) coefficient of the physics object.
|
||||||
|
/// </summary>
|
||||||
float Restitution { get; }
|
float Restitution { get; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,33 @@ using Syntriax.Engine.Core.Abstract;
|
||||||
|
|
||||||
namespace Syntriax.Engine.Physics2D.Abstract;
|
namespace Syntriax.Engine.Physics2D.Abstract;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a 2D rigid body in the engine.
|
||||||
|
/// </summary>
|
||||||
public interface IRigidBody2D : IBehaviour, IAssignableTransform
|
public interface IRigidBody2D : IBehaviour, IAssignableTransform
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The physics material of the <see cref="IRigidBody2D"/>.
|
||||||
|
/// </summary>
|
||||||
IPhysicsMaterial2D Material { get; set; }
|
IPhysicsMaterial2D Material { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The velocity of the <see cref="IRigidBody2D"/>.
|
||||||
|
/// </summary>
|
||||||
Vector2D Velocity { get; set; }
|
Vector2D Velocity { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The angular velocity (rotation rate) of the <see cref="IRigidBody2D"/>.
|
||||||
|
/// </summary>
|
||||||
float AngularVelocity { get; set; }
|
float AngularVelocity { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The mass of the <see cref="IRigidBody2D"/>.
|
||||||
|
/// </summary>
|
||||||
float Mass { get; set; }
|
float Mass { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The value indicating whether the <see cref="IRigidBody2D"/> is static/immovable.
|
||||||
|
/// </summary>
|
||||||
bool IsStatic { get; set; }
|
bool IsStatic { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,19 @@ using Syntriax.Engine.Physics2D.Primitives;
|
||||||
|
|
||||||
namespace Syntriax.Engine.Physics2D.Abstract;
|
namespace Syntriax.Engine.Physics2D.Abstract;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a <see cref="ICollider2D"/> with a custom <see cref="Shape"/>.
|
||||||
|
/// </summary>
|
||||||
public interface IShapeCollider2D : ICollider2D
|
public interface IShapeCollider2D : ICollider2D
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the local <see cref="Shape"/> of the <see cref="ICollider2D"/>.
|
||||||
|
/// </summary>
|
||||||
Shape ShapeLocal { get; set; }
|
Shape ShapeLocal { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the world space representation of the <see cref="Shape"/>.
|
||||||
|
/// </summary>
|
||||||
Shape ShapeWorld { get; }
|
Shape ShapeWorld { get; }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue