Basic project setup - rspforhp/WildfrostModdingDocumentation GitHub Wiki

Basic Setup

Table of Contents:

Installing an IDE

If you already have an IDE for C#, skip this section. Otherwise, here are the steps to install Visual Studios:

  1. Find and download some version of Visual Studio (the purple logo). Here is the Microsoft website: https://visualstudio.microsoft.com/


  1. Run the installer. It will ask you which workloads you want to install. You must install "ASP.NET and web development" or something similar. Optionally, you would also want to install "Game Development with Unity" though this is not necessary.


  1. Wait for the installation to finish.

New Project/Solution

In your prefered IDE(Visual Studio/Jetbrains Rider) create a solution with such settings

image

or a project from this template

Warning

The project has to have these exact settings. It must be a Class Library that targets .NET Framework 4.7.2, not .NET or .NET Standard


Your IDE should look something like this

image

Tip

For most cases, all your code should stay within the boundaries of this main class. That is, everything between the highlighted curly brackets { }.


Add & Use References

Firstly we have to add references to game dlls, press the "add reference..." button and locate them in [GameRoot]/Modded/Wildfrost_Data/Managed folder. ([GameRoot] is usually C:/Program Files (X86)/Steam/steamapps/common/Wildfrost. If not, you can figure out where [GameRoot] is by right-clicking Wildfrost on Steam and going to Properties > Installed Files > Browse.).

The essential references are Assembly-CSharp.dll, 0Harmony.dll, DeadExtensions.dll, and the dlls starting with "Unity". You are recommended to add all of them EXCEPT mscorlib.dll and the dlls starting with "System". Trying to add those references will typically throw an error.

image

Now, we have to tell the code that we are using parts of the dlls we just referenced, usually their type or namespace. Add these lines at the top of your code:

using Deadpan.Enums.Engine.Components.Modding; // this allows us to make WildfrostMod's
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

Tip

Error CS0246: "The type or namespace name 'WildfrostMod' could not be found"
Errors like this usually show up when you're missing a using statement. If you come across this despite adding all references, Visual Studio can suggest a fix: Right-click the part underlined in red, and select "Quick Actions". Some options will drop down, one of should be a using statement. {B39A5253-BD92-4A67-87F6-EE304C72B8EB}


Overriding the WildfrostMod

Next we have to derive (or extend) our main class from the WildfrostMod class, by adding : WildfrostMod after the name of the class. This allows us our class to override (or inherit) properties that are needed for a WildfrostMod. For now, you'll immediately be hit with 4 errors:

Errors: OurMod doesn't implement inherited WildfrostMod properties

The way we implement these is by overriding those properties (by literally writing override <name> to override the <name> property). While it doesn't error, you'll also need to implement a special constructor. No need to worry what this means, other than that any code put here will always run when the game starts.

// ... usings

namespace ProjectName
{
   public class OurMod : WildfrostMod
   {
      // Our mod's constructor
      public OurMod(string modDirectory) : base(modDirectory)
      {
      }
      
      public override string GUID => "yourName.wildfrost.projectName"; //[creator name].[game name].[mod name] is standard convention. LOWERCASE!
      public override string[] Depends => new string[] { }; //The GUIDs of other mods that must load before yours. Usually empty
      public override string Title => "Mod title";
      public override string Description => "Mod description";
   }
}

The Title and Description variables are the title and description of your mod respectively. As titles are not unique, the GUID (Globally Unique IDentifier) serves as the unique identifier for your mod. All builders will automatically prefix names with the GUID. The typical convention is [name].[game name].[mod name], so a card that you add in the game via CardDataBuilder is named [name].[game name].[mod name].[card name] internally. The Depends variable is used to list the other mods (by GUID) that your mod depends on. The game will ensure all mods listed in depends are loaded before yours.

Now we have a basic mod project all set up! Look at other pages for more tutorials.


Debug with Line Numbers

By default, errors thrown during Wildfrost will indicate what class/method the error occurs in but not the line number. To fix this for your mod code, head to the settings of your project. In Visual Studios, this can be done by double-clicking Properties in the solution explorer (see the first picture in the Add & Use References section). In the settings, go to Build > Output > Advanced > Debugging Information and change "Full" to "Embedded" as shown below. Now your code will be easier to debug!


image


Advanced Setup - Assembly Stripping

This part of the project set up is not necessary to do immediately. Come back later once you have read/done other things. Assembly stripping is meant to give you access to originally inaccessible (private) variables and methods.

See Advanced Project Setup - Assembly Stripping for more

⚠️ **GitHub.com Fallback** ⚠️