The Long Dark Modding Wiki
Advertisement

Stuffs you have to do to port a mod from Mono to IL2CPP (assuming MelonLoader is already installed):

- Open the Properties window, set the target framework to .NET Framework 4.7.2 - Add ...\TheLongDark\MelonLoader, ...\TheLongDark\MelonLoader\Managed\, and likely also ...\TheLongDark\Mods as reference paths - Remove the dependency on the 0Harmony library

- Add dependencies (select the "Extensions" tab) to: - Il2Cppmscorlib - Il2CppSystem - MelonLoader.ModHandler (just called "MelonLoader") - UnhollowerBaseLib - UnhollowerRuntimeLib

- Create a new "main mod class" (or change an existing one) and make it inherit from MelonMod - Optional: In public override void OnApplicationStart() in that MelonMod class, add the following call:

Debug.Log($"[{InfoAttribute.Name}] Version {InfoAttribute.Version} loaded!");

- Open AssemblyInfo.cs and add the following two properties (obviously, change the main class, name, version, and author)

[assembly: MelonInfo(typeof(DeveloperConsole.DeveloperConsole), "DeveloperConsole", "1.2", "FINDarkside, zeobviouslyfakeacc")]
[assembly: MelonGame("Hinterland", "TheLongDark")]

- OnLoad methods no longer get called automatically. You'll have to find a workaround, e.g. by using a Harmony patch

- Harmony transpilers don't work with IL2CPP. No way to emulate this, unfortunately.

- Any lambdas that are intended for IL2CPP methods need to be wrapped in new System.Action(...) (or Func)

- Make sure stuff still compiles and patches still actually run. Lots of stuff gets completely compiled out because of IL2CPP. Patches on "Update", "Start" and "Awake" methods are never compiled out and should always work.

Advertisement