GeWuYou.GFramework 0.0.162

dotnet add package GeWuYou.GFramework --version 0.0.162
                    
NuGet\Install-Package GeWuYou.GFramework -Version 0.0.162
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GeWuYou.GFramework" Version="0.0.162" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GeWuYou.GFramework" Version="0.0.162" />
                    
Directory.Packages.props
<PackageReference Include="GeWuYou.GFramework" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GeWuYou.GFramework --version 0.0.162
                    
#r "nuget: GeWuYou.GFramework, 0.0.162"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package GeWuYou.GFramework@0.0.162
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=GeWuYou.GFramework&version=0.0.162
                    
Install as a Cake Addin
#tool nuget:?package=GeWuYou.GFramework&version=0.0.162
                    
Install as a Cake Tool

GFramework

专为游戏开发场景设计的综合性C#游戏开发框架,Core 模块与平台无关

NuGet Godot .NET License zread

本项目参考(CV)自QFramework,并进行了模块化重构和功能增强。

🚀 快速导航

📚 学习路径

🎯 新手入门
  1. 📚 从零开始教程 - 完整的项目创建和开发指南
  2. 📖 基本概念 - 理解核心概念
  3. 💡 快速示例 - 5分钟上手体验
🏗️ 进阶开发
  1. 📖 Godot 集成教程 - 深度 Godot 集成和最佳实践
  2. 高级模式教程 - CQRS、事件溯源、插件系统等
  3. 🏗️ 架构模式最佳实践 - 推荐的架构设计模式
  4. 🏗️ 性能优化技巧 - 内存和性能优化
🏗️ 专家指南
  1. 📊 API 参考 - 详细的类和接口说明

📖 详细文档

