# IMotionAdapter<TValue, TOptions>

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

Namespace: MeatMotion

Assembly: MeatMotion

```csharp
public interface IMotionAdapter<TValue, TOptions>
    where TValue : unmanaged
    where TOptions : unmanaged, IMotionOptions
```

[Runtime/Adapters/IMotionAdapter.cs · L21](../../../source/Runtime/Adapters/IMotionAdapter.cs.html#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.

```csharp
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;
    }
}
```

```csharp
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;
```

## Evaluate

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

```csharp
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`

[Runtime/Adapters/IMotionAdapter.cs · L25](../../../source/Runtime/Adapters/IMotionAdapter.cs.html#L25)
