supervisor-simulator/scripts/Core/ContentCollectionResource.cs
2026-01-18 20:05:23 +08:00

27 lines
685 B
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.

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;
}
}