2023-08-26 17:59:50 -04:00
|
|
|
|
using HarmonyLib;
|
|
|
|
|
using System;
|
2023-08-27 02:44:35 -04:00
|
|
|
|
using UnityEngine;
|
2023-08-26 17:59:50 -04:00
|
|
|
|
|
|
|
|
|
namespace CustomCosmeticLoader.Patches
|
|
|
|
|
{
|
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
|
|
|
|
|
{
|
2023-08-27 02:44:35 -04:00
|
|
|
|
private static Cosmetic hijackSkin = null;
|
2023-08-26 17:59:50 -04:00
|
|
|
|
|
|
|
|
|
[HarmonyPostfix]
|
|
|
|
|
static void Postfix(MarbleController __instance)
|
|
|
|
|
{
|
2023-08-27 02:44:35 -04:00
|
|
|
|
if (!Config.enabled)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (Config.skinToHijack == "*")
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (hijackSkin == null)
|
2023-08-26 17:59:50 -04:00
|
|
|
|
{
|
|
|
|
|
foreach (Cosmetic skin in CosmeticManager.Skins)
|
|
|
|
|
{
|
2023-08-27 02:44:35 -04:00
|
|
|
|
if (skin.Id == Config.skinToHijack)
|
2023-08-26 17:59:50 -04:00
|
|
|
|
{
|
2023-08-27 02:44:35 -04:00
|
|
|
|
hijackSkin = skin;
|
2023-08-26 17:59:50 -04:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-27 02:44:35 -04:00
|
|
|
|
if (hijackSkin == null)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogWarning("Couldn't hijack skin " + Config.skinToHijack);
|
2023-08-26 17:59:50 -04:00
|
|
|
|
return;
|
2023-08-27 02:44:35 -04:00
|
|
|
|
}
|
2023-08-26 17:59:50 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MarbleHolder mHolder = __instance.MHolder;
|
|
|
|
|
string actualSkinId = mHolder.CosmeticSet.skin;
|
2023-08-27 02:44:35 -04:00
|
|
|
|
mHolder.SetMarble(hijackSkin);
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|