# EngineModeSwapper

`EngineModeSwapper` replaces one or more stock engine-mode entries with variant-specific `EngineMode` definitions.

## Purpose

Use this transformer when a variant changes how an engine behaves, such as swapping propellants, thrust curves, or localized engine-mode labels. It is the main V-SwiFT bridge between variant authoring and the stock [`Data_Engine`](https://docs.ksp2redux.org/doc/data_engine-l8dN8uxbGx) / [`EngineMode`](https://docs.ksp2redux.org/doc/enginemode-8kM38hVGCK) structures.

## Type

Source-backed runtime type: `VSwift.Modules.Transformers.EngineModeSwapper`

## Fields

* `Modes`: `List<Data_Engine.EngineMode>`
* `Name`: `string`
* Replacement is keyed by `engineID`, so each provided mode should target an existing stock engine-mode entry

## Behavior

* `ApplyCommon`: no effect
* `ApplyInOab`: clones the current `Data_Engine`, replaces any `engineModes` whose `engineID` matches a provided entry, rebuilds the data context, and reinitializes `Module_Engine`
* `ApplyInFlight`: no effect

## State handling

* Reverter: yes, via `EngineModesReverter.Instance`
* Saves information: yes, through `EngineModeSwapLoader`
* Visualizes information: yes

## Visualization

When shown in the part-actions manager popup, this transformer builds stat blocks for:

* propellant
* sea-level and vacuum thrust
* sea-level and vacuum ISP

## Example

This fragment is intentionally abbreviated. The `Modes` entries use the same shape as the stock `EngineMode` data documented in the engine reference.

```patch
@use "VSwift:*"

@parts {
  #my_engine_part {
    @include part-switch() {
      VariantSets +: [{
        VariantSetId: "propellant",
        VariantSetLocalizationKey: "MyMod/VSwift/Propellant",
        Variants: [{
          VariantId: "vacuum",
          VariantLocalizationKey: "MyMod/VSwift/Vacuum",
          Transformers: [{
            Name: "EngineModeSwapper",
            Modes: [{
              engineID: "main",
              EngineDisplayName: "MyMod/VSwift/EngineMode/Vacuum"
            }]
          }]
        }]
      }];
    }
  }
}
```

## Caveats

* The swap is keyed by `engineID`. If the target ID does not exist on the base part, nothing will be replaced.
* The page-level snippet above is not a complete engine-mode definition; for a production patch, provide the full `EngineMode` payload.
* Runtime support is OAB-focused. The current transformer does not implement an in-flight mode swap path.

## Related

* [Patch Manager integration](https://docs.ksp2redux.org/doc/patch-manager-integration-gBAA7yXoEM)
* [Data_Engine](https://docs.ksp2redux.org/doc/data_engine-l8dN8uxbGx)
* [EngineMode](https://docs.ksp2redux.org/doc/enginemode-8kM38hVGCK)