Pain-Brioche / COM3D2.MaidLoader

ModLoader replacement
7 stars 0 forks source link

MaidLoader

Introduction

Maid Loader is the BepinEx equivalent of Neerhom's ModLoader
While the latter still works and has proven its reliablility, Maid Loader adds some quality of life features for those who wish.
Transition from one to the other is seamless.
Part of ModLoader code was reused with Neerhom's authorisation.

ModLoader legacy

This is the list of features ModLoader already has and implemented in MaidLoader:

New

These features are exclusive to MaidLoader they are described in more details later:

Not Implemented

Known Issues

Installation

New features descriptions

ModRefresh

This function adds a button in your gear menu to refresh the entire Mod folder, and adds any new mods to your game while it's running.
A few things to note:

QuickMod

This function monitors a folder so that any mod placed inside can be quickly added to the game without any restart needed.
A few things to note:

Relevant options:

Auto .asset_bg

.asset_bg files placed in PhotoBG_NEI will automatically be added to the game's background List, without the need of .nei.
.asset_bg files placed in PhotoBG_OBJ_NEI will automatically be added to the game's props List, without the need of .nei.
Deskitem currently still required a .nei in the same way ModLoader required them to be.

Faster Load

In order to load .ks and .ogg into the game, ModLoader as well as MaidLoader need to create a dummy .arc. Where Maid Loader does things differently is by loading said .arc earlier in the game's Init. That way one of the game's slower process only happens once. Depending on your computer you may see a significant drop in this starting phase (95s down to 39s for me). This is also one reason .arc loading isn't possible from the Mod Folder. In addition you can skip this entirely if you do not have .ks and/or .ogg in your Mod folder, gaining a few more seconds for not searching in vain for inexistant files. Or as an option creating a dedicated folder to put your .ks and .ogg into if your Mod folder is very large.

Relevant options:

Mod Debug

Advanced options bellow are reserved for game debugging should some mod cause issue and you can't/won't disable plugins.
Relevant options:

Mod Refresh Event

A Custom Event is raised when mods have been sucessfuly refreshed. Here's a small example for it.

using BepInEx;
using UnityEngine;

namespace COM3D2.RefreshModEventTest
{
    [BepInPlugin("COM3D2.RefreshModEventTest", "RefreshModEventTest", "1.0")]
    [BepInDependency("COM3D2.MaidLoader", BepInDependency.DependencyFlags.SoftDependency)]
    public sealed class RefreshModEventTest : BaseUnityPlugin
    {
        private void Awake()
        {
            if(BepInEx.Bootstrap.Chainloader.PluginInfos.ContainsKey("COM3D2.MaidLoader"))
                MaidLoader.RefreshMod.Refreshed += OnRefreshMod;
        }

        private static void OnRefreshMod(object sender, MaidLoader.RefreshMod.RefreshEventArgs e)
        {
            foreach (string str in e.NewMenus)
                Debug.Log($"Added: {str}");

            foreach (string str in e.DeletedMenus)
                Debug.Log($"Removed: {str}");
        }
    }
}

Notes