Skip to main content

Creating a new mod

Introduction

This guide will walk you through the process of creating a new mod for Cities: Skylines. It will cover the basics of creating a new mod by referencing the Unlimited Money mod from the Game.

Steps

  1. Set up your development environment using the Development Environment guide.

  2. Create a new file with the name of your mod in the Source folder. For example, InfiniteResources.cs. For simplicity, we will use a single file for the mod's logic. In a real-world scenario, you would create a new folder for your mod and split the logic into multiple files.

  3. Add the following code to your new file.

    This code implements the IUserMod interface, which is required for all mods. It provides the name and description of the mod that will be displayed in the game's Content Manager.

    using ICities;
    using UnityEngine;

    namespace UnlimitedMoney.source
    {
    public class UnlimitedMoney : IUserMod
    {
    public string Name => "Unlimited Money";
    public string Description => "Adds unlimited money to the game.";
    }
    }
  4. Create the class that will handle the mod's logic.

    This code implements the EconomyExtensionBase class, which is used to modify the game's economy system. It overrides the OnUpdateMoneyAmount method to set the player's budget to the maximum value and the OnPeekResource method to allow the player to peek at any amount of resources.

    public class UnlimitedMoney : EconomyExtensionBase
    {
    public override long OnUpdateMoneyAmount(long budget)
    {
    return long.MaxValue;
    }

    public override bool OverrideDefaultPeekResource
    {
    get { return true; }
    }

    public override int OnPeekResource(EconomyResource resource, int amount)
    {
    return amount;
    }
    }
  5. Build the project by pressing Ctrl + Shift + B in Visual Studio.

  6. Copy the generated dll file from the bin folder to the Mods folder in the game's installation directory.

  7. Start the game and enable the mod in the Content Manager.

  8. Enjoy your new mod!s