# MotionWorld

Own a set of tweens and its update clock. Schedule builders into the world and advance it on the main thread with Tick.

Namespace: MeatMotion

Assembly: MeatMotion

```csharp
public sealed class MotionWorld : IDisposable, IMotionScheduler
```

[Runtime/Core/MotionWorld.cs · L12](../../../source/Runtime/Core/MotionWorld.cs.html#L12)

## Drive two clocks independently

Add `using MeatMotion;`. Ticking one world leaves the other world's value at its starting point.

```csharp
float a = 0f, b = 0f;
using var first = new MotionWorld();
using var second = new MotionWorld();
MMotion.Create(0f, 1f, 1f).WithScheduler(first).Bind(v => a = v);
MMotion.Create(0f, 1f, 1f).WithScheduler(second).Bind(v => b = v);
first.Tick(0.5);
```

## Default

Get the default automatically driven world.

```csharp
public static MotionWorld Default { get; }
```

[Runtime/Core/MotionWorld.cs · L104](../../../source/Runtime/Core/MotionWorld.cs.html#L104)

## MotionWorld

Create an independently driven world. Dispose it after use.

```csharp
public MotionWorld(int capacity = 0)
```

Parameters

- `capacity = 0` (`int`) Number of entries to reserve.

[Runtime/Core/MotionWorld.cs · L106](../../../source/Runtime/Core/MotionWorld.cs.html#L106)

## Schedule

Schedule the builder on this world's clock and return its handle.

```csharp
public MotionHandle Schedule<TValue, TOptions, TAdapter>(ref MotionBuilder<TValue, TOptions, TAdapter> builder)
    where TValue : unmanaged
    where TOptions : unmanaged, IMotionOptions
    where TAdapter : unmanaged, IMotionAdapter<TValue, TOptions>
```

Parameters and return value

- `builder` (`ref MotionBuilder<TValue, TOptions, TAdapter>`) Configured builder, passed as the receiver for extension calls.
- Returns: `MotionHandle`

[Runtime/Core/MotionWorld.cs · L108](../../../source/Runtime/Core/MotionWorld.cs.html#L108)

## EnsureCapacity

Reserve storage for the requested number of motions.

```csharp
public void EnsureCapacity(int capacity)
```

Parameters

- `capacity` (`int`) Number of entries to reserve.

[Runtime/Core/MotionWorld.cs · L114](../../../source/Runtime/Core/MotionWorld.cs.html#L114)

## Tick

Advance the world's scheduled motions by the supplied delta in seconds.

```csharp
public void Tick(double deltaTime)
```

Parameters

- `deltaTime` (`double`) Seconds to advance from the preceding update.

[Runtime/Core/MotionWorld.cs · L386](../../../source/Runtime/Core/MotionWorld.cs.html#L386)

## Dispose

Release this world's storage and its motions.

```csharp
public void Dispose()
```

[Runtime/Core/MotionWorld.cs · L448](../../../source/Runtime/Core/MotionWorld.cs.html#L448)

## CancelAll

Cancel the motions in this world.

```csharp
public void CancelAll()
```

[Runtime/Core/MotionWorld.cs · L473](../../../source/Runtime/Core/MotionWorld.cs.html#L473)

## Related types

- [IMotionScheduler](../../../en/api/imotionscheduler/index.md)

- [ManualMotionDispatcher](../../../en/api/manualmotiondispatcher/index.md)

- [MotionHandle](../../../en/api/motionhandle/index.md)
