Skip to content

Developer Resources

Nico Borgsmüller edited this page Apr 11, 2023 · 8 revisions

Requirements

Windows: Visual Studio 2017 & Cities: Skylines installed, be running Windows 10 and have developer mode enabled. Linux/MacOS: msbuild (e.g. mono-msbuild) for compilation and Powershell (pwsh) to run the scripts.

Building

The mod can manually installed using the built in scripts. The following steps will guide you though this. This script will automatically pull in the required files (after specifying a folder), build the mod and then install it.

  1. Open the scripts folder.
  2. Run the following command in powershell or bash (if pwsh is installed) .\build.ps1 -Update -Build -Install. This will copy dlls from your game, build the mod and then install it.
  3. When you run this script, it will ask you for your game installation folder.
  4. Run Cities: Skylines and enable the mod.

Important locations

SteamApps default location

  • Windows: C:\Program Files\Steam
  • Linux: ~/.steam/steam/
  • MacOS: ~/Library/Application Support/Steam/

Steam Game installation directory:

  • Windows: <SteamDirectory>\SteamApps\common\Cities_Skylines\
  • Linux/MacOS: <SteamDirectory>/steamapps/common/Cities_Skylines/

Cities data folder:

  • Windows: %LOCALAPPDATA%\Colossal Order\Cities_Skylines
  • Linux: ~/.local/share/Colossal Order/Cities_Skylines
  • MacOS: ~/Library/Application Support/Colossal Order/Cities_Skylines

Mod installation folder:

  • Windows: <CitiesDataFolder>\Addons\Mods
  • Linux/MacOS: <CitiesDataFolder>/Addons/Mods

CSM log:

  • Windows: <CitiesDataFolder>\multiplayer-logs\log-current.txt
  • Linux/MacOS: <CitiesDataFolder>/multiplayer-logs/log-current.txt

Game log:

  • Windows: <GameInstallationDirectory>\Cities_Data\output_log.txt
  • Linux: ~/.config/unity3d/Colossal Order/Cities: Skylines/Player.log
  • MacOS: ~/Library/Logs/Unity/Player.log

Contributing

If you have access to the main project, create a new branch for your feature, work on it and then create a pull request when complete (or a draft pull request if still in development). Before a pull request can be merged, it must be approved, builds must run and it must be based off the latest code change to avoid conflicts.

If you don't have access to the main project, fork this project, make your changes and then create a pull request like above.

Creating a Command

  1. Create a new class under the CSM.Commands namespace (src/Commands/Data folder) with a suffux of Command (see other commands as an example).
  2. Adjust the class to extend CommandBase. Implement the class level attribute of [ProtoContract].
  3. Create your getters and setters, these should all be public and contain public level get and set, e.g. public Vector3 Position { get; set; }.
  4. Annotate your getters and setters using [ProtoMember(<number>)]. Start at 1 and work your way up.
  5. Make sure you document your getters/setters and class.
  6. Create a new class under the CSM.Commands.Handler namespace (src/Commands/Handler folder) with a suffix of Handler (see other handlers as an example).
  7. Adjust this class to extend CommandHandler<COMMAND> where COMMAND is your newly created command.
  8. Override other methods and implement logic.

Client-Server Model

This mod uses the client-server model. A user will setup their game as a server and transmit information like currency, roads, needs etc. to all connected clients. Clients will connect to the server and retrieve currency, roads, needs etc. from the server, updating the client UI.

This is all done by running a UDP server alongside Cities Skylines implemented by the LiteNetLib library.

Logic Flow

Below is information that I have jotted down about the flow of this mod.

Server:

  1. Open a level (new or existing).
  2. "Show Multiplayer Menu" --> "Host Game". User enters port and password (optional).
  3. Server is setup and message process queue is started. (Networking/Server.cs)

Message Queue:

  • Parse incoming messages and update game accordingly.
  • On extension changes, send a packet to all clients.

Client:

  • User launches game, enabled mod.
  • Click "Join Game".
  • Enter game IP address / port.
    • Connect the client using Networking/Client.cs.
    • Client connects to server (try) and performs setup functions (check mods/DLCs are the same etc.)
    • Download and load the map
    • On all events, update the server.
    • On incoming message, update client UI.

Steamworks

Cities Skylines uses version 1.36 of the steamworks sdk (Feb 9, 2016), you can find a download here.