-
Notifications
You must be signed in to change notification settings - Fork 2
Modding
Welcome to SimCovid Modding Page!
Modding SimCovid requires a basic understanding of C#. However, you don't have to be a good programmer to create mods in SimCovid if you follow the guides. Currently, SimCovid only supports modding via C# using SimCovidAPI. We have no plans to support in-game modding in the foreseeable future.
SimCovidAPI.dll is NOT released yet as of this writing, however, developers can build the dll files themselves in Unity.
SimCovid application reads the mods from (Build Directory)\SimCovid_Data\Mods, please see Folder Structure on how to set it up
SimCovid application reads every folder inside (Build Directory)\SimCovid_Data\Mods\ as a seperate mod, every folder in Mods folder should include the following:
- settings.json
- (Mod Name).dll
*Note: the folder name MUST be identical as the dll file name
Modding SimCovid requires the following tools:
- Visual Studio 2022 / JetBrains rider (recommended)
- Unity 2021.3.16f1 LTS
- SimCovidAPI.dll
1: Cloning the repository
Get SimCovid using git clone https://github.com/Anson-Cheung1227/SimCovid
.
2: Opening the Project with Unity
Open Unity Hub, navigate to Open->Add Project from disk, select the directory that you've cloned this project to.
Wait until Unity opens the Project.
Go to Window->TextMeshPro->Import TMP Essentials Resources
A prompt should pop up asking which resources you'd like to import, click All, and Import
Load All scenes
Go to File->Build Settings
Select all scenes to build, and make sure _boot has a build number of 0
Go to *(Build Directory)\SimCovid_Data\Managed* and find SimCovidAPI.dll
3: Creating a mods folder
Navigate to *(Build Directory)\SimCovid_Data\Mods*
Create a sub folder of your mod name
Open the IDE of your choosing, create a new class library under Dotnet framework
Select your project and click Add Reference
Add the following as a reference:
- SimCovidAPI.dll ((Build Directory)\SimCovid_Data\Managed)
- UnityEngine.dll ((Build Directory)\SimCovid_Data\Managed\ or Unity installation location)
*Please refer to the documentation of your IDE if you have issues with the steps above
The first step is to add the using directives to your C# file
using SimCovidAPI;
using UnityEngine;
After that, you can create a class that inherits from IMod in SimCovidAPI namespace
public class ExampleMod : IMod
{
}
Add a name and description to the mod by implementing the following properties
public class ExampleMod : IMod
{
public string Name { get { return "Example Mod"; } }
public string Description { get { return "Test Mod"; } }
}
Finally, you can implement the OnLoadMod() method! This will run once your mod has been loaded (only once). You should set up all the resources you need here.
public class ExampleMod : IMod
{
public string Name { get { return "Example Mod"; } }
public string Description { get { return "Test Mod"; } }
public void OnLoadMod()
{
Debug.Log("Hello from " + Name);
}
}
*Note: any classes that implements IMod MUST have a parameterless constructor
public ExampleMod() { }
Then, build your project.
Place your .dll file inside (Build Directory)\SimCovid_Data\Mods(YourModName)\
SimCovid application will read settings.json to obtain information about your mod. The "main" value MUST be set to the name of the class that implements IMod.
Navigate to (Build Directory)\SimCovid_Data\Mods(YourModName)\
Create a file called "settings.json"
Edit the file and provide the name of the class that implements IMod using the "main" value
{
"main" : "ExampleMod"
}
Lastly, save the file.
Congratulations! You've created your first mod in SimCovid!