This article is to give code of an Empty Mod in Visual Studio 2022.
Step 1 :Â Create an empty DLL project with latest .NET Framework (4.8).
Step 2:Â You need to add "references" to DLLs of the game that you use. Only few DLL are needed to get references & allow compilation to work.
--Directories should be like " F:\Going.Medieval.v0.14.23\Going Medieval_Data\Managed\Assembly-CSharp.dll" , then you need :
- AssemblyCSharp.dll
- UnityEngine & UnityEngine.CoreModule
- And DLLs from mod launcher & harmony with "F:\Going.Medieval.v0.14.23\Mods\GoingMedievalModLauncher.dll" :
- GoingMedievalModLauncher.dll
- 0harmony.dll (from Nuget Package, Lib.Harmony, reference should be automatic once package installed)
Screen of "References" when OK : https://prnt.sc/FEIq296NZT6k
Step 3 :Â Just create one C# file for your DLL. Here is the code :
- Pastebin link : https://pastebin.com/ujL84EER
using System;
using GoingMedievalModLauncher;
using UnityEngine;
using Logger = GoingMedievalModLauncher.Logger;
namespace QualityOfLife
{
  public class MY_MOD_NAME : IPlugin
  {    Â
    public string Name => "My mod name";
    public string Description => "Mod Description";
    public string Version => "Mod Version";
    public bool activeState { get; set; }
    Â
    public void initialize()
    {
      activeState = true;      Â
    }
    public void start(MonoBehaviour root)
    {
    }
    public void update(MonoBehaviour root)
    {
      if (!activeState) return;
      try
      {
      }
      catch (Exception e)
      {
        //THIS LINE ADD DEBUG INFO INTO DEBUG FILE.
        Logger.getInstance().info(e.ToString());
        throw;
      }
    }
    public void disable(MonoBehaviour root)
    {
activeState = false;     Â
    }
  }
}
Then you should be able to compile & run your MOD ! Well this code will just show mod running , and you can activate/desactivate it.
Everything is almost happening into "update" function.
With usage of References you ll get access to all Going Medival Unity Functions in intelliSense to help you coding :) You can also decompile & see sources of the game.
0 comments