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.

SimpleEntitiesSubmissionScheduler.cs 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.Collections;
  3. namespace Svelto.ECS.Schedulers
  4. {
  5. public sealed class SimpleEntitiesSubmissionScheduler : EntitiesSubmissionScheduler
  6. {
  7. public SimpleEntitiesSubmissionScheduler(uint maxNumberOfOperationsPerFrame = UInt32.MaxValue)
  8. {
  9. _maxNumberOfOperationsPerFrame = maxNumberOfOperationsPerFrame;
  10. }
  11. public IEnumerator SubmitEntitiesAsync()
  12. {
  13. if (paused == false)
  14. {
  15. var submitEntities = _onTick.Invoke(_maxNumberOfOperationsPerFrame);
  16. while (submitEntities.MoveNext())
  17. yield return null;
  18. }
  19. }
  20. public void SubmitEntities()
  21. {
  22. var enumerator = SubmitEntitiesAsync();
  23. while (enumerator.MoveNext());
  24. }
  25. public override bool paused { get; set; }
  26. public override void Dispose() { }
  27. protected internal override EnginesRoot.EntitiesSubmitter onTick
  28. {
  29. set
  30. {
  31. DBC.ECS.Check.Require(_onTick.IsUnused, "a scheduler can be exclusively used by one enginesRoot only");
  32. _onTick = value;
  33. }
  34. }
  35. EnginesRoot.EntitiesSubmitter _onTick;
  36. readonly uint _maxNumberOfOperationsPerFrame;
  37. }
  38. }