< Summary

Information
Line coverage
100%
Covered lines: 14
Uncovered lines: 0
Coverable lines: 14
Total lines: 61
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/WaitForFrames.cs

#LineLine coverage
 1//=======================================================================
 2// WaitForFrames.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
 8namespace Gravitas.Support;
 9
 10/// <summary>
 11/// A coroutine yield instruction that waits for a specified number of Gravitas simulation frames.
 12/// </summary>
 13/// <remarks>
 14/// Uses a checked deadline in the context's current clock lifetime. Reading an
 15/// instruction after context reset or disposal throws; reads never consume frames.
 16/// </remarks>
 17public readonly struct WaitForFrames : ILockedYieldInstruction
 18{
 19    private readonly GravitasWorldContext _context;
 20    private readonly object _lifetime;
 21    private readonly long _deadlineFrame;
 22
 23    /// <summary>
 24    /// Creates an instruction that waits for a nonnegative number of simulation frames.
 25    /// </summary>
 26    public WaitForFrames(GravitasWorldContext context, long numberOfFrames)
 27    {
 22528        ChronicleGuard.ThrowIfNull(context, nameof(context));
 22529        ChronicleGuard.ThrowIfArgumentOutOfRange(numberOfFrames < 0, null,
 22530            nameof(numberOfFrames), "Wait frame count cannot be negative.");
 31
 22432        _context = context;
 22433        _lifetime = context.CaptureClockLifetime();
 22434        _deadlineFrame = context.GetDeadlineFrame(numberOfFrames);
 22335    }
 36
 37    /// <inheritdoc />
 738    public GravitasWorldContext Context => _context;
 39
 40    /// <inheritdoc />
 41    public bool KeepWaiting
 42    {
 43        get
 44        {
 43645            _context.ValidateClockLifetime(_lifetime);
 43446            return _context.FrameCount < _deadlineFrame;
 47        }
 48    }
 49
 50    /// <inheritdoc />
 151    public object? Current => null;
 52
 53    /// <inheritdoc />
 254    public bool MoveNext() => KeepWaiting;
 55
 56    /// <inheritdoc />
 157    public void Reset() { }
 58
 59    /// <inheritdoc />
 860    public void Dispose() { }
 61}