GeWuYou d7bd9fc569 refactor(ecs): 将ECS系统重构为Arch适配器模式
- 移除原有的ECS基础实现和接口定义
- 添加ArchEcsModule作为新的ECS模块实现
- 创建ArchSystemAdapter基类用于桥接Arch系统
- 修改MovementSystem继承ArchSystemAdapter适配新架构
- 更新ServiceModuleManager使用新的ArchECS模块
- 移除ArchitectureContext中的ECS相关方法
- 从项目中移除对Arch包的直接依赖引用
2026-03-02 21:20:50 +08:00

39 lines
1.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Arch.Core;
using GFramework.Core.ecs.components;
namespace GFramework.Core.ecs.systems;
/// <summary>
/// 移动系统 - Arch 原生实现
/// 负责更新具有位置和速度组件的实体的位置
/// </summary>
public sealed class MovementSystem : ArchSystemAdapter<float>
{
private QueryDescription _query;
/// <summary>
/// 初始化系统
/// </summary>
public void Initialize(World world)
{
// 创建查询查找所有同时拥有Position和Velocity组件的实体
_query = new QueryDescription()
.WithAll<Position, Velocity>();
}
/// <summary>
/// 系统更新方法,每帧调用一次
/// </summary>
/// <param name="world">ECS 世界</param>
/// <param name="deltaTime">帧间隔时间</param>
public void Update(World world, float deltaTime)
{
// 查询并更新所有符合条件的实体
world.Query(in _query, (ref Position pos, ref Velocity vel) =>
{
pos.X += vel.X * deltaTime;
pos.Y += vel.Y * deltaTime;
});
}
}