Terry Hearst
af4ef66db5
Really nice simplification here, I could remove two patches at once and clear out some headaches. Now, the logic for switching skins in multiplayer and in replays is in the same place, which is great and will make it more expandable in the future
32 lines
925 B
C#
32 lines
925 B
C#
using HarmonyLib;
|
|
|
|
namespace CustomCosmeticLoader.Patches
|
|
{
|
|
/*
|
|
* Hijack the cosmetic of the marble in single player, then apply the custom skin texture.
|
|
*/
|
|
[HarmonyPatch(typeof(MarbleController), nameof(MarbleController.ApplyMyCosmetics))]
|
|
internal class MarbleControllerApplyMyCosmeticsPatch
|
|
{
|
|
[HarmonyPostfix]
|
|
static void Postfix(MarbleController __instance)
|
|
{
|
|
if (!Config.enabled)
|
|
return;
|
|
|
|
if (Config.skinNameToHijack == "*")
|
|
return;
|
|
|
|
// Shouldn't happen I don't think but we do this elsewhere in mp
|
|
if (NetworkManager.IsMultiplayer)
|
|
return;
|
|
|
|
MarbleHolder mHolder = __instance.MHolder;
|
|
string actualSkinId = mHolder.CosmeticSet.skin;
|
|
mHolder.SetMarble(Shared.SkinToHijack);
|
|
Shared.ApplyCustomTexture(mHolder.currentMarble);
|
|
// Setting the skin id here allows others in multiplayer/replays to see your normal skin
|
|
mHolder.CosmeticSet.skin = actualSkinId;
|
|
}
|
|
}
|
|
}
|