# MotionWorld

独立したTweenの集合と更新時計を持ちます。WithSchedulerでビルダーを登録し、メインスレッドでTickに経過秒数を渡します。

Namespace: MeatMotion

Assembly: MeatMotion

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

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

## 2つの時計を独立して進める

`using MeatMotion;` を追加します。片方のworldだけにTickを呼ぶと、もう片方の値は初期値のままです。

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

既定の自動更新worldを取得します。

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

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

## MotionWorld

独立した手動worldを作成します。使用後はDisposeで解放します。

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

引数

- `capacity = 0` (`int`) 事前に確保する要素数。

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

## Schedule

呼び出し元のworldの時計でビルダーを登録し、MotionHandleを返します。

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

引数と戻り値

- `builder` (`ref MotionBuilder<TValue, TOptions, TAdapter>`) 設定済みのビルダー。拡張メソッドでは呼び出し元として渡されます。
- 戻り値: `MotionHandle`

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

## EnsureCapacity

指定件数を扱えるようにストレージを事前確保します。

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

引数

- `capacity` (`int`) 事前に確保する要素数。

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

## Tick

手動worldに渡した経過秒数だけ、登録したTweenを更新します。

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

引数

- `deltaTime` (`double`) 前回の更新から進める秒数。

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

## Dispose

worldのストレージと管理するTweenを解放します。

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

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

## CancelAll

このworldのTweenをまとめてキャンセルします。

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

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

## 関連する型

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

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

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