#nullable enable using System; using System.Runtime.InteropServices; using UnityEngine; namespace ZLinq { [StructLayout(LayoutKind.Auto)] public struct OfComponentT : IValueEnumerator where TEnumerable : struct, IValueEnumerator where TComponent : Component { TEnumerable source; internal OfComponentT(TEnumerable source) { this.source = source; } public bool TryGetNonEnumeratedCount(out int count) { count = 0; return false; } public bool TryGetSpan(out ReadOnlySpan span) { span = default; return false; } public bool TryGetNext(out TComponent current) { while (source.TryGetNext(out var value)) { var component = value.GetComponent(); if (component != null) { current = component; return true; } } current = default!; return false; } public void Dispose() { source.Dispose(); } public bool TryCopyTo(Span destination, Index offset) { return false; } } [StructLayout(LayoutKind.Auto)] public struct OfComponentG : IValueEnumerator where TEnumerable : struct, IValueEnumerator where TComponent : Component { TEnumerable source; internal OfComponentG(TEnumerable source) { this.source = source; } public bool TryGetNonEnumeratedCount(out int count) { count = 0; return false; } public bool TryGetSpan(out ReadOnlySpan span) { span = default; return false; } public bool TryGetNext(out TComponent current) { while (source.TryGetNext(out var value)) { var component = value.GetComponent(); if (component != null) { current = component; return true; } } current = default!; return false; } public void Dispose() { source.Dispose(); } public bool TryCopyTo(Span destination, Index offset) { return false; } } }