From 40ba1096716486ae58a338d5a4ae980a2662ebe4 Mon Sep 17 00:00:00 2001
From: GeWuYou <95328647+GeWuYou@users.noreply.github.com>
Date: Sun, 1 Mar 2026 23:26:54 +0800
Subject: [PATCH] =?UTF-8?q?refactor(ecs):=20=E4=BC=98=E5=8C=96=E4=BD=8D?=
=?UTF-8?q?=E7=BD=AE=E5=92=8C=E9=80=9F=E5=BA=A6=E7=BB=84=E4=BB=B6=E7=9A=84?=
=?UTF-8?q?=E5=86=85=E5=AD=98=E5=B8=83=E5=B1=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 为 Position 结构体添加 StructLayout 特性以确保顺序布局
- 为 Velocity 结构体添加 StructLayout 特性以确保顺序布局
- 更新 Velocity 组件的 XML 文档注释,提供更详细的描述
- 优化 Velocity 组件属性的文档注释,明确单位信息
- 添加 System.Runtime.InteropServices 命名空间引用
---
GFramework.Core/ecs/components/Position.cs | 3 +++
GFramework.Core/ecs/components/Velocity.cs | 12 +++++++-----
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/GFramework.Core/ecs/components/Position.cs b/GFramework.Core/ecs/components/Position.cs
index 472679f..204f66d 100644
--- a/GFramework.Core/ecs/components/Position.cs
+++ b/GFramework.Core/ecs/components/Position.cs
@@ -1,3 +1,5 @@
+using System.Runtime.InteropServices;
+
namespace GFramework.Core.ecs.components;
///
@@ -5,6 +7,7 @@ namespace GFramework.Core.ecs.components;
///
/// X轴坐标值
/// Y轴坐标值
+[StructLayout(LayoutKind.Sequential)]
public struct Position(float x, float y)
{
///
diff --git a/GFramework.Core/ecs/components/Velocity.cs b/GFramework.Core/ecs/components/Velocity.cs
index 51e8892..26465b2 100644
--- a/GFramework.Core/ecs/components/Velocity.cs
+++ b/GFramework.Core/ecs/components/Velocity.cs
@@ -1,19 +1,21 @@
+using System.Runtime.InteropServices;
+
namespace GFramework.Core.ecs.components;
///
-/// 速度组件,用于表示实体在二维空间中的运动速度。
+/// 速度结构体,用于表示二维空间中实体的瞬时速度向量
+/// 包含X轴和Y轴的速度分量,通常用于物理计算和运动系统
///
-/// X轴方向的速度分量
-/// Y轴方向的速度分量
+[StructLayout(LayoutKind.Sequential)]
public struct Velocity(float x, float y)
{
///
- /// X轴方向的速度分量
+ /// X轴速度分量,单位为距离单位/秒
///
public float X { get; set; } = x;
///
- /// Y轴方向的速度分量
+ /// Y轴速度分量,单位为距离单位/秒
///
public float Y { get; set; } = y;
}
\ No newline at end of file