testing despawn patch

This commit is contained in:
2025-03-17 16:55:01 +02:00
parent f06af0647d
commit ba6d71a2ec

View File

@@ -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;
@@ -123,7 +121,6 @@ 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<bool>), typeof(Il2CppSystem.Nullable<Color>) }), HarmonyPrefix]
private static bool DespawnPatchPre(Poolee __instance, ref Il2CppSystem.Nullable<bool> playVFX, ref Il2CppSystem.Nullable<Color> 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;
}
}
}