testing despawn patch
This commit is contained in:
@@ -62,8 +62,7 @@ namespace BoneSync.Patching
|
|||||||
[HarmonyPatch(typeof(Pool))]
|
[HarmonyPatch(typeof(Pool))]
|
||||||
public static class PoolPatches
|
public static class PoolPatches
|
||||||
{
|
{
|
||||||
[HarmonyPatch(nameof(Pool.InstantiatePoolee))]
|
[HarmonyPatch(nameof(Pool.InstantiatePoolee), new Type[] { typeof(Vector3), typeof(Quaternion) }), HarmonyPrefix]
|
||||||
[HarmonyPrefix]
|
|
||||||
private static bool InstantiatePooleePatchPre(Pool __instance)
|
private static bool InstantiatePooleePatchPre(Pool __instance)
|
||||||
{
|
{
|
||||||
if (!__instance.Prefab)
|
if (!__instance.Prefab)
|
||||||
@@ -71,8 +70,7 @@ namespace BoneSync.Patching
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(Pool.InstantiatePoolee))]
|
[HarmonyPatch(nameof(Pool.InstantiatePoolee), new Type[] { typeof(Vector3), typeof(Quaternion) }), HarmonyPostfix]
|
||||||
[HarmonyPostfix]
|
|
||||||
private static void InstantiatePooleePatchPost(Pool __instance, Poolee __result, Vector3 position, Quaternion rotation)
|
private static void InstantiatePooleePatchPost(Pool __instance, Poolee __result, Vector3 position, Quaternion rotation)
|
||||||
{
|
{
|
||||||
if (CallPatchedMethods.allowPatchedMethodCall) return;
|
if (CallPatchedMethods.allowPatchedMethodCall) return;
|
||||||
@@ -123,7 +121,6 @@ namespace BoneSync.Patching
|
|||||||
[HarmonyPatch(typeof(Poolee))]
|
[HarmonyPatch(typeof(Poolee))]
|
||||||
public static class PooleePatches
|
public static class PooleePatches
|
||||||
{
|
{
|
||||||
|
|
||||||
public static void OnSpawnPatchPost(Poolee __instance)
|
public static void OnSpawnPatchPost(Poolee __instance)
|
||||||
{
|
{
|
||||||
if (CallPatchedMethods.allowPatchedMethodCall) return;
|
if (CallPatchedMethods.allowPatchedMethodCall) return;
|
||||||
@@ -193,6 +190,20 @@ namespace BoneSync.Patching
|
|||||||
return null;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user