Patches train unloaders to remove the gap when switching containers.
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Underscore Nul 6ccf378407 Initial commit
Tested on Linux under Proton

Signed-off-by: Underscore Nul <underscore.nul@proton.me>
2026-08-08 20:02:30 -05:00
.gitignore Initial commit 2026-08-08 20:02:30 -05:00
GameBindings.cs Initial commit 2026-08-08 20:02:30 -05:00
LICENSE-APACHE Initial commit 2026-08-08 20:02:30 -05:00
LICENSE-MIT Initial commit 2026-08-08 20:02:30 -05:00
manifest.json Initial commit 2026-08-08 20:02:30 -05:00
README.md Initial commit 2026-08-08 20:02:30 -05:00
TrainCargoUnloaderSimulationPatch.cs Initial commit 2026-08-08 20:02:30 -05:00
TrainFix.cs Initial commit 2026-08-08 20:02:30 -05:00
TrainFix.csproj Initial commit 2026-08-08 20:02:30 -05:00
TrainFix.Local.props.example Initial commit 2026-08-08 20:02:30 -05:00
TrainFix.slnx Initial commit 2026-08-08 20:02:30 -05:00
TrainUnloaderPatch.cs Initial commit 2026-08-08 20:02:30 -05:00

TrainFix

TrainFix is a small shapez 2 mod that fixes the periodic output gap produced by train unloaders when switching between cargo containers.

The game currently models additional container travel inside the unloader station. This can introduce unavoidable bubbles in otherwise saturated output belts.

TrainFix preserves the physical movement of cargo containers from trains into the station, but makes switching to the next container already buffered inside the station effectively instantaneous.

Status

TrainFix is currently developed against the experimental Unity 6.3 build of shapez 2.

The mod relies on internal game implementation details and may require updates when shapez 2 changes its train simulation.

Requirements

MonoMod.RuntimeDetour is also declared as a mod dependency and must be installed for TrainFix to load.

Installation

Steam Workshop

Subscribe to TrainFix and its required MonoMod.RuntimeDetour dependency through the Steam Workshop.

Manual installation

Place the following files in a TrainFix directory inside the shapez 2 local mods directory:

TrainFix/
├── TrainFix.dll
└── manifest.json

The shapez 2 persistent data directory is:

Windows

%USERPROFILE%\AppData\LocalLow\tobspr Games\shapez 2\

Linux

~/.config/unity3d/tobspr Games/shapez 2/

macOS

~/Library/Application Support/tobspr Games/shapez 2/

Place the TrainFix directory under the mods directory within that location.

Building

TrainFix targets .NET Standard 2.1 and compiles against the managed assemblies from a local shapez 2 installation.

Clone the repository and copy the example local configuration:

cp TrainFix.Local.props.example TrainFix.Local.props

Edit TrainFix.Local.props for the platform and installation you want to use.

The configuration needs three paths:

  • SPZ2_PATH — directory containing the shapez 2 managed assemblies
  • MonoModRuntimeDetour — path to MonoMod.RuntimeDetour.dll
  • SPZ2_MOD_PATH — optional local mod directory used for automatic deployment

Examples for Windows, Linux, macOS, and Proton are included in TrainFix.Local.props.example.

TrainFix.Local.props contains machine-specific paths and is intentionally not tracked by Git.

Build normally:

dotnet build

or:

dotnet build -c Release

If SPZ2_MOD_PATH is configured, successful builds automatically deploy TrainFix.dll and manifest.json into the configured local mod directory.

TrainFix itself is a managed .NET assembly. The build is not platform-specific; Windows, Linux, and macOS builds use the same TrainFix assembly.

How it works

TrainFix hooks creation of shape cargo unloader simulations using MonoMod.RuntimeDetour.

The original TrainCargoUnloaderSimulation<ShapeId> remains responsible for train interaction, state, and serialization. TrainFix wraps the connectable simulation used by the station and modifies only the package transition behavior.

When the active cargo package becomes empty:

  1. Normal train and bridge simulation runs first.
  2. If another container has already entered the station, TrainFix promotes only the frontmost buffered container to the unloading position.
  3. The new package is made available to the output belts without granting it additional simulated movement time.
  4. Containers still traveling from the train to the station continue to use the game's normal movement timing.

This prevents the periodic package-switch bubble without making trains unload cargo that has not yet reached the station.

Compatibility

TrainFix accesses several internal shapez 2 implementation details using reflection. These are validated when the patch is installed so incompatible game updates should fail explicitly rather than silently changing simulation behavior.

Because of this, compatibility with future shapez 2 releases is not guaranteed.

TrainFix does not alter its save-game format and does not replace the underlying train unloader state used by shapez 2 serialization.

Achievements

TrainFix does not disable achievements. This is because I (personally) maintains the spirit of what was intended by the game developers, while fixing a minor throughput bug.

License

TrainFix is licensed under either of:

  • Apache License, Version 2.0
  • MIT License

at your option.

See LICENSE-APACHE and LICENSE-MIT.

SPDX-License-Identifier: MIT OR Apache-2.0

shapez 2 is developed by tobspr Games. TrainFix is an independent community mod and is not affiliated with or endorsed by tobspr Games.

MonoMod.RuntimeDetour is a separate project and is distributed under its own license.