mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-25 21:34:28 +08:00
- 修复 IEventHandler 接口中的参数关键字冲突 - 修正场景管理器接口中的泛型约束拼写错误 - 本地化核心抽象文档链接为中文标题 - 更新事件系统文档中的接口链接路径 - 修复扩展方法文档中的上下文感知链接 - 调整日志系统文档中的接口链接路径 - 重构架构概述中的代码示例和设计原则 - 统一 Godot 设置模块中的代码块格式 - 优化音频和图形设置的代码示例
114 lines
1.9 KiB
Markdown
114 lines
1.9 KiB
Markdown
# Game Abstractions
|
||
|
||
> GFramework.Game.Abstractions 游戏模块抽象接口定义
|
||
|
||
## 概述
|
||
|
||
GFramework.Game.Abstractions 包含了游戏特定功能的抽象接口,这些接口定义了游戏开发中的通用契约。
|
||
|
||
## 存档接口
|
||
|
||
### ISaveSystem
|
||
|
||
存档系统接口:
|
||
|
||
```csharp
|
||
public interface ISaveSystem
|
||
{
|
||
void Save(string slotId, SaveData data);
|
||
SaveData Load(string slotId);
|
||
bool HasSave(string slotId);
|
||
void Delete(string slotId);
|
||
List<SaveSlotInfo> GetAllSaveSlots();
|
||
}
|
||
```
|
||
|
||
### ISaveData
|
||
|
||
存档数据接口:
|
||
|
||
```csharp
|
||
public interface ISaveData
|
||
{
|
||
int Version { get; }
|
||
DateTime Timestamp { get; }
|
||
void Validate();
|
||
}
|
||
```
|
||
|
||
## 设置接口
|
||
|
||
### IGameSettings
|
||
|
||
游戏设置接口:
|
||
|
||
```csharp
|
||
public interface IGameSettings
|
||
{
|
||
AudioSettings Audio { get; }
|
||
GraphicsSettings Graphics { get; }
|
||
InputSettings Input { get; }
|
||
|
||
void Save();
|
||
void Load();
|
||
void ResetToDefaults();
|
||
}
|
||
```
|
||
|
||
## 场景管理接口
|
||
|
||
### ISceneManager
|
||
|
||
场景管理器接口:
|
||
|
||
```csharp
|
||
public interface ISceneManager
|
||
{
|
||
void SwitchScene<TScene>() where TScene : IScene;
|
||
Task SwitchSceneAsync<TScene>() where TScene : IScene;
|
||
|
||
void PushScene<TScene>() where TScene : IScene;
|
||
void PopScene();
|
||
|
||
IScene CurrentScene { get; }
|
||
}
|
||
```
|
||
|
||
### IScene
|
||
|
||
场景接口:
|
||
|
||
```csharp
|
||
public interface IScene
|
||
{
|
||
void OnEnter();
|
||
void OnExit();
|
||
void OnUpdate(float delta);
|
||
}
|
||
```
|
||
|
||
## 资源管理接口
|
||
|
||
### IAssetManager
|
||
|
||
资源管理器接口:
|
||
|
||
```csharp
|
||
public interface IAssetManager
|
||
{
|
||
T Load<T>(string path) where T : Resource;
|
||
void Preload<T>(string path) where T : Resource;
|
||
void Unload(string path);
|
||
bool IsLoaded(string path);
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
**相关文档**:
|
||
|
||
- [Game 概述](../game)
|
||
- [核心抽象](./core-abstractions)
|
||
- [存档系统](../game/storage)
|
||
- [场景管理](../game/scene-management)
|