From 551dc650fb3312a557ea5752aa7fbd3e5f15968b Mon Sep 17 00:00:00 2001 From: FreezeDriedMangoes Date: Fri, 17 Jun 2022 23:06:43 -0400 Subject: [PATCH] fixed quantum socketed objects --- NewHorizons/Builder/Props/QuantumBuilder.cs | 7 ++-- ...TemporaryDebugOnlyPatchesDeleteBeforePR.cs | 35 +++++++++++++++++++ NewHorizons/Utility/BoxShapeVisualizer.cs | 2 +- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/NewHorizons/Builder/Props/QuantumBuilder.cs b/NewHorizons/Builder/Props/QuantumBuilder.cs index 694a0166..8ac14923 100644 --- a/NewHorizons/Builder/Props/QuantumBuilder.cs +++ b/NewHorizons/Builder/Props/QuantumBuilder.cs @@ -16,6 +16,8 @@ using Logger = NewHorizons.Utility.Logger; // 1) MultiStateQuantumObjects don't check to see if the new state would be visible before choosing it // 2) QuantumShuffleObjects don't respect rotation, they set rotation to 0 on collapse +// New features to support +// 1) multiState._prerequisiteObjects namespace NewHorizons.Builder.Props { @@ -72,11 +74,8 @@ namespace NewHorizons.Builder.Props quantumObject._prebuilt = true; quantumObject._childSockets = new List(); // TODO: support _alignWithGravity? + if (prop.GetComponentInChildren() == null) AddBoundsVisibility(prop); prop.SetActive(true); - - if (prop.GetComponentInChildren() != null) continue; - - AddBoundsVisibility(prop); } } diff --git a/NewHorizons/Patches/TemporaryDebugOnlyPatchesDeleteBeforePR.cs b/NewHorizons/Patches/TemporaryDebugOnlyPatchesDeleteBeforePR.cs index bca95a33..782f8efb 100644 --- a/NewHorizons/Patches/TemporaryDebugOnlyPatchesDeleteBeforePR.cs +++ b/NewHorizons/Patches/TemporaryDebugOnlyPatchesDeleteBeforePR.cs @@ -13,11 +13,45 @@ namespace NewHorizons.Patches [HarmonyPatch] public static class TemporaryDebugOnlyPatchesDeleteBeforePR { + + [HarmonyPrefix] + [HarmonyPatch(typeof(QuantumObject), nameof(QuantumObject.Collapse))] + public static bool QuantumObject_Collapse(QuantumObject __instance, ref bool __result, bool skipInstantVisibilityCheck = false) + { + Logger.Log("trying to collapse"); + Logger.Log(__instance.gameObject.activeInHierarchy+""); + return true; + } + + + + // This is some dark magic + // this creates a method called base_DropItem that basically just calls OWItem.PickUpItem whenever it (VisionTorchItemPatches.base_PickUpItem) is called + [HarmonyReversePatch] + [HarmonyPatch(typeof(VisibilityObject), nameof(VisibilityObject.Update))] + private static void base_Update(VisibilityObject __instance) { } + + [HarmonyPrefix] + [HarmonyPatch(typeof(QuantumObject), nameof(QuantumObject.Update))] + public static bool QuantumObject_Update(QuantumObject __instance) + { + base_Update(__instance); + bool flag = __instance.IsLocked(); + if (__instance._wasLocked && !flag) Logger.Log("locked falling edge"); + if (__instance._wasLocked && !flag && !__instance.Collapse() && !__instance._ignoreRetryQueue) + { + ShapeManager.AddToRetryQueue(__instance); + } + __instance._wasLocked = flag; + + return false; + } [HarmonyPrefix] [HarmonyPatch(typeof(SocketedQuantumObject), nameof(SocketedQuantumObject.ChangeQuantumState))] public static bool SocketedQuantumObject_ChangeQuantumState(SocketedQuantumObject __instance, ref bool __result, bool skipInstantVisibilityCheck) { + Logger.Log("attempting change state"); for (int i = 0; i < __instance._childSockets.Count; i++) { if (__instance._childSockets[i].IsOccupied()) @@ -28,6 +62,7 @@ namespace NewHorizons.Patches } if (__instance._socketList.Count <= 1) { + Logger.Log("not enough sockets"); Debug.LogError("Not enough quantum sockets in list!", __instance); Debug.Break(); __result = false; diff --git a/NewHorizons/Utility/BoxShapeVisualizer.cs b/NewHorizons/Utility/BoxShapeVisualizer.cs index 1bdbc217..fa8ddaef 100644 --- a/NewHorizons/Utility/BoxShapeVisualizer.cs +++ b/NewHorizons/Utility/BoxShapeVisualizer.cs @@ -19,7 +19,7 @@ namespace NewHorizons.Utility void OnRenderObject() { - Popcron.Gizmos.Cube(transform.TransformPoint(box.center), transform.rotation, box.size); + Popcron.Gizmos.Cube(transform.TransformPoint(box.center), transform.rotation, Vector3.Scale(box.size, transform.lossyScale)); } } }