Skip to content

Commit

Permalink
[F] Nested types patches without enable
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Sep 10, 2024
1 parent 9b7f2b3 commit d9fc262
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
15 changes: 11 additions & 4 deletions AquaMai/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ public class AquaMai : MelonMod
{
public static Config AppConfig { get; private set; }

private static void Patch(Type type)
private void Patch(Type type)
{
MelonLogger.Msg($"> Patching {type}");
HarmonyLib.Harmony.CreateAndPatchAll(type);
HarmonyInstance.PatchAll(type);
}

/**
* Apply patches using reflection, based on the settings
*/
private static void ApplyPatches()
private void ApplyPatches()
{
// Iterate over all properties of AppConfig
foreach (var categoryProp in AppConfig.GetType().GetProperties())
Expand All @@ -53,7 +53,14 @@ private static void ApplyPatches()
var directiveType = Type.GetType($"AquaMai.{categoryProp.Name}.{settingProp.Name}");

// If the type is found, call the Patch method
if (directiveType != null) Patch(directiveType);
if (directiveType != null)
{
Patch(directiveType);
foreach (var nested in directiveType.GetNestedTypes())
{
Patch(nested);
}
}
else MelonLogger.Error($"Type not found for {categoryProp.Name}.{settingProp.Name}");
}
}
Expand Down
3 changes: 2 additions & 1 deletion AquaMai/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
[assembly: AssemblyFileVersion(AquaMai.BuildInfo.Version)]
[assembly: MelonInfo(typeof(AquaMai.AquaMai), AquaMai.BuildInfo.Name, AquaMai.BuildInfo.Version, AquaMai.BuildInfo.Author, AquaMai.BuildInfo.DownloadLink)]
[assembly: MelonColor()]
[assembly: HarmonyDontPatchAll]

// Create and Setup a MelonGame Attribute to mark a Melon as Universal or Compatible with specific Games.
// If no MelonGame Attribute is found or any of the Values for any MelonGame Attribute on the Melon is null or empty it will be assumed the Melon is Universal.
// Values for MelonGame Attribute can be found in the Game's app.info file or printed at the top of every log directly beneath the Unity version.
[assembly: MelonGame(null, null)]
[assembly: MelonGame(null, null)]

0 comments on commit d9fc262

Please sign in to comment.