-
Notifications
You must be signed in to change notification settings - Fork 4
Refactor/extract ecs to independent module #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
af76e0a
refactor(ecs): 移除Arch ECS模块及相关组件和系统
GeWuYou bca92e5
refactor(ecs): 重构 Arch ECS 模块注册机制
GeWuYou 4257d58
feat(GFramework.Ecs.Arch): 注册模块自身到容器中
GeWuYou ac2a975
refactor(ArchEcsModule): 优化系统适配器管理
GeWuYou 5c5525e
refactor(architecture): 简化模块注册接口并增强配置管理
GeWuYou f35c930
docs(menu): 重构 ECS 文档导航结构
GeWuYou f771b7d
chore(ci): 添加 GFramework.Ecs.Arch.Tests 测试步骤
GeWuYou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
GFramework.Core.Abstractions/architecture/ArchitectureModuleRegistry.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| namespace GFramework.Core.Abstractions.architecture; | ||
|
|
||
| /// <summary> | ||
| /// 架构模块注册表 - 用于外部模块的自动注册 | ||
| /// </summary> | ||
| public static class ArchitectureModuleRegistry | ||
| { | ||
| private static readonly List<Func<IServiceModule>> _factories = []; | ||
|
|
||
| /// <summary> | ||
| /// 注册模块工厂 | ||
| /// </summary> | ||
| /// <param name="factory">模块工厂函数</param> | ||
| public static void Register(Func<IServiceModule> factory) | ||
| { | ||
| _factories.Add(factory); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// 创建所有已注册的模块实例 | ||
| /// </summary> | ||
| /// <returns>模块实例集合</returns> | ||
| public static IEnumerable<IServiceModule> CreateModules() | ||
| { | ||
| return _factories.Select(f => f()); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// 清空注册表(主要用于测试) | ||
| /// </summary> | ||
| public static void Clear() | ||
| { | ||
| _factories.Clear(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| namespace GFramework.Ecs.Arch.Abstractions; | ||
|
|
||
| /// <summary> | ||
| /// Arch ECS 配置选项 | ||
| /// </summary> | ||
| public sealed class ArchOptions | ||
| { | ||
| /// <summary> | ||
| /// World 初始容量 | ||
| /// </summary> | ||
| public int WorldCapacity { get; set; } = 1000; | ||
|
|
||
| /// <summary> | ||
| /// 是否启用统计信息 | ||
| /// </summary> | ||
| public bool EnableStatistics { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// 模块优先级 | ||
| /// </summary> | ||
| public int Priority { get; set; } = 50; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| <Project> | ||
| <PropertyGroup> | ||
| <TargetFramework>netstandard2.1</TargetFramework> | ||
| <ContinuousIntegrationBuild>true</ContinuousIntegrationBuild> | ||
| <EmbedUntrackedSources>true</EmbedUntrackedSources> | ||
| <LangVersion>preview</LangVersion> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <PackageReference Include="Meziantou.Analyzer" Version="2.0.264"> | ||
| <PrivateAssets>all</PrivateAssets> | ||
| <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> | ||
| </PackageReference> | ||
| <PackageReference Include="Meziantou.Polyfill" Version="1.0.71"> | ||
| <PrivateAssets>all</PrivateAssets> | ||
| <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> | ||
| </PackageReference> | ||
| </ItemGroup> | ||
| </Project> |
13 changes: 13 additions & 0 deletions
13
GFramework.Ecs.Arch.Abstractions/GFramework.Ecs.Arch.Abstractions.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <PackageId>GeWuYou.$(AssemblyName)</PackageId> | ||
| <GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
| <Nullable>enable</Nullable> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\GFramework.Core.Abstractions\GFramework.Core.Abstractions.csproj" PrivateAssets="all"/> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| global using System; | ||
| global using System.Collections.Generic; | ||
| global using System.Threading.Tasks; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| using GFramework.Core.Abstractions.architecture; | ||
|
|
||
| namespace GFramework.Ecs.Arch.Abstractions; | ||
|
|
||
| /// <summary> | ||
| /// Arch ECS 模块接口 - 定义 ECS 模块的核心契约 | ||
| /// </summary> | ||
| public interface IArchEcsModule : IServiceModule | ||
| { | ||
| /// <summary> | ||
| /// 更新所有 ECS 系统 | ||
| /// </summary> | ||
| /// <param name="deltaTime">帧间隔时间</param> | ||
| void Update(float deltaTime); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| using GFramework.Core.Abstractions.system; | ||
|
|
||
| namespace GFramework.Ecs.Arch.Abstractions; | ||
|
|
||
| /// <summary> | ||
| /// Arch 系统适配器接口 - 桥接 Arch.System.ISystem<T> 到框架上下文 | ||
| /// </summary> | ||
| /// <typeparam name="T">系统数据类型(通常是 float 表示 deltaTime)</typeparam> | ||
| public interface IArchSystemAdapter<T> : ISystem | ||
| { | ||
| /// <summary> | ||
| /// 更新系统 | ||
| /// </summary> | ||
| /// <param name="t">系统数据参数(通常是 deltaTime)</param> | ||
| void Update(in T t); | ||
| } |
25 changes: 25 additions & 0 deletions
25
GFramework.Ecs.Arch.Tests/GFramework.Ecs.Arch.Tests.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFrameworks>net8.0;net10.0</TargetFrameworks> | ||
| <ImplicitUsings>disable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| <IsPackable>false</IsPackable> | ||
| <IsTestProject>true</IsTestProject> | ||
| <GenerateAssemblyInfo>false</GenerateAssemblyInfo> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="coverlet.collector" Version="6.0.2"/> | ||
| <PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0"/> | ||
| <PackageReference Include="Moq" Version="4.20.72"/> | ||
| <PackageReference Include="NUnit" Version="4.5.0"/> | ||
| <PackageReference Include="NUnit3TestAdapter" Version="6.1.0"/> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\GFramework.Ecs.Arch\GFramework.Ecs.Arch.csproj"/> | ||
| <ProjectReference Include="..\GFramework.Core\GFramework.Core.csproj"/> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| global using System; | ||
| global using System.Collections.Generic; | ||
| global using System.Threading.Tasks; | ||
| global using NUnit.Framework; | ||
| global using GFramework.Ecs.Arch; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
GFramework.Core/ecs/ArchEcsModule.cs → GFramework.Ecs.Arch/ArchEcsModule.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.