Show custom skin in My Marble widget on the level select screen
This commit is contained in:
parent
6c721df0ce
commit
a145e22fce
1 changed files with 31 additions and 0 deletions
31
Patches/MarbleWidgetPatches.cs
Normal file
31
Patches/MarbleWidgetPatches.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using HarmonyLib;
|
||||
using System;
|
||||
|
||||
namespace CustomCosmeticLoader.Patches
|
||||
{
|
||||
/*
|
||||
* This is called on the LevelSelect screen to show the "My Marble" widget in the top left corner. Hijack the cosmetic
|
||||
* and apply the custom texture here too (if configured)
|
||||
*/
|
||||
[HarmonyPatch(typeof(MarbleWidget), nameof(MarbleWidget.SetCosmetic), new Type[] {})]
|
||||
internal class MarbleWidgetSetCosmeticLevelSelectPatch
|
||||
{
|
||||
static bool Prefix(MarbleWidget __instance)
|
||||
{
|
||||
if (!Config.enabled)
|
||||
return true;
|
||||
|
||||
if (!Config.inMainMenu)
|
||||
return true;
|
||||
|
||||
Cosmetic skin = Config.skinNameToHijack == "*" ?
|
||||
(CosmeticManager.MySkin == null ? CosmeticManager.Skins[0] : CosmeticManager.MySkin) :
|
||||
Shared.SkinToHijack;
|
||||
Cosmetic hat = CosmeticManager.MyHat == null ? CosmeticManager.Hats[0] : CosmeticManager.MyHat;
|
||||
|
||||
__instance.SetCosmetic(skin, hat);
|
||||
Shared.ApplyCustomTexture(__instance.cosmeticDisplay.gameObject);
|
||||
return false; // Skip original method, since we do everything it was supposed to
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue