Show custom skins of ghost marbles when racing them
This commit is contained in:
parent
a88479be93
commit
2c0fda0285
1 changed files with 35 additions and 0 deletions
35
Patches/GhostRaceMarbleControllerPatches.cs
Normal file
35
Patches/GhostRaceMarbleControllerPatches.cs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using MIU;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace CustomCosmeticLoader.Patches
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(GhostRaceMarbleController), nameof(GhostRaceMarbleController.ApplyCosmetics))]
|
||||||
|
internal class GhostRaceMarbleControllerApplyCosmeticsPatch
|
||||||
|
{
|
||||||
|
static void Postfix(GhostRaceMarbleController __instance)
|
||||||
|
{
|
||||||
|
if (!Config.enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
string replayName = null;
|
||||||
|
GamePlayManager.Get().GetCurrentReplays(delegate (List<Replay> replays)
|
||||||
|
{
|
||||||
|
if (replays.Count > 0)
|
||||||
|
replayName = replays[0].Player;
|
||||||
|
});
|
||||||
|
Shared.Log("GhostRaceMarbleControllerApplyCosmeticsPatch Replay name: " + replayName);
|
||||||
|
|
||||||
|
if (Config.otherPlayers.ContainsKey(replayName) || replayName == Player.Current.Name)
|
||||||
|
{
|
||||||
|
MarbleHolder mHolder = __instance.GetComponentInChildren<MarbleHolder>();
|
||||||
|
|
||||||
|
if (Config.skinNameToHijack != "*")
|
||||||
|
mHolder.SetMarble(Shared.SkinToHijack);
|
||||||
|
|
||||||
|
Shared.ApplyCustomTexture(mHolder.currentMarble, Config.skins[Config.otherPlayers[replayName]]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue