mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-07 00:39:00 +08:00
- 更新根 README 的内部支撑模块入口标签,避免继续暴露路径式链接名 - 优化 docs/zh-CN 多个 landing 与 core 页面标题,提升中文读者的导航可读性 - 同步 documentation-full-coverage-governance 的 tracking 与 trace,记录最新 baseline 和验证结果
133 lines
4.6 KiB
Markdown
133 lines
4.6 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](./config-system.md)
|
||
- 数据、设置、序列化与存储
|
||
- [data](./data.md)
|
||
- [setting](./setting.md)
|
||
- [serialization](./serialization.md)
|
||
- [storage](./storage.md)
|
||
- 导航与界面
|
||
- [scene](./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](./setting.md)
|
||
- [data](./data.md)
|
||
- [storage](./storage.md)
|
||
|
||
### 3. 接入静态 YAML 配置
|
||
|
||
当你要维护怪物、物品、技能、任务等只读内容数据时,优先使用:
|
||
|
||
- `GFramework.Game` 运行时
|
||
- `GFramework.Game.SourceGenerators`
|
||
- `schemas/**/*.schema.json` + `config/**/*.yaml`
|
||
|
||
完整约定见:
|
||
|
||
- [config-system](./config-system.md)
|
||
|
||
### 4. 接入 Scene / UI 路由
|
||
|
||
`SceneRouterBase` 与 `UiRouterBase` 提供的是可复用基类,不直接绑定具体引擎。工厂、root、注册表通常由引擎适配层或项目自身提供。
|
||
|
||
入口见:
|
||
|
||
- [scene](./scene.md)
|
||
- [ui](./ui.md)
|
||
|
||
## 推荐阅读顺序
|
||
|
||
1. [Core 入口](../core/index.md)
|
||
2. [config-system](./config-system.md)
|
||
3. [data](./data.md)
|
||
4. [setting](./setting.md)
|
||
5. [scene](./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`、模块 `README.md` 与 `ai-libs/` 下已验证的参考接法为准。
|
||
|
||
例如当前文档应优先和以下已验证事实保持一致:
|
||
|
||
- 配置系统采用 `YAML + JSON Schema + Source Generator`
|
||
- 设置持久化通常通过 `UnifiedSettingsDataRepository`
|
||
- 场景与 UI 路由依赖项目自己的 factory / root,而不是框架替你绑定引擎对象
|
||
|
||
如果某个旧页面与这些事实冲突,应以源码和模块 README 为准,并在同一轮里修正文档。
|
||
|
||
## 对应模块入口
|
||
|
||
- [`GFramework.Game README`](https://github.com/GeWuYou/GFramework/blob/main/GFramework.Game/README.md)
|
||
- [`GFramework.Game.Abstractions README`](https://github.com/GeWuYou/GFramework/blob/main/GFramework.Game.Abstractions/README.md)
|
||
- 仓库根 [`README.md`](https://github.com/GeWuYou/GFramework/blob/main/README.md)
|