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.

AsyncUtilsEngine.cs 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. yield break; //TODO
  21. }
  22. private IEnumerator WaitForNextFrameInternal(TaskCompletionSource<object> task)
  23. {
  24. yield return null;
  25. task.SetResult(null);
  26. }
  27. public Task WaitForSubmission()
  28. {
  29. var task = new TaskCompletionSource<object>();
  30. WaitForSubmissionInternal(_efu, _efa, entitiesDB, task).RunOn(ExtraLean.EveryFrameStepRunner_TimeStopped);
  31. return task.Task;
  32. }
  33. public Task WaitForNextFrame()
  34. {
  35. var task = new TaskCompletionSource<object>();
  36. WaitForNextFrameInternal(task).RunOn(ExtraLean.EveryFrameStepRunner_TimeStopped);
  37. return task.Task;
  38. }
  39. public void Setup(IEntityFunctions efu, IEntityFactory efa)
  40. {
  41. _efu = efu;
  42. _efa = efa;
  43. }
  44. public void Ready()
  45. {
  46. }
  47. public EntitiesDB entitiesDB { get; set; }
  48. public void Dispose()
  49. {
  50. }
  51. public string Name { get; } = "GamecraftModdingAPIAsyncUtilsGameEngine";
  52. public bool isRemovable { get; } = false;
  53. }
  54. }