×
Create a new article
Write your page title here:
We currently have 152 articles on Grow Song of The Evertree Wiki. Type your article name above or create one of the articles listed here!



    Grow Song of The Evertree Wiki
    Revision as of 01:20, 10 January 2023 by NotAracham (talk | contribs) (complete section 3)

    The following limited set of instructions is a copy of those relayed to a user who assisted in the the creation of my ConfigureLimits mod. While a proper guide will eventually be written, I am recording this in the case it may be useful to others.

    Initial Setup of IDE

    1. Like the install instructions on my mod page (ConfigureLimits on NexusMods), I downloaded BepInEx and put it into Grow's root directory in the steam library, then ran the game once to generate all the extra directories/files I'd need

    2. I downloaded and installed Visual Studio community edition, which is free for everyone: https://visualstudio.microsoft.com/vs/community/

    3. Launch Visual Studio and click on 'Create a New Project'

    4. Choose the Class Library (.NET Framework) option, check the box to place solution and project in the same directory, then click Next

    5. Adjust any project or solution names as you see fit (this will be the name attached to the .dll file you create) and make sure that the framework selected is 4.7.2 (this is the version compatible with grow)

    6. Note the directory the project will be created in, then click Next

    7. After a few seconds, the project will be created! Now we can move on to part two...

    Dependencies + Importing References

    1. Now, navigate to the directory for your mod project (usually something like C:\users\<username>\source\repos\<projectname>)

    2. Inside this folder, we'll create a new folder called Libs. This is where we'll put all the reference files we'll need for the IDE to do what it needs to.

    3. Open a new file explorer window, then head to Grow's root directory and dive down into Grow_Data > Managed. Copy the Assembly-CSharp.dll file and paste it into your newly-created Libs folder

    4. Repeat this for the UnityEngine.dll and UnityEngine.CoreModule.dll files in the same directory

    5. Back out to the root directory again, then dive to BepInEx > Core

    6. Copy over the 0Harmony.dll and BepInEx.dll files to the Libs directory as well

    7. Now, return to the Visual Studio window where we've set up your project. On the right-hand Solution explorer pane, you should see properties, references, and your class file.

    8. Expand References, then right click and choose 'Add Reference'.

    9. Click the 'browse' button at bottom right, then navigate to the Libs directory that's full of the .dlls you borrowed. Add each one this way, then click OK after all have been added.

    Now we're ready to start actually coding in part three!

    Adding References + wakeup script

    1. While some 'using xxx;' lines already probably exist at the start of your project, you'll need a few more for Visual Studio to recognize all the code you're going to want to write. These lines essentially say 'bring this function of the .dll into what I'm doing'

    Example: using System; using System.Reflection; using System.Reflection.Emit; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using HarmonyLib.Tools; using UnityEngine; using UnityEngine.Diagnostics; using BepInEx.Logging;

    Once you've got all that sorted, it'll look something like this:

    File:ModdingDisplayWakeup.png

    2. Next step is to set up a namespace, this is essentially 'everything that is part of the mod' now, so pick a namespace that matches your mod.

    Syntax is:

    namespace Mod_Name
    {
        //more code goes here
    }

    3. Next step is telling our mod loader (BepInEx) important locations for this mod.

    This takes the syntax: [BepInPlugin("CreatorName.PatchingTool.ModName", "long name of mod to display", "x.x.x.x")], replacing those values with the actual appropriate name, long name, and version number to tell BepInEx more info about our mod

    We'll add the game executable we want to target on launch in a similar way, as:

    [BepInProcess("Grow.exe")]

    4. The next step is creating our entry script to make BepInEx patch the game. This is fairly straightforward, but the most basic version won't do terribly much by itself.

    Example to start from:

    namespace Grow_ConfigureLimits
    {
        [BepInPlugin("aracham.bpx.Grow-ConfigureLimits", "Grow-ConfigureLimits", "1.1.0.0")]
        [BepInProcess("Grow.exe")]
       internal class Mod : BaseUnityPlugin
       {
            private void Awake()
            {
                //Creating Harmony Patcher Instance
                var harmony = new Harmony("aracham.bpx.Grow-ConfigureLimits");
    
                //Replacing default patch-all function for granular control over patching behavior based on config variables
                harmony.PatchAll();
            }
        }

    What this is doing is creating a 'class' called Mod, where we're going to put our instructions to execute.

    We're also making it an internal class so it doesn't accidentally override another mod file's class of the same name and break their instructions

    We're then defining a method called Awake(), which will run as soon as the game launches and BepInEx starts patching stuff. Code inside Awake will always attempt to run.

    We're then creating a new instance of one of BepInEx's patching tools, named Harmony.

    We're then instructing harmony to try to run every patch that comes later in our file.

    Right now we have no patches created, so this doesn't actually do anything. Example image of current state:

    File:ModdingDisplayFullWakeup.png

    At this point, we have our IDE set up, a basic namespace and patch script, but no actual patches to apply and no options for users to change. That we can handle in part four...

    Cookies help us deliver our services. By using our services, you agree to our use of cookies.
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.