Zone patches
This commit is contained in:
@@ -99,6 +99,7 @@
|
|||||||
<Compile Include="Patching\InteractableHostPatches.cs" />
|
<Compile Include="Patching\InteractableHostPatches.cs" />
|
||||||
<Compile Include="Patching\ObjectHealthPatches.cs" />
|
<Compile Include="Patching\ObjectHealthPatches.cs" />
|
||||||
<Compile Include="Patching\PlugPatches.cs" />
|
<Compile Include="Patching\PlugPatches.cs" />
|
||||||
|
<Compile Include="Patching\ZonePatches.cs" />
|
||||||
<Compile Include="Sync\Components\SyncableBase.cs" />
|
<Compile Include="Sync\Components\SyncableBase.cs" />
|
||||||
<Compile Include="Sync\Components\SyncableDamage.cs" />
|
<Compile Include="Sync\Components\SyncableDamage.cs" />
|
||||||
<Compile Include="Sync\Components\SyncableNetworking.cs" />
|
<Compile Include="Sync\Components\SyncableNetworking.cs" />
|
||||||
|
|||||||
@@ -11,11 +11,10 @@ using StressLevelZero.Interaction;
|
|||||||
|
|
||||||
namespace BoneSync.Patching
|
namespace BoneSync.Patching
|
||||||
{
|
{
|
||||||
[HarmonyPatch(typeof(Socket))]
|
/*[HarmonyPatch(typeof(Socket))]
|
||||||
public class SocketPatches
|
public static class SocketPatches
|
||||||
{
|
{
|
||||||
[HarmonyPatch(nameof(Socket.OnPlugEnter)), HarmonyPostfix]
|
public static void GenericSocketEnterPatch(Socket __instance, Plug plug)
|
||||||
public static void SocketEnterPatch(Socket __instance, Plug plug)
|
|
||||||
{
|
{
|
||||||
if (!plug) return;
|
if (!plug) return;
|
||||||
MelonLogger.Msg("Plug entered: " + __instance.name + " Plug: " + plug.name);
|
MelonLogger.Msg("Plug entered: " + __instance.name + " Plug: " + plug.name);
|
||||||
@@ -27,8 +26,7 @@ namespace BoneSync.Patching
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(Socket.OnPlugExit)), HarmonyPostfix]
|
public static void GenericSocketExitPatch(Socket __instance, Plug plug)
|
||||||
public static void SocketExitPatch(Socket __instance, Plug plug)
|
|
||||||
{
|
{
|
||||||
if (!plug) return;
|
if (!plug) return;
|
||||||
MelonLogger.Msg("Plug exited: " + __instance.name + " Plug: " + plug.name);
|
MelonLogger.Msg("Plug exited: " + __instance.name + " Plug: " + plug.name);
|
||||||
@@ -38,8 +36,56 @@ namespace BoneSync.Patching
|
|||||||
byte socketId = syncable.GetSocketId(__instance);
|
byte socketId = syncable.GetSocketId(__instance);
|
||||||
MelonLogger.Msg("Plug exited: " + __instance.transform.GetPath() + " Plug: " + plug.transform.GetPath() + " ID: " + plugId + " Socket ID: " + socketId);
|
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
|
public class PlugPatches
|
||||||
{
|
{
|
||||||
/*[HarmonyPatch(typeof(Plug))]
|
/*[HarmonyPatch(typeof(Plug))]
|
||||||
|
|||||||
52
BoneSync/Patching/ZonePatches.cs
Normal file
52
BoneSync/Patching/ZonePatches.cs
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ namespace BoneSync.Sync.Components
|
|||||||
|
|
||||||
public bool AllRigidbodiesSleeping()
|
public bool AllRigidbodiesSleeping()
|
||||||
{
|
{
|
||||||
|
if (rigidbodies.Length == 0) return false;
|
||||||
foreach (Rigidbody rb in rigidbodies)
|
foreach (Rigidbody rb in rigidbodies)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -25,11 +26,11 @@ namespace BoneSync.Sync.Components
|
|||||||
catch { } // ignore null rigidbodies
|
catch { } // ignore null rigidbodies
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private void SetKinematic(bool kinematic)
|
private void SetKinematic(bool kinematic)
|
||||||
{
|
{
|
||||||
|
if (!this) return;
|
||||||
foreach (Rigidbody rb in rigidbodies)
|
foreach (Rigidbody rb in rigidbodies)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using UnhollowerBaseLib;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace BoneSync.Sync
|
namespace BoneSync.Sync
|
||||||
|
|||||||
Reference in New Issue
Block a user