A stable modding interface between Techblox and mods https://mod.exmods.org/
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.

50 lines
1.4KB

  1. using System.Collections;
  2. using System.Threading.Tasks;
  3. using RobocraftX.Schedulers;
  4. using Svelto.ECS;
  5. using Svelto.Tasks.ExtraLean;
  6. using GamecraftModdingAPI.Engines;
  7. namespace GamecraftModdingAPI.Utility
  8. {
  9. public class AsyncUtilsEngine : IApiEngine
  10. {
  11. private IEntityFunctions _efu;
  12. private IEntityFactory _efa;
  13. private IEnumerator WaitForSubmissionInternal(IEntityFunctions efu, IEntityFactory efa,
  14. EntitiesDB entitiesDB, TaskCompletionSource<object> task)
  15. {
  16. var waitEnumerator = new WaitForSubmissionEnumerator(efu, efa, entitiesDB);
  17. while (waitEnumerator.MoveNext())
  18. yield return null;
  19. task.SetResult(null);
  20. }
  21. public Task WaitForSubmission()
  22. {
  23. var task = new TaskCompletionSource<object>();
  24. WaitForSubmissionInternal(_efu, _efa, entitiesDB, task).RunOn(ExtraLean.EveryFrameStepRunner);
  25. return task.Task;
  26. }
  27. public void Setup(IEntityFunctions efu, IEntityFactory efa)
  28. {
  29. _efu = efu;
  30. _efa = efa;
  31. }
  32. public void Ready()
  33. {
  34. }
  35. public EntitiesDB entitiesDB { get; set; }
  36. public void Dispose()
  37. {
  38. }
  39. public string Name { get; } = "GamecraftModdingAPIAsyncUtilsGameEngine";
  40. public bool isRemovable { get; } = false;
  41. }
  42. }