Add Iterator.IsField(int, Identifier) method

wip/bindgen
copygirl 2 years ago
parent 9ab42afb0b
commit 47090887ca
  1. 11
      src/gaemstone.ECS/Iterator.cs

@ -94,13 +94,14 @@ public unsafe class Iterator
return ecs_field_is_set(ptr, index);
}
// TODO: Potentially misleading, doesn't check the field's backing data type.
// The id might be "(Identifier, Name)", but its data type "Identifier".
public bool FieldIs<T>(int index)
=> FieldIs(index, World.LookupByType<T>());
public bool FieldIs(int index, Identifier id)
{
fixed (ecs_iter_t* ptr = &Value) {
var id = ecs_field_id(ptr, index);
var comp = World.LookupByTypeOrThrow<T>();
return id == comp.Entity.Value.Data;
}
fixed (ecs_iter_t* ptr = &Value)
return ecs_field_id(ptr, index) == id.Value;
}
public override string ToString()

Loading…
Cancel
Save