diff --git a/CustomCosmeticLoader.csproj b/CustomCosmeticLoader.csproj
index c968807..c044a81 100644
--- a/CustomCosmeticLoader.csproj
+++ b/CustomCosmeticLoader.csproj
@@ -3,7 +3,7 @@
net48
-
+
diff --git a/Patches/MainMenuPanelPatches.cs b/Patches/MainMenuPanelPatches.cs
index 9654a13..bbc943d 100644
--- a/Patches/MainMenuPanelPatches.cs
+++ b/Patches/MainMenuPanelPatches.cs
@@ -17,9 +17,6 @@ namespace CustomCosmeticLoader.Patches
if (Config.skinNameToHijack == "*")
return;
- if (Shared.SkinToHijack == null)
- return;
-
if (__instance.cosmeticDisplay)
{
__instance.cosmeticDisplay.Clear();
diff --git a/Patches/MarbleControllerPatches.cs b/Patches/MarbleControllerPatches.cs
index 77c9245..1949e35 100644
--- a/Patches/MarbleControllerPatches.cs
+++ b/Patches/MarbleControllerPatches.cs
@@ -16,7 +16,8 @@ namespace CustomCosmeticLoader.Patches
if (Config.skinNameToHijack == "*")
return;
- if (Shared.SkinToHijack == null)
+ // Shouldn't happen I don't think but we do this elsewhere in mp
+ if (NetworkManager.IsMultiplayer)
return;
MarbleHolder mHolder = __instance.MHolder;
diff --git a/Patches/MarbleHolderPatches.cs b/Patches/MarbleHolderPatches.cs
index c1a2f95..730ac7b 100644
--- a/Patches/MarbleHolderPatches.cs
+++ b/Patches/MarbleHolderPatches.cs
@@ -1,5 +1,6 @@
using HarmonyLib;
using System;
+using System.Reflection;
using UnityEngine;
namespace CustomCosmeticLoader.Patches
@@ -17,8 +18,42 @@ namespace CustomCosmeticLoader.Patches
if (!Config.inCosmeticMenu && __instance == CosmeticPanel.cosmHolder)
return;
-
+
+ // If this is a networked game, ONLY apply to my marble and not anyone else happening to use our SkinToHijack
+ if (NetworkManager.IsMultiplayer)
+ {
+ MarbleController controller = __instance.GetComponentInParent();
+ if (!controller.isMyClientMarble())
+ return;
+ }
+
Shared.ApplyCustomTexture(__instance.currentMarble);
}
}
+
+ [HarmonyPatch(typeof(MarbleHolder), nameof(MarbleHolder.CheckSet))]
+ internal class MarbleHolderCheckSetPatch
+ {
+ static void Postfix(MarbleHolder __instance, Cosmetic.Set cs)
+ {
+ if (!Config.enabled)
+ return;
+
+ if (!NetworkManager.IsMultiplayer)
+ return;
+
+ FieldInfo mbcField = typeof(MarbleHolder).GetField("mbc", BindingFlags.NonPublic | BindingFlags.Instance);
+ MarbleController controller = mbcField.GetValue(__instance) as MarbleController;
+
+ if (controller == null)
+ return;
+
+ // Don't hijack the soccer ball or zombie skins
+ if (cs.skin == "SoccerBall_V4" || cs.skin == "Zombie")
+ return;
+
+ __instance.SetMarble(Shared.SkinToHijack);
+ __instance.CosmeticSet.skin = cs.skin;
+ }
+ }
}
diff --git a/Shared.cs b/Shared.cs
index 77a062f..ef9403b 100644
--- a/Shared.cs
+++ b/Shared.cs
@@ -20,7 +20,7 @@ namespace CustomCosmeticLoader
if (skinToHijack == null)
Debug.LogWarning("Couldn't hijack skin " + Config.skinNameToHijack);
}
-
+
return skinToHijack;
}
}