Mirror of Svelto.ECS because we're a fan of it
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

60 rindas
1.7KB

  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 && _current.group.IsEnabled() == true)
  17. break;
  18. }
  19. return _indexGroup < _filter.groupCount;
  20. }
  21. public void Reset()
  22. {
  23. _indexGroup = -1;
  24. }
  25. public RefCurrent Current => new RefCurrent(_current);
  26. int _indexGroup;
  27. readonly EntityFilterCollection _filter;
  28. EntityFilterCollection.GroupFilters _current;
  29. public readonly ref struct RefCurrent
  30. {
  31. internal RefCurrent(EntityFilterCollection.GroupFilters filter)
  32. {
  33. _filter = filter;
  34. }
  35. public void Deconstruct(out EntityFilterIndices indices, out ExclusiveGroupStruct group)
  36. {
  37. indices = _filter.indices;
  38. group = _filter.group;
  39. }
  40. public void Deconstruct(out EntityFilterIndices indices, out ExclusiveGroupStruct group,
  41. out EntityFilterCollection.GroupFilters groupFilter)
  42. {
  43. indices = _filter.indices;
  44. group = _filter.group;
  45. groupFilter = _filter;
  46. }
  47. readonly EntityFilterCollection.GroupFilters _filter;
  48. }
  49. }
  50. }