chore: converted PhysicsMaterial2D's to classes and renamed Default to be ReadOnly
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
namespace Engine.Physics2D;
|
namespace Engine.Physics2D;
|
||||||
|
|
||||||
public readonly struct PhysicsMaterial2D(float Friction, float Restitution) : IPhysicsMaterial2D
|
public class PhysicsMaterial2D(float Friction, float Restitution) : IPhysicsMaterial2D
|
||||||
{
|
{
|
||||||
public readonly float Friction { get; init; } = Friction;
|
public float Friction { get; set; } = Friction;
|
||||||
public readonly float Restitution { get; init; } = Restitution;
|
public float Restitution { get; set; } = Restitution;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
namespace Engine.Physics2D;
|
|
||||||
|
|
||||||
public readonly struct PhysicsMaterial2DDefault : IPhysicsMaterial2D
|
|
||||||
{
|
|
||||||
public readonly float Friction => .1f;
|
|
||||||
|
|
||||||
public readonly float Restitution => .1f;
|
|
||||||
}
|
|
||||||
9
Engine.Physics2D/ReadOnlyPhysicsMaterial2D.cs
Normal file
9
Engine.Physics2D/ReadOnlyPhysicsMaterial2D.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Engine.Physics2D;
|
||||||
|
|
||||||
|
public readonly struct ReadOnlyPhysicsMaterial2D(float Friction, float Restitution) : IPhysicsMaterial2D
|
||||||
|
{
|
||||||
|
public readonly float Friction { get; } = Friction;
|
||||||
|
public readonly float Restitution { get; } = Restitution;
|
||||||
|
|
||||||
|
public readonly static ReadOnlyPhysicsMaterial2D Default = new(.1f, .1f);
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ public class RigidBody2D : Behaviour2D, IRigidBody2D
|
|||||||
{
|
{
|
||||||
private const float LOWEST_ALLOWED_MASS = 0.00001f;
|
private const float LOWEST_ALLOWED_MASS = 0.00001f;
|
||||||
|
|
||||||
public IPhysicsMaterial2D Material { get; set; } = new PhysicsMaterial2DDefault();
|
public IPhysicsMaterial2D Material { get; set; } = ReadOnlyPhysicsMaterial2D.Default;
|
||||||
|
|
||||||
public Vector2D Velocity { get; set; } = Vector2D.Zero;
|
public Vector2D Velocity { get; set; } = Vector2D.Zero;
|
||||||
public float AngularVelocity { get; set; } = 0f;
|
public float AngularVelocity { get; set; } = 0f;
|
||||||
|
|||||||
Reference in New Issue
Block a user