From 0698e1f5ce82cf9d1770cffebce61893963610bf Mon Sep 17 00:00:00 2001 From: xen-42 Date: Mon, 7 Oct 2024 23:01:47 -0400 Subject: [PATCH] Do not destroy dreamworld ever --- NewHorizons/Builder/Props/DetailBuilder.cs | 3 +- NewHorizons/Handlers/DreamHandler.cs | 56 ------------------- .../Handlers/PlanetDestructionHandler.cs | 8 ++- 3 files changed, 9 insertions(+), 58 deletions(-) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index f4009e7c..14560b16 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -274,7 +274,8 @@ namespace NewHorizons.Builder.Props // For DLC related props // Make sure to do this before its set active - if (detail.path.ToLowerInvariant().StartsWith("ringworld") || detail.path.ToLowerInvariant().StartsWith("dreamworld")) + if (!string.IsNullOrEmpty(detail?.path) && + (detail.path.ToLowerInvariant().StartsWith("ringworld") || detail.path.ToLowerInvariant().StartsWith("dreamworld"))) { prop.AddComponent()._destroyOnDLCNotOwned = true; } diff --git a/NewHorizons/Handlers/DreamHandler.cs b/NewHorizons/Handlers/DreamHandler.cs index d96e6457..9098170d 100644 --- a/NewHorizons/Handlers/DreamHandler.cs +++ b/NewHorizons/Handlers/DreamHandler.cs @@ -2,10 +2,6 @@ using NewHorizons.Utility; using NewHorizons.Utility.OWML; using OWML.Utils; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using UnityEngine; namespace NewHorizons.Handlers @@ -32,57 +28,5 @@ namespace NewHorizons.Handlers return DreamArrivalPoint.Location.Undefined; } } - - public static void MigrateDreamWorldController() - { - // Create new DreamWorldController instance since the existing one is disabled - var managerObj = new GameObject("DreamWorldManager"); - managerObj.SetActive(false); - var oldDWC = Locator.GetDreamWorldController(); - var dwc = managerObj.AddComponent(); - - var simRootObj = MigrateCopy(oldDWC._primarySimulationRoot.gameObject, managerObj); - - dwc._primarySimulationRoot = simRootObj.transform; - dwc._simulationRoots = new Transform[] { simRootObj.transform }; - dwc._simulationCamera = simRootObj.FindChild("Camera_Simulation").GetComponent(); - dwc._simulationSphere = simRootObj.FindChild("SimulationSphere").GetComponent(); - - dwc._tempSkyboxColor = oldDWC._tempSkyboxColor; - dwc._sarcophagusController = oldDWC._sarcophagusController; - dwc._prisonerDirector = oldDWC._prisonerDirector; - - // These should correspond to the arrival point's attached body - dwc._dreamBody = null; - dwc._dreamWorldSector = null; - dwc._dreamWorldVolume = null; - - // These should correspond to the campfire's attached body - dwc._planetBody = null; - dwc._ringWorldController = null; - - managerObj.SetActive(true); - - // Run after Start() completes - Delay.FireOnNextUpdate(() => - { - dwc._dreamBody = null; - dwc._dreamWorldSector = null; - dwc._dreamWorldVolume = null; - dwc._planetBody = null; - dwc._ringWorldController = null; - - // Dreamworld has a giant plane for simulation water, we don't want that in our custom world - dwc._primarySimulationRoot.Find("water_simulation").gameObject.SetActive(false); - }); - - } - - private static GameObject MigrateCopy(GameObject go, GameObject newParent) - { - var clone = GameObject.Instantiate(go); - clone.transform.SetParent(newParent.transform, false); - return clone; - } } } diff --git a/NewHorizons/Handlers/PlanetDestructionHandler.cs b/NewHorizons/Handlers/PlanetDestructionHandler.cs index 65152541..01b5fabe 100644 --- a/NewHorizons/Handlers/PlanetDestructionHandler.cs +++ b/NewHorizons/Handlers/PlanetDestructionHandler.cs @@ -93,7 +93,13 @@ namespace NewHorizons.Handlers private static void DreamWorldRemoved() { - DreamHandler.MigrateDreamWorldController(); + // No you didn't + // Needs to stay alive so that custom Dreamworlds can use its Dreamworld controller + // We had a separate dreamworld controller solution before, but that broke Eyes of the Past somehow + Locator.GetAstroObject(AstroObject.Name.DreamWorld).gameObject.SetActive(true); + // We thought of disabling the children for consistency: However this broke the tronworld for some reason + // Basically, leaving the real Dreamworld in is fine since as long as you don't place your own custom dreamworld on top + // of it, you'll never have it appear when you dont want it to } private static void SunRemoved()