Started adding multiplayer
This commit is contained in:
26
Assets/Scripts/Extensions/TaskExtensions.cs
Normal file
26
Assets/Scripts/Extensions/TaskExtensions.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections;
|
||||
|
||||
namespace PashaBibko.PenguinChase.Extensions
|
||||
{
|
||||
public sealed class Result<T>
|
||||
{
|
||||
public T Value { get; set; }
|
||||
}
|
||||
|
||||
public static class TaskExtensions
|
||||
{
|
||||
public static IEnumerator Await<T>(this Task<T> task, Result<T> result)
|
||||
where T : class
|
||||
{
|
||||
// Waits until the task is completed
|
||||
while (!task.IsCompleted)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
|
||||
// Has to return the value like this because of the wonders of C#
|
||||
result.Value = task.Result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user