Captain-Of-Coit / cities-skylines-2-mod-template

Starter template for Cities Skylines 2 modding with BepInEx and Harmony

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cities: Skylines 2 - C# Mod template

This repository template allows you to get started with Cities: Skylines 2 modding easily, all the way to building your mod on commit with GitHub Actions and publishing your mod automatically on Thunderstore.

Requirements

Usage

  • Create a new repository based on this one
  • Clone your new repository to your computer
  • Uncomment and update the Cities2_Location variable in MyCoolMod.csproj
  • Run make build

After running the last command, the mod should be automatically copied to your game directory, so launching the game should include running the mod you just started :)

Renaming your project

You can leverage the helper script in scripts/rename.csx in order to replace "MyCoolMod" with whatever you want to name your project. Usage:

$ dotnet script scripts\rename.csx "MyCoolMod" "AnotherModIMade"

Set license details

You'll need to update LICENSE with the correct details for <Year> and <Author>, and change "MyCoolMod" to your mod name if you haven't already.

Incrementing version number

  • Update .csproj file with new version number
  • Update thunderstore.toml file with new version number
  • Update CHANGELOG to describe the changes you've made between this and previous version
  • Commit version bump
  • Do a git tag with the new version number
    • git tag -a v0.2.0 -m v0.2.0
  • Push your changes + tags
    • git push origin master --tags

CI / GitHub Actions - Setup

In order to get the CI/GitHub Actions workflow to work, you have to do a couple of things.

  • Create a new private repository with all the game DLLs that you require for building your mod
  • Create a new GitHub Personal Access Token ("PAT") that has only READ access to the created private repository
  • Create a new secret variable in GitHub Actions called GH_PAT that has your PAT with read access to the private repository

Now the CI job should work as expected :)

Regarding BepInEx version 5 (Stable) VS 6 (Alpha/Unstable/Nightly)

Currently, this mod template defaults to building against BepInEx version 6 (unstable pre-release). If you'd like to instead use Stable BepInEx version 5, you can run the build like this:

$ make build BEPINEX_VERSION=5

In order to run code only for one BepInEx version, you can do something like this:

#if BEPINEX_V6
    using BepInEx.Unity.Mono;
#endif

That would only run using BepInEx.Unity.Mono when you're building the project for BepInEx 6. Add in a else if you want to do something different when it's version 5.

Credits

  • Thanks to Cities Skylines 2 Unofficial Modding Discord
  • Particular thanks to @StudioLE who helped with feedback and improving .csproj setup

Community

Looking to discuss Cities: Skylines 2 Unofficial modding together with other modders? You're welcome to join our "Cities 2 Modding" Discord, which you can find here: https://discord.gg/vd7HXnpPJf

About

Starter template for Cities Skylines 2 modding with BepInEx and Harmony

License:Other


Languages

Language:C# 91.9%Language:Makefile 8.1%