Mirror of Svelto.ECS because we're a fan of it
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.

EntityFilterIterator.cs 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. namespace Svelto.ECS
  2. {
  3. public ref struct EntityFilterIterator
  4. {
  5. internal EntityFilterIterator(EntityFilterCollection filter)
  6. {
  7. _filter = filter;
  8. _indexGroup = -1;
  9. _current = default;
  10. }
  11. public bool MoveNext()
  12. {
  13. while (++_indexGroup < _filter.groupCount)
  14. {
  15. _current = _filter.GetGroup(_indexGroup);
  16. if (_current.count > 0) break;
  17. }
  18. return _indexGroup < _filter.groupCount;
  19. }
  20. public void Reset()
  21. {
  22. _indexGroup = -1;
  23. }
  24. public RefCurrent Current => new RefCurrent(_current);
  25. int _indexGroup;
  26. readonly EntityFilterCollection _filter;
  27. EntityFilterCollection.GroupFilters _current;
  28. public readonly ref struct RefCurrent
  29. {
  30. internal RefCurrent(EntityFilterCollection.GroupFilters filter)
  31. {
  32. _filter = filter;
  33. }
  34. public void Deconstruct(out EntityFilterIndices indices, out ExclusiveGroupStruct group)
  35. {
  36. indices = _filter.indices;
  37. group = _filter.group;
  38. }
  39. readonly EntityFilterCollection.GroupFilters _filter;
  40. }
  41. }
  42. }