Awesome
Cities Compiler Extender - CCE
A tool for Cities: Skylines for easier mod development.
TL;DR
Allows you to use more stuff in scripting mods without having to use an external compiler.
Why?
Cities: Skylines comes with a built-in C# compiler, which allows you to hot-compile and hot-load mod scripts while running the game. Unfortunately you can only use certain assemblies, which means that the mods developed this way are heavily limited, since the most powerful & useful APIs are not available.
Luckily, you can compile your mods with an external compiler to bypass the limitations, but by default the game won't reload your mods without a restart. You can delete your mod binary and change the assembly version every time you recompile it (which can be automated in an IDE) to enable hot-loading, but it is not ideal.
This tool gives you the ability to use additional assembly references in code-only mods. This is accomplished by modifying one of the game's assemblies (namely Assembly-CSharp.dll) to change the internal compiler's configuration to include Assembly-CSharp.dll and ColossalManaged.dll into the list of referenced assemblies.
Caveats
You have to (most likely) run this tool again after each game update. This tool might (and probably will) stop working at some point in the future, because it relies on the bytecode of Starter.Awake() not changing too much.
How to use
.NET
CCE path-to-the-game-directory
Mono
mono CCE path-to-the-game-directory
The path must be an absolute path to the game's installation directory (for example "C:/Program Files (x86)/Steam/steamapps/common/Cities_Skylines"). The tool creates a new file, which is called Assembly-CSharp.mod.dll, in Cities_Data/Managed. This tool won't overwrite the existing Assembly-CSharp.dll. You have to backup the current version of the file and replace it yourself with the modified version.
How to build
A Visual Studio project file is included. Alternatively, you can build the project with the included makefile (which requires Mono in system path). The project requires Mono.Cecil, which is included in /Dependencies.
Prebuilt binaries
Not currently available.
Todo
- Separate Debug and Release targets for Makefile
- Automatic backup & replacement of Assembly-CSharp.dll
- Better error handling
- For example, a warning if the .dll has been already modified
License
See LICENSE.txt.