Mirror of Svelto.ECS because we're a fan of it
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

65 строки
1.9KB

  1. using Svelto.ECS.Internal;
  2. namespace Svelto.ECS
  3. {
  4. public readonly ref struct NativeEntityFilterIterator<T> where T : unmanaged, _IInternalEntityComponent
  5. {
  6. internal NativeEntityFilterIterator(NativeEntityFilterCollection<T> filter)
  7. {
  8. _filter = filter;
  9. }
  10. public Iterator GetEnumerator() => new Iterator(_filter);
  11. readonly NativeEntityFilterCollection<T> _filter;
  12. public ref struct Iterator
  13. {
  14. internal Iterator(NativeEntityFilterCollection<T> filter)
  15. {
  16. _filter = filter;
  17. _indexGroup = -1;
  18. _current = default;
  19. }
  20. public bool MoveNext()
  21. {
  22. while (++_indexGroup < _filter.groupCount)
  23. {
  24. _current = _filter.GetGroup(_indexGroup);
  25. if (_current.count > 0) break;
  26. }
  27. return _indexGroup < _filter.groupCount;
  28. }
  29. public void Reset()
  30. {
  31. _indexGroup = -1;
  32. }
  33. public RefCurrent Current => new RefCurrent(_current);
  34. int _indexGroup;
  35. readonly NativeEntityFilterCollection<T> _filter;
  36. NativeEntityFilterCollection<T>.GroupFilters _current;
  37. }
  38. public readonly ref struct RefCurrent
  39. {
  40. internal RefCurrent(NativeEntityFilterCollection<T>.GroupFilters filter)
  41. {
  42. _filter = filter;
  43. }
  44. public void Deconstruct(out EntityFilterIndices indices, out ExclusiveGroupStruct group)
  45. {
  46. indices = _filter.indices;
  47. group = _filter.group;
  48. }
  49. readonly NativeEntityFilterCollection<T>.GroupFilters _filter;
  50. }
  51. }
  52. }