From 6f7cf91d86eca4e8f7eeab76e8fbcd3e239cee71 Mon Sep 17 00:00:00 2001 From: Terry Hearst Date: Wed, 25 Oct 2023 00:16:13 -0400 Subject: [PATCH] Fix isCosmeticMenu setting --- Patches/CosmeticPanelPatches.cs | 25 +++++++++++++++++++++++++ Patches/MarbleHolderPatches.cs | 3 --- 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 Patches/CosmeticPanelPatches.cs diff --git a/Patches/CosmeticPanelPatches.cs b/Patches/CosmeticPanelPatches.cs new file mode 100644 index 0000000..f9a9ab1 --- /dev/null +++ b/Patches/CosmeticPanelPatches.cs @@ -0,0 +1,25 @@ +using HarmonyLib; +using System; + +namespace CustomCosmeticLoader.Patches +{ + /* + * Override the marble cosmetic to be the hijacked marble if configured to appear in cosmetic menu. + */ + [HarmonyPatch(typeof(CosmeticPanel), nameof(CosmeticPanel.SelectCosmetic), new Type[] { typeof(Cosmetic), typeof(CosmeticType), typeof(bool) })] + internal class CosmeticPanelSelectCosmeticPatch + { + static void Postfix(CosmeticType ctype) + { + if (!Config.enabled) + return; + + if (ctype == CosmeticType.Skin && Config.inCosmeticMenu && Config.skinNameToHijack != "*") + { + MarbleHolder holder = CosmeticPanel.cosmHolder; + holder.SetMarble(Shared.SkinToHijack); + Shared.ApplyCustomTexture(holder.currentMarble); + } + } + } +} diff --git a/Patches/MarbleHolderPatches.cs b/Patches/MarbleHolderPatches.cs index 1772e4b..36edae5 100644 --- a/Patches/MarbleHolderPatches.cs +++ b/Patches/MarbleHolderPatches.cs @@ -33,9 +33,6 @@ namespace CustomCosmeticLoader.Patches if (marbleObject.Id != Config.skinNameToHijack && Config.skinNameToHijack != "*") return; - if (!Config.inCosmeticMenu && __instance == CosmeticPanel.cosmHolder) - return; - MarbleController controller = MarbleHolderValues.MbcField.GetValue(__instance) as MarbleController; if (controller == null) return;