Add option to override a replays cosmetics with yours
This commit is contained in:
parent
486a4acc32
commit
8d5de1a6c1
3 changed files with 38 additions and 1 deletions
|
@ -19,6 +19,7 @@ namespace CustomCosmeticLoader
|
||||||
public const string PROPERTY_IN_MAIN_MENU = "inMainMenu";
|
public const string PROPERTY_IN_MAIN_MENU = "inMainMenu";
|
||||||
public const string PROPERTY_IN_COSMETIC_MENU = "inCosmeticMenu";
|
public const string PROPERTY_IN_COSMETIC_MENU = "inCosmeticMenu";
|
||||||
public const string PROPERTY_IN_ALL_REPLAYS = "inAllReplays";
|
public const string PROPERTY_IN_ALL_REPLAYS = "inAllReplays";
|
||||||
|
public const string PROPERTY_OVERRIDE_REPLAY_COSMETICS = "overrideReplayCosmetics";
|
||||||
public const string PROPERTY_OTHER_PLAYERS = "otherPlayers";
|
public const string PROPERTY_OTHER_PLAYERS = "otherPlayers";
|
||||||
|
|
||||||
public static bool enabled = true;
|
public static bool enabled = true;
|
||||||
|
@ -27,6 +28,7 @@ namespace CustomCosmeticLoader
|
||||||
public static bool inMainMenu = true;
|
public static bool inMainMenu = true;
|
||||||
public static bool inCosmeticMenu = false;
|
public static bool inCosmeticMenu = false;
|
||||||
public static bool inAllReplays = false;
|
public static bool inAllReplays = false;
|
||||||
|
public static bool overrideReplayCosmetics = false;
|
||||||
public static Dictionary<string, string> otherPlayers = new Dictionary<string, string>();
|
public static Dictionary<string, string> otherPlayers = new Dictionary<string, string>();
|
||||||
|
|
||||||
public static Dictionary<string, Texture2D> skins = new Dictionary<string, Texture2D>();
|
public static Dictionary<string, Texture2D> skins = new Dictionary<string, Texture2D>();
|
||||||
|
@ -83,6 +85,9 @@ namespace CustomCosmeticLoader
|
||||||
if (data[PROPERTY_IN_ALL_REPLAYS] != null)
|
if (data[PROPERTY_IN_ALL_REPLAYS] != null)
|
||||||
inAllReplays = data[PROPERTY_IN_ALL_REPLAYS].AsBool;
|
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)
|
if (data[PROPERTY_OTHER_PLAYERS] != null)
|
||||||
{
|
{
|
||||||
JSONClass otherPlayersData = data[PROPERTY_OTHER_PLAYERS].AsObject;
|
JSONClass otherPlayersData = data[PROPERTY_OTHER_PLAYERS].AsObject;
|
||||||
|
@ -116,6 +121,7 @@ namespace CustomCosmeticLoader
|
||||||
{ PROPERTY_IN_MAIN_MENU, inMainMenu ? "true" : "false" },
|
{ PROPERTY_IN_MAIN_MENU, inMainMenu ? "true" : "false" },
|
||||||
{ PROPERTY_IN_COSMETIC_MENU, inCosmeticMenu ? "true" : "false" },
|
{ PROPERTY_IN_COSMETIC_MENU, inCosmeticMenu ? "true" : "false" },
|
||||||
{ PROPERTY_IN_ALL_REPLAYS, inAllReplays ? "true" : "false" },
|
{ PROPERTY_IN_ALL_REPLAYS, inAllReplays ? "true" : "false" },
|
||||||
|
{ PROPERTY_OVERRIDE_REPLAY_COSMETICS, overrideReplayCosmetics ? "true" : "false" },
|
||||||
};
|
};
|
||||||
|
|
||||||
JSONNode otherPlayersData = new JSONClass();
|
JSONNode otherPlayersData = new JSONClass();
|
||||||
|
|
|
@ -140,5 +140,19 @@ namespace CustomCosmeticLoader
|
||||||
|
|
||||||
return "Custom skins in all replays " + (Config.inAllReplays ? "enabled" : "disabled");
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* 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))]
|
[HarmonyPatch(typeof(MarbleController), nameof(MarbleController.ApplyCosmetics))]
|
||||||
internal class MarbleControllerApplyCosmeticsPatch
|
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)
|
static void Postfix(MarbleController __instance, ReplayCosmetics cosmetics)
|
||||||
{
|
{
|
||||||
if (!Config.enabled)
|
if (!Config.enabled)
|
||||||
|
|
Loading…
Add table
Reference in a new issue