From 566d840adaaaad15085bcf8bb6e809a1dc61acdb Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 19 May 2024 14:36:50 -0400 Subject: [PATCH 01/18] Update NewHorizonsData.cs --- NewHorizons/External/NewHorizonsData.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/NewHorizons/External/NewHorizonsData.cs b/NewHorizons/External/NewHorizonsData.cs index 63a62392..cedb624a 100644 --- a/NewHorizons/External/NewHorizonsData.cs +++ b/NewHorizons/External/NewHorizonsData.cs @@ -187,7 +187,11 @@ namespace NewHorizons.External public static void ReadOneTimePopup(string id) { - _activeProfile?.PopupsRead.Add(id); + // else it re-adds it each time + if (_activeProfile != null && !_activeProfile.PopupsRead.Contains(id)) + { + _activeProfile.PopupsRead.Add(id); + } } public static bool HasReadOneTimePopup(string id) From 811299579ecfdea09d6cccb28d826916ca54f64e Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Fri, 24 May 2024 03:07:41 -0400 Subject: [PATCH 02/18] Fix and update xsd schemas --- NewHorizons/Schemas/dialogue_schema.xsd | 52 ++++++++++++++++--------- NewHorizons/Schemas/shiplog_schema.xsd | 49 +++++++++++++---------- NewHorizons/Schemas/text_schema.xsd | 16 ++++---- 3 files changed, 69 insertions(+), 48 deletions(-) diff --git a/NewHorizons/Schemas/dialogue_schema.xsd b/NewHorizons/Schemas/dialogue_schema.xsd index 55f1a632..2e57dfff 100644 --- a/NewHorizons/Schemas/dialogue_schema.xsd +++ b/NewHorizons/Schemas/dialogue_schema.xsd @@ -1,4 +1,4 @@ - + @@ -8,7 +8,7 @@ - + The name of the character, used for the interaction prompt. Set to `SIGN` for the prompt @@ -16,7 +16,7 @@ - + The different nodes of this dialogue tree @@ -30,7 +30,7 @@ - + The name of this dialogue node @@ -45,28 +45,28 @@ - + When used with multiple Dialogues, the node will choose a random one to show - + The dialogue to show to the player - + A list of options to show to the player once the character is done talking - + Facts to reveal when the player goes through this dialogue node @@ -80,7 +80,7 @@ - + Set a new persistent condition that will last indefinitely in the current save, unless cancelled @@ -88,6 +88,13 @@ + + + + Disable a set persistent condition from the current save + + + @@ -95,7 +102,7 @@ - + The name of the `DialogueNode` to go to after this node. Mutually exclusive with @@ -109,7 +116,7 @@ - + A page of dialogue to show to the player @@ -122,7 +129,7 @@ - + The ID of a fact to reveal @@ -135,13 +142,20 @@ - + Options the player can select from + + + + Name of another DialogueNode whose options you want to repeat to avoid having to copy paste + + + @@ -162,14 +176,14 @@ - + Require a (single-loop) condition to be met to show this option - + Hide this option if a (single-loop) condition has been met @@ -183,28 +197,28 @@ - + The text to show for this option - + Set a condition when this option is chosen - + Cancel a condition when this option is chosen - + The name of the `DialogueNode` to go to when this option is selected diff --git a/NewHorizons/Schemas/shiplog_schema.xsd b/NewHorizons/Schemas/shiplog_schema.xsd index c702c4ea..1c68acde 100644 --- a/NewHorizons/Schemas/shiplog_schema.xsd +++ b/NewHorizons/Schemas/shiplog_schema.xsd @@ -1,18 +1,18 @@ - + - + ID of the planet these entries are for - + A set of entries that belong to this planet @@ -29,49 +29,56 @@ - + The ID of this entry - + Name of this entry - + The curiosity this entry belongs to - + Whether this entry is a curiosity - + Whether to hide the "More To Explore" text on this entry - + + + + When the parent of this entry is determining whether its "More To Explore" text should appear, this child entry will be ignored. + + + + Ignore more to explore if a persistent condition is `true` - + If this fact is revealed, show the Alt picture @@ -105,35 +112,35 @@ - + The ID of this rumor fact - + The source of this rumor, this draws a line in detective mode - + Displays on the card in detective mode if no ExploreFacts have been revealed on the parent entry - + Priority over other RumorFacts to appear as the entry card's title - + Whether to hide the "More to explore" on this rumor fact @@ -147,14 +154,14 @@ - + The ID of this explore fact - + Whether to hide the "More to explore" text for this fact @@ -168,14 +175,14 @@ - + The text content for this fact - + Display alt-text given a certain fact is revealed @@ -183,14 +190,14 @@ - + The text to display if the condition is met - + The condition that needs to be fulfilled to have the alt text be displayed diff --git a/NewHorizons/Schemas/text_schema.xsd b/NewHorizons/Schemas/text_schema.xsd index 297e21cd..797497f4 100644 --- a/NewHorizons/Schemas/text_schema.xsd +++ b/NewHorizons/Schemas/text_schema.xsd @@ -27,27 +27,27 @@ - + The id of this text block - + The id of the parent text block - + - + - + The text to show for this option @@ -58,17 +58,17 @@ - + - + - + Facts to reveal when the player goes through this dialogue node From c9132a1450dcc301e0d16010e26c0819b7b6baad Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Fri, 24 May 2024 03:16:54 -0400 Subject: [PATCH 03/18] rearrange things to somewhat match base games's xmls even if they aren't always consistent there --- NewHorizons/Schemas/dialogue_schema.xsd | 56 ++++++++++++------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/NewHorizons/Schemas/dialogue_schema.xsd b/NewHorizons/Schemas/dialogue_schema.xsd index 2e57dfff..2b458cd5 100644 --- a/NewHorizons/Schemas/dialogue_schema.xsd +++ b/NewHorizons/Schemas/dialogue_schema.xsd @@ -59,13 +59,6 @@ - - - - A list of options to show to the player once the character is done talking - - - @@ -73,13 +66,6 @@ - - - - Set a new condition that will only last for the current loop - - - @@ -88,6 +74,13 @@ + + + + Set a new condition that will only last for the current loop + + + @@ -110,6 +103,13 @@ + + + + A list of options to show to the player once the character is done talking + + + @@ -162,6 +162,13 @@ + + + + Require a ship log fact to be known to show this option + + + @@ -190,13 +197,6 @@ - - - - Require a ship log fact to be known to show this option - - - @@ -204,6 +204,13 @@ + + + + The name of the `DialogueNode` to go to when this option is selected + + + @@ -218,13 +225,6 @@ - - - - The name of the `DialogueNode` to go to when this option is selected - - - From 3265f8b076195f84ee1bf368b152442ec2165f1d Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Fri, 3 May 2024 03:51:57 -0400 Subject: [PATCH 04/18] Add parentPath to scatter --- NewHorizons/Builder/Props/ScatterBuilder.cs | 24 ++++++++++++++++--- .../External/Modules/Props/ScatterInfo.cs | 5 ++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/NewHorizons/Builder/Props/ScatterBuilder.cs b/NewHorizons/Builder/Props/ScatterBuilder.cs index e725bf8a..e9416b3a 100644 --- a/NewHorizons/Builder/Props/ScatterBuilder.cs +++ b/NewHorizons/Builder/Props/ScatterBuilder.cs @@ -3,6 +3,7 @@ using NewHorizons.External.Modules.Props; using NewHorizons.Utility; using NewHorizons.Utility.Files; using NewHorizons.Utility.Geometry; +using NewHorizons.Utility.OWML; using OWML.Common; using System; using System.Collections.Generic; @@ -120,10 +121,27 @@ namespace NewHorizons.Builder.Props } } + + var parent = sector?.transform ?? go.transform; + + if (go != null && !string.IsNullOrEmpty(propInfo.parentPath)) + { + var newParent = go.transform.Find(propInfo.parentPath); + if (newParent != null) + { + parent = newParent; + sector = newParent.GetComponentInParent(); + } + else + { + NHLogger.LogError($"Cannot find parent object at path: {go.name}/{propInfo.parentPath}"); + } + } + var prop = scatterPrefab.InstantiateInactive(); - prop.transform.SetParent(sector?.transform ?? go.transform); - prop.transform.localPosition = go.transform.TransformPoint(point * height); - var up = go.transform.InverseTransformPoint(prop.transform.position).normalized; + prop.transform.SetParent(parent, false); + prop.transform.position = go.transform.TransformPoint(point * height); + var up = (prop.transform.position - go.transform.position).normalized; prop.transform.rotation = Quaternion.FromToRotation(Vector3.up, up); if (propInfo.offset != null) prop.transform.localPosition += prop.transform.TransformVector(propInfo.offset); diff --git a/NewHorizons/External/Modules/Props/ScatterInfo.cs b/NewHorizons/External/Modules/Props/ScatterInfo.cs index b53cd4e8..21d32d35 100644 --- a/NewHorizons/External/Modules/Props/ScatterInfo.cs +++ b/NewHorizons/External/Modules/Props/ScatterInfo.cs @@ -66,5 +66,10 @@ namespace NewHorizons.External.Modules.Props /// Should this detail stay loaded even if you're outside the sector (good for very large props) /// public bool keepLoaded; + + /// + /// The relative path from the planet to the parent of this object. Optional (will default to the root sector). + /// + public string parentPath; } } From 892bf624f45abb6dda5088e41ac1f84c707d0979 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Fri, 3 May 2024 04:09:15 -0400 Subject: [PATCH 05/18] Fix sectors being rotated on tidally locked bodies --- NewHorizons/Builder/General/SectorBuilder.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/NewHorizons/Builder/General/SectorBuilder.cs b/NewHorizons/Builder/General/SectorBuilder.cs index 467ed91f..eeaa08a8 100644 --- a/NewHorizons/Builder/General/SectorBuilder.cs +++ b/NewHorizons/Builder/General/SectorBuilder.cs @@ -11,8 +11,7 @@ namespace NewHorizons.Builder.General { var sectorGO = new GameObject("Sector"); sectorGO.SetActive(false); - sectorGO.transform.parent = planetBody.transform; - sectorGO.transform.localPosition = Vector3.zero; + sectorGO.transform.SetParent(planetBody.transform, false); var SS = sectorGO.AddComponent(); SS.SetCollisionMode(Shape.CollisionMode.Volume); From 90f7d234794298d71bdb61bcf42fe3e5c098b06f Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Fri, 3 May 2024 08:40:09 -0400 Subject: [PATCH 06/18] Make it local so that scatter works on tidally locked bodies --- NewHorizons/Builder/Props/ScatterBuilder.cs | 2 +- NewHorizons/External/Modules/Props/ScatterInfo.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NewHorizons/Builder/Props/ScatterBuilder.cs b/NewHorizons/Builder/Props/ScatterBuilder.cs index e9416b3a..5b6faa34 100644 --- a/NewHorizons/Builder/Props/ScatterBuilder.cs +++ b/NewHorizons/Builder/Props/ScatterBuilder.cs @@ -140,7 +140,7 @@ namespace NewHorizons.Builder.Props var prop = scatterPrefab.InstantiateInactive(); prop.transform.SetParent(parent, false); - prop.transform.position = go.transform.TransformPoint(point * height); + prop.transform.localPosition = point * height; var up = (prop.transform.position - go.transform.position).normalized; prop.transform.rotation = Quaternion.FromToRotation(Vector3.up, up); diff --git a/NewHorizons/External/Modules/Props/ScatterInfo.cs b/NewHorizons/External/Modules/Props/ScatterInfo.cs index 21d32d35..a03b2003 100644 --- a/NewHorizons/External/Modules/Props/ScatterInfo.cs +++ b/NewHorizons/External/Modules/Props/ScatterInfo.cs @@ -68,7 +68,7 @@ namespace NewHorizons.External.Modules.Props public bool keepLoaded; /// - /// The relative path from the planet to the parent of this object. Optional (will default to the root sector). + /// The relative path from the planet to the parent of this object. Optional (will default to the root sector). This parent should be at the position where you'd like to scatter (which would usually be zero). /// public string parentPath; } From 5027ca8fd028c4db3126f07d5927dbd28f003e23 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Fri, 3 May 2024 09:52:32 -0400 Subject: [PATCH 07/18] Update schemas --- NewHorizons/Schemas/body_schema.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 3e9321e8..b679d7d3 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -2046,6 +2046,10 @@ "keepLoaded": { "type": "boolean", "description": "Should this detail stay loaded even if you're outside the sector (good for very large props)" + }, + "parentPath": { + "type": "string", + "description": "The relative path from the planet to the parent of this object. Optional (will default to the root sector). This parent should be at the position where you'd like to scatter (which would usually be zero)." } } }, From 14cf9ced3bed6e15c1ef296fe6e0c042c8c55ad4 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Fri, 3 May 2024 08:40:02 -0400 Subject: [PATCH 08/18] Fix the solar system radius calculation needs to divide not multiply --- NewHorizons/Handlers/PlanetCreationHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index 75edb30a..d8e017b4 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -928,7 +928,7 @@ namespace NewHorizons.Handlers } // Uses the ratio of the interlopers furthest point to what the base game considers the edge of the solar system - var distanceToCenter = go.transform.position.magnitude * (24000 / 30000f); + var distanceToCenter = go.transform.position.magnitude / (24000 / 30000f); if (distanceToCenter > SolarSystemRadius) { SolarSystemRadius = distanceToCenter; From 6a516ef6af48ae6a7ad57e9082bf0ab06e092363 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Fri, 31 May 2024 06:18:33 -0400 Subject: [PATCH 09/18] Move scatter after details So that we can parent it to a root detail --- NewHorizons/Builder/Props/PropBuildManager.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/NewHorizons/Builder/Props/PropBuildManager.cs b/NewHorizons/Builder/Props/PropBuildManager.cs index 86dcf826..f8c1380f 100644 --- a/NewHorizons/Builder/Props/PropBuildManager.cs +++ b/NewHorizons/Builder/Props/PropBuildManager.cs @@ -47,17 +47,6 @@ namespace NewHorizons.Builder.Props } } } - if (config.Props.scatter != null) - { - try - { - ScatterBuilder.Make(go, sector, config, mod); - } - catch (Exception ex) - { - NHLogger.LogError($"Couldn't make planet scatter for [{go.name}]:\n{ex}"); - } - } if (config.Props.details != null) { foreach (var detail in config.Props.details) @@ -72,6 +61,17 @@ namespace NewHorizons.Builder.Props } } } + if (config.Props.scatter != null) + { + try + { + ScatterBuilder.Make(go, sector, config, mod); + } + catch (Exception ex) + { + NHLogger.LogError($"Couldn't make planet scatter for [{go.name}]:\n{ex}"); + } + } if (config.Props.geysers != null) { foreach (var geyserInfo in config.Props.geysers) From 4719831f455fcf3f4756eda0fde1c36bc58387a6 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Sat, 4 May 2024 02:14:48 -0400 Subject: [PATCH 10/18] Set reference frame collider radius to just above zero because it being at zero makes it use the sphereOfInfluence instead --- NewHorizons/Builder/General/RFVolumeBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Builder/General/RFVolumeBuilder.cs b/NewHorizons/Builder/General/RFVolumeBuilder.cs index f8fa8aa8..808a7314 100644 --- a/NewHorizons/Builder/General/RFVolumeBuilder.cs +++ b/NewHorizons/Builder/General/RFVolumeBuilder.cs @@ -13,7 +13,7 @@ namespace NewHorizons.Builder.General // We can't not build a reference frame volume, Cloak requires one to be there module.maxTargetDistance = 0f; module.targetWhenClose = true; - module.targetColliderRadius = 0f; + module.targetColliderRadius = 0.001f; module.hideInMap = true; owrb.SetIsTargetable(false); } From 7489ecb7f8977d199d06812f4b2b8bb3f7ad43e2 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sat, 1 Jun 2024 00:43:31 -0700 Subject: [PATCH 11/18] MAYBE fix eye softlock (and use owml methods instead of copied qsb ones) --- NewHorizons/Main.cs | 8 +++-- NewHorizons/Patches/RigidbodyPatches.cs | 2 +- NewHorizons/Utility/NewHorizonExtensions.cs | 34 --------------------- 3 files changed, 7 insertions(+), 37 deletions(-) diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index df767fe7..0f8eebea 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -388,7 +388,9 @@ namespace NewHorizons { IsWarpingBackToEye = false; OWTime.Pause(OWTime.PauseType.Loading); - LoadManager.LoadScene(OWScene.EyeOfTheUniverse); // LoadScene loads one frame later in Update. will this break since we unpause before that in the next line? + // fire OnStartSceneLoad so qsb and other mods are happy + ((Delegate)AccessTools.Field(typeof(LoadManager), nameof(LoadManager.OnStartSceneLoad)).GetValue(null)).DynamicInvoke(); + LoadManager.LoadSceneImmediate(OWScene.EyeOfTheUniverse); OWTime.Unpause(OWTime.PauseType.Loading); return; } @@ -936,11 +938,13 @@ namespace NewHorizons OWInput.ChangeInputMode(InputMode.None); // Hide unloading + // fire OnStartSceneLoad so qsb and other mods are happy + ((Delegate)AccessTools.Field(typeof(LoadManager), nameof(LoadManager.OnStartSceneLoad)).GetValue(null)).DynamicInvoke(); FadeHandler.FadeThen(1f, () => { // Slide reel unloading is tied to being removed from the sector, so we do that here to prevent a softlock Locator.GetPlayerSectorDetector().RemoveFromAllSectors(); - LoadManager.LoadScene(sceneToLoad); // this used to be LoadSceneImmediate, but that breaks with qsb. hopefully it doesnt break nh + LoadManager.LoadSceneImmediate(sceneToLoad); }); } } diff --git a/NewHorizons/Patches/RigidbodyPatches.cs b/NewHorizons/Patches/RigidbodyPatches.cs index 22ad16dc..963a6406 100644 --- a/NewHorizons/Patches/RigidbodyPatches.cs +++ b/NewHorizons/Patches/RigidbodyPatches.cs @@ -1,5 +1,5 @@ using HarmonyLib; -using NewHorizons.Utility; +using OWML.Utils; using System.Collections.Generic; using UnityEngine; diff --git a/NewHorizons/Utility/NewHorizonExtensions.cs b/NewHorizons/Utility/NewHorizonExtensions.cs index 3ba29885..7236af7e 100644 --- a/NewHorizons/Utility/NewHorizonExtensions.cs +++ b/NewHorizons/Utility/NewHorizonExtensions.cs @@ -372,40 +372,6 @@ namespace NewHorizons.Utility return curve; } - // From QSB - public static void RaiseEvent(this T instance, string eventName, params object[] args) - { - const BindingFlags flags = BindingFlags.Instance - | BindingFlags.Static - | BindingFlags.Public - | BindingFlags.NonPublic - | BindingFlags.DeclaredOnly; - if (typeof(T) - .GetField(eventName, flags)? - .GetValue(instance) is not MulticastDelegate multiDelegate) - { - return; - } - - multiDelegate.SafeInvoke(args); - } - - // From QSB - public static void SafeInvoke(this MulticastDelegate multicast, params object[] args) - { - foreach (var del in multicast.GetInvocationList()) - { - try - { - del.DynamicInvoke(args); - } - catch (TargetInvocationException ex) - { - NHLogger.LogError($"Error invoking delegate! {ex.InnerException}"); - } - } - } - public static List GetChildNodes(this XmlNode parentNode, string tagName) { return parentNode.ChildNodes.Cast().Where(node => node.LocalName == tagName).ToList(); From 1d41360c00ea4d3a704215af257c33c04f29fa99 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sat, 1 Jun 2024 10:34:49 -0700 Subject: [PATCH 12/18] forgot to pass in the right arguments --- NewHorizons/Main.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 0f8eebea..b0dd6bf3 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -389,7 +389,7 @@ namespace NewHorizons IsWarpingBackToEye = false; OWTime.Pause(OWTime.PauseType.Loading); // fire OnStartSceneLoad so qsb and other mods are happy - ((Delegate)AccessTools.Field(typeof(LoadManager), nameof(LoadManager.OnStartSceneLoad)).GetValue(null)).DynamicInvoke(); + ((Delegate)AccessTools.Field(typeof(LoadManager), nameof(LoadManager.OnStartSceneLoad)).GetValue(null)).DynamicInvoke(LoadManager.s_currentScene, LoadManager.s_loadingScene); LoadManager.LoadSceneImmediate(OWScene.EyeOfTheUniverse); OWTime.Unpause(OWTime.PauseType.Loading); return; @@ -939,7 +939,7 @@ namespace NewHorizons // Hide unloading // fire OnStartSceneLoad so qsb and other mods are happy - ((Delegate)AccessTools.Field(typeof(LoadManager), nameof(LoadManager.OnStartSceneLoad)).GetValue(null)).DynamicInvoke(); + ((Delegate)AccessTools.Field(typeof(LoadManager), nameof(LoadManager.OnStartSceneLoad)).GetValue(null)).DynamicInvoke(LoadManager.s_currentScene, LoadManager.s_loadingScene); FadeHandler.FadeThen(1f, () => { // Slide reel unloading is tied to being removed from the sector, so we do that here to prevent a softlock From 8ec148bb9a083a68737d785e6f56e443938ae67c Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sat, 1 Jun 2024 12:16:16 -0700 Subject: [PATCH 13/18] do things as properly as i can --- NewHorizons/Main.cs | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index b0dd6bf3..3ea714ae 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -387,11 +387,10 @@ namespace NewHorizons else if (IsWarpingBackToEye) { IsWarpingBackToEye = false; - OWTime.Pause(OWTime.PauseType.Loading); - // fire OnStartSceneLoad so qsb and other mods are happy - ((Delegate)AccessTools.Field(typeof(LoadManager), nameof(LoadManager.OnStartSceneLoad)).GetValue(null)).DynamicInvoke(LoadManager.s_currentScene, LoadManager.s_loadingScene); + // OWTime.Pause(OWTime.PauseType.Loading); // loading already pauses + ManualOnStartSceneLoad(OWScene.EyeOfTheUniverse); LoadManager.LoadSceneImmediate(OWScene.EyeOfTheUniverse); - OWTime.Unpause(OWTime.PauseType.Loading); + // OWTime.Unpause(OWTime.PauseType.Loading); // changing active scenes already unpauses return; } @@ -629,6 +628,39 @@ namespace NewHorizons HasWarpDrive = true; } + /// + /// sometimes we call LoadSceneImmediate, which doesnt do the required event firing for mods to be happy. + /// this method emulates that via copying parts of LoadManager. + /// + public static void ManualOnStartSceneLoad(OWScene scene) + { + LoadManager.s_loadSceneJob = new LoadManager.LoadSceneJob(); + LoadManager.s_loadSceneJob.sceneToLoad = scene; + LoadManager.s_loadSceneJob.fadeType = LoadManager.FadeType.None; + LoadManager.s_loadSceneJob.fadeLength = 0; + LoadManager.s_loadSceneJob.pauseDuringFade = true; + LoadManager.s_loadSceneJob.asyncOperation = false; + LoadManager.s_loadSceneJob.skipPreLoadMemoryDump = false; + LoadManager.s_loadSceneJob.skipVsyncChange = false; + + LoadManager.s_loadingScene = LoadManager.s_loadSceneJob.sceneToLoad; + LoadManager.s_fadeType = LoadManager.s_loadSceneJob.fadeType; + LoadManager.s_fadeStartTime = Time.unscaledTime; + LoadManager.s_fadeLength = LoadManager.s_loadSceneJob.fadeLength; + LoadManager.s_pauseDuringFade = LoadManager.s_loadSceneJob.pauseDuringFade; + LoadManager.s_skipVsyncChange = LoadManager.s_loadSceneJob.skipVsyncChange; + + // cant fire events from outside of class without reflection + ((Delegate)AccessTools.Field(typeof(LoadManager), nameof(LoadManager.OnStartSceneLoad)).GetValue(null)) + .DynamicInvoke(LoadManager.s_currentScene, LoadManager.s_loadingScene); + + if (LoadManager.s_pauseDuringFade) + { + OWTime.Pause(OWTime.PauseType.Loading); + } + + LoadManager.s_loadSceneJob = null; + } #region Load public void LoadStarSystemConfig(string starSystemName, StarSystemConfig starSystemConfig, string relativePath, IModBehaviour mod) @@ -938,8 +970,7 @@ namespace NewHorizons OWInput.ChangeInputMode(InputMode.None); // Hide unloading - // fire OnStartSceneLoad so qsb and other mods are happy - ((Delegate)AccessTools.Field(typeof(LoadManager), nameof(LoadManager.OnStartSceneLoad)).GetValue(null)).DynamicInvoke(LoadManager.s_currentScene, LoadManager.s_loadingScene); + ManualOnStartSceneLoad(sceneToLoad); FadeHandler.FadeThen(1f, () => { // Slide reel unloading is tied to being removed from the sector, so we do that here to prevent a softlock From 79ad86467f348021ed566bf52ea2a888ca95920d Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sat, 1 Jun 2024 12:59:26 -0700 Subject: [PATCH 14/18] format --- NewHorizons/Main.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 3ea714ae..7ca6e322 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -389,7 +389,7 @@ namespace NewHorizons IsWarpingBackToEye = false; // OWTime.Pause(OWTime.PauseType.Loading); // loading already pauses ManualOnStartSceneLoad(OWScene.EyeOfTheUniverse); - LoadManager.LoadSceneImmediate(OWScene.EyeOfTheUniverse); + LoadManager.LoadSceneImmediate(OWScene.EyeOfTheUniverse); // OWTime.Unpause(OWTime.PauseType.Loading); // changing active scenes already unpauses return; } From fc1f25a70d6c312dc9c0360d5ea7b682e2b7886f Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Sat, 1 Jun 2024 22:17:20 -0400 Subject: [PATCH 15/18] check InConversation to avoid unnecessary EndConversation calls (#859) even though this already happens in CharacterDialogueTree.EndConversation itself, I did it for Ixrec anyways. --- .../Patches/DialoguePatches/CharacterDialogueTreePatches.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Patches/DialoguePatches/CharacterDialogueTreePatches.cs b/NewHorizons/Patches/DialoguePatches/CharacterDialogueTreePatches.cs index 1ef6c7b3..d30cc7b7 100644 --- a/NewHorizons/Patches/DialoguePatches/CharacterDialogueTreePatches.cs +++ b/NewHorizons/Patches/DialoguePatches/CharacterDialogueTreePatches.cs @@ -24,7 +24,10 @@ public static class CharacterDialogueTreePatches private static void OnAttachPlayerToPoint(this CharacterDialogueTree characterDialogueTree, OWRigidbody rigidbody) { - characterDialogueTree.EndConversation(); + if (characterDialogueTree.InConversation()) + { + characterDialogueTree.EndConversation(); + } } [HarmonyPostfix] From e74e690ef87474e794ed0c8817bcdb78247fc575 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 3 Jun 2024 22:49:26 -0400 Subject: [PATCH 16/18] Add a comment --- NewHorizons/Builder/General/SectorBuilder.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/NewHorizons/Builder/General/SectorBuilder.cs b/NewHorizons/Builder/General/SectorBuilder.cs index eeaa08a8..6ad8e462 100644 --- a/NewHorizons/Builder/General/SectorBuilder.cs +++ b/NewHorizons/Builder/General/SectorBuilder.cs @@ -11,6 +11,7 @@ namespace NewHorizons.Builder.General { var sectorGO = new GameObject("Sector"); sectorGO.SetActive(false); + // Have to use set parent method without keeping world position to Fix sectors being rotated on tidally locked bodies #870 sectorGO.transform.SetParent(planetBody.transform, false); var SS = sectorGO.AddComponent(); From e617d98e1f31898f2a6bdb20780cc5bb62073ecb Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 3 Jun 2024 22:52:04 -0400 Subject: [PATCH 17/18] Add comment --- NewHorizons/Builder/Props/ScatterBuilder.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/NewHorizons/Builder/Props/ScatterBuilder.cs b/NewHorizons/Builder/Props/ScatterBuilder.cs index 5b6faa34..862f0629 100644 --- a/NewHorizons/Builder/Props/ScatterBuilder.cs +++ b/NewHorizons/Builder/Props/ScatterBuilder.cs @@ -139,6 +139,7 @@ namespace NewHorizons.Builder.Props } var prop = scatterPrefab.InstantiateInactive(); + // Have to use SetParent method to work with tidally locked bodies #872 prop.transform.SetParent(parent, false); prop.transform.localPosition = point * height; var up = (prop.transform.position - go.transform.position).normalized; From 0f56b59d631b60743d0bcebb566bfeccf4df7e46 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 3 Jun 2024 23:06:10 -0400 Subject: [PATCH 18/18] Update manifest.json --- NewHorizons/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/manifest.json b/NewHorizons/manifest.json index c57ae22d..222822d4 100644 --- a/NewHorizons/manifest.json +++ b/NewHorizons/manifest.json @@ -4,7 +4,7 @@ "author": "xen, Bwc9876, JohnCorby, MegaPiggy, Clay, Trifid, and friends", "name": "New Horizons", "uniqueName": "xen.NewHorizons", - "version": "1.20.2", + "version": "1.20.3", "owmlVersion": "2.10.3", "dependencies": [ "JohnCorby.VanillaFix", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ], "conflicts": [ "PacificEngine.OW_CommonResources" ],