Bunch more networking stuff

This commit is contained in:
2025-02-28 14:35:14 +02:00
parent 1dce1960f6
commit d0eb7f89be
8 changed files with 126 additions and 36 deletions

View File

@@ -4,6 +4,8 @@ using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using BoneSync.Networking.Messages;
using BoneSync.Sync;
using HarmonyLib;
using MelonLoader;
using StressLevelZero;
@@ -17,6 +19,27 @@ namespace BoneSync.Patching
internal class PoolPatches
{
public readonly static string[] ignoredPools = new string[] {
"RigidbodyProjectile",
"VFX Despawn Mesh",
"AudioPlayer",
"Decal",
"PopupText",
};
public static bool IsIgnoredPool(string poolName)
{
string lowercasePoolName = poolName.ToLower();
foreach (string ignoredPool in ignoredPools)
{
if (lowercasePoolName.Contains(ignoredPool.ToLower()))
{
return true;
}
}
return false;
}
[HarmonyPatch(nameof(Pool.Spawn))]
[HarmonyPostfix]
private static void SpawnPatchPost(Pool __instance, ref GameObject __result)
@@ -29,11 +52,12 @@ namespace BoneSync.Patching
private static bool SpawnPatchPre(Pool __instance, ref Vector3 position, ref Quaternion rotation, ref Il2CppSystem.Nullable<Vector3> scale, ref Il2CppSystem.Nullable<bool> autoEnable)
{
if (CallPatchedMethods.allowPatchedMethodCall) return true;
if (IsIgnoredPool(__instance.name)) return true;
if (BoneSync.lobby.IsConnected())
{
MelonLogger.Msg("Patched Spawning object in pool: " + __instance.name);
return false;
return BoneSync.lobby.IsHost; // only allow host to spawn objects naturally
}
return true;
}