Skip to content

Commit

Permalink
run the MMPostLoad callback earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
al2me6 committed Jul 28, 2024
1 parent 83b27e6 commit 807cc68
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Source/Shabby.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static Shader FindShader(string shaderName)
return shader;
}

public static void ModuleManagerPostLoad()
public static void MMPostLoadCallback()
{
var configNodes = GameDatabase.Instance.GetConfigNodes("SHABBY");
foreach (var shabbyNode in configNodes) {
Expand Down Expand Up @@ -123,6 +123,13 @@ void Awake()
harmony.PatchAll(Assembly.GetExecutingAssembly());

Debug.Log($"[Shabby] hooked");

// Register as an explicit MM callback such that it is run before all reflected
// callbacks (as used by most mods), which may wish to access the MaterialDef library.
var addPostPatchCB = AccessTools.Method("ModuleManager.MMPatchLoader:AddPostPatchCallback");
var delegateType = addPostPatchCB.GetParameters()[0].ParameterType;
var callbackDelegate = Delegate.CreateDelegate(delegateType, typeof(Shabby), nameof(MMPostLoadCallback));
addPostPatchCB.Invoke(null, new object[] { callbackDelegate });
}
}

Expand Down

0 comments on commit 807cc68

Please sign in to comment.