Fix isCosmeticMenu setting

This commit is contained in:
Terry Hearst 2023-10-25 00:16:13 -04:00
parent 2c43db37b5
commit 6f7cf91d86
2 changed files with 25 additions and 3 deletions

View file

@ -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);
}
}
}
}

View file

@ -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;