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

33 lines
925 B
C#
Raw Permalink Normal View History

2023-08-26 17:59:50 -04:00
using HarmonyLib;
namespace CustomCosmeticLoader.Patches
{
2023-09-08 00:24:00 -04:00
/*
* Hijack the cosmetic of the marble in single player, then apply the custom skin texture.
2023-09-08 00:24:00 -04:00
*/
2023-09-02 23:19:35 -04:00
[HarmonyPatch(typeof(MarbleController), nameof(MarbleController.ApplyMyCosmetics))]
2023-08-26 17:59:50 -04:00
internal class MarbleControllerApplyMyCosmeticsPatch
{
[HarmonyPostfix]
static void Postfix(MarbleController __instance)
{
if (!Config.enabled)
return;
2023-09-03 02:06:53 -04:00
if (Config.skinNameToHijack == "*")
return;
// Shouldn't happen I don't think but we do this elsewhere in mp
if (NetworkManager.IsMultiplayer)
2023-09-03 02:06:53 -04:00
return;
2023-08-26 17:59:50 -04:00
MarbleHolder mHolder = __instance.MHolder;
string actualSkinId = mHolder.CosmeticSet.skin;
2023-09-03 02:06:53 -04:00
mHolder.SetMarble(Shared.SkinToHijack);
Shared.ApplyCustomTexture(mHolder.currentMarble);
2023-08-26 17:59:50 -04:00
// Setting the skin id here allows others in multiplayer/replays to see your normal skin
mHolder.CosmeticSet.skin = actualSkinId;
}
}
}