diff --git a/Config.cs b/Config.cs index b1fec31..4b585b2 100644 --- a/Config.cs +++ b/Config.cs @@ -18,6 +18,7 @@ namespace CustomCosmeticLoader public const string PROPERTY_SKIN_NAME_TO_HIJACK = "skinNameToHijack"; public const string PROPERTY_IN_MAIN_MENU = "inMainMenu"; public const string PROPERTY_IN_COSMETIC_MENU = "inCosmeticMenu"; + public const string PROPERTY_IN_ALL_REPLAYS = "inAllReplays"; public const string PROPERTY_OTHER_PLAYERS = "otherPlayers"; public static bool enabled = true; @@ -25,6 +26,7 @@ namespace CustomCosmeticLoader public static string skinNameToHijack = "Swirl_M"; // Mirage, simple skin with nice properties public static bool inMainMenu = true; public static bool inCosmeticMenu = false; + public static bool inAllReplays = false; public static Dictionary otherPlayers = new Dictionary(); public static Dictionary skins = new Dictionary(); @@ -78,6 +80,9 @@ namespace CustomCosmeticLoader if (data[PROPERTY_IN_COSMETIC_MENU] != null) inCosmeticMenu = data[PROPERTY_IN_COSMETIC_MENU].AsBool; + if (data[PROPERTY_IN_ALL_REPLAYS] != null) + inAllReplays = data[PROPERTY_IN_ALL_REPLAYS].AsBool; + if (data[PROPERTY_OTHER_PLAYERS] != null) { JSONClass otherPlayersData = data[PROPERTY_OTHER_PLAYERS].AsObject; @@ -110,6 +115,7 @@ namespace CustomCosmeticLoader { PROPERTY_SKIN_NAME_TO_HIJACK, skinNameToHijack }, { PROPERTY_IN_MAIN_MENU, inMainMenu ? "true" : "false" }, { PROPERTY_IN_COSMETIC_MENU, inCosmeticMenu ? "true" : "false" }, + { PROPERTY_IN_ALL_REPLAYS, inAllReplays ? "true" : "false" }, }; JSONNode otherPlayersData = new JSONClass(); diff --git a/Patches/MarbleControllerPatches.cs b/Patches/MarbleControllerPatches.cs index 1182051..f6c872b 100644 --- a/Patches/MarbleControllerPatches.cs +++ b/Patches/MarbleControllerPatches.cs @@ -1,4 +1,5 @@ using HarmonyLib; +using MIU; using System; using UnityEngine; @@ -31,4 +32,29 @@ namespace CustomCosmeticLoader.Patches mHolder.CosmeticSet.skin = actualSkinId; } } + + /* + * Hijack the cosmetic of the marble when watching Replays. This doesn't apply the custom texture, just swaps out + * the marble with the designated marble to hijack. + */ + [HarmonyPatch(typeof(MarbleController), nameof(MarbleController.ApplyCosmetics))] + internal class MarbleControllerApplyCosmeticsPatch + { + static void Postfix(MarbleController __instance, ReplayCosmetics cosmetics) + { + if (!Config.enabled) + return; + + if (Config.skinNameToHijack == "*") + return; + + if (!Config.inAllReplays) + return; + + MarbleHolder mHolder = __instance.GetComponentInChildren(); + string actualSkinId = mHolder.CosmeticSet.skin; + mHolder.SetMarble(Shared.SkinToHijack); + mHolder.CosmeticSet.skin = actualSkinId; + } + } }