2023-08-26 17:59:50 -04:00
|
|
|
|
using HarmonyLib;
|
|
|
|
|
|
|
|
|
|
namespace CustomCosmeticLoader.Patches
|
|
|
|
|
{
|
2023-09-08 00:24:00 -04:00
|
|
|
|
/*
|
2024-01-02 01:22:31 -05: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)
|
|
|
|
|
{
|
2023-08-27 02:44:35 -04:00
|
|
|
|
if (!Config.enabled)
|
|
|
|
|
return;
|
|
|
|
|
|
2023-09-03 02:06:53 -04:00
|
|
|
|
if (Config.skinNameToHijack == "*")
|
2023-08-27 02:44:35 -04:00
|
|
|
|
return;
|
|
|
|
|
|
2023-09-03 22:29:29 -04:00
|
|
|
|
// 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);
|
2024-01-02 01:22:31 -05:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|