miuu-custom-cosmetic-loader/Patches/MainMenuPanelPatches.cs

32 lines
861 B
C#

using HarmonyLib;
using System;
namespace CustomCosmeticLoader.Patches
{
/*
* Show your custom marble skin on the "My Marble" display on the main menu (if configured).
*/
[HarmonyPatch(typeof(MainMenuPanel), nameof(MainMenuPanel.SetupImages), new Type[] { typeof(bool) })]
internal class MainMenuPanelSetupImagesPatch
{
static void Postfix(MainMenuPanel __instance)
{
if (!Config.enabled)
return;
if (!Config.inMainMenu)
return;
if (__instance.cosmeticDisplay)
{
if (Config.skinNameToHijack != "*")
{
__instance.cosmeticDisplay.Clear();
GameObjectAllocator.Deinitialize(__instance.cosmeticDisplay.gameObject);
__instance.cosmeticDisplay.Setup(Shared.SkinToHijack, CosmeticType.Skin, true, true);
}
Shared.ApplyCustomTexture(__instance.cosmeticDisplay.CachedCosmeticGameObject);
}
}
}
}