XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEEDToolBox

【WinUI】XFE精英危险工具箱

公开
关注 0 Fork 0 Star 0
UTF-8
namespace XFEEDToolBox.Core.Galaxy;

/// <summary>
/// Original normal frame event value, recovered from7F8CC0 ->7F3430 ->
///1EB9C0/8494 ->1EB050 ->global5F007A0. The ordinary source is a seconds/
/// nanoseconds timestamp difference converted to float seconds by52C3F0.
/// The host owns its clock epoch and scheduling; it need not share the
/// original wall-clock timestamp or another camera's transition history.
/// </summary>
public static class GalaxyOriginalFrameFadeClock
{
    public const float MinimumFrameValue=.000009999999747378752f;
    public const float MaximumFrameValue=.5f;
    public const float LongFrameThreshold=4f;
    public const float LongFrameValue=.03333333507180214f;

    /// <summary>
    /// Bind host elapsed seconds to the original event policy. A frame over
    /// four seconds uses the original1/30 cap; exactly four uses the normal
    /// .5 cap. fixedFramesPerSecond explicitly selects the original app9B4
    /// branch (1/app9B0), independently of elapsed time. Null elapsed remains
    /// unavailable in ordinary mode; no assumed timer period is supplied.
    /// </summary>
    public static bool TryFromElapsedSeconds(double? elapsedSeconds,out float frameValue,float? fixedFramesPerSecond=null)
    {
        frameValue=default;float raw;
        if(fixedFramesPerSecond is {} rate)
        {
            if(!float.IsFinite(rate)||rate<=0)return false;
            raw=1f/rate;
        }
        else
        {
            if(elapsedSeconds is not {} seconds||!double.IsFinite(seconds))return false;
            raw=(float)seconds;
        }
        if(!float.IsFinite(raw))return false;
        raw=Math.Max(MinimumFrameValue,raw);
        frameValue=Math.Min(raw,raw>LongFrameThreshold?LongFrameValue:MaximumFrameValue);
        return true;
    }
}