using System; namespace Coroutine { /// /// Represents either an amount of time, or an that is being waited for by an . /// public struct Wait { internal readonly Event Event; private double seconds; /// /// Creates a new wait that waits for the given . /// /// The event to wait for public Wait(Event evt) { this.Event = evt; this.seconds = 0; } /// /// Creates a new wait that waits for the given amount of seconds. /// /// The amount of seconds to wait for public Wait(double seconds) { this.seconds = seconds; this.Event = null; } /// /// Creates a new wait that waits for the given . /// Note that the exact value may be slightly different, since waits operate in rather than ticks. /// /// The time span to wait for public Wait(TimeSpan time) : this(time.TotalSeconds) { } internal bool Tick(double deltaSeconds) { this.seconds -= deltaSeconds; return this.seconds <= 0; } } }