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.

38 lines
1.1KB

  1. using System.Threading.Tasks;
  2. using RobocraftX.Schedulers;
  3. using Svelto.ECS;
  4. using Techblox.Server.Schedulers;
  5. using TechbloxModdingAPI.Common.Engines;
  6. using TechbloxModdingAPI.Utility;
  7. namespace TechbloxModdingAPI.Common.Utils;
  8. public static class AsyncUtils
  9. {
  10. private static AsyncUtilsEngine gameEngine = new();
  11. /// <summary>
  12. /// Waits for entity submission asynchronously.
  13. /// Use after placing a block or otherwise creating things in the game to access their properties.
  14. /// </summary>
  15. public static async Task WaitForSubmission()
  16. {
  17. await gameEngine.WaitForSubmission();
  18. }
  19. public static async Task WaitForNextFrame()
  20. {
  21. await gameEngine.WaitForNextFrame();
  22. }
  23. public static void Setup(EnginesRoot enginesRoot, bool clientside)
  24. {
  25. gameEngine.Setup(enginesRoot,
  26. clientside ? ClientExtraLean.UIScheduler : ServerExtraLean.DeterministicTimeRunningStepRunner);
  27. }
  28. public static void Init()
  29. {
  30. EngineManager.AddEngine(gameEngine, ApiEngineType.Build, ApiEngineType.Menu, ApiEngineType.PlayClient, ApiEngineType.PlayServer);
  31. }
  32. }