From 84089f7bd79b0163b281ac8719446a187c105667 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Tue, 3 May 2022 23:17:10 -0700 Subject: [PATCH] AllObjectsReady checks in meteor patches --- QSB/MeteorSync/Patches/MeteorPatches.cs | 29 ++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/QSB/MeteorSync/Patches/MeteorPatches.cs b/QSB/MeteorSync/Patches/MeteorPatches.cs index eb517b40..d5ba621f 100644 --- a/QSB/MeteorSync/Patches/MeteorPatches.cs +++ b/QSB/MeteorSync/Patches/MeteorPatches.cs @@ -21,6 +21,11 @@ public class MeteorServerPatches : QSBPatch [HarmonyPatch(typeof(MeteorLauncher), nameof(MeteorLauncher.FixedUpdate))] public static bool MeteorLauncher_FixedUpdate(MeteorLauncher __instance) { + if (!QSBWorldSync.AllObjectsReady) + { + return true; + } + if (__instance._launchedMeteors != null) { for (var i = __instance._launchedMeteors.Count - 1; i >= 0; i--) @@ -87,6 +92,11 @@ public class MeteorServerPatches : QSBPatch [HarmonyPatch(typeof(MeteorLauncher), nameof(MeteorLauncher.LaunchMeteor))] public static bool MeteorLauncher_LaunchMeteor(MeteorLauncher __instance) { + if (!QSBWorldSync.AllObjectsReady) + { + return true; + } + var flag = __instance._dynamicMeteorPool != null && (__instance._meteorPool == null || Random.value < __instance._dynamicProbability); MeteorController meteorController = null; if (!flag) @@ -140,9 +150,16 @@ public class MeteorServerPatches : QSBPatch [HarmonyPostfix] [HarmonyPatch(typeof(FragmentIntegrity), nameof(FragmentIntegrity.AddDamage))] - public static void FragmentIntegrity_AddDamage(FragmentIntegrity __instance) => + public static void FragmentIntegrity_AddDamage(FragmentIntegrity __instance) + { + if (!QSBWorldSync.AllObjectsReady) + { + return; + } + __instance.GetWorldObject() .SendMessage(new FragmentIntegrityMessage(__instance._integrity)); + } } /// @@ -175,6 +192,11 @@ public class MeteorPatches : QSBPatch public static void MeteorController_Impact(MeteorController __instance, GameObject hitObject, Vector3 impactPoint, Vector3 impactVel) { + if (!QSBWorldSync.AllObjectsReady) + { + return; + } + if (QSBMeteor.IsSpecialImpact(hitObject)) { __instance.GetWorldObject() @@ -202,6 +224,11 @@ public class MeteorPatches : QSBPatch return; } + if (!QSBWorldSync.AllObjectsReady) + { + return; + } + var qsbFragment = __instance._detachableFragment._fragmentIntegrity.GetWorldObject(); if (qsbFragment.LeashLength != null) {