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.

48 lines
1.3KB

  1. using System;
  2. using System.Collections;
  3. using Svelto.ECS.Schedulers;
  4. namespace Svelto.ECS
  5. {
  6. /// <summary>
  7. /// Enumerator that yields until the next Entities Submission
  8. /// </summary>
  9. public struct WaitForSubmissionEnumerator : IEnumerator
  10. {
  11. public WaitForSubmissionEnumerator(EntitiesSubmissionScheduler scheduler):this()
  12. {
  13. _scheduler = scheduler;
  14. }
  15. public bool MoveNext()
  16. {
  17. switch (_state)
  18. {
  19. case 0:
  20. _iteration = _scheduler.iteration;
  21. _state = 1;
  22. return true;
  23. case 1:
  24. if (_iteration != _scheduler.iteration)
  25. {
  26. _state = 0;
  27. return false;
  28. }
  29. return true;
  30. }
  31. throw new Exception("something is wrong");
  32. }
  33. void IEnumerator.Reset()
  34. {
  35. throw new NotImplementedException();
  36. }
  37. public object Current { get; }
  38. readonly EntitiesSubmissionScheduler _scheduler;
  39. uint _state;
  40. uint _iteration;
  41. }
  42. }