Files
sbox-public/game/editor/MovieMaker/Code/Signals/Operations/Blend.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

35 lines
931 B
C#

using Sandbox.MovieMaker;
namespace Editor.MovieMaker;
#nullable enable
partial record PropertySignal<T>
{
public PropertySignal<T> Blend( PropertySignal<T> second, float alpha )
{
if ( alpha <= 0f ) return this;
if ( alpha >= 1f ) return second;
if ( Equals( second ) )
{
return this;
}
return Interpolator.GetDefault<T>() is not null
? new BlendOperation<T>( this, second, alpha )
: this;
}
}
[JsonDiscriminator( "Blend" )]
file sealed record BlendOperation<T>( PropertySignal<T> First, PropertySignal<T> Second, float Alpha ) : InterpolateOperation<T>( First, Second )
{
public override float GetAlpha( MovieTime time ) => Alpha;
protected override PropertySignal<T> OnSmooth( MovieTime size ) =>
this with { First = First.Smooth( size ), Second = Second.Smooth( size ) };
public override bool CanSmooth( MovieTimeRange range ) => First.CanSmooth( range ) || Second.CanSmooth( range );
}