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

39 lines
949 B
C#
Raw Normal View History

2023-08-26 17:59:50 -04:00
using HarmonyLib;
using System;
namespace CustomCosmeticLoader.Patches
{
[HarmonyPatch(typeof(MarbleController))]
[HarmonyPatch("ApplyMyCosmetics")]
internal class MarbleControllerApplyMyCosmeticsPatch
{
private static Cosmetic mirageSkin = null;
[HarmonyPostfix]
static void Postfix(MarbleController __instance)
{
if (mirageSkin == null)
{
// We hijack one skin (Mirage) since it's one of the basic skins with no animations/different UVs/etc
foreach (Cosmetic skin in CosmeticManager.Skins)
{
if (skin.Id == "Swirl_M")
{
mirageSkin = skin;
break;
}
}
if (mirageSkin == null) //whut
return;
}
MarbleHolder mHolder = __instance.MHolder;
string actualSkinId = mHolder.CosmeticSet.skin;
mHolder.SetMarble(mirageSkin);
// Setting the skin id here allows others in multiplayer/replays to see your normal skin
mHolder.CosmeticSet.skin = actualSkinId;
}
}
}