|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- using System.Collections;
- using System.Threading.Tasks;
-
- using RobocraftX.Schedulers;
- using Svelto.ECS;
- using Svelto.Tasks.ExtraLean;
-
- using GamecraftModdingAPI.Engines;
-
- namespace GamecraftModdingAPI.Utility
- {
- public class AsyncUtilsEngine : IApiEngine
- {
- private IEntityFunctions _efu;
- private IEntityFactory _efa;
- private IEnumerator WaitForSubmissionInternal(IEntityFunctions efu, IEntityFactory efa,
- EntitiesDB entitiesDB, TaskCompletionSource<object> task)
- {
- var waitEnumerator = new WaitForSubmissionEnumerator(efu, efa, entitiesDB);
- while (waitEnumerator.MoveNext())
- yield return null;
- task.SetResult(null);
- }
-
- public Task WaitForSubmission()
- {
- var task = new TaskCompletionSource<object>();
- WaitForSubmissionInternal(_efu, _efa, entitiesDB, task).RunOn(ExtraLean.EveryFrameStepRunner);
- return task.Task;
- }
-
- public void Setup(IEntityFunctions efu, IEntityFactory efa)
- {
- _efu = efu;
- _efa = efa;
- }
-
- public void Ready()
- {
- }
-
- public EntitiesDB entitiesDB { get; set; }
- public void Dispose()
- {
- }
-
- public string Name { get; } = "GamecraftModdingAPIAsyncUtilsGameEngine";
- public bool isRemovable { get; } = false;
- }
- }
|