using System.Collections; using System.Collections.Generic; using gaemstone.Utility; using static flecs_hub.flecs; namespace gaemstone.ECS; public unsafe readonly struct EntityType : IReadOnlyList { public Universe Universe { get; } public ecs_type_t* Handle { get; } public EntityType(Universe universe, ecs_type_t* handle) { Universe = universe; Handle = handle; } public override string ToString() => ecs_type_str(Universe, Handle).FlecsToStringAndFree()!; // IReadOnlyList implementation public int Count => Handle->count; public IdentifierRef this[int index] => new(Universe, new(Handle->array[index])); public IEnumerator GetEnumerator() { for (var i = 0; i < Count; i++) yield return this[i]; } IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); }