MeatMotion

IMotionAdapter<TValue, TOptions>

Define interpolation for an unmanaged value type. Evaluate receives endpoints, options, eased progress and motion time.

Namespace
MeatMotion
Assembly
MeatMotion

Jump to members

public interface IMotionAdapter<TValue, TOptions>
    where TValue : unmanaged
    where TOptions : unmanaged, IMotionOptions
IMotionAdapter.cs · L21

Define a step adapter

Add using MeatMotion;. Declare the adapter outside the calling method. Its value switches to the endpoint once eased progress reaches 0.5.

public struct StepAdapter : IMotionAdapter<float, NoOptions>
{
    public float Evaluate(ref float startValue, ref float endValue,
        ref NoOptions options, in MotionEvaluationContext context)
    {
        return context.Progress < 0.5f ? startValue : endValue;
    }
}
using var world = new MotionWorld();
float value = 0f;
var handle = MMotion.Create<float, NoOptions, StepAdapter>(2f, 8f, 1f)
    .WithScheduler(world).Bind(v => value = v);
handle.Time = 0.25;
float before = value;
handle.Time = 0.5;

Members

Evaluate

Return the sampled value from the endpoints, options and evaluation context. The binding writes the result to the target.

TValue Evaluate(ref TValue startValue, ref TValue endValue, ref TOptions options, in MotionEvaluationContext context)
Parameters and return value
startValue
ref TValue Starting value.
endValue
ref TValue End value.
options
ref TOptions Options passed to this value adapter.
context
in MotionEvaluationContext Eased Progress and elapsed Time in seconds.
Returns
TValue