Skip to content

tobspr-games/shapez2-mod-samples

Repository files navigation

Complete documentation here

The Shapez 2 Example Mods solution contain small sample projects that cover the 101 of modding shapez 2

Requirements

  • Shapez2 1.0.0
  • ShapezShifter - MonoMod based Shapez2 base API
  • Visual Studio (recommended) or Rider or VSCode

For MacOS users, patching with either MonoMod, HarmonyX, MelonLoader, tModLoader, BepInEx, require running the game with Rosetta

Shapez Shifter

For the example mods to compile and execute properly, we need a copy of the Shapez Shifter mod. There are two ways to go about it:

Steam Workshop: The mod is available as an item in the Steam Workshop here. However, access to the workshop is limited and the access will be gradually granted

Source: You can grab a copy of the mod source code on Github and compile it yourself

Installation

The projects is configured for very easy installation with Visual Studio and fairly straightforward with other IDEs. It only requires three environment variables:

  1. SPZ2_PATH: Pointing to the game folder containing the managed assemblies
  2. SPZ2_PERSISTENT: Should point to Unity's Application.persistentDataPath
  3. SPZ2_SHIFTER: Points to the Shapez Shifter mod location

On Windows, these can be set automatically by the game by running the game with the command line argument --set-modding-env-vars. You can also add them manually to your environment variables

On Unix, these must be set somehow. My recommendation for MacOS is using the .zprofile to export the variables and then opening Visual Studio from the console.

After these variables are set, it is as easy as building the solution and the mods should already be available in the game. The project will automatically link the game references and the ShapezShifter API.

Building

If the installation was successful, you should be able to build the example mods

Diagonal Cutter

The most complete official mod example to date. It adds a new building to the game, a diagonal cutter that destroys the odd parts of a shape. The project uses the ShapezShifter mod and highlights how to use its fluent API to create an atomic building while covering how to:

  • Add a new building and building group to the current scenario game data
  • Add a new specialized stateful simulation that can cutter the diagonals of a shape
  • Add a new simulation system to the simulation loop that pattern matches for the building and creates the simulation
  • Add a new placer for the building
  • Add a new toolbar entry for the placer
  • Add a new set of modules to be displayed by the HUD when the building is selected
  • Load a custom .FBX model and using it for the static rendering
  • Add new translation entries for the building
  • Add a new dynamic renderer for rendering the building current state
  • Add progression requirements to unlock the building

Sandbox Islands

This mod is very similar to the Diagonal Cutter in the sense that it highlights how to add an entity (in this case an island) with simulation. The mod adds a new island to the game for discarding paint conveniently. Similarly to the diagonal cutter it also uses the ShapezShifter mod and demonstrate how to extend the game data, research, simulation systems, placement system, toolbar, localization and rendering

Bigger Foundations

This mod example also shows how to add an island, but focusing in the data requirements for creating new foundation platforms

About

Modding examples for Shapez2 using the official Shapez 2 modding API (Shapez Shifter)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published