改动说明 - 实现内容加载器并支持 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),便于后续扩展。
27 lines
519 B
C#
27 lines
519 B
C#
using System.Collections.Generic;
|
||
using Godot;
|
||
using Godot.Collections;
|
||
|
||
namespace Core;
|
||
|
||
/// <summary>
|
||
/// 资源集合(便于打包多个定义到一个 .tres)
|
||
/// </summary>
|
||
[GlobalClass]
|
||
public partial class ContentCollectionResource : Resource, IContentResourceCollection
|
||
{
|
||
[Export] public Array<Resource> Items { get; set; } = new();
|
||
|
||
public IEnumerable<IContentResource> GetItems()
|
||
{
|
||
foreach (var item in Items)
|
||
{
|
||
if (item is IContentResource content)
|
||
{
|
||
yield return content;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|