Modding Basics - Cities: Skylines Wiki (2024)

This article is timeless and should be accurate for any version of the game.

Contents

  • 1 Getting Started
    • 1.1 Namespace
    • 1.2 Using directives
    • 1.3 IUserMod
  • 2 Modding Basics
    • 2.1 Unity
    • 2.2 Basic mods
      • 2.2.1 Example
      • 2.2.2 Managers
      • 2.2.3 Modding API
    • 2.3 Advanced mods
      • 2.3.1 Singletons
  • 3 See also

After you've setup your basic or advanced mod it's time to actually start making a mod.This page will cover how to get started and all the basics of modding.

Getting Started[edit | edit source]

The first thing you do to create a mod is to create a class that implements IUserMod.This is the start point for any mod and by implementing IUserMod the game will be able to load your mod.

Namespace[edit | edit source]

Your mod should always be within a namespace.The name of the namespace doesn't matter that much but it's recommended to just use the name of your mod.This will prevent conflicts with other mods and it will keep your projects more organized by scoping your code within your namespace.

Using directives[edit | edit source]

To properly use the ICities API and other assemblies you have to add the using directives.In most cases you'll be using ICities and UnityEngine so start of by adding these lines in your code.

using ICities;using UnityEngine;

IUserMod[edit | edit source]

By implementing IUserMod you have to specify a Name and Description for your mod.These are used within the Content Manager to display your mod.The initial code for your mod should then look something like this and you should be able to load it in the content manager.

using ICities;using UnityEngine;namespace ModName {public class ModName: IUserMod {public string Name {get { return "Mod Name"; }}public string Description {get { return "My first awesome mod that doesn't do anything! *JEEY*"; }}}}

Modding Basics[edit | edit source]

Now that you have a working mod it's time to make it actually do something.This differs for each mod obviously but here are some things you should know to get started.There are millions of possibilities what your mod can do so after this you'll be on your own to figure out how to convert your ideas into an actual mod.There are still a lot of other guides you can read to learn how to do specific things.

Unity[edit | edit source]

The game is built in Unity which means you have access to all the functionality Unity offers in both basic and advanced mods.For example you could create game objects and monobehaviours, render UI elements, use physics and a bunch of other things.Check out the Unity Manual or the Unity API to learn how Unity works and to see what you can do.

Basic mods[edit | edit source]

For basic mods you'll mostly be implementing interfaces and extending the base classes.

Example[edit | edit source]

If you add this class to your mod you get unlimited oil and ore resources.Classes can be added in your main file or by creating a new file.

public class UnlimitedOilAndOreResource: ResourceExtensionBase { public override void OnAfterResourcesModified(int x, int z, NaturalResource type, int amount) { if ((type == NaturalResource.Oil || type == NaturalResource.Ore) && amount < 0) { resourceManager.SetResource(x, z, type, (byte)(resourceManager.GetResource(x, z, type) - amount), false); } }}

If we break this down you can see that we create a new class that extends ResourceExtensionBase.By doing this we can override an API method OnAfterResourcesModified which gets executed when a natural resource is modified.We then do some checks to make sure we're only overriding oil and ore.The last thing it does is actually modify the resource by using the resourceManager.There are a lot of managers that can be used to modify things and get values so you'll mostly be using managers and calling their methods.

Managers[edit | edit source]

All interfaces/base classes have a OnCreated method which provides you with the related manager.For example if you extend LoadingExtensionBase you can override the OnCreated method and you'll get the ILoading manager.Each manager interface also has a reference to all other managers.

public class LoadingExample: LoadingExtensionBase {public override void OnCreated(ILoading loading) { loading.managers.milestones.UnlockMilestone("Basic Road Created");}}

As you can see here we get a reference to the ILoading manager but then we access all managers and are able to access the milestones manager.We can then unlock the 'Basic Road Created' milestone when a level is loaded.For more information see the managers info on the modding page.

Modding API[edit | edit source]

The next step is to look at the Modding API and see what you can do.It describes all the classes and interfaces within the ICities assembly.

Advanced mods[edit | edit source]

Apart from the things you can do in basic mods you have a lot more possibilities.There are a lot of guides explaining how to do specific things so make sure to take a look at them.You'll mostly be Reverse Engineering the CS code to figure out what exactly you can do.By using Reflection you can go even further but this is for more advanced programmers only.

Singletons[edit | edit source]

There are a lot of singletons in the game for managers and other things.This will be the starting point for most things you do to modify the game.For example to simply pause the game you could do this.

Singleton<SimulationManager>.instance.SimulationPaused = true;

Most Manager instances can also be referenced using the static instance property, which wraps the Singleton, the above example becomes:

SimulationManager.instance.SimulationPaused = true;

See also[edit | edit source]

  • Modding
Modding Basics - Cities: Skylines Wiki (2024)
Top Articles
Latest Posts
Article information

Author: Wyatt Volkman LLD

Last Updated:

Views: 5880

Rating: 4.6 / 5 (46 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Wyatt Volkman LLD

Birthday: 1992-02-16

Address: Suite 851 78549 Lubowitz Well, Wardside, TX 98080-8615

Phone: +67618977178100

Job: Manufacturing Director

Hobby: Running, Mountaineering, Inline skating, Writing, Baton twirling, Computer programming, Stone skipping

Introduction: My name is Wyatt Volkman LLD, I am a handsome, rich, comfortable, lively, zealous, graceful, gifted person who loves writing and wants to share my knowledge and understanding with you.