From 3e0e809420dd37dd98561afa1846e7b02ff9668a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Garro?= Date: Sat, 11 Jun 2022 01:31:47 -0300 Subject: [PATCH 01/18] Fix slide not showing after blackFrameDuration --- NewHorizons/Builder/Props/ProjectionBuilder.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/NewHorizons/Builder/Props/ProjectionBuilder.cs b/NewHorizons/Builder/Props/ProjectionBuilder.cs index 4a9f1bb7..05eff66f 100644 --- a/NewHorizons/Builder/Props/ProjectionBuilder.cs +++ b/NewHorizons/Builder/Props/ProjectionBuilder.cs @@ -96,7 +96,7 @@ namespace NewHorizons.Builder.Props imageLoader.imageLoadedEvent.AddListener( (Texture2D tex, int index) => { - slideCollection.slides[index].textureOverride = ImageUtilities.Invert(tex); + slideCollection.slides[index]._image = ImageUtilities.Invert(tex); // Track the first 15 to put on the slide reel object if (index < 15) @@ -176,7 +176,7 @@ namespace NewHorizons.Builder.Props slideCollection.slides[i] = slide; } - imageLoader.imageLoadedEvent.AddListener((Texture2D tex, int index) => { slideCollection.slides[index].textureOverride = ImageUtilities.Invert(tex); }); + imageLoader.imageLoadedEvent.AddListener((Texture2D tex, int index) => { slideCollection.slides[index]._image = ImageUtilities.Invert(tex); }); slideCollectionContainer.slideCollection = slideCollection; @@ -185,8 +185,8 @@ namespace NewHorizons.Builder.Props // Change the picture on the lens var lens = projectorObj.transform.Find("Spotlight/Prop_IP_SingleSlideProjector/Projector_Lens").GetComponent(); - lens.materials[1].mainTexture = slideCollection.slides[0]._textureOverride; - lens.materials[1].SetTexture(EmissionMap, slideCollection.slides[0]._textureOverride); + lens.materials[1].mainTexture = slideCollection.slides[0]._image; + lens.materials[1].SetTexture(EmissionMap, slideCollection.slides[0]._image); projectorObj.SetActive(true); } @@ -224,7 +224,7 @@ namespace NewHorizons.Builder.Props slideCollection.slides[i] = slide; } - imageLoader.imageLoadedEvent.AddListener((Texture2D tex, int index) => { slideCollection.slides[index].textureOverride = tex; }); + imageLoader.imageLoadedEvent.AddListener((Texture2D tex, int index) => { slideCollection.slides[index]._image = tex; }); // attatch a component to store all the data for the slides that play when a vision torch scans this target @@ -298,7 +298,7 @@ namespace NewHorizons.Builder.Props imageLoader.imageLoadedEvent.AddListener( (Texture2D tex, int index) => { - slideCollection.slides[index].textureOverride = tex; + slideCollection.slides[index]._image = tex; displaySlidesLoaded++; // threading moment if (displaySlidesLoaded >= slides.Length) @@ -380,7 +380,7 @@ namespace NewHorizons.Builder.Props public class VisionTorchTarget : MonoBehaviour { public MindSlideCollection slideCollection; - public SlideCollectionContainer slideCollectionContainer; + public SlideCollectionContainer slideCollectionContainer; public OWEvent.OWCallback onSlidesComplete; } } From 584b76458a9579d608580abbb5b077d543371baa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Garro?= Date: Sat, 11 Jun 2022 01:32:21 -0300 Subject: [PATCH 02/18] Fix auto projector container not enabled --- NewHorizons/Patches/AutoSlideProjectorPatches.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 NewHorizons/Patches/AutoSlideProjectorPatches.cs diff --git a/NewHorizons/Patches/AutoSlideProjectorPatches.cs b/NewHorizons/Patches/AutoSlideProjectorPatches.cs new file mode 100644 index 00000000..7d045635 --- /dev/null +++ b/NewHorizons/Patches/AutoSlideProjectorPatches.cs @@ -0,0 +1,14 @@ +using HarmonyLib; + +namespace NewHorizons.Patches; + +[HarmonyPatch] +public class AutoSlideProjectorPatches +{ + [HarmonyPostfix] + [HarmonyPatch(typeof(AutoSlideProjector), nameof(AutoSlideProjector.Play))] + public static void AutoSlideProjector_Play(ref SlideCollectionContainer ____slideCollectionItem) + { + ____slideCollectionItem.enabled = true; + } +} From e604bc00f79103d0a2d42157c639602e759b9478 Mon Sep 17 00:00:00 2001 From: Ben C Date: Sat, 11 Jun 2022 10:30:32 -0400 Subject: [PATCH 03/18] Bump Version --- NewHorizons/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/manifest.json b/NewHorizons/manifest.json index 45398176..129a60c2 100644 --- a/NewHorizons/manifest.json +++ b/NewHorizons/manifest.json @@ -3,7 +3,7 @@ "author": "xen, Bwc9876, & Book", "name": "New Horizons", "uniqueName": "xen.NewHorizons", - "version": "1.2.4", + "version": "1.2.5", "owmlVersion": "2.3.3", "conflicts": [ "Raicuparta.QuantumSpaceBuddies", "Vesper.AutoResume", "PacificEngine.OW_Randomizer" ], "pathsToPreserve": [ "planets", "systems", "translations" ] From c9f127e3ed709d2e4f7da75dacd77335ddbd5c5e Mon Sep 17 00:00:00 2001 From: Ben C Date: Sun, 12 Jun 2022 23:26:53 -0400 Subject: [PATCH 04/18] Added support for pre-crash styled Nomai recorders --- NewHorizons/Builder/Props/NomaiTextBuilder.cs | 8 +++++++- NewHorizons/External/Modules/PropModule.cs | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/NewHorizons/Builder/Props/NomaiTextBuilder.cs b/NewHorizons/Builder/Props/NomaiTextBuilder.cs index d304a9b8..01cd479a 100644 --- a/NewHorizons/Builder/Props/NomaiTextBuilder.cs +++ b/NewHorizons/Builder/Props/NomaiTextBuilder.cs @@ -19,6 +19,7 @@ namespace NewHorizons.Builder.Props private static GameObject _computerPrefab; private static GameObject _cairnPrefab; private static GameObject _recorderPrefab; + private static GameObject _preCrashRecorderPrefab; private static void InitPrefabs() { @@ -65,6 +66,10 @@ namespace NewHorizons.Builder.Props _recorderPrefab = SearchUtilities.Find("Comet_Body/Prefab_NOM_Shuttle/Sector_NomaiShuttleInterior/Interactibles_NomaiShuttleInterior/Prefab_NOM_Recorder").InstantiateInactive(); _recorderPrefab.name = "Prefab_NOM_Recorder"; _recorderPrefab.transform.rotation = Quaternion.identity; + + _preCrashRecorderPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_EscapePodCrashSite/Sector_CrashFragment/Interactables_CrashFragment/Prefab_NOM_Recorder").InstantiateInactive(); + _preCrashRecorderPrefab.name = "Prefab_NOM_Recorder_Vessel"; + _preCrashRecorderPrefab.transform.rotation = Quaternion.identity; } public static void Make(GameObject planetGO, Sector sector, PropModule.NomaiTextInfo info, IModBehaviour mod) @@ -222,9 +227,10 @@ namespace NewHorizons.Builder.Props sector.OnOccupantEnterSector.AddListener((x) => OWAssetHandler.LoadObject(cairnObject)); break; } + case PropModule.NomaiTextInfo.NomaiTextType.PreCrashRecorder: case PropModule.NomaiTextInfo.NomaiTextType.Recorder: { - var recorderObject = _recorderPrefab.InstantiateInactive(); + var recorderObject = (info.type == PropModule.NomaiTextInfo.NomaiTextType.PreCrashRecorder? _preCrashRecorderPrefab : _recorderPrefab).InstantiateInactive(); recorderObject.transform.parent = sector?.transform ?? planetGO.transform; recorderObject.transform.position = planetGO.transform.TransformPoint(info?.position ?? Vector3.zero); diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index c378c7af..2faf6324 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -407,7 +407,9 @@ namespace NewHorizons.External.Modules [EnumMember(Value = @"cairn")] Cairn = 3, - [EnumMember(Value = @"recorder")] Recorder = 4 + [EnumMember(Value = @"recorder")] Recorder = 4, + + [EnumMember(Value = @"preCrashRecorder")] PreCrashRecorder = 5 } /// From 47d1d7f1d8371bc043ca62162d81c13ff0848a72 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 13 Jun 2022 03:28:57 +0000 Subject: [PATCH 05/18] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 00b268c8..1914592e 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -1018,14 +1018,16 @@ "Scroll", "Computer", "Cairn", - "Recorder" + "Recorder", + "PreCrashRecorder" ], "enum": [ "wall", "scroll", "computer", "cairn", - "recorder" + "recorder", + "preCrashRecorder" ] }, "RaftInfo": { From f659c97ef76e768a2dde1ffab0328fdb3d416fca Mon Sep 17 00:00:00 2001 From: Ben C Date: Mon, 13 Jun 2022 04:59:12 -0400 Subject: [PATCH 06/18] Fix typo in ImageUtilities.ClearCache --- NewHorizons/Utility/ImageUtilities.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Utility/ImageUtilities.cs b/NewHorizons/Utility/ImageUtilities.cs index ffde01f1..0efff7d3 100644 --- a/NewHorizons/Utility/ImageUtilities.cs +++ b/NewHorizons/Utility/ImageUtilities.cs @@ -44,7 +44,7 @@ namespace NewHorizons.Utility public static void ClearCache() { - Logger.Log("Cleaing image cache"); + Logger.Log("Clearing image cache"); foreach (var texture in _loadedTextures.Values) { From 62269557d2fe0be9d3204492b38cce5362cc2a0b Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 13 Jun 2022 06:22:59 -0400 Subject: [PATCH 07/18] Fixed: Black sphere when using same height and texture map image #176 --- NewHorizons/Builder/Body/HeightMapBuilder.cs | 32 +++++++++++++++----- NewHorizons/Utility/ImageUtilities.cs | 15 +++++++++ 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/NewHorizons/Builder/Body/HeightMapBuilder.cs b/NewHorizons/Builder/Body/HeightMapBuilder.cs index 50d7c93a..31caa3c7 100644 --- a/NewHorizons/Builder/Body/HeightMapBuilder.cs +++ b/NewHorizons/Builder/Body/HeightMapBuilder.cs @@ -14,18 +14,33 @@ namespace NewHorizons.Builder.Body public static void Make(GameObject planetGO, Sector sector, HeightMapModule module, IModBehaviour mod, int resolution = 51) { + var deleteHeightmapFlag = false; + Texture2D heightMap, textureMap; try { - if (module.heightMap == null) heightMap = Texture2D.whiteTexture; + if (module.heightMap == null) + { + heightMap = Texture2D.whiteTexture; + } else { + // If we've loaded a new heightmap we'll delete the texture after heightMap = ImageUtilities.GetTexture(mod, module.heightMap); - // defer remove texture to next frame - Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => Object.Destroy(heightMap)); + deleteHeightmapFlag = true; } - if (module.textureMap == null) textureMap = Texture2D.whiteTexture; - else textureMap = ImageUtilities.GetTexture(mod, module.textureMap); + + if (module.textureMap == null) + { + textureMap = Texture2D.whiteTexture; + } + else + { + textureMap = ImageUtilities.GetTexture(mod, module.textureMap); + } + + // If the texturemap is the same as the heightmap don't delete it #176 + if (textureMap == heightMap) deleteHeightmapFlag = false; } catch (Exception e) { @@ -45,11 +60,9 @@ namespace NewHorizons.Builder.Body cubeSphere.GetComponent().mesh = mesh; if (PlanetShader == null) PlanetShader = Main.NHAssetBundle.LoadAsset("Assets/Shaders/SphereTextureWrapper.shader"); - //if (PlanetShader == null) PlanetShader = Shader.Find("Standard"); var cubeSphereMR = cubeSphere.AddComponent(); - var material = cubeSphereMR.material; - material = new Material(PlanetShader); + var material = new Material(PlanetShader); cubeSphereMR.material = material; material.name = textureMap.name; material.mainTexture = textureMap; @@ -65,6 +78,9 @@ namespace NewHorizons.Builder.Body cubeSphere.transform.position = planetGO.transform.position; cubeSphere.SetActive(true); + + // Now that we've made the mesh we can delete the heightmap texture + if (deleteHeightmapFlag) ImageUtilities.DeleteTexture(mod, module.heightMap, heightMap); } } } diff --git a/NewHorizons/Utility/ImageUtilities.cs b/NewHorizons/Utility/ImageUtilities.cs index 0efff7d3..67985004 100644 --- a/NewHorizons/Utility/ImageUtilities.cs +++ b/NewHorizons/Utility/ImageUtilities.cs @@ -42,6 +42,21 @@ namespace NewHorizons.Utility } } + public static void DeleteTexture(IModBehaviour mod, string filename, Texture2D texture) + { + var path = mod.ModHelper.Manifest.ModFolderPath + filename; + if (_loadedTextures.ContainsKey(path)) + { + if (_loadedTextures[path] == texture) + { + _loadedTextures.Remove(path); + UnityEngine.Object.Destroy(texture); + } + } + + UnityEngine.Object.Destroy(texture); + } + public static void ClearCache() { Logger.Log("Clearing image cache"); From 6df3b86fbc7b9758a47a9bd1c487024b625814b9 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 13 Jun 2022 07:38:21 -0400 Subject: [PATCH 08/18] Non-latin star system fonts (#174) and add translation for warp prompts --- .../AssetBundle/translations/english.json | 6 ++++-- NewHorizons/Components/ShipLogStarChartMode.cs | 18 +++++++++++++----- NewHorizons/Handlers/TranslationHandler.cs | 11 ++++++++++- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/NewHorizons/AssetBundle/translations/english.json b/NewHorizons/AssetBundle/translations/english.json index 5de572c5..ddd88a5b 100644 --- a/NewHorizons/AssetBundle/translations/english.json +++ b/NewHorizons/AssetBundle/translations/english.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/xen-42/outer-wilds-new-horizons/master/NewHorizons/translation_schema.json", + "$schema": "https://raw.githubusercontent.com/xen-42/outer-wilds-new-horizons/main/NewHorizons/Schemas/translation_schema.json", "DialogueDictionary": { "NEW_HORIZONS_WARP_DRIVE_DIALOGUE_1" : "Your ship is now equiped with a warp drive!", @@ -11,6 +11,8 @@ "INTERSTELLAR_MODE" : "Interstellar Mode", "FREQ_STATUE" : "Nomai Statue", "FREQ_WARP_CORE" : "Anti-Graviton Flux", - "FREQ_UNKNOWN" : "???" + "FREQ_UNKNOWN" : "???", + "ENGAGE_WARP_PROMPT" : "Engage Warp To {0}", + "WARP_LOCKED" : "AUTOPILOT LOCKED TO:\n{0}" } } \ No newline at end of file diff --git a/NewHorizons/Components/ShipLogStarChartMode.cs b/NewHorizons/Components/ShipLogStarChartMode.cs index 70a6e48f..1b25d99b 100644 --- a/NewHorizons/Components/ShipLogStarChartMode.cs +++ b/NewHorizons/Components/ShipLogStarChartMode.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; using UnityEngine; +using UnityEngine.UI; using Logger = NewHorizons.Utility.Logger; namespace NewHorizons.Components { @@ -105,12 +106,15 @@ namespace NewHorizons.Components } var newCard = GameObject.Instantiate(_cardTemplate, parent); - var textComponent = newCard.transform.Find("EntryCardRoot/NameBackground/Name").GetComponent(); + var textComponent = newCard.transform.Find("EntryCardRoot/NameBackground/Name").GetComponent(); var name = UniqueIDToName(uniqueID); textComponent.text = name; if (name.Length > 17) textComponent.fontSize = 10; + // Do it next frame + var fontPath = "Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/DetectiveMode/ScaleRoot/PanRoot/TH_VILLAGE/EntryCardRoot/NameBackground/Name"; + Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => textComponent.font = SearchUtilities.Find(fontPath).GetComponent().font); newCard.SetActive(true); newCard.transform.name = uniqueID; @@ -273,16 +277,20 @@ namespace NewHorizons.Components private void SetWarpTarget(ShipLogEntryCard shipLogEntryCard) { RemoveWarpTarget(false); - _oneShotSource.PlayOneShot(global::AudioType.ShipLogUnmarkLocation, 1f); + _oneShotSource.PlayOneShot(AudioType.ShipLogUnmarkLocation, 1f); _target = shipLogEntryCard; _target.SetMarkedOnHUD(true); Locator._rfTracker.UntargetReferenceFrame(); - GlobalMessenger.FireEvent("UntargetReferenceFrame"); - _warpNotificationData = new NotificationData($"AUTOPILOT LOCKED TO:\n{UniqueIDToName(shipLogEntryCard.name).ToUpper()}"); + + var name = UniqueIDToName(shipLogEntryCard.name); + + var warpNotificationDataText = TranslationHandler.GetTranslation("WARP_LOCKED", TranslationHandler.TextType.UI).Replace("{0}", name.ToUpper()); + _warpNotificationData = new NotificationData(warpNotificationDataText); NotificationManager.SharedInstance.PostNotification(_warpNotificationData, true); - _warpPrompt.SetText($" Engage Warp To {UniqueIDToName(shipLogEntryCard.name)}"); + var warpPromptText = " " + TranslationHandler.GetTranslation("ENGAGE_WARP_PROMPT", TranslationHandler.TextType.UI).Replace("{0}", name); + _warpPrompt.SetText(warpPromptText); } private void RemoveWarpTarget(bool playSound = false) diff --git a/NewHorizons/Handlers/TranslationHandler.cs b/NewHorizons/Handlers/TranslationHandler.cs index 9987fb96..634bbe4d 100644 --- a/NewHorizons/Handlers/TranslationHandler.cs +++ b/NewHorizons/Handlers/TranslationHandler.cs @@ -1,4 +1,4 @@ -using NewHorizons.External.Configs; +using NewHorizons.External.Configs; using System; using System.Collections.Generic; using System.Linq; @@ -18,6 +18,11 @@ namespace NewHorizons.Handlers } public static string GetTranslation(string text, TextType type) + { + return GetTranslation(text, type, out var _); + } + + public static string GetTranslation(string text, TextType type, out TextTranslation.Language translatedLanguage) { Dictionary> dictionary; var language = TextTranslation.Get().m_language; @@ -34,6 +39,7 @@ namespace NewHorizons.Handlers dictionary = _uiTranslationDictionary; break; default: + translatedLanguage = TextTranslation.Language.UNKNOWN; return text; } @@ -41,6 +47,7 @@ namespace NewHorizons.Handlers { if (table.TryGetValue(text, out var translatedText)) { + translatedLanguage = language; return translatedText; } } @@ -51,11 +58,13 @@ namespace NewHorizons.Handlers if (englishTable.TryGetValue(text, out var englishText)) { + translatedLanguage = TextTranslation.Language.ENGLISH; return englishText; } } // Default to the key + translatedLanguage = TextTranslation.Language.UNKNOWN; return text; } From 87bc02fc17744a11c76a986daac344ac8cf5652d Mon Sep 17 00:00:00 2001 From: Tlya <94857119+Tllya@users.noreply.github.com> Date: Mon, 13 Jun 2022 18:01:42 +0500 Subject: [PATCH 09/18] Update RUS translation --- NewHorizons/AssetBundle/translations/russian.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/NewHorizons/AssetBundle/translations/russian.json b/NewHorizons/AssetBundle/translations/russian.json index 55537fed..e3decd66 100644 --- a/NewHorizons/AssetBundle/translations/russian.json +++ b/NewHorizons/AssetBundle/translations/russian.json @@ -11,6 +11,8 @@ "INTERSTELLAR_MODE" : "Режим Interstellar", "FREQ_STATUE" : "Статуя Номаи", "FREQ_WARP_CORE" : "Гиперядро", - "FREQ_UNKNOWN" : "???" + "FREQ_UNKNOWN" : "???", + "ENGAGE_WARP_PROMPT" : "Телепортироваться к {0}", + "WARP_LOCKED" : "АВТОПИЛОТ ЗАКРЕПЛЁН НА:\n{0}" } -} \ No newline at end of file +} From d2ee13bff9840726342d02eaf9fc5fe307bf9de5 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 13 Jun 2022 20:03:42 -0400 Subject: [PATCH 10/18] Make system override work from title screen --- NewHorizons/Main.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 49c6690f..e0bc641a 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -80,6 +80,9 @@ namespace NewHorizons _defaultSystemOverride = config.GetSettingsValue("Default System Override"); + // Else it doesn't get set idk + if (SceneManager.GetActiveScene().name == "TitleScreen") _currentStarSystem = _defaultSystemOverride; + var wasUsingCustomTitleScreen = _useCustomTitleScreen; _useCustomTitleScreen = config.GetSettingsValue("Custom title screen"); // Reload the title screen if this was updated on it From 7c9ce5d4b153fc686c9254bab1b155e81e4669ee Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 13 Jun 2022 20:09:40 -0400 Subject: [PATCH 11/18] Fix tornado audio distances (Implements #178) --- NewHorizons/Builder/Props/TornadoBuilder.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Props/TornadoBuilder.cs b/NewHorizons/Builder/Props/TornadoBuilder.cs index 34c21494..29e093fa 100644 --- a/NewHorizons/Builder/Props/TornadoBuilder.cs +++ b/NewHorizons/Builder/Props/TornadoBuilder.cs @@ -116,7 +116,8 @@ namespace NewHorizons.Builder.Props tornadoGO.transform.localScale = Vector3.one * scale; // Resize the distance it can be heard from to match roughly with the size - audioSource.maxDistance = 100 * scale; + audioSource.maxDistance = 10 * scale; + audioSource.minDistance = scale; var controller = tornadoGO.GetComponent(); controller.SetSector(sector); From 7a7dc7f57a419d100600e9e2a4e8369076b07bde Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 13 Jun 2022 20:18:40 -0400 Subject: [PATCH 12/18] Remove documentation of deprecated features --- NewHorizons/External/Configs/StarSystemConfig.cs | 5 ----- NewHorizons/External/Modules/PropModule.cs | 6 ++---- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/NewHorizons/External/Configs/StarSystemConfig.cs b/NewHorizons/External/Configs/StarSystemConfig.cs index 86cc9c2b..5d5cdc75 100644 --- a/NewHorizons/External/Configs/StarSystemConfig.cs +++ b/NewHorizons/External/Configs/StarSystemConfig.cs @@ -14,11 +14,6 @@ namespace NewHorizons.External.Configs /// public bool canEnterViaWarpDrive = true; - /// - /// [DEPRECATED] Not implemented - /// - public NomaiCoordinates coords; - /// /// Do you want a clean slate for this star system? Or will it be a modified version of the original. /// diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index 2faf6324..eef55e22 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -5,6 +5,7 @@ using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using Newtonsoft.Json; using Newtonsoft.Json.Converters; +using System; namespace NewHorizons.External.Modules { @@ -191,10 +192,7 @@ namespace NewHorizons.External.Modules [EnumMember(Value = @"hurricane")] Hurricane = 2 } - /// - /// [DEPRECATED] Should this tornado shoot you down instead of up? - /// - public bool downwards; + [Obsolete("Downwards is deprecated. Use Type instead.")] public bool downwards; /// /// Alternative to setting the position. Will choose a random place at this elevation. From b0bc48465cef49c6178cf5e5927fd5a4672f0c10 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 13 Jun 2022 20:21:05 -0400 Subject: [PATCH 13/18] Add audioDistance to tornados (#178) --- NewHorizons/Builder/Props/TornadoBuilder.cs | 5 +++-- NewHorizons/External/Modules/PropModule.cs | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/NewHorizons/Builder/Props/TornadoBuilder.cs b/NewHorizons/Builder/Props/TornadoBuilder.cs index 29e093fa..843923c9 100644 --- a/NewHorizons/Builder/Props/TornadoBuilder.cs +++ b/NewHorizons/Builder/Props/TornadoBuilder.cs @@ -116,8 +116,9 @@ namespace NewHorizons.Builder.Props tornadoGO.transform.localScale = Vector3.one * scale; // Resize the distance it can be heard from to match roughly with the size - audioSource.maxDistance = 10 * scale; - audioSource.minDistance = scale; + var maxDistance = info.audioDistance == 0 ? 10 * scale : info.audioDistance; + audioSource.maxDistance = maxDistance; + audioSource.minDistance = maxDistance / 10f; var controller = tornadoGO.GetComponent(); controller.SetSector(sector); diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index eef55e22..940577cb 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -234,6 +234,11 @@ namespace NewHorizons.External.Modules /// 0.1. /// public float wanderRate; + + /// + /// The maximum distance at which you'll hear the sounds of the cyclone. If not set it will scale relative to the size of the cyclone. + /// + public float audioDistance; } [JsonObject] From 038275eb11d31e81e7761be912dea5580b31ed05 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 14 Jun 2022 00:23:00 +0000 Subject: [PATCH 14/18] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 9 +++--- NewHorizons/Schemas/star_system_schema.json | 31 --------------------- 2 files changed, 5 insertions(+), 35 deletions(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 1914592e..fff468c4 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -1240,10 +1240,6 @@ "type": "object", "additionalProperties": false, "properties": { - "downwards": { - "type": "boolean", - "description": "[DEPRECATED] Should this tornado shoot you down instead of up?" - }, "elevation": { "type": "number", "description": "Alternative to setting the position. Will choose a random place at this elevation.", @@ -1283,6 +1279,11 @@ "type": "number", "description": "The rate at which the tornado will wander around the planet. Set to 0 for it to be stationary. Should be around\n0.1.", "format": "float" + }, + "audioDistance": { + "type": "number", + "description": "The maximum distance at which you'll hear the sounds of the cyclone. If not set it will scale relative to the size of the cyclone.", + "format": "float" } } }, diff --git a/NewHorizons/Schemas/star_system_schema.json b/NewHorizons/Schemas/star_system_schema.json index 1a4076a5..1e937325 100644 --- a/NewHorizons/Schemas/star_system_schema.json +++ b/NewHorizons/Schemas/star_system_schema.json @@ -9,10 +9,6 @@ "type": "boolean", "description": "Whether this system can be warped to via the warp drive" }, - "coords": { - "description": "[DEPRECATED] Not implemented", - "$ref": "#/definitions/NomaiCoordinates" - }, "destroyStockPlanets": { "type": "boolean", "description": "Do you want a clean slate for this star system? Or will it be a modified version of the original." @@ -52,33 +48,6 @@ } }, "definitions": { - "NomaiCoordinates": { - "type": "object", - "additionalProperties": false, - "properties": { - "x": { - "type": "array", - "items": { - "type": "integer", - "format": "int32" - } - }, - "y": { - "type": "array", - "items": { - "type": "integer", - "format": "int32" - } - }, - "z": { - "type": "array", - "items": { - "type": "integer", - "format": "int32" - } - } - } - }, "SkyboxConfig": { "type": "object", "additionalProperties": false, From 0083e485b3389c25c9bb94be3ced5e36be04c0d6 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 13 Jun 2022 20:28:26 -0400 Subject: [PATCH 15/18] Make it so planets must fall farther into stars to be destroyed --- NewHorizons/Builder/Body/StarBuilder.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Body/StarBuilder.cs b/NewHorizons/Builder/Body/StarBuilder.cs index d50ae5c7..b722e6fe 100644 --- a/NewHorizons/Builder/Body/StarBuilder.cs +++ b/NewHorizons/Builder/Body/StarBuilder.cs @@ -73,10 +73,18 @@ namespace NewHorizons.Builder.Body deathVolume.transform.localPosition = Vector3.zero; deathVolume.transform.localScale = Vector3.one; deathVolume.GetComponent().radius = 1f; - deathVolume.GetComponent()._onlyAffectsPlayerAndShip = false; + deathVolume.GetComponent()._onlyAffectsPlayerAndShip = true; deathVolume.GetComponent()._shrinkBodies = true; deathVolume.name = "DestructionVolume"; + var planetDestructionVolume = Object.Instantiate(deathVolume, starGO.transform); + planetDestructionVolume.transform.localPosition = Vector3.zero; + planetDestructionVolume.transform.localScale = Vector3.one; + planetDestructionVolume.GetComponent().radius = 0.75f; + planetDestructionVolume.GetComponent()._onlyAffectsPlayerAndShip = false; + planetDestructionVolume.GetComponent()._shrinkBodies = true; + planetDestructionVolume.name = "PlanetDestructionVolume"; + Light ambientLight = ambientLightGO.GetComponent(); var sunLight = new GameObject("StarLight"); From d25de139145deaf359d280d51d1761998efe8a4e Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 13 Jun 2022 20:37:10 -0400 Subject: [PATCH 16/18] When a quantum planet is destroyed, only destroy that state (#134) --- NewHorizons/Components/QuantumPlanet.cs | 4 ++- .../Patches/DestructionVolumePatches.cs | 35 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 NewHorizons/Patches/DestructionVolumePatches.cs diff --git a/NewHorizons/Components/QuantumPlanet.cs b/NewHorizons/Components/QuantumPlanet.cs index 68763c74..d6b4222e 100644 --- a/NewHorizons/Components/QuantumPlanet.cs +++ b/NewHorizons/Components/QuantumPlanet.cs @@ -1,4 +1,4 @@ -using NewHorizons.Builder.General; +using NewHorizons.Builder.General; using NewHorizons.Builder.Orbital; using NewHorizons.Components.Orbital; using NewHorizons.External.Modules; @@ -21,6 +21,8 @@ namespace NewHorizons.Components private AlignWithTargetBody _alignment; private OWRigidbody _rb; + public int CurrentIndex { get { return _currentIndex; } } + public override void Awake() { base.Awake(); diff --git a/NewHorizons/Patches/DestructionVolumePatches.cs b/NewHorizons/Patches/DestructionVolumePatches.cs new file mode 100644 index 00000000..23221daa --- /dev/null +++ b/NewHorizons/Patches/DestructionVolumePatches.cs @@ -0,0 +1,35 @@ +using HarmonyLib; +using NewHorizons.Components; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NewHorizons.Patches +{ + [HarmonyPatch] + public static class DestructionVolumePatches + { + [HarmonyPrefix] + [HarmonyPatch(typeof(DestructionVolume), nameof(DestructionVolume.Vanish))] + public static bool DestructionVolume_Vanish(OWRigidbody __0) + { + var quantumPlanet = __0.gameObject.GetComponent(); + + if (quantumPlanet == null) return true; + + // Allow it to vanish if this is the only state + if (quantumPlanet.states.Count <= 1) return true; + + // Force it to change states but if it can't, remove it + var oldIndex = quantumPlanet.CurrentIndex; + quantumPlanet.ChangeQuantumState(true); + if (quantumPlanet.CurrentIndex == oldIndex) return true; + + quantumPlanet.states.RemoveAt(oldIndex); + + return false; + } + } +} From ab47789c5d0f81a8c0d4e5dd4af67504e9766a16 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 13 Jun 2022 20:42:54 -0400 Subject: [PATCH 17/18] Make quantum planet orbit line update between states (#134) --- .../Builder/Orbital/OrbitlineBuilder.cs | 10 +---- NewHorizons/Components/Orbital/NHOrbitLine.cs | 41 +++++++++++-------- NewHorizons/Components/QuantumPlanet.cs | 12 ++++++ 3 files changed, 37 insertions(+), 26 deletions(-) diff --git a/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs b/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs index 4cd2b3bf..e6ad0a53 100644 --- a/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs +++ b/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs @@ -45,15 +45,7 @@ namespace NewHorizons.Builder.Orbital { orbitLine = orbitGO.AddComponent(); - var a = astroObject.semiMajorAxis; - var e = astroObject.eccentricity; - var b = a * Mathf.Sqrt(1f - (e * e)); - var l = astroObject.longitudeOfAscendingNode; - var p = astroObject.argumentOfPeriapsis; - var i = astroObject.inclination; - - (orbitLine as NHOrbitLine).SemiMajorAxis = a * OrbitalParameters.Rotate(Vector3.left, l, i, p); - (orbitLine as NHOrbitLine).SemiMinorAxis = b * OrbitalParameters.Rotate(Vector3.forward, l, i, p); + (orbitLine as NHOrbitLine).SetFromParameters(astroObject); } var color = Color.white; diff --git a/NewHorizons/Components/Orbital/NHOrbitLine.cs b/NewHorizons/Components/Orbital/NHOrbitLine.cs index bf894e77..f58d5e92 100644 --- a/NewHorizons/Components/Orbital/NHOrbitLine.cs +++ b/NewHorizons/Components/Orbital/NHOrbitLine.cs @@ -1,20 +1,17 @@ -using System; +using System; using UnityEngine; using Logger = NewHorizons.Utility.Logger; namespace NewHorizons.Components.Orbital { public class NHOrbitLine : OrbitLine { - public Vector3 SemiMajorAxis { get; set; } - public Vector3 SemiMinorAxis { get; set; } + private Vector3 _semiMajorAxis; + private Vector3 _semiMinorAxis; private Vector3 _upAxis; private float _fociDistance; private Vector3[] _verts; - private float semiMajorAxis; - private float semiMinorAxis; - public override void InitializeLineRenderer() { base.GetComponent().positionCount = this._numVerts; @@ -36,10 +33,10 @@ namespace NewHorizons.Components.Orbital { base.Start(); - var a = SemiMajorAxis.magnitude; - var b = SemiMinorAxis.magnitude; + var a = _semiMajorAxis.magnitude; + var b = _semiMinorAxis.magnitude; - _upAxis = Vector3.Cross(SemiMajorAxis.normalized, SemiMinorAxis.normalized); + _upAxis = Vector3.Cross(_semiMajorAxis.normalized, _semiMinorAxis.normalized); _fociDistance = Mathf.Sqrt(a * a - b * b); if (float.IsNaN(_fociDistance)) _fociDistance = 0f; @@ -48,9 +45,6 @@ namespace NewHorizons.Components.Orbital transform.localRotation = Quaternion.Euler(270, 90, 0); - semiMajorAxis = SemiMajorAxis.magnitude; - semiMinorAxis = SemiMinorAxis.magnitude; - base.enabled = false; } @@ -67,22 +61,22 @@ namespace NewHorizons.Components.Orbital return; } - Vector3 origin = primary.transform.position + SemiMajorAxis.normalized * _fociDistance; + Vector3 origin = primary.transform.position + _semiMajorAxis.normalized * _fociDistance; - float num = CalcProjectedAngleToCenter(origin, SemiMajorAxis, SemiMinorAxis, _astroObject.transform.position); + float num = CalcProjectedAngleToCenter(origin, _semiMajorAxis, _semiMinorAxis, _astroObject.transform.position); for (int i = 0; i < _numVerts; i++) { var stepSize = 2f * Mathf.PI / (float)(_numVerts - 1); float f = num + stepSize * i; - _verts[i] = SemiMajorAxis * Mathf.Cos(f) + SemiMinorAxis * Mathf.Sin(f); + _verts[i] = _semiMajorAxis * Mathf.Cos(f) + _semiMinorAxis * Mathf.Sin(f); } _lineRenderer.SetPositions(_verts); transform.position = origin; transform.rotation = Quaternion.Euler(0, 0, 0); //Quaternion.LookRotation(-SemiMajorAxis, _upAxis); - float num2 = DistanceToEllipticalOrbitLine(origin, SemiMajorAxis, SemiMinorAxis, _upAxis, Locator.GetActiveCamera().transform.position); + float num2 = DistanceToEllipticalOrbitLine(origin, _semiMajorAxis, _semiMinorAxis, _upAxis, Locator.GetActiveCamera().transform.position); float widthMultiplier = Mathf.Min(num2 * (_lineWidth / 1000f), _maxLineWidth); float num3 = _fade ? (1f - Mathf.Clamp01((num2 - _fadeStartDist) / (_fadeEndDist - _fadeStartDist))) : 1f; @@ -96,6 +90,19 @@ namespace NewHorizons.Components.Orbital } } + public void SetFromParameters(IOrbitalParameters parameters) + { + var a = parameters.semiMajorAxis; + var e = parameters.eccentricity; + var b = a * Mathf.Sqrt(1f - (e * e)); + var l = parameters.longitudeOfAscendingNode; + var p = parameters.argumentOfPeriapsis; + var i = parameters.inclination; + + _semiMajorAxis = a * OrbitalParameters.Rotate(Vector3.left, l, i, p); + _semiMinorAxis = b * OrbitalParameters.Rotate(Vector3.forward, l, i, p); + } + private float CalcProjectedAngleToCenter(Vector3 foci, Vector3 semiMajorAxis, Vector3 semiMinorAxis, Vector3 point) { Vector3 lhs = point - foci; @@ -107,7 +114,7 @@ namespace NewHorizons.Components.Orbital private float DistanceToEllipticalOrbitLine(Vector3 foci, Vector3 semiMajorAxis, Vector3 semiMinorAxis, Vector3 upAxis, Vector3 point) { float f = CalcProjectedAngleToCenter(foci, semiMajorAxis, semiMinorAxis, point); - Vector3 b = foci + SemiMajorAxis * Mathf.Cos(f) + SemiMinorAxis * Mathf.Sin(f); + Vector3 b = foci + _semiMajorAxis * Mathf.Cos(f) + _semiMinorAxis * Mathf.Sin(f); return Vector3.Distance(point, b); } } diff --git a/NewHorizons/Components/QuantumPlanet.cs b/NewHorizons/Components/QuantumPlanet.cs index d6b4222e..58c7d716 100644 --- a/NewHorizons/Components/QuantumPlanet.cs +++ b/NewHorizons/Components/QuantumPlanet.cs @@ -20,6 +20,7 @@ namespace NewHorizons.Components private ConstantForceDetector _detector; private AlignWithTargetBody _alignment; private OWRigidbody _rb; + private OrbitLine _orbitLine; public int CurrentIndex { get { return _currentIndex; } } @@ -31,6 +32,7 @@ namespace NewHorizons.Components _detector = GetComponentInChildren(); _alignment = GetComponent(); _rb = GetComponent(); + _orbitLine = GetComponent(); GlobalMessenger.AddListener("PlayerBlink", new Callback(OnPlayerBlink)); @@ -143,6 +145,16 @@ namespace NewHorizons.Components } _rb.SetVelocity(orbitalParameters.InitialVelocity + primaryBody.GetAttachedOWRigidbody().GetVelocity()); + + if (_orbitLine is NHOrbitLine nhOrbitLine) + { + nhOrbitLine.SetFromParameters(orbitalParameters); + } + + if (_orbitLine is TrackingOrbitLine trackingOrbitLine) + { + trackingOrbitLine.Reset(); + } } private void OnPlayerBlink() From cc551090f4ed0bdd610336d3f37aaae4297c60be Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 13 Jun 2022 20:59:31 -0400 Subject: [PATCH 18/18] Make stuff public --- NewHorizons/Components/CloakSectorController.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NewHorizons/Components/CloakSectorController.cs b/NewHorizons/Components/CloakSectorController.cs index e7d8e9b0..e7322cdd 100644 --- a/NewHorizons/Components/CloakSectorController.cs +++ b/NewHorizons/Components/CloakSectorController.cs @@ -12,9 +12,9 @@ namespace NewHorizons.Components private List _renderers = null; - internal static bool isPlayerInside = false; - internal static bool isProbeInside = false; - internal static bool isShipInside = false; + public static bool isPlayerInside = false; + public static bool isProbeInside = false; + public static bool isShipInside = false; public void Init(CloakFieldController cloak, GameObject root) {