🏛️ 核心项目 Core Projects
📖 源代码生成器 Source Generators
  • [📖 日志生成器 - 自动 ILogger 字段生成
  • [📖 上下文感知生成器 - 自动 IContextAware 实现
  • [📖 枚举扩展生成器 - 自动枚举扩展方法
📖 API 参考
  • [📖 Core API 参考 - 核心类和接口详细说明
  • [📖 Godot API 参考 - Godot 模块 API 详细说明
  • [📖 Source Generators API 参考 - 源码生成器 API 详细说明
  • [📖 Game API 参考 - Game 模块 API 详细说明
🏗️ 教程和指南
  • [🏗️ 架构模式最佳实践 - 推荐的架构设计模式
  • [🏗️ 性能优化技巧 - 内存和性能优化
🏗️ 常见问题解决
  • [🏗️ 错误处理策略 - 异常处理和错误恢复
  • [🏗️ 调试技巧 - 调试和测试指南

✨ 主要特性

🏗️ 核心架构 Core Architecture

  • 依赖注入 Dependency Injection: 内置IoC容器管理对象生命周期
  • 事件系统 Event System: 类型安全的事件系统,实现松耦合
  • 属性绑定 Property Binding: 可绑定属性,支持响应式编程
  • 日志框架 Logging Framework: 结构化日志,支持多个日志级别
  • 生命周期管理 Lifecycle Management: 阶段式的架构生命周期管理
  • 命令查询分离 CQRS: 命令和查询的职责分离

🎮 游戏开发特性 Game Development Features

  • 资产管理 Asset Management: 集中化资产目录系统
  • 资源工厂 Resource Factory: 工厂模式的资源创建模式
  • 架构模式 Architecture Pattern: 关注点分离的清晰架构
  • 模块化 Module System: 支持架构模块安装和扩展
  • 源码生成 Source Generators: 零运行时开销的代码生成

🌐 平台无关 Platform Agnostic

  • 纯 .NET 实现: Core 模块无任何平台特定依赖
  • Godot 集成 Godot Integration: GFramework.Godot 提供 Godot 特定功能
  • 可移植 Portable: 可以轻松移植到 Unity、.NET MAUI 等平台

🚀 快速开始 Getting Started

1️⃣ 安装 Installation

# 安装核心包(平台无关)
dotnet add package GeWuYou.GFramework.Core
dotnet add package GeWuYou.GFramework.Core.Abstractions

# 安装游戏包
dotnet add package GeWuYou.GFramework.Game
dotnet add package GeWuYou.GFramework.Game.Abstractions

# 安装源码生成器(推荐)
dotnet add package GeWuYou.GFramework.SourceGenerators
dotnet add package GeWuYou.GFramework.SourceGenerators.Attributes

# 安装Godot包(仅Godot项目需要)
dotnet add package GeWuYou.GFramework.Godot

2️⃣ 基本使用 Basic Usage

using GFramework.Core.architecture;
using GFramework.SourceGenerators.Attributes;

// 1. 定义架构(继承 Architecture 基类)
public class GameArchitecture : Architecture
{
    protected override void Init()
    {
        // 注册 Model - 游戏数据
        RegisterModel(new PlayerModel());
        RegisterModel(new GameModel());
        
        // 注册 System - 业务逻辑
        RegisterSystem(new CombatSystem());
        RegisterSystem(new UISystem());
        
        // 注册 Utility - 工具类
        RegisterUtility(new StorageUtility());
    }
}

// 2. 创建并初始化架构
var architecture = new GameArchitecture();
architecture.Initialize();

// 3. 通过依赖注入在Controller中使用
[Log]
[ContextAware]
public partial class PlayerController : IController
{
    private PlayerModel _playerModel;
    
    public PlayerController(IArchitecture architecture)
    {
        _playerModel = architecture.GetModel<PlayerModel>();
    }
    
    // 监听属性变化
    public void Initialize()
    {
        _playerModel.Health.RegisterWithInitValue(hp => UpdateHealthDisplay(hp));
    }
    
    private void UpdateHealthDisplay(int hp)
    {
        // 更新 UI 显示
        Console.WriteLine($"Health: {hp}");
    }
}

3️⃣ 命令和查询 Command & Query

// 定义命令
public class AttackCommand : AbstractCommand
{
    protected override void OnExecute()
    {
        var playerModel = this.GetModel<PlayerModel>();
        var enemyModel = this.GetModel<EnemyModel>();
        
        // 业务逻辑
        int damage = playerModel.AttackPower.Value;
        enemyModel.Health.Value -= damage;
        
        // 发送事件
        this.SendEvent(new DamageDealtEvent { Damage = damage });
    }
}

// 定义查询
public class CanAttackQuery : AbstractQuery<bool>
{
    protected override bool OnDo()
    {
        var playerModel = this.GetModel<PlayerModel>();
        return playerModel.Health.Value > 0 && !playerModel.IsStunned.Value;
    }
}

// 使用命令和查询
public class CombatController : IController
{
    private readonly IArchitecture _architecture;
    
    public CombatController(IArchitecture architecture)
    {
        _architecture = architecture;
    }
    
    public void OnAttackButtonPressed()
    {
        // 先查询
        if (_architecture.SendQuery(new CanAttackQuery()))
        {
            // 再执行命令
            _architecture.SendCommand(new AttackCommand());
        }
    }
}

4️⃣ 事件系统 Event System

// 定义事件
public struct DamageDealtEvent
{
    public int Damage;
    public Vector3 Position;
}

// 发送事件
this.SendEvent(new DamageDealtEvent { Damage = 100, Position = position });

// 注册事件监听
this.RegisterEvent<DamageDealtEvent>(OnDamageDealt);

private void OnDamageDealt(DamageDealtEvent e)
{
    ShowDamageNumber(e.Damage, e.Position);
}

📦 项目架构 Architecture

框架遵循清洁架构原则,具有以下层次:

┌─────────────────────────────────────────┐
│           View / UI                      │  UI 层:用户界面
├─────────────────────────────────────────┤
│            Controller                    │  控制层:处理用户输入
├─────────────────────────────────────────┤
│             System                       │ 逻辑层:业务逻辑
├─────────────────────────────────────────┤
│              Model                       │  数据层:游戏状态
├─────────────────────────────────────────┤
│             Utility                      │  工具层:无状态工具
├─────────────────────────────────────────┤
│         Command / Query                  │  横切关注点
└─────────────────────────────────┘

🔧 平台集成 Platform Integration

Godot 项目

// 使用 GFramework.Godot 获取 Godot 特定功能
using GFramework.Godot;

public class GodotPlayerController : Node, IController
{
    public IArchitecture GetArchitecture() => GameArchitecture.Interface;
    
    public override void _Ready()
    {
        // 使用 Godot 特定的扩展方法
        this.RegisterEvent<DamageDealtEvent>(OnDamageDealt)
            .UnRegisterWhenNodeExitTree(this);
    }
}

移植到其他平台

GFramework.Core 是纯 .NET 库,可以轻松移植到:

  • Unity(使用 Unity 容器替代 Godot 节点)
  • .NET MAUI(用于跨平台 UI 应用)
  • 任何其他 .NET 应用

📖 版本历史 Version History

v1.0.0 (2026-01-12)

  • ✅ 完整的文档体系创建完成
  • ✅ 核心项目文档完善
  • ✅ 源码生成器文档完成
  • ✅ 最佳实践指南创建
  • ✅ API 参考文档生成
  • ✅ 从零开始教程完善

计划中的任务

  • [📝 待完成任务] - 2 个低优先级任务
  • [📝 进行中的任务] - 0 个

🎯 如果这个项目对你有帮助,请给我们一个 ⭐!

Fork 本仓库并创建 Pull Request
Report Issues 报告 Bug 或功能请求
Star 给我们一个 Star!


📚 文档统计

  • 新增文档: 10+ 个文件
  • 代码示例: 150+ 个可直接使用的代码片段
  • 文档总量: 6000+ 行
  • 覆盖项目: 100% 项目文档覆盖

许可证: Apache 2.0
更新日期: 2026-01-12

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.162 6 2/1/2026
0.0.161 28 2/1/2026
0.0.160 25 2/1/2026
0.0.159 25 2/1/2026
0.0.158 27 2/1/2026
0.0.157 31 1/31/2026
0.0.156 27 1/31/2026
0.0.155 27 1/31/2026
0.0.154 35 1/31/2026
0.0.153 29 1/31/2026
0.0.152 31 1/30/2026
0.0.151 32 1/30/2026
0.0.150 35 1/30/2026
0.0.149 30 1/30/2026
0.0.148 27 1/30/2026
0.0.147 33 1/30/2026
0.0.146 37 1/29/2026
0.0.145 35 1/29/2026
0.0.144 31 1/29/2026
0.0.143 25 1/29/2026
0.0.142 31 1/29/2026
0.0.141 31 1/28/2026
0.0.140 31 1/28/2026
0.0.139 30 1/28/2026
0.0.138 32 1/28/2026
0.0.137 31 1/27/2026
0.0.136 27 1/27/2026
0.0.135 35 1/27/2026
0.0.134 44 1/27/2026
0.0.133 79 1/26/2026
0.0.132 76 1/26/2026
0.0.131 81 1/24/2026
0.0.130 84 1/23/2026
0.0.129 82 1/21/2026
0.0.128 80 1/20/2026
0.0.127 85 1/20/2026
0.0.126 88 1/19/2026
0.0.125 94 1/19/2026
0.0.124 86 1/19/2026
0.0.123 89 1/19/2026
0.0.122 87 1/19/2026
0.0.121 86 1/18/2026
0.0.120 92 1/18/2026
0.0.119 98 1/18/2026
0.0.118 95 1/17/2026
0.0.117 84 1/17/2026
0.0.116 87 1/17/2026
0.0.115 88 1/17/2026
0.0.114 91 1/17/2026
0.0.113 91 1/16/2026
0.0.112 93 1/16/2026
0.0.111 99 1/16/2026
0.0.110 93 1/15/2026
0.0.109 93 1/15/2026
0.0.108 95 1/15/2026
0.0.107 95 1/14/2026
0.0.106 98 1/12/2026
0.0.105 95 1/11/2026
0.0.104 138 1/9/2026
0.0.103 97 1/7/2026
0.0.102 92 1/7/2026
0.0.101 95 1/7/2026
0.0.100 105 1/4/2026
0.0.99 97 1/3/2026
0.0.98 98 1/3/2026
0.0.97 104 1/3/2026
0.0.96 99 1/3/2026
0.0.95 101 1/3/2026
0.0.94 105 1/2/2026
0.0.93 103 1/2/2026
0.0.92 99 1/2/2026
0.0.91 101 1/2/2026
0.0.90 108 1/2/2026
0.0.89 104 1/2/2026
0.0.88 104 1/2/2026
0.0.87 102 1/1/2026
0.0.86 104 1/1/2026
0.0.85 111 1/1/2026
0.0.84 106 12/31/2025
0.0.83 102 12/31/2025
0.0.82 101 12/30/2025
0.0.81 108 12/30/2025
0.0.80 107 12/30/2025
0.0.77 108 12/29/2025
0.0.76 115 12/29/2025
0.0.75 121 12/28/2025
0.0.74 112 12/28/2025
0.0.72 112 12/28/2025
0.0.71 112 12/28/2025
0.0.70 112 12/28/2025
0.0.69 112 12/28/2025
0.0.68 110 12/28/2025
0.0.67 111 12/27/2025
0.0.66 108 12/27/2025
0.0.61 112 12/27/2025
0.0.60 108 12/27/2025
0.0.59 147 12/26/2025
0.0.58 195 12/25/2025
0.0.57 193 12/25/2025
0.0.56 192 12/25/2025
0.0.55 192 12/25/2025
0.0.54 189 12/24/2025
0.0.53 192 12/24/2025
0.0.52 193 12/24/2025
0.0.51 201 12/23/2025
0.0.50 189 12/23/2025
0.0.49 186 12/23/2025
0.0.48 200 12/23/2025
0.0.47 191 12/23/2025
0.0.46 192 12/23/2025
0.0.45 195 12/22/2025
0.0.44 199 12/22/2025
0.0.43 197 12/22/2025
0.0.42 202 12/22/2025
0.0.41 198 12/22/2025
0.0.40 182 12/21/2025
0.0.39 185 12/21/2025
0.0.38 179 12/21/2025
0.0.37 153 12/21/2025
0.0.36 143 12/21/2025
0.0.35 140 12/21/2025
0.0.34 146 12/20/2025
0.0.33 302 12/18/2025
0.0.32 300 12/18/2025
0.0.31 299 12/18/2025
0.0.30 292 12/18/2025
0.0.29 293 12/18/2025
0.0.28 291 12/18/2025
0.0.27 295 12/18/2025
0.0.26 293 12/17/2025
0.0.25 293 12/17/2025
0.0.24 291 12/17/2025
0.0.23 293 12/17/2025
0.0.22 294 12/17/2025
0.0.21 297 12/16/2025
0.0.20 292 12/16/2025
0.0.19 205 12/13/2025
0.0.18 202 12/13/2025
0.0.17 198 12/13/2025
0.0.16 143 12/13/2025
0.0.15 148 12/12/2025
0.0.14 142 12/12/2025
0.0.13 146 12/12/2025
0.0.12 448 12/11/2025
0.0.11 451 12/11/2025
0.0.10 442 12/11/2025
0.0.9 443 12/11/2025
0.0.8 473 12/10/2025
0.0.7 463 12/10/2025
0.0.6 419 12/10/2025
0.0.5 422 12/10/2025
0.0.4 424 12/10/2025
0.0.3 429 12/9/2025
0.0.2 425 12/9/2025
0.0.1 424 12/9/2025