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