diff --git a/Config.cs b/Config.cs index 4b585b2..6370206 100644 --- a/Config.cs +++ b/Config.cs @@ -19,6 +19,7 @@ namespace CustomCosmeticLoader 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_OVERRIDE_REPLAY_COSMETICS = "overrideReplayCosmetics"; public const string PROPERTY_OTHER_PLAYERS = "otherPlayers"; public static bool enabled = true; @@ -27,6 +28,7 @@ namespace CustomCosmeticLoader public static bool inMainMenu = true; public static bool inCosmeticMenu = false; public static bool inAllReplays = false; + public static bool overrideReplayCosmetics = false; public static Dictionary otherPlayers = new Dictionary(); public static Dictionary skins = new Dictionary(); @@ -83,6 +85,9 @@ namespace CustomCosmeticLoader if (data[PROPERTY_IN_ALL_REPLAYS] != null) inAllReplays = data[PROPERTY_IN_ALL_REPLAYS].AsBool; + if (data[PROPERTY_OVERRIDE_REPLAY_COSMETICS] != null) + overrideReplayCosmetics = data[PROPERTY_OVERRIDE_REPLAY_COSMETICS].AsBool; + if (data[PROPERTY_OTHER_PLAYERS] != null) { JSONClass otherPlayersData = data[PROPERTY_OTHER_PLAYERS].AsObject; @@ -116,6 +121,7 @@ namespace CustomCosmeticLoader { PROPERTY_IN_MAIN_MENU, inMainMenu ? "true" : "false" }, { PROPERTY_IN_COSMETIC_MENU, inCosmeticMenu ? "true" : "false" }, { PROPERTY_IN_ALL_REPLAYS, inAllReplays ? "true" : "false" }, + { PROPERTY_OVERRIDE_REPLAY_COSMETICS, overrideReplayCosmetics ? "true" : "false" }, }; JSONNode otherPlayersData = new JSONClass(); diff --git a/ConsoleCommands.cs b/ConsoleCommands.cs index ac9d1ed..ea16dfc 100644 --- a/ConsoleCommands.cs +++ b/ConsoleCommands.cs @@ -140,5 +140,19 @@ namespace CustomCosmeticLoader return "Custom skins in all replays " + (Config.inAllReplays ? "enabled" : "disabled"); } + + [ConsoleCommand(description = "Enable/disable overriding a replay's cosmetics with your cosmetics", paramsDescription = "[true/false]", hidden = true)] + public static string cclOverrideReplayCosmetics(params string[] args) + { + if (args.Length == 0) + return "overrideReplayCosmetics: " + (Config.overrideReplayCosmetics ? "true" : "false"); ; + + if (args.Length != 1 || (args[0] != "true" && args[0] != "false")) + return "Requires a true or false argument"; + + Config.overrideReplayCosmetics = args[0] == "true"; + + return "Overriding cosmetics in all replays " + (Config.overrideReplayCosmetics ? "enabled" : "disabled"); + } } } diff --git a/Patches/MarbleControllerPatches.cs b/Patches/MarbleControllerPatches.cs index f6c872b..36e4ba2 100644 --- a/Patches/MarbleControllerPatches.cs +++ b/Patches/MarbleControllerPatches.cs @@ -35,11 +35,28 @@ namespace CustomCosmeticLoader.Patches /* * 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. + * the marble with the designated marble to hijack. If overrideReplayCosmetics is enabled, we swap out all cosmetics + * to match our current configuration to view the replay that way. */ [HarmonyPatch(typeof(MarbleController), nameof(MarbleController.ApplyCosmetics))] internal class MarbleControllerApplyCosmeticsPatch { + static void Prefix(ref ReplayCosmetics cosmetics) + { + // Actually, we can let this one run even if the custom skins are disabled + //if (!Config.enabled) + // return; + + if (!Config.overrideReplayCosmetics) + return; + + cosmetics.Skin = CosmeticManager.MySkin.Id; + cosmetics.Trail = CosmeticManager.MyTrail.Id; + cosmetics.Respawn = CosmeticManager.MyRespawn.Id; + cosmetics.Hat = CosmeticManager.MyHat.Id; + cosmetics.Blast = CosmeticManager.MyBlast.Id; + } + static void Postfix(MarbleController __instance, ReplayCosmetics cosmetics) { if (!Config.enabled)