add project work

This commit is contained in:
2025-10-28 13:48:36 +08:00
parent 9e0a2963e8
commit 875a77ff5b
22 changed files with 498 additions and 80 deletions

View File

@ -32,6 +32,16 @@ namespace Hazel
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern static void RigidBody2DComponent_ApplyLinearImpulseToCenter(ulong entityID, ref Vector2 impulse, bool wake);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern static void RigidBody2DComponent_GetLinearVelocity(ulong entityID, out Vector2 LinearVelocity);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern static RigidBody2DComponent.BodyType RigidBody2DComponent_GetType(ulong entityID);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern static void RigidBody2DComponent_SetType(ulong entityID, RigidBody2DComponent.BodyType bodyType);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern static bool Input_IsKeyDown(KeyCode keycode);
}

View File

@ -21,6 +21,23 @@ namespace Hazel
public class RigidBody2DComponent : Component
{
public enum BodyType { Static = 0, Dynamic, Kinematic}
public Vector2 LinearVelocity
{
get
{
InternalCalls.RigidBody2DComponent_GetLinearVelocity(Entity.ID, out Vector2 velocity);
return velocity;
}
}
public BodyType Type
{
get => InternalCalls.RigidBody2DComponent_GetType(Entity.ID);
set => InternalCalls.RigidBody2DComponent_SetType(Entity.ID, value);
}
public void ApplyLinearImpulse(Vector2 impulse, Vector2 point, bool wake) {
InternalCalls.RigidBody2DComponent_ApplyLinearImpulse(Entity.ID, ref impulse, ref point, wake);
}

View File

@ -1,3 +1,4 @@
using System;
namespace Hazel
{
@ -26,6 +27,16 @@ namespace Hazel
{
return new Vector2(a.X + b.X, a.Y + b.Y);
}
public float LengthSquared()
{
return X * X + Y * Y;
}
public float Length()
{
return (float)Math.Sqrt(LengthSquared());
}
}
public struct Vector3