diff --git a/BoneSync/BoneSync.csproj b/BoneSync/BoneSync.csproj
index 488518d..54373c3 100644
--- a/BoneSync/BoneSync.csproj
+++ b/BoneSync/BoneSync.csproj
@@ -99,6 +99,7 @@
+
diff --git a/BoneSync/Patching/PlugPatches.cs b/BoneSync/Patching/PlugPatches.cs
index 95f1b43..2f64586 100644
--- a/BoneSync/Patching/PlugPatches.cs
+++ b/BoneSync/Patching/PlugPatches.cs
@@ -11,11 +11,10 @@ using StressLevelZero.Interaction;
namespace BoneSync.Patching
{
- [HarmonyPatch(typeof(Socket))]
- public class SocketPatches
+ /*[HarmonyPatch(typeof(Socket))]
+ public static class SocketPatches
{
- [HarmonyPatch(nameof(Socket.OnPlugEnter)), HarmonyPostfix]
- public static void SocketEnterPatch(Socket __instance, Plug plug)
+ public static void GenericSocketEnterPatch(Socket __instance, Plug plug)
{
if (!plug) return;
MelonLogger.Msg("Plug entered: " + __instance.name + " Plug: " + plug.name);
@@ -27,8 +26,7 @@ namespace BoneSync.Patching
}
- [HarmonyPatch(nameof(Socket.OnPlugExit)), HarmonyPostfix]
- public static void SocketExitPatch(Socket __instance, Plug plug)
+ public static void GenericSocketExitPatch(Socket __instance, Plug plug)
{
if (!plug) return;
MelonLogger.Msg("Plug exited: " + __instance.name + " Plug: " + plug.name);
@@ -38,8 +36,56 @@ namespace BoneSync.Patching
byte socketId = syncable.GetSocketId(__instance);
MelonLogger.Msg("Plug exited: " + __instance.transform.GetPath() + " Plug: " + plug.transform.GetPath() + " ID: " + plugId + " Socket ID: " + socketId);
}
+
+
+ [HarmonyPatch(nameof(Socket.OnPlugEnter)), HarmonyPostfix]
+ public static void SocketEnterPatch(Socket __instance, Plug plug)
+ {
+ GenericSocketEnterPatch(__instance, plug);
+ }
+
+ [HarmonyPatch(nameof(Socket.OnPlugExit)), HarmonyPostfix]
+ public static void SocketExitPatch(Socket __instance, Plug plug)
+ {
+ GenericSocketExitPatch(__instance, plug);
+ }
}
+ [HarmonyPatch(typeof(MagazineSocket))]
+ public static class MagazineSocketPatches
+ {
+ [HarmonyPatch(nameof(MagazineSocket.OnPlugEnter)), HarmonyPostfix]
+ public static void MagazineSocketEnterPatch(MagazineSocket __instance, Plug plug)
+ {
+ SocketPatches.GenericSocketEnterPatch(__instance, plug);
+ }
+
+ [HarmonyPatch(nameof(MagazineSocket.OnPlugExit)), HarmonyPostfix]
+ public static void SocketExitPatch(MagazineSocket __instance, Plug plug)
+ {
+ SocketPatches.GenericSocketExitPatch(__instance, plug);
+ }
+ }*/
+
+ [HarmonyPatch(typeof(AlignPlug))]
+ public static class AlignPlugPatches
+ {
+ [HarmonyPatch(nameof(AlignPlug.InsertPlug)), HarmonyPostfix]
+ public static void AlignPlugInsertPatch(AlignPlug __instance, Socket socket)
+ {
+ MelonLogger.Msg("AlignPlug inserted: " + __instance.transform.GetPath() + " Socket: " + socket.transform.GetPath());
+ }
+
+ [HarmonyPatch(nameof(AlignPlug.EjectPlug)), HarmonyPostfix]
+ public static void AlignPlugEjectPatch(AlignPlug __instance)
+ {
+ MelonLogger.Msg("AlignPlug ejected: " + __instance.transform.GetPath());
+ }
+
+ }
+
+
+
public class PlugPatches
{
/*[HarmonyPatch(typeof(Plug))]
diff --git a/BoneSync/Patching/ZonePatches.cs b/BoneSync/Patching/ZonePatches.cs
new file mode 100644
index 0000000..97fe633
--- /dev/null
+++ b/BoneSync/Patching/ZonePatches.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using BoneSync.Sync.Components;
+using HarmonyLib;
+using MelonLoader;
+using StressLevelZero.Zones;
+
+namespace BoneSync.Patching
+{
+ [HarmonyPatch(typeof(ZoneSpawner))]
+ public static class ZoneSpawnerPatch
+ {
+ // this patch should catch most of the spawning, but the pool spawning patch should catch the rest
+ [HarmonyPatch(nameof(ZoneSpawner.Spawn)), HarmonyPrefix]
+ public static bool ZoneSpawnPrefix(ZoneSpawner __instance)
+ {
+ if (!BoneSync.lobby.IsConnected()) return true; // do not block if not connected
+
+ MelonLogger.Msg("ZoneSpawner.Spawn: " + __instance.transform.GetPath());
+
+ if (BoneSync.lobby.IsHost)
+ {
+ return true;
+ }
+
+ return false; // don't spawn if not host
+
+ }
+ }
+
+ [HarmonyPatch(typeof(ZoneEncounter))]
+ public static class ZoneEncounterPatch
+ {
+ [HarmonyPatch(nameof(ZoneEncounter.StartEncounter)), HarmonyPrefix]
+ public static bool ZoneEncounterSpawnPrefix(ZoneEncounter __instance)
+ {
+ if (!BoneSync.lobby.IsConnected()) return true;
+
+ MelonLogger.Msg("ZoneEncounter.StartEncounter: " + __instance.transform.GetPath());
+
+ if (BoneSync.lobby.IsHost)
+ {
+ return true;
+ }
+
+ return false;
+ }
+ }
+}
diff --git a/BoneSync/Sync/Components/SyncablePhysics.cs b/BoneSync/Sync/Components/SyncablePhysics.cs
index aae553f..5277fdf 100644
--- a/BoneSync/Sync/Components/SyncablePhysics.cs
+++ b/BoneSync/Sync/Components/SyncablePhysics.cs
@@ -16,6 +16,7 @@ namespace BoneSync.Sync.Components
public bool AllRigidbodiesSleeping()
{
+ if (rigidbodies.Length == 0) return false;
foreach (Rigidbody rb in rigidbodies)
{
try
@@ -25,11 +26,11 @@ namespace BoneSync.Sync.Components
catch { } // ignore null rigidbodies
}
-
return true;
}
private void SetKinematic(bool kinematic)
{
+ if (!this) return;
foreach (Rigidbody rb in rigidbodies)
{
try
diff --git a/BoneSync/Sync/ObjectSyncCache.cs b/BoneSync/Sync/ObjectSyncCache.cs
index ce9d00e..10ff950 100644
--- a/BoneSync/Sync/ObjectSyncCache.cs
+++ b/BoneSync/Sync/ObjectSyncCache.cs
@@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using UnhollowerBaseLib;
using UnityEngine;
namespace BoneSync.Sync