# MotionBuilderExtensions

値型の状態を渡すBind、整数の丸め、文字列のスクランブル、Punch・Shakeの振動設定を追加します。

Namespace: MeatMotion

Assembly: MeatMotion

```csharp
public static partial class MotionBuilderExtensions
```

[Runtime/Adapters/Strings/StringMotion.cs · L50](../../source/Runtime/Adapters/Strings/StringMotion.cs.html#L50)

## WithRichText

文字列補間でリッチテキストのタグを考慮するか指定します。

```csharp
public static MotionBuilder<TValue, StringOptions, TAdapter> WithRichText<TValue, TAdapter>( this MotionBuilder<TValue, StringOptions, TAdapter> builder, bool richTextEnabled = true)
    where TValue : unmanaged
    where TAdapter : unmanaged, IMotionAdapter<TValue, StringOptions>
```

引数と戻り値

- `builder` (`this MotionBuilder<TValue, StringOptions, TAdapter>`) 設定済みのビルダー。拡張メソッドでは呼び出し元として渡されます。
- `richTextEnabled = true` (`bool`) 文字列の補間でリッチテキストを考慮するか。
- 戻り値: `MotionBuilder<TValue, StringOptions, TAdapter>`

[Runtime/Adapters/Strings/StringMotion.cs · L52](../../source/Runtime/Adapters/Strings/StringMotion.cs.html#L52)

## WithScrambleChars

未表示部分を埋める文字集合またはカスタム文字列を設定します。

```csharp
public static MotionBuilder<TValue, StringOptions, TAdapter> WithScrambleChars<TValue, TAdapter>( this MotionBuilder<TValue, StringOptions, TAdapter> builder, ScrambleMode scrambleMode)
    where TValue : unmanaged
    where TAdapter : unmanaged, IMotionAdapter<TValue, StringOptions>
```

引数と戻り値

- `builder` (`this MotionBuilder<TValue, StringOptions, TAdapter>`) 設定済みのビルダー。拡張メソッドでは呼び出し元として渡されます。
- `scrambleMode` (`ScrambleMode`) 未表示の文字を埋める文字集合。
- 戻り値: `MotionBuilder<TValue, StringOptions, TAdapter>`

[Runtime/Adapters/Strings/StringMotion.cs · L61](../../source/Runtime/Adapters/Strings/StringMotion.cs.html#L61)

```csharp
public static MotionBuilder<TValue, StringOptions, TAdapter> WithScrambleChars<TValue, TAdapter>( this MotionBuilder<TValue, StringOptions, TAdapter> builder, FixedString64Bytes customScrambleChars)
    where TValue : unmanaged
    where TAdapter : unmanaged, IMotionAdapter<TValue, StringOptions>
```

引数と戻り値

- `builder` (`this MotionBuilder<TValue, StringOptions, TAdapter>`) 設定済みのビルダー。拡張メソッドでは呼び出し元として渡されます。
- `customScrambleChars` (`FixedString64Bytes`) 未表示の文字を埋める文字集合。
- 戻り値: `MotionBuilder<TValue, StringOptions, TAdapter>`

[Runtime/Adapters/Strings/StringMotion.cs · L71](../../source/Runtime/Adapters/Strings/StringMotion.cs.html#L71)

## WithRandomSeed

スクランブルやShakeで使う乱数シードを設定します。

```csharp
public static MotionBuilder<TValue, StringOptions, TAdapter> WithRandomSeed<TValue, TAdapter>( this MotionBuilder<TValue, StringOptions, TAdapter> builder, uint seed)
    where TValue : unmanaged
    where TAdapter : unmanaged, IMotionAdapter<TValue, StringOptions>
```

引数と戻り値

- `builder` (`this MotionBuilder<TValue, StringOptions, TAdapter>`) 設定済みのビルダー。拡張メソッドでは呼び出し元として渡されます。
- `seed` (`uint`) 疑似乱数のシード。
- 戻り値: `MotionBuilder<TValue, StringOptions, TAdapter>`

[Runtime/Adapters/Strings/StringMotion.cs · L81](../../source/Runtime/Adapters/Strings/StringMotion.cs.html#L81)

```csharp
public static MotionBuilder<TValue, ShakeOptions, TAdapter> WithRandomSeed<TValue, TAdapter>( this MotionBuilder<TValue, ShakeOptions, TAdapter> builder, uint seed)
    where TValue : unmanaged
    where TAdapter : unmanaged, IMotionAdapter<TValue, ShakeOptions>
```

引数と戻り値

- `builder` (`this MotionBuilder<TValue, ShakeOptions, TAdapter>`) 設定済みのビルダー。拡張メソッドでは呼び出し元として渡されます。
- `seed` (`uint`) 疑似乱数のシード。
- 戻り値: `MotionBuilder<TValue, ShakeOptions, TAdapter>`

[Runtime/Adapters/Vibration/VibrationMotion.cs · L105](../../source/Runtime/Adapters/Vibration/VibrationMotion.cs.html#L105)

## WithFrequency

Punch・Shakeの振動の細かさを指定します。

```csharp
public static MotionBuilder<TValue, PunchOptions, TAdapter> WithFrequency<TValue, TAdapter>( this MotionBuilder<TValue, PunchOptions, TAdapter> builder, int frequency)
    where TValue : unmanaged
    where TAdapter : unmanaged, IMotionAdapter<TValue, PunchOptions>
```

引数と戻り値

- `builder` (`this MotionBuilder<TValue, PunchOptions, TAdapter>`) 設定済みのビルダー。拡張メソッドでは呼び出し元として渡されます。
- `frequency` (`int`) 振動の周波数設定。
- 戻り値: `MotionBuilder<TValue, PunchOptions, TAdapter>`

[Runtime/Adapters/Vibration/VibrationMotion.cs · L65](../../source/Runtime/Adapters/Vibration/VibrationMotion.cs.html#L65)

```csharp
public static MotionBuilder<TValue, ShakeOptions, TAdapter> WithFrequency<TValue, TAdapter>( this MotionBuilder<TValue, ShakeOptions, TAdapter> builder, int frequency)
    where TValue : unmanaged
    where TAdapter : unmanaged, IMotionAdapter<TValue, ShakeOptions>
```

引数と戻り値

- `builder` (`this MotionBuilder<TValue, ShakeOptions, TAdapter>`) 設定済みのビルダー。拡張メソッドでは呼び出し元として渡されます。
- `frequency` (`int`) 振動の周波数設定。
- 戻り値: `MotionBuilder<TValue, ShakeOptions, TAdapter>`

[Runtime/Adapters/Vibration/VibrationMotion.cs · L85](../../source/Runtime/Adapters/Vibration/VibrationMotion.cs.html#L85)

## WithDampingRatio

Punch・Shakeの振幅を時間とともに減衰させる比率を指定します。

```csharp
public static MotionBuilder<TValue, PunchOptions, TAdapter> WithDampingRatio<TValue, TAdapter>( this MotionBuilder<TValue, PunchOptions, TAdapter> builder, float dampingRatio)
    where TValue : unmanaged
    where TAdapter : unmanaged, IMotionAdapter<TValue, PunchOptions>
```

引数と戻り値

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

[Runtime/Adapters/Vibration/VibrationMotion.cs · L75](../../source/Runtime/Adapters/Vibration/VibrationMotion.cs.html#L75)

```csharp
public static MotionBuilder<TValue, ShakeOptions, TAdapter> WithDampingRatio<TValue, TAdapter>( this MotionBuilder<TValue, ShakeOptions, TAdapter> builder, float dampingRatio)
    where TValue : unmanaged
    where TAdapter : unmanaged, IMotionAdapter<TValue, ShakeOptions>
```

引数と戻り値

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

[Runtime/Adapters/Vibration/VibrationMotion.cs · L95](../../source/Runtime/Adapters/Vibration/VibrationMotion.cs.html#L95)

## WithShakeMode

揺れの計算方式をRandomとPerlinNoiseから選びます。

```csharp
public static MotionBuilder<TValue, ShakeOptions, TAdapter> WithShakeMode<TValue, TAdapter>( this MotionBuilder<TValue, ShakeOptions, TAdapter> builder, ShakeMode shakeMode)
    where TValue : unmanaged
    where TAdapter : unmanaged, IMotionAdapter<TValue, ShakeOptions>
```

引数と戻り値

- `builder` (`this MotionBuilder<TValue, ShakeOptions, TAdapter>`) 設定済みのビルダー。拡張メソッドでは呼び出し元として渡されます。
- `shakeMode` (`ShakeMode`) 揺れの計算に使うノイズ方式。
- 戻り値: `MotionBuilder<TValue, ShakeOptions, TAdapter>`

[Runtime/Adapters/Vibration/VibrationMotion.cs · L115](../../source/Runtime/Adapters/Vibration/VibrationMotion.cs.html#L115)

## Bind

構造体の状態をsetterに渡します。setterには補間値と状態がこの順で渡されます。

```csharp
public static MotionHandle Bind<TState>(this FloatMotionBuilder builder, TState state, Action<float, TState> action)
    where TState : struct
```

引数と戻り値

- `builder` (`this FloatMotionBuilder`) 設定済みのビルダー。拡張メソッドでは呼び出し元として渡されます。
- `state` (`TState`) setterの呼び出し時に補間値に続けて渡す状態。
- `action` (`Action<float, TState>`) 補間した値を受け取る処理。
- 戻り値: `MotionHandle`

[Runtime/Builders/MotionBuilderExtensions.cs · L7](../../source/Runtime/Builders/MotionBuilderExtensions.cs.html#L7)

```csharp
public static MotionHandle Bind<TValue, TOptions, TAdapter, TState>( this MotionBuilder<TValue, TOptions, TAdapter> builder, TState state, Action<TValue, TState> action)
    where TValue : unmanaged
    where TOptions : unmanaged, IMotionOptions
    where TAdapter : unmanaged, IMotionAdapter<TValue, TOptions>
    where TState : struct
```

引数と戻り値

- `builder` (`this MotionBuilder<TValue, TOptions, TAdapter>`) 設定済みのビルダー。拡張メソッドでは呼び出し元として渡されます。
- `state` (`TState`) setterの呼び出し時に補間値に続けて渡す状態。
- `action` (`Action<TValue, TState>`) 補間した値を受け取る処理。
- 戻り値: `MotionHandle`

[Runtime/Builders/MotionBuilderExtensions.cs · L11](../../source/Runtime/Builders/MotionBuilderExtensions.cs.html#L11)

## WithRoundingMode

intまたはlongの補間値を整数に変換するときの丸め規則を選びます。

```csharp
public static MotionBuilder<TValue, IntegerOptions, TAdapter> WithRoundingMode<TValue, TAdapter>( this MotionBuilder<TValue, IntegerOptions, TAdapter> builder, RoundingMode roundingMode)
    where TValue : unmanaged
    where TAdapter : unmanaged, IMotionAdapter<TValue, IntegerOptions>
```

引数と戻り値

- `builder` (`this MotionBuilder<TValue, IntegerOptions, TAdapter>`) 設定済みのビルダー。拡張メソッドでは呼び出し元として渡されます。
- `roundingMode` (`RoundingMode`) 整数補間の丸め規則。
- 戻り値: `MotionBuilder<TValue, IntegerOptions, TAdapter>`

[Runtime/Builders/MotionBuilderExtensions.cs · L19](../../source/Runtime/Builders/MotionBuilderExtensions.cs.html#L19)

## 関連する型

- [IMotionAdapter<TValue, TOptions>](../../api/imotionadapter-2/index.md)

- [MotionBuilder<TValue, TOptions, TAdapter>](../../api/motionbuilder-3/index.md)
