mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-07 00:39:00 +08:00
- 更新 meta-package 与安装入口,明确聚合范围、当前运行时基线和首页选包路径 - 补充 Game 配置工具文档与导航,把 VS Code config workflow 纳入 reader-facing 采用链路 - 修正文档与实现不一致的 source-generator 与 CQRS 契约说明,补充 support module 边界 - 记录 RP-038 批处理恢复点、委派结论和本轮验证结果
135 lines
4.7 KiB
Markdown
135 lines
4.7 KiB
Markdown
---
|
||
title: Game 模块
|
||
description: GFramework.Game family 的运行时入口、采用顺序与源码阅读导航。
|
||
---
|
||
|
||
# Game 模块
|
||
|
||
`Game` 栏目对应 `GFramework.Game` 与 `GFramework.Game.Abstractions` 这层游戏运行时能力。
|
||
|
||
它建立在 `Core` 之上,负责把“能运行的基础架构”继续扩展成“可落地的游戏项目基础设施”,重点覆盖静态内容配置、数据与存档、设置、场景与 UI 路由、序列化和文件存储。
|
||
|
||
## 模块与包关系
|
||
|
||
- `GeWuYou.GFramework.Game`
|
||
- 游戏层默认运行时实现。
|
||
- `GeWuYou.GFramework.Game.Abstractions`
|
||
- 对应的契约层。
|
||
- `GeWuYou.GFramework.Game.SourceGenerators`
|
||
- 面向 `schemas/**/*.schema.json` 的配置类型与表包装生成器。
|
||
- `GeWuYou.GFramework.Core`
|
||
- 本层直接依赖的底座,提供架构、生命周期、事件、日志等通用能力。
|
||
|
||
如果你的项目只想依赖契约,不想带入默认实现,请选择 `Game.Abstractions`。如果你需要可运行的默认基类与实现,请使用
|
||
`Game`。
|
||
|
||
## 栏目覆盖范围
|
||
|
||
`Game` 栏目聚焦“游戏项目该怎么接这些运行时能力”,不再保留与当前实现脱节的泛化模块示例。
|
||
|
||
当前栏目主要入口:
|
||
|
||
- 配置与内容系统
|
||
- [配置系统](./config-system.md)
|
||
- [VS Code 配置工具](./config-tool.md)
|
||
- 数据、设置、序列化与存储
|
||
- [数据系统](./data.md)
|
||
- [设置系统](./setting.md)
|
||
- [序列化系统](./serialization.md)
|
||
- [存储系统](./storage.md)
|
||
- 导航与界面
|
||
- [场景系统](./scene.md)
|
||
- [UI 系统](./ui.md)
|
||
|
||
## 最小接入路径
|
||
|
||
接入 `Game` 层前,先确保你已经完成 `Core` 的基础架构初始化。
|
||
|
||
最常见的四种接入目标如下:
|
||
|
||
### 1. 只想先拿到文件存储
|
||
|
||
```csharp
|
||
using GFramework.Core.Abstractions.Storage;
|
||
using GFramework.Game.Serializer;
|
||
using GFramework.Game.Storage;
|
||
|
||
var serializer = new JsonSerializer();
|
||
IStorage storage = new FileStorage("GameData", serializer);
|
||
```
|
||
|
||
### 2. 接入设置与存档
|
||
|
||
典型顺序是:
|
||
|
||
1. 注册 `JsonSerializer`
|
||
2. 注册 `IStorage`
|
||
3. 注册 `ISettingsDataRepository`
|
||
4. 注册 `SettingsModel<TRepository>`
|
||
5. 注册 `SettingsSystem`
|
||
6. 注册 `ISaveRepository<TSaveData>`
|
||
|
||
具体组合方式见:
|
||
|
||
- [设置系统](./setting.md)
|
||
- [数据系统](./data.md)
|
||
- [存储系统](./storage.md)
|
||
|
||
### 3. 接入静态 YAML 配置
|
||
|
||
当你要维护怪物、物品、技能、任务等只读内容数据时,优先使用:
|
||
|
||
- `GFramework.Game` 运行时
|
||
- `GFramework.Game.SourceGenerators`
|
||
- `schemas/**/*.schema.json` + `config/**/*.yaml`
|
||
|
||
完整约定见:
|
||
|
||
- [配置系统](./config-system.md)
|
||
|
||
### 4. 接入 Scene / UI 路由
|
||
|
||
`SceneRouterBase` 与 `UiRouterBase` 提供的是可复用基类,不直接绑定具体引擎。工厂、root、注册表通常由引擎适配层或项目自身提供。
|
||
|
||
入口见:
|
||
|
||
- [场景系统](./scene.md)
|
||
- [UI 系统](./ui.md)
|
||
|
||
## 阅读顺序
|
||
|
||
1. [Core 入口](../core/index.md)
|
||
2. [配置系统](./config-system.md)
|
||
3. [VS Code 配置工具](./config-tool.md)
|
||
4. [数据系统](./data.md)
|
||
5. [设置系统](./setting.md)
|
||
6. [场景系统](./scene.md)或[UI 系统](./ui.md)
|
||
|
||
## 源码与 API 阅读入口
|
||
|
||
如果你已经完成栏目入口页阅读,下一步通常不是看统计表,而是按模块角色回到源码和 XML 文档:
|
||
|
||
| 模块 | 代表类型 | 建议先确认什么 |
|
||
| --- | --- | --- |
|
||
| `GFramework.Game` | `YamlConfigLoader`、`SettingsModel<TRepository>`、`SceneRouterBase`、`UiRouterBase` | 默认运行时实现、配置加载、设置编排和路由基类 |
|
||
| `GFramework.Game.Abstractions` | `IConfigRegistry`、`ISaveRepository<TSaveData>`、`ISettingsSystem`、`ISceneRouter`、`IUiRouter` | 契约层边界,以及项目中哪些程序集只应依赖接口 |
|
||
| `GFramework.Game.SourceGenerators` | `SchemaConfigGenerator`、`ConfigSchemaDiagnostics` | schema 生成入口与诊断模型,确认配置系统的编译期链路 |
|
||
|
||
## 与真实接法的关系
|
||
|
||
本栏目内容以源码、`*.csproj`、模块说明页与 `ai-libs/` 下已验证的参考接法为准。
|
||
|
||
例如当前文档应优先和以下已验证事实保持一致:
|
||
|
||
- 配置系统采用 `YAML + JSON Schema + Source Generator`
|
||
- 设置持久化通常通过 `UnifiedSettingsDataRepository`
|
||
- 场景与 UI 路由依赖项目自己的 factory / root,而不是框架替你绑定引擎对象
|
||
|
||
如果某个旧页面与这些事实冲突,应以源码和模块说明页为准,并在同一轮里修正文档。
|
||
|
||
## 对应模块入口
|
||
|
||
- [Game 运行时说明](https://github.com/GeWuYou/GFramework/blob/main/GFramework.Game/README.md)
|
||
- [Game 抽象层说明](https://github.com/GeWuYou/GFramework/blob/main/GFramework.Game.Abstractions/README.md)
|
||
- [仓库总览](https://github.com/GeWuYou/GFramework/blob/main/README.md)
|