mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-07 00:39:00 +08:00
- 实现面向静态游戏内容的AI-First配置方案,支持怪物、物品、技能、任务等数据管理 - 集成YAML作为配置源文件格式,JSON Schema作为结构描述标准 - 提供一对象一文件的目录组织结构和运行时只读查询功能 - 实现Source Generator生成配置类型、表包装和注册/访问辅助代码 - 添加VS Code插件支持配置浏览、raw编辑、schema打开和递归校验功能 - 创建YamlConfigSchemaValidator类提供YAML与JSON Schema的运行时校验能力 - 支持嵌套对象、对象数组、标量数组的递归校验和深层约束检查 - 实现跨表引用验证和配置热重载功能 - 提供详细的错误诊断信息和开发期工具链支持
GFramework.SourceGenerators
Core 侧通用源码生成器模块。
Context Get 注入
当类本身是上下文感知类型时,可以通过字段特性生成一个手动调用的注入方法:
[GetService][GetServices][GetSystem][GetSystems][GetModel][GetModels][GetUtility][GetUtilities][GetAll]
上下文感知类满足以下任一条件即可:
- 类上带有
[ContextAware] - 继承
ContextAwareBase - 实现
IContextAware
生成器会生成 __InjectContextBindings_Generated(),需要在合适的生命周期中手动调用。在 Godot 中通常放在 _Ready():
using GFramework.SourceGenerators.Abstractions.Rule;
[ContextAware]
public partial class InventoryPanel
{
[GetModel]
private IInventoryModel _inventory = null!;
[GetServices]
private IReadOnlyList<IInventoryStrategy> _strategies = null!;
public override void _Ready()
{
__InjectContextBindings_Generated();
}
}
[GetAll] 作用于类本身,会自动扫描字段并推断 Model、System、Utility 相关的 GetX 调用;已显式标记字段的优先级更高。
Service 和 Services 绑定不会在 [GetAll] 下自动推断。对于普通引用类型字段,请显式使用 [GetService] 或
[GetServices],避免将非上下文服务字段误判为服务依赖。
[GetAll] 会跳过 const、static 和 readonly 字段。若某个字段本来会被 [GetAll] 推断为
Model、System 或 Utility 绑定,但因为是不可赋值的 static 或 readonly 字段而被跳过,生成器会发出警告提示该字段不会参与生成。