Skip to content

A template for making mods in the game The Long Dark

License

Notifications You must be signed in to change notification settings

Arkhorse/TLD-Mod-Template

Repository files navigation

License Commit Rate Sponsers Issues
GitHub Github GitHub Sponsors GitHub issues

About

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.

Usage

Initial Steps

Step One

Either download the repo as a zip, download via git fetch or Github Desktop or you can fork the repo.

Step Two

Which ever way you use, rename TEMPLATE.cs and TEMPLATE.csproj to match your namespace.

Step Three

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.

Folder Structure Adherence

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.

ModComponent Structure

Unity Editor Structure

Assembly Structure

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.

Patches

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
        }
    }
}

Properties

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.

Settings

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

Utilities

NAMESPACE: TEMPLATE.Utilities
Path: VisualStudio\Utilities
This folder contains all your utilities.

Enums

NAMESPACE: TEMPLATE.Utilities.Enums
Path: VisualStudio\Utilities\Enums
This folder contains all your enums

Exceptions

NAMESPACE: TEMPLATE.Utilities.Exceptions
Path: VisualStudio\Utilities\Exceptions
This folder contains all your custom exceptions

JSON

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.

Logger

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

Minimal Usage

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

Nugets

Nuget Nuget Nuget Nuget Nuget Nuget Nuget

About

A template for making mods in the game The Long Dark

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published