Bunch more networking stuff
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user