改动说明 - 实现内容加载器并支持 res:///user:// 路径解析与 JSON 枚举解析:scripts/Core/ContentRegistry.cs - 新增 .tres 资源定义接口与样例资源类(学科定义):scripts/Core/ContentResources.cs - 默认注册资源/JSON 数据源,启动时自动合并进内容库:scripts/Core/GameSession.cs - 样例 .tres 与 JSON 内容定义:resources/definitions/discipline_biology.tres, resources/definitions/disciplines.json, resources/definitions/archetypes.json - 当前 .tres 走“扁平字段 + RuleIds”,数值型 Modifier 更适合先用 JSON 落地,后续可以把更多字段迁入资源类。 - JSON 采用与 Models 定义一致的结构(DefinitionHeader/LocalizedText/ModifierBundle),便于后续扩展。
28 lines
701 B
C#
28 lines
701 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Core;
|
|
|
|
/// <summary>
|
|
/// 资源定义接口(用于 .tres/.res 的内容加载)
|
|
/// 设计说明:
|
|
/// 1) 资源负责“序列化友好”,模型负责“运行时友好”。
|
|
/// 2) 通过 ToDefinition 映射到纯数据模型,保持解耦。
|
|
/// 注意事项:
|
|
/// - 资源字段尽量使用 Godot 可序列化的基础类型与 Array。
|
|
/// 未来扩展:
|
|
/// - 可加入验证器,确保 Id/路径等关键字段符合规范。
|
|
/// </summary>
|
|
public interface IContentResource
|
|
{
|
|
Type GetDefinitionType();
|
|
object ToDefinition();
|
|
}
|
|
|
|
public interface IContentResourceCollection
|
|
{
|
|
IEnumerable<IContentResource> GetItems();
|
|
}
|
|
|
|
|