< Summary

Information
Class: Gravitas.GravitasLifecycleHooks
Assembly: Gravitas
File(s): /home/runner/work/Gravitas/Gravitas/src/Gravitas/Runtime/LifecycleHooks/GravitasLifecycleHooks.cs
Line coverage
100%
Covered lines: 31
Uncovered lines: 0
Coverable lines: 31
Total lines: 86
Line coverage: 100%
Branch coverage
100%
Covered branches: 12
Total branches: 12
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
RegisterOnSimulate(...)100%11100%
RegisterOnLateSimulate(...)100%11100%
RegisterOnVisualize(...)100%11100%
RegisterOnLateVisualize(...)100%11100%
RegisterOnReset(...)100%11100%
RegisterOnFrameRateChanged(...)100%11100%
InvokeSimulate()100%22100%
InvokeLateSimulate()100%22100%
InvokeVisualize()100%22100%
InvokeLateVisualize()100%22100%
InvokeReset()100%22100%
InvokeFrameRateChanged()100%22100%

File(s)

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Runtime/LifecycleHooks/GravitasLifecycleHooks.cs

#LineLine coverage
 1//=======================================================================
 2// GravitasLifecycleHooks.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 System;
 9using Gravitas.Support;
 10using SwiftCollections;
 11
 12namespace Gravitas;
 13
 14/// <summary>
 15/// Owns ordered lifecycle hook storage for one Gravitas runtime owner.
 16/// </summary>
 17internal sealed class GravitasLifecycleHooks
 18{
 1019119    private readonly LifecycleHookHandler _hookHandler = new();
 20
 1019121    private readonly SwiftList<OrderedLifecycleHook> _simulateHooks = new();
 22
 1019123    private readonly SwiftList<OrderedLifecycleHook> _lateSimulateHooks = new();
 24
 1019125    private readonly SwiftList<OrderedLifecycleHook> _visualizeHooks = new();
 26
 1019127    private readonly SwiftList<OrderedLifecycleHook> _lateVisualizeHooks = new();
 28
 1019129    private readonly SwiftList<OrderedLifecycleHook> _resetHooks = new();
 30
 1019131    private readonly SwiftList<OrderedLifecycleHook> _frameRateChangedHooks = new();
 32
 33    internal IDisposable RegisterOnSimulate(string owner, int order, Action callback) =>
 1834        _hookHandler.RegisterHook(_simulateHooks, owner, order, callback);
 35
 36    internal IDisposable RegisterOnLateSimulate(string owner, int order, Action callback) =>
 1137        _hookHandler.RegisterHook(_lateSimulateHooks, owner, order, callback);
 38
 39    internal IDisposable RegisterOnVisualize(string owner, int order, Action callback) =>
 140        _hookHandler.RegisterHook(_visualizeHooks, owner, order, callback);
 41
 42    internal IDisposable RegisterOnLateVisualize(string owner, int order, Action callback) =>
 143        _hookHandler.RegisterHook(_lateVisualizeHooks, owner, order, callback);
 44
 45    internal IDisposable RegisterOnReset(string owner, int order, Action callback) =>
 246        _hookHandler.RegisterHook(_resetHooks, owner, order, callback);
 47
 48    internal IDisposable RegisterOnFrameRateChanged(string owner, int order, Action callback) =>
 249        _hookHandler.RegisterHook(_frameRateChangedHooks, owner, order, callback);
 50
 51    internal void InvokeSimulate()
 52    {
 7096753        if (_simulateHooks.Count != 0)
 1654            _hookHandler.InvokeHooks(_simulateHooks);
 7096255    }
 56
 57    internal void InvokeLateSimulate()
 58    {
 7130259        if (_lateSimulateHooks.Count != 0)
 1860            _hookHandler.InvokeHooks(_lateSimulateHooks);
 7129961    }
 62
 63    internal void InvokeVisualize()
 64    {
 4965        if (_visualizeHooks.Count != 0)
 166            _hookHandler.InvokeHooks(_visualizeHooks);
 4967    }
 68
 69    internal void InvokeLateVisualize()
 70    {
 3571        if (_lateVisualizeHooks.Count != 0)
 172            _hookHandler.InvokeHooks(_lateVisualizeHooks);
 3573    }
 74
 75    internal void InvokeReset()
 76    {
 11377        if (_resetHooks.Count != 0)
 178            _hookHandler.InvokeHooks(_resetHooks);
 11379    }
 80
 81    internal void InvokeFrameRateChanged()
 82    {
 422683        if (_frameRateChangedHooks.Count != 0)
 284            _hookHandler.InvokeHooks(_frameRateChangedHooks);
 422685    }
 86}