using System.Threading.Tasks; namespace Barotrauma { static class TaskExtensions { public static bool TryGetResult(this Task task, out T result) { if (task is Task { IsCompletedSuccessfully: true } castTask) { result = castTask.Result; return true; } result = default; return false; } public static async Task WaitForLoadingScreen(this Task task) { var result = await task; #if CLIENT while (GameMain.Instance.LoadingScreenOpen) { await Task.Delay((int)(1000 * Timing.Step)); } #endif return result; } } }