27 lines
685 B
C#
27 lines
685 B
C#
using System.Collections.Generic;
|
||
using Godot;
|
||
using Godot.Collections;
|
||
|
||
namespace Core;
|
||
|
||
/// <summary>
|
||
/// 资源集合(便于打包多个定义到一个 .tres)
|
||
/// </summary>
|
||
[GlobalClass]
|
||
public partial class ContentCollectionResource : Resource, IContentResourceCollection {
|
||
/// <summary>
|
||
/// 资源列表
|
||
/// </summary>
|
||
[Export]
|
||
public Array<Resource> Items { get; set; } = new();
|
||
|
||
/// <summary>
|
||
/// 获取资源项
|
||
/// </summary>
|
||
/// <returns>资源项集合</returns>
|
||
public IEnumerable<IContentResource> GetItems() {
|
||
foreach (var item in Items)
|
||
if (item is IContentResource content)
|
||
yield return content;
|
||
}
|
||
} |