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
-
Set up your development environment using the Development Environment guide.
-
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. -
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'sContent 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.";
}
} -
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 theOnUpdateMoneyAmount
method to set the player's budget to the maximum value and theOnPeekResource
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;
}
} -
Build the project by pressing
Ctrl + Shift + B
in Visual Studio. -
Copy the generated
dll
file from thebin
folder to theMods
folder in the game's installation directory. -
Start the game and enable the mod in the
Content Manager
. -
Enjoy your new mod!s