-
Notifications
You must be signed in to change notification settings - Fork 2
/
TweenExt.cs
43 lines (40 loc) · 1.29 KB
/
TweenExt.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System.Threading.Tasks;
using Godot;
using JetBrains.Annotations;
namespace GodotExt
{
/// <summary>
/// This class contains useful extension methods for <see cref="Tween"/>
/// </summary>
[PublicAPI]
public static class TweenExt
{
/// <summary>
/// Returns a <see cref="SignalAwaiter"/> that waits until this Tween is
/// completed.
/// </summary>
public static SignalAwaiter IsCompleted(this Tween tween)
{
return tween.FiresSignal("tween_completed");
}
/// <summary>
/// Returns a <see cref="SignalAwaiter"/> that waits until all interpolations
/// of the tween are completed.
/// </summary>
public static SignalAwaiter AreAllCompleted(this Tween tween)
{
return tween.FiresSignal("tween_all_completed");
}
/// <summary>
/// Waits until the Tween has finished an interpolation of the given object.
/// </summary>
public static async Task IsCompleted(this Tween tween, Object interpolatedObject)
{
object[] result;
do
{
result = await tween.IsCompleted();
} while (!(result.Length == 2 && result[0] == interpolatedObject));
}
}
}