feat: Default Physic Materials

This commit is contained in:
Syntriax 2024-01-23 12:17:49 +03:00
parent 7c18ccf4c2
commit b6b974feeb
3 changed files with 13 additions and 3 deletions

View File

@ -0,0 +1,5 @@
using Syntriax.Engine.Physics2D.Abstract;
namespace Syntriax.Engine.Physics2D;
public record PhysicsMaterial2D(float Friction, float Restitution) : IPhysicsMaterial2D { }

View File

@ -0,0 +1,6 @@
namespace Syntriax.Engine.Physics2D;
public record PhysicsMaterial2DDefault : PhysicsMaterial2D
{
public PhysicsMaterial2DDefault() : base(.1f, .1f) { }
}

View File

@ -1,7 +1,5 @@
using System; using System;
using Microsoft.Xna.Framework;
using Syntriax.Engine.Core; using Syntriax.Engine.Core;
using Syntriax.Engine.Core.Abstract; using Syntriax.Engine.Core.Abstract;
using Syntriax.Engine.Physics2D.Abstract; using Syntriax.Engine.Physics2D.Abstract;
@ -13,11 +11,12 @@ public class RigidBody2D : BehaviourOverride, IRigidBody2D
public Action<IAssignableTransform>? OnTransformAssigned { get => GameObject.OnTransformAssigned; set => GameObject.OnTransformAssigned = value; } public Action<IAssignableTransform>? OnTransformAssigned { get => GameObject.OnTransformAssigned; set => GameObject.OnTransformAssigned = value; }
public IPhysicsMaterial2D Material { get; set; } = null!; public IPhysicsMaterial2D Material { get; set; } = new PhysicsMaterial2DDefault();
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;
public float Mass { get; set; } = 0f; public float Mass { get; set; } = 0f;
ITransform IAssignableTransform.Transform => Transform; ITransform IAssignableTransform.Transform => Transform;