diff --git a/QSB/ElevatorSync/Patches/NomaiElevatorPatches.cs b/QSB/ElevatorSync/Patches/NomaiElevatorPatches.cs index e453dd58..26e72913 100644 --- a/QSB/ElevatorSync/Patches/NomaiElevatorPatches.cs +++ b/QSB/ElevatorSync/Patches/NomaiElevatorPatches.cs @@ -1,5 +1,6 @@ using HarmonyLib; using QSB.Patches; +using QSB.Utility; using UnityEngine; namespace QSB.ElevatorSync.Patches; @@ -14,6 +15,8 @@ public class NomaiElevatorPatches : QSBPatch private static NomaiElevator blackHoleForgeEntrance; private static OWTriggerVolume blackHoleForgeEntranceTrigger; + private static bool runOnce; + [HarmonyPostfix] [HarmonyPatch(typeof(NomaiElevator), nameof(NomaiElevator.FixedUpdate))] public static void NomaiElevator_FixedUpdate(NomaiElevator __instance) @@ -34,23 +37,8 @@ public class NomaiElevatorPatches : QSBPatch if (!blackHoleForgeEntrance || !blackHoleForgeEntranceTrigger) { blackHoleForgeEntrance = GameObject.Find("BlackHoleForge_EntrancePivot").GetComponent(); - - // Use a built-in trigger and alter it. - var baseTrigger = GameObject.Find("BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/" + - "Sector_NorthPole/Sector_HangingCity/Sector_HangingCity_BlackHoleForge/" + - "BlackHoleForgePivot/Interactables_BlackHoleForge/BlackHoleForge_EntrancePivot/" + - "Geometry_BlackHoleForge_Entrance/GravityVolume (20)"); - - var newTrigger = Object.Instantiate(baseTrigger, baseTrigger.transform.parent); - blackHoleForgeEntranceTrigger = newTrigger.GetComponent(); - - // Make a new box and move it so that the entrance trigger is aligned with the entrance better. - // This prevents the player from moving with the entrance when they aren't in it - // because the base shape is too far up. - var box = (BoxShape)blackHoleForgeEntranceTrigger._shape; - // The shape is rotated so we dont use Y. - box.center = new Vector3(-1.85f, 0f, 0f); - box.enabled = true; + blackHoleForgeEntranceTrigger = GameObject.Find("FakeSector_BlackHoleForge_EntrancePivot") + .GetComponent(); } var speed = blackHoleForge._speed; @@ -73,5 +61,17 @@ public class NomaiElevatorPatches : QSBPatch var newPos = Locator.GetPlayerTransform().position + new Vector3(0f, speed * Time.deltaTime, 0f); Locator.GetPlayerTransform().position = newPos; } + + if (!runOnce) + { + // Recenter the universe because the player has been manually moved. + runOnce = true; + + Delay.RunWhen(() => !__instance.enabled, () => + { + runOnce = false; + CenterOfTheUniverse.s_instance.OnPlayerRepositioned(); + }); + } } } diff --git a/QSB/SectorSync/QSBSectorManager.cs b/QSB/SectorSync/QSBSectorManager.cs index 97ced643..3469d1c8 100644 --- a/QSB/SectorSync/QSBSectorManager.cs +++ b/QSB/SectorSync/QSBSectorManager.cs @@ -153,6 +153,36 @@ public class QSBSectorManager : WorldObjectManager }); } + + //black hole forge + { + var forge = GameObject.Find("BlackHoleForgePivot"); + FakeSector.Create(forge, + forge.GetComponentInParent(), + x => + { + var trigger = x.gameObject.AddComponent(); + x._triggerRoot = GameObject.Find("BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/" + + "Sector_HangingCity/Sector_HangingCity_BlackHoleForge/BlackHoleForgePivot/" + + "Volumes_BlackHoleForge/DirectionalForceVolume"); + }); + } + + // black hole forge entrance elevator + { + var entrance = GameObject.Find("BlackHoleForge_EntrancePivot"); + var sector = GameObject.Find("Sector_HangingCity_BlackHoleForge").GetComponent(); + FakeSector.Create(entrance, + sector, + x => + { + x.gameObject.AddComponent(); + var shape = x.gameObject.AddComponent(); + shape.size = new Vector3(5.5f, 5.8f, 5.5f); + shape.center = new Vector3(0f, 2.9f, 1.5f); + }); + } + // OPC probe { var probe = Locator._orbitalProbeCannon