Modding Cities Skylines game - AD-EYE/AD-EYE_Core GitHub Wiki
Summary
Get started
Useful links
- CSL Modding page
- Modding API - Cities: Skylines
- For Mod Setup
- Modding Basic
- ILSpy C# Decompiler
- Boformer's tutorials Very useful
Visual Studio setup
- Download Visual Studio 2019, choosing "Community".
- Open the "Visual Studio Installer" then. Select .NET desktop development and then select the .NET Framework of your choice.
- Open Visual Studio 2019 and create a new project, find and select Class Library (.NET Framework)
- Give the project a name, the location should be here →
C:\Users\adeye\AppData\Local\Colossal Order\Cities_Skylines\Addons\Mods
. There should be a way to use the location of your choice but so far this method works. Do not forget to tick "Place solution and project in the same directory"
Write a simple mod
- First, the reference have to be added to the project. Go to References → Add Reference → Browse
C:\Program Files (x86)\Steam\steamapps\workshop\content\255710\530771650
(for PrefabHook - it is a game mod needed to make the mod working)
C:\Program Files (x86)\Steam\steamapps\common\Cities_Skylines\Cities_Data\Managed
(for all the important assemblies)
- After selecting the assemblies (in the picture above the most important ones are highlighted ) add them and tick them.
-
We can now write a litte first mod: There is a class called class1.cs, delete it (or rename it). Right click on the .csproj → Add → New Item → Class → Give your class a name (for instance "MyFirstMod") → Click on Add.
-
Replace all the code with:
using System; using ICities; namespace Wiki { public class MyFirstMod : IUserMod { public string Name => "First Mod"; public string Description => "My First Mod"; } }
-
Right click on the .csproj (here it is called Wiki) go to properties then Build Events copy and paste the following for the post build event:
_mkdir "%25LOCALAPPDATA%25\Colossal Order\Cities_Skylines\Addons\Mods\$(SolutionName)" del "%25LOCALAPPDATA%25\Colossal Order\Cities_Skylines\Addons\Mods\$(SolutionName)\$(TargetFileName)" xcopy /y "$(TargetPath)" "%25LOCALAPPDATA%25\Colossal Order\Cities_Skylines\Addons\Mods\$(SolutionName)"_
-
IMPORTANT NOTE: Unfortunatly, the post build event sometimes won't work. In that case, copy (From →
C:\Users\adeye\AppData\Local\Colossal Order\Cities_Skylines\Addons\Mods\Wiki\bin\Debug
)
and paste (here →C:\Users\adeye\AppData\Local\Colossal Order\Cities_Skylines\Addons\Mods\Wiki\
) the .dll (with the name of the project, here it is Wiki.dll)
- Open the game → Content manager → Mod (or Camera Script). If the mod does not appear, make sure you have copied the .dll to the good place, and restart the game. The mod is likely to appear in "Camera Script" but when some improvement will be made, the mod might change its location to "Mod".
- Toggle the button On/Off to activate or desactivate the mod (the mod does nothing yet).
Using ModTools for reverse engineering
-
ModTools is a Mod for Cities: Skylines Steam ModTools: For more info
-
By clicking the arrow on top right corner, the objects explorer will be enabled. By hoovering with the mouse on an object, its ID and asset name can be seen. It works for cars, buildings, roads, pedestrians...
- When hoovering on a car, open the scene explorer by clicking on the left mouse button. It will open all information related to the selected car for instance: his ID, his location, his velocity, the current path ID and many more.The "path" of the selected vehicle appears at the top of the window, it is important when coding because it shows from where the selected objects can be accessed (the class name for instance, for vehicles it will be VehicleManager).
- Clicking on the road will also open the scene explorer. From there it is possible to have access to the "path", the class is called "NetManager",it deals with the roads. This road is surrounded by nodes, it is possible to have access to the IDs of those nodes. In addition, the left and right roads can be accessible (if they are existing).
- By clicking on the nodes, you will also have access to the node's information:
- If we go back to the vehicles scene explorer, one can find something called Path. At the right there is a button called "Show path unit" and clicking on it will show you the following (see below). A path is composed of 12 positions (road segments). When we are at the end of the path, an other path is attributed to the vehicle.
Parameters for data collection
- There are four parameters displayed here:
- The opening angle will ignore everything that is not in front of the vehicle, see the angle below:
- The "Angle moving forward" will ignore the vehicles going the same way that the vehicle collecting data.
- The "Angle moving backward" will ignore the vehicles going the same way but in the other direction that the vehicle collecting data.
- And the distance from the vehicle.