namespace XFEEDToolBox.Core.Galaxy;
///
/// A tool-owned instance of the original input component's frame-fade state.
/// Original activation3B37630 resets component1A8 to zero. This instance must
/// follow this tool's own camera/input lifetime; another camera's live1A8 is
/// not interchangeable with its history. All methods run on the owning frame
/// thread, once per input event, rather than once per alpha consumer.
///
public sealed class GalaxyOriginalFrameFadeState
{
public bool IsActive { get; private set; }
public float? CurrentTransition { get; private set; }
public float? TargetTransition { get; private set; }
/// Begin a new camera/input lifetime at the recovered initial0.
public void Activate()
{
IsActive=true;CurrentTransition=0;TargetTransition=null;
}
public void Deactivate()
{
IsActive=false;CurrentTransition=TargetTransition=null;
}
///
/// Advance from the actual camera, not its pending target. The same
/// current catalogue Descriptor.InnerRadius binds both renderer280 and
/// the Settings getter: provider3A5E4E0 -> interface551F408+30 ->1A3C960
/// returns interface228, which is component280. Zero is a known range.
/// inputFrameValue remains explicit: the original callback3ABA020 copies
/// XMM2 to3AF5D70's XMM1 unchanged. Use GalaxyOriginalFrameFadeClock to
/// bind host elapsed seconds through the recovered original frame
/// clamps. Null never becomes an assumed cadence.
///
public bool TryAdvanceForCamera(GalaxyCamera? camera,float? rendererInnerRadius,
int? originalViewMode,float? inputFrameValue)
{
if(!IsActive)return false;
if(camera is null||
!GalaxyOriginalFrameFade.TryTargetTransition((float)camera.Distance,rendererInnerRadius,originalViewMode,out var target)||
!GalaxyOriginalFrameFade.TryAdvanceTransition(CurrentTransition,target,inputFrameValue,out var next))
{
// An unobserved event loses the history. Later valid parameters
// cannot recover the missing actual value from a target alone.
CurrentTransition=TargetTransition=null;return false;
}
CurrentTransition=next;TargetTransition=target;return true;
}
///
/// Prepare any number of consumers without advancing time. Call only
/// after this frame's input update; never change the state per vertex.
///
public bool TryCreateForCamera(GalaxyCamera? camera,float? rendererInnerRadius,out GalaxyOriginalFrameFade fade)
=>GalaxyOriginalFrameFade.TryCreateForCamera(IsActive?camera:null,rendererInnerRadius,CurrentTransition,out fade);
}