License | Commit Rate | Sponsers | Issues |
---|---|---|---|
This is a template for modifications which mod the game The Long Dark. Unlike other templates, this one contains alot of extra code. This is intended to provide newer modders with the nessesary functions that have already been fully optimized. This will help ensure less messy mods.
Either download the repo as a zip, download via git fetch or Github Desktop or you can fork the repo.
Which ever way you use, rename TEMPLATE.cs
and TEMPLATE.csproj
to match your namespace.
Then go into TEMPLATE.cs
and rename the namespace using F2
(if your using Visual Studio or Visual Studio Code). This will rename the namespace wherever its used. This includes all using directives.
As you can see, this template uses a very clean folder structure to ensure things dont get messy. All content relating to each part of a mod has its own folder. ModComponent
files go into Distribuitable
, Unity Editor project files go into Unity
and the assembly files go into VisualStudio
.
For the most part, you can technically put any file anywhere. However this is a bad habit as it can be hard to read such a mod. The only absolutly required file location is the AssemblyInfo.cs
file, which must be in VisualStudio\Properties\AssemblyInfo.cs
as otherwise it will not be properly read by Visual Studio.
NAMESPACE
: TEMPLATE.Patches
Path: VisualStudio\Patches
You should put your patches into this folder, using a single file per patch. Example:
namespace TEMPLATE
{
[HarmonyPatch(typeof(Panel_FirstAid), nameof(Panel_FirstAid.Enable), new Type[] { typeof(bool) })]
public class Panel_FirstAid_Enable
{
public static void Postfix(Panel_FirstAid __instance)
{
// do stuff
}
}
}
NAMESPACE
: N/A
Path: VisualStudio\Properties
This folder is for assembly related stuff. For instance, this is where you will always find the AssemblyInfo.cs
file.
NAMESPACE
: (Optional)TEMPLATE.Settings
Path: VisualStudio\Settings
This folder is used for your settings file. As some mods have multiple settings pages, this folder was made to handle such situations
NAMESPACE
: TEMPLATE.Utilities
Path: VisualStudio\Utilities
This folder contains all your utilities.
NAMESPACE
: TEMPLATE.Utilities.Enums
Path: VisualStudio\Utilities\Enums
This folder contains all your enums
NAMESPACE
: TEMPLATE.Utilities.Exceptions
Path: VisualStudio\Utilities\Exceptions
This folder contains all your custom exceptions
NAMESPACE
: TEMPLATE.Utilities.JSON
Path: VisualStudio\Utilities\JSON
This folder contains files related to hanlding json
files. This includes a complete class which can load and save those files, both synchronous
and asynchronous
.
NAMESPACE
: TEMPLATE.Utilities.Logger
Path: VisualStudio\Utilities\Logger
This contains the custom logger I have created for everyone. Allows for level based logging instead of build flag based logging
If all you want is the bare minimum, you will want to download the template, then delete the following folders/files:
VisualStudio\Settings
VisualStudio\Utilities
VisualStudio\Spawner.cs