Skip to content

Applying the Harmony Patch

WARNING

Our MelonLoader plugin is no longer being developed. Please instead check out our new BepInEx plugin. We apologise for the incomplete documentation at this time.

In order to have your effects run, you will need to use a HarmonyPatch to loop through your queued effects.

Base.cs

Navigate to Base.cs in your effect pack and check out the EffectProcessing class.

cs
//[HarmonyPatch(typeof(PlayerController), "Update")] 
class EffectProcessing {
    public static void Prefix() {
        if (CrowdControl.ActionQueue.Count == 0)
            return;

        Queue<Action> recycledActions = new Queue<Action>();

        while (CrowdControl.ActionQueue.Count > 0) {
            Action action = CrowdControl.ActionQueue.Dequeue();

            try {
                action.Invoke();
            }
            catch (Exception e) {
                recycledActions.Enqueue(action);
            }
        }

		if (recycledActions.Count > 0)
            CrowdControl.ActionQueue = recycledActions;
    }
}

Attaching to a Component

Open dnSpy and load Cuphead's Assembly-CSharp.dll, as directed in the previous step. Search for a frequently-used game component. Here, let's explore the LevelPlayerAnimationController and its functions.

Alt

Looks like a good fit! Modify the HarmonyPatch to align with the class and function:

cs
[HarmonyPatch(typeof(LevelPlayerAnimationController), "Update")]

Now, after implementing them, our effects should run after we implement them. We'll cover how to do that in the next step.