< Summary

Information
Line coverage
100%
Covered lines: 13
Uncovered lines: 0
Coverable lines: 13
Total lines: 65
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_Context()100%11100%
get_KeepWaiting()100%11100%
get_Current()100%11100%
MoveNext()100%11100%
Reset()100%11100%
Dispose()100%11100%

File(s)

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Runtime/Coroutines/LockedYieldInstructions/WaitForRealSeconds.cs

#LineLine coverage
 1//=======================================================================
 2// WaitForRealSeconds.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2026-present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8using Chronicler.Timing;
 9using FixedMathSharp;
 10using FixedMathSharp.Chronicler;
 11
 12namespace Gravitas.Support;
 13
 14/// <summary>
 15/// A coroutine yield instruction that waits for a specified duration on the owning context's deterministic clock.
 16/// </summary>
 17/// <remarks>
 18/// Uses a wide timestamp deadline, preserving the requested duration across frame-rate
 19/// changes. Reading an instruction after context reset or disposal throws; reads never
 20/// consume time. An unrepresentable deadline throws during construction.
 21/// </remarks>
 22public readonly struct WaitForRealSeconds : ILockedYieldInstruction
 23{
 24    private readonly GravitasWorldContext _context;
 25    private readonly object _lifetime;
 26    private readonly ChronicleTimestamp _targetTime;
 27
 28    /// <summary>
 29    /// Creates an instruction that waits for a nonnegative duration on the context's deterministic clock.
 30    /// </summary>
 31    public WaitForRealSeconds(GravitasWorldContext context, Fixed64 seconds)
 32    {
 22133        ChronicleGuard.ThrowIfNull(context, nameof(context));
 22034        ChronicleGuard.ThrowIfArgument(seconds < Fixed64.Zero, nameof(seconds), "Wait duration cannot be negative.");
 35
 21936        _context = context;
 21937        _lifetime = context.CaptureClockLifetime();
 21938        _targetTime = context.ElapsedTime + FixedChronicleTime.FromFixed64(seconds);
 21839    }
 40
 41    /// <inheritdoc />
 342    public GravitasWorldContext Context => _context;
 43
 44    /// <inheritdoc />
 45    public bool KeepWaiting
 46    {
 47        get
 48        {
 43549            _context.ValidateClockLifetime(_lifetime);
 43350            return _context.ElapsedTime < _targetTime;
 51        }
 52    }
 53
 54    /// <inheritdoc />
 155    public object? Current => null;
 56
 57    /// <inheritdoc />
 358    public bool MoveNext() => KeepWaiting;
 59
 60    /// <inheritdoc />
 161    public void Reset() { }
 62
 63    /// <inheritdoc />
 364    public void Dispose() { }
 65}