GFramework/GFramework.Godot/data/IResourceRepository.cs
GeWuYou 4fd90e45a1 feat(godot): 添加资源仓储功能支持
- 新增 IHasKey 接口定义键值访问契约
- 新增 IRepository 接口提供通用数据仓储功能
- 实现 GodotResourceRepository 类支持资源的存储和加载
- 添加 IResourceRepository 接口扩展通用仓储功能
- 实现从路径批量加载 Godot 资源的功能
- 支持递归加载子目录中的资源文件
- 提供 .tres 和 .res 文件的自动识别和加载
2026-02-23 22:33:29 +08:00

41 lines
1.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Copyright (c) 2026 GeWuYou
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using GFramework.Game.Abstractions.data;
using Godot;
namespace GFramework.Godot.data;
/// <summary>
/// 定义资源仓储接口专门用于管理Godot资源的加载和存储
/// 继承自通用仓储接口,添加了从路径加载资源的功能
/// </summary>
/// <typeparam name="TKey">资源键的类型</typeparam>
/// <typeparam name="TResource">资源类型必须继承自Godot.Resource</typeparam>
public interface IResourceRepository<in TKey, TResource> : IRepository<TKey, TResource> where TResource : Resource
{
/// <summary>
/// 从指定路径加载资源到仓储中
/// </summary>
/// <param name="paths">资源文件的路径集合</param>
/// <param name="recursive">是否递归加载子目录中的资源</param>
void LoadFromPath(IEnumerable<string> paths, bool recursive = false);
/// <summary>
/// 从指定路径数组加载资源到仓储中
/// 提供便捷的参数数组重载方法
/// </summary>
/// <param name="recursive">是否递归加载子目录中的资源</param>
/// <param name="paths">资源文件路径的参数数组</param>
void LoadFromPath(bool recursive = false, params string[] paths);
}