From ba6d71a2ecd23788ae84cb6f5908e03288089447 Mon Sep 17 00:00:00 2001 From: Aaro Varis Date: Mon, 17 Mar 2025 16:55:01 +0200 Subject: [PATCH] testing despawn patch --- BoneSync/Patching/PoolPatches.cs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/BoneSync/Patching/PoolPatches.cs b/BoneSync/Patching/PoolPatches.cs index 76446dc..0ae4875 100644 --- a/BoneSync/Patching/PoolPatches.cs +++ b/BoneSync/Patching/PoolPatches.cs @@ -62,8 +62,7 @@ namespace BoneSync.Patching [HarmonyPatch(typeof(Pool))] public static class PoolPatches { - [HarmonyPatch(nameof(Pool.InstantiatePoolee))] - [HarmonyPrefix] + [HarmonyPatch(nameof(Pool.InstantiatePoolee), new Type[] { typeof(Vector3), typeof(Quaternion) }), HarmonyPrefix] private static bool InstantiatePooleePatchPre(Pool __instance) { if (!__instance.Prefab) @@ -71,8 +70,7 @@ namespace BoneSync.Patching return true; } - [HarmonyPatch(nameof(Pool.InstantiatePoolee))] - [HarmonyPostfix] + [HarmonyPatch(nameof(Pool.InstantiatePoolee), new Type[] { typeof(Vector3), typeof(Quaternion) }), HarmonyPostfix] private static void InstantiatePooleePatchPost(Pool __instance, Poolee __result, Vector3 position, Quaternion rotation) { if (CallPatchedMethods.allowPatchedMethodCall) return; @@ -122,8 +120,7 @@ namespace BoneSync.Patching } [HarmonyPatch(typeof(Poolee))] public static class PooleePatches - { - + { public static void OnSpawnPatchPost(Poolee __instance) { if (CallPatchedMethods.allowPatchedMethodCall) return; @@ -193,6 +190,20 @@ namespace BoneSync.Patching return null; } + [HarmonyPatch(nameof(Poolee.Despawn), new Type[] { typeof(Il2CppSystem.Nullable), typeof(Il2CppSystem.Nullable) }), HarmonyPrefix] + private static bool DespawnPatchPre(Poolee __instance, ref Il2CppSystem.Nullable playVFX, ref Il2CppSystem.Nullable despawnColor) + { + if (CallPatchedMethods.allowPatchedMethodCall) return true; + if (!BoneSync.IsConnected) return true; + + Syncable syncable = ObjectSync.MakeOrGetSyncable(__instance); + if (syncable == null) return true; + if (!syncable.isOwner) return false; // if not owner, don't despawn + + return true; + } + + } }