Code/Stallers/WaitForRealSeconds.cs
using Sandbox;
using static Sandbox.GameObjectSystem;
namespace Coroutines.Stallers;
/// <summary>
/// Pauses a coroutine until a specified amount of seconds have passed.
/// </summary>
public sealed class WaitForRealSeconds : ICoroutineStaller
{
/// <inheritdoc/>
public bool IsComplete => RealSecondsUntilComplete <= 0;
/// <inheritdoc/>
public Stage PollingStage { get; }
/// <summary>
/// The number of seconds left until completion.
/// </summary>
private RealTimeUntil RealSecondsUntilComplete { get; }
/// <summary>
/// Initializes a new instance of <see cref="WaitForRealSeconds"/>.
/// </summary>
/// <param name="seconds">The number of seconds to wait.</param>
/// <param name="pollingStage">The way for the coroutine to wait for completion.</param>
public WaitForRealSeconds( float seconds, Stage pollingStage = Coroutine.PreservePollingStage )
{
RealSecondsUntilComplete = seconds;
PollingStage = pollingStage;
}
/// <inheritdoc/>
public void Update()
{
}
}