Skip to content

Commit

Permalink
Added TimeManager docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vchelaru committed Feb 29, 2024
1 parent 74c1e4a commit 05a8d92
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Engines/FlatRedBallXNA/FlatRedBall/TimeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -580,11 +580,21 @@ public static double CurrentScreenSecondsSince(double time)
return Screens.ScreenManager.CurrentScreen.PauseAdjustedSecondsSince(time);
}

/// <summary>
/// Returns a task which completes after the argument timespan has passed in screen time. This considers slow-motion and pausing.
/// </summary>
/// <param name="timeSpan">The amount of time to wait.</param>
/// <returns>A task which will complete when the arugment time passes.</returns>
public static Task Delay(TimeSpan timeSpan)
{
return DelaySeconds(timeSpan.TotalSeconds);
}

/// <summary>
/// Returns a task which completes after the argument seconds have passed in screen time. This considers slow-motion and pausing.
/// </summary>
/// <param name="seconds">The number of seconds to wait.</param>
/// <returns>The task which will complete when the argument time passes.</returns>
public static Task DelaySeconds(double seconds)
{
if(seconds <= 0)
Expand All @@ -609,6 +619,11 @@ public static Task DelaySeconds(double seconds)
return taskSource.Task;
}

/// <summary>
/// Returns a task which completes once the argument predicate is fulfilled. This is checked once per frame.
/// </summary>
/// <param name="predicate">The predicate to check for completion.</param>
/// <returns>The task which will complete when the predicate returns true.</returns>
public static Task DelayUntil(Func<bool> predicate)
{
if(predicate())
Expand All @@ -620,6 +635,11 @@ public static Task DelayUntil(Func<bool> predicate)
return taskSource.Task;
}

/// <summary>
/// Returns a task which completes after the argument number of frames have passed.
/// </summary>
/// <param name="frameCount">The number of frames to wait.</param>
/// <returns>That task which completes once the argument number of rames have passed.</returns>
public static Task DelayFrames(int frameCount)
{
if(frameCount <= 0)
Expand Down

0 comments on commit 05a8d92

Please sign in to comment.