You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
789 B
26 lines
789 B
1 year ago
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using gaemstone.Utility;
|
||
|
using static flecs_hub.flecs;
|
||
|
|
||
|
namespace gaemstone.ECS;
|
||
|
|
||
|
public unsafe readonly struct EntityType
|
||
|
: IReadOnlyList<IdentifierRef>
|
||
|
{
|
||
|
public World World { get; }
|
||
|
public ecs_type_t* Handle { get; }
|
||
|
|
||
|
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 IdentifierRef this[int index] => new(World, new(Handle->array[index]));
|
||
|
public IEnumerator<IdentifierRef> GetEnumerator() { for (var i = 0; i < Count; i++) yield return this[i]; }
|
||
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||
|
}
|