< Summary

Information
Class: Gravitas.GravitasLifecycleHooks
Assembly: Gravitas
File(s): /home/runner/work/Gravitas/Gravitas/src/Gravitas/Runtime/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/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 Gravitas.Support;
 9using SwiftCollections;
 10using System;
 11
 12namespace Gravitas;
 13
 14/// <summary>
 15/// Owns ordered lifecycle hook storage for one Gravitas runtime owner.
 16/// </summary>
 17internal sealed class GravitasLifecycleHooks
 18{
 508319    private readonly LifecycleHookHandler _hookHandler = new();
 20
 508321    private readonly SwiftList<OrderedLifecycleHook> _simulateHooks = new();
 22
 508323    private readonly SwiftList<OrderedLifecycleHook> _lateSimulateHooks = new();
 24
 508325    private readonly SwiftList<OrderedLifecycleHook> _visualizeHooks = new();
 26
 508327    private readonly SwiftList<OrderedLifecycleHook> _lateVisualizeHooks = new();
 28
 508329    private readonly SwiftList<OrderedLifecycleHook> _resetHooks = new();
 30
 508331    private readonly SwiftList<OrderedLifecycleHook> _frameRateChangedHooks = new();
 32
 33    internal IDisposable RegisterOnSimulate(string owner, int order, Action callback) =>
 934        _hookHandler.RegisterHook(_simulateHooks, owner, order, callback);
 35
 36    internal IDisposable RegisterOnLateSimulate(string owner, int order, Action callback) =>
 337        _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    {
 232053        if (_simulateHooks.Count != 0)
 454            _hookHandler.InvokeHooks(_simulateHooks);
 231855    }
 56
 57    internal void InvokeLateSimulate()
 58    {
 282559        if (_lateSimulateHooks.Count != 0)
 360            _hookHandler.InvokeHooks(_lateSimulateHooks);
 282461    }
 62
 63    internal void InvokeVisualize()
 64    {
 2965        if (_visualizeHooks.Count != 0)
 166            _hookHandler.InvokeHooks(_visualizeHooks);
 2967    }
 68
 69    internal void InvokeLateVisualize()
 70    {
 1571        if (_lateVisualizeHooks.Count != 0)
 172            _hookHandler.InvokeHooks(_lateVisualizeHooks);
 1573    }
 74
 75    internal void InvokeReset()
 76    {
 3177        if (_resetHooks.Count != 0)
 178            _hookHandler.InvokeHooks(_resetHooks);
 3179    }
 80
 81    internal void InvokeFrameRateChanged()
 82    {
 186383        if (_frameRateChangedHooks.Count != 0)
 284            _hookHandler.InvokeHooks(_frameRateChangedHooks);
 186385    }
 86}