From c2f2ddde7b3e675f6830b5ca1b87a995eec00e5f Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Thu, 19 May 2022 23:26:31 -0400 Subject: [PATCH 01/12] Removable Star Controller Adds an option to not add a star controller. --- NewHorizons/Builder/Body/StarBuilder.cs | 2 +- NewHorizons/External/Modules/VariableSize/StarModule.cs | 1 + NewHorizons/Schemas/body_schema.json | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Body/StarBuilder.cs b/NewHorizons/Builder/Body/StarBuilder.cs index c173eb35..47f7c6e2 100644 --- a/NewHorizons/Builder/Body/StarBuilder.cs +++ b/NewHorizons/Builder/Body/StarBuilder.cs @@ -105,7 +105,7 @@ namespace NewHorizons.Builder.Body proxyShadowLight._light = light; StarController starController = null; - if (starModule.SolarLuminosity != 0) + if (starModule.SolarLuminosity != 0 && starModule.HasStarController) { starController = planetGO.AddComponent(); starController.Light = light; diff --git a/NewHorizons/External/Modules/VariableSize/StarModule.cs b/NewHorizons/External/Modules/VariableSize/StarModule.cs index bb1a684e..368f2cab 100644 --- a/NewHorizons/External/Modules/VariableSize/StarModule.cs +++ b/NewHorizons/External/Modules/VariableSize/StarModule.cs @@ -24,5 +24,6 @@ namespace NewHorizons.External.Modules.VariableSize [DefaultValue(true)] public bool GoSupernova { get; set; } = true; + public bool HasStarController { get; set; } = true; } } diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index e099d6bd..4ac6a4cb 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -666,6 +666,11 @@ "type": "boolean", "default": true, "description": "Should this star explode after 22 minutes?" + }, + "hasStarController": { + "type": "boolean", + "default": true, + "description": "Should we add a star controller to this body? If you want clouds to work on a binary brown dwarf system, set this to false." } } }, From 756a602d7e8c4af37ce2432155f5510650845e41 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Thu, 19 May 2022 18:18:26 -0400 Subject: [PATCH 02/12] Support MP3 --- NewHorizons/Utility/AudioUtilities.cs | 49 +++++++++++++++++++++------ 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/NewHorizons/Utility/AudioUtilities.cs b/NewHorizons/Utility/AudioUtilities.cs index 129cbdc4..66684c22 100644 --- a/NewHorizons/Utility/AudioUtilities.cs +++ b/NewHorizons/Utility/AudioUtilities.cs @@ -49,25 +49,54 @@ namespace NewHorizons.Utility case ("ogg"): audioType = UnityEngine.AudioType.OGGVORBIS; break; + case ("mp3"): + Logger.LogWarning($".mp3 files take up a lot of memory! Please use .wav or .ogg instead."); + audioType = UnityEngine.AudioType.MPEG; + break; default: Logger.LogError($"Invalid audio file extension ({extension}) must be .wav or .ogg"); return null; } - using (UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(filePath, audioType)) + if (audioType == UnityEngine.AudioType.MPEG) { - var result = www.SendWebRequest(); - - while (!result.isDone) { await Task.Delay(100); } - - if (www.isNetworkError) + string fileProtocolPath = $"file://{filePath}"; + DownloadHandlerAudioClip dh = new DownloadHandlerAudioClip(fileProtocolPath, UnityEngine.AudioType.MPEG); + dh.compressed = true; + using (UnityWebRequest www = new UnityWebRequest(fileProtocolPath, "GET", dh, null)) { - Debug.Log(www.error); - return null; + var result = www.SendWebRequest(); + + while (!result.isDone) { await Task.Delay(100); } + + if (www.isNetworkError) + { + Debug.Log(www.error); + return null; + } + else + { + return dh.audioClip; + } } - else + } + else + { + using (UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(filePath, audioType)) { - return DownloadHandlerAudioClip.GetContent(www); + var result = www.SendWebRequest(); + + while (!result.isDone) { await Task.Delay(100); } + + if (www.isNetworkError) + { + Debug.Log(www.error); + return null; + } + else + { + return DownloadHandlerAudioClip.GetContent(www); + } } } } From 5f2d4d7e66b4169e17761ff4fdfd14d23ad169b4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 25 May 2022 23:31:29 +0000 Subject: [PATCH 03/12] Updated Schemas --- NewHorizons/Schemas/star_system_schema.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/NewHorizons/Schemas/star_system_schema.json b/NewHorizons/Schemas/star_system_schema.json index 07de3486..13ae6ecc 100644 --- a/NewHorizons/Schemas/star_system_schema.json +++ b/NewHorizons/Schemas/star_system_schema.json @@ -38,10 +38,6 @@ "type": "boolean", "description": "Set to `true` if you want to spawn here after dying, not Timber Hearth. You can still warp back to the main star\nsystem." }, - "subtitle": { - "type": "string", - "description": "Relative path to the image file to use as the subtitle image (replaces the eote banner)" - }, "$schema": { "type": "string", "description": "The schema to validate with" From 96421fc07954fea245af7ecc2b56171665fb7809 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Sun, 22 May 2022 19:17:28 -0400 Subject: [PATCH 04/12] Other Remove GetValue Add names --- NewHorizons/Builder/Body/StarBuilder.cs | 7 +++---- NewHorizons/Handlers/PlanetDestructionHandler.cs | 2 +- NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/NewHorizons/Builder/Body/StarBuilder.cs b/NewHorizons/Builder/Body/StarBuilder.cs index 47f7c6e2..fa76aebb 100644 --- a/NewHorizons/Builder/Body/StarBuilder.cs +++ b/NewHorizons/Builder/Body/StarBuilder.cs @@ -78,11 +78,10 @@ namespace NewHorizons.Builder.Body Light ambientLight = ambientLightGO.GetComponent(); - var sunLight = new GameObject(); + var sunLight = new GameObject("StarLight"); sunLight.transform.parent = starGO.transform; sunLight.transform.localPosition = Vector3.zero; sunLight.transform.localScale = Vector3.one; - sunLight.name = "StarLight"; var light = sunLight.AddComponent(); light.CopyPropertiesFrom(GameObject.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent()); @@ -198,8 +197,8 @@ namespace NewHorizons.Builder.Body var colour = starModule.Tint.ToColor(); var sun = GameObject.Find("Sun_Body"); - var mainSequenceMaterial = sun.GetComponent().GetValue("_startSurfaceMaterial"); - var giantMaterial = sun.GetComponent().GetValue("_endSurfaceMaterial"); + var mainSequenceMaterial = sun.GetComponent()._startSurfaceMaterial; + var giantMaterial = sun.GetComponent()._endSurfaceMaterial; surface.sharedMaterial = new Material(starModule.Size >= 3000 ? giantMaterial : mainSequenceMaterial); var mod = Mathf.Max(1f, 2f * Mathf.Sqrt(starModule.SolarLuminosity)); diff --git a/NewHorizons/Handlers/PlanetDestructionHandler.cs b/NewHorizons/Handlers/PlanetDestructionHandler.cs index 081b7d97..6dead21b 100644 --- a/NewHorizons/Handlers/PlanetDestructionHandler.cs +++ b/NewHorizons/Handlers/PlanetDestructionHandler.cs @@ -175,7 +175,7 @@ namespace NewHorizons.Handlers // Deal with proxies foreach (var p in GameObject.FindObjectsOfType()) { - if (p.GetValue("_originalBody") == ao.gameObject) + if (p._originalBody == ao.gameObject) { DisableBody(p.gameObject, true); break; diff --git a/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs b/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs index 26f595ea..e50c4fbb 100644 --- a/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs +++ b/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs @@ -1,4 +1,4 @@ -using NewHorizons.Builder.Props; +using NewHorizons.Builder.Props; using NewHorizons.External.Configs; using System; using System.Collections.Generic; @@ -114,7 +114,7 @@ namespace NewHorizons.Utility.DebugUtilities prop.transform.localEulerAngles = alignToSurface; // rotate facing dir towards player - GameObject g = new GameObject(); + GameObject g = new GameObject("DebugProp"); g.transform.parent = prop.transform.parent; g.transform.localPosition = prop.transform.localPosition; g.transform.localRotation = prop.transform.localRotation; From 6bf74a86b502ba3794d8b84d629d1d3f91b22d1a Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Sun, 22 May 2022 19:19:26 -0400 Subject: [PATCH 05/12] Star Evolution Fix --- .../SizeControllers/StarEvolutionController.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs index 25b18414..b27854a9 100644 --- a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs +++ b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs @@ -46,7 +46,7 @@ namespace NewHorizons.Components.SizeControllers private float maxScale; - void Awake() + void Start() { var sun = GameObject.FindObjectOfType(); _collapseStartSurfaceMaterial = new Material(sun._collapseStartSurfaceMaterial); @@ -54,11 +54,13 @@ namespace NewHorizons.Components.SizeControllers _startSurfaceMaterial = new Material(sun._startSurfaceMaterial); _endSurfaceMaterial = new Material(sun._endSurfaceMaterial); + var supernovaSurfaceColorRamp = supernova._surface.sharedMaterial.GetTexture("_ColorRamp"); + // Copy over the material that was set in star builder - _collapseStartSurfaceMaterial.SetTexture("_ColorRamp", supernova._surface.sharedMaterial.GetTexture("_ColorRamp")); - _collapseEndSurfaceMaterial.SetTexture("_ColorRamp", supernova._surface.sharedMaterial.GetTexture("_ColorRamp")); - _startSurfaceMaterial.SetTexture("_ColorRamp", supernova._surface.sharedMaterial.GetTexture("_ColorRamp")); - _endSurfaceMaterial.SetTexture("_ColorRamp", supernova._surface.sharedMaterial.GetTexture("_ColorRamp")); + _collapseStartSurfaceMaterial.SetTexture("_ColorRamp", supernovaSurfaceColorRamp); + _collapseEndSurfaceMaterial.SetTexture("_ColorRamp", supernovaSurfaceColorRamp); + _startSurfaceMaterial.SetTexture("_ColorRamp", supernovaSurfaceColorRamp); + _endSurfaceMaterial.SetTexture("_ColorRamp", supernovaSurfaceColorRamp); if (startColour == null) { From 367cffc258eafa71f8518d679b093d9d842893e6 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Sun, 22 May 2022 19:55:07 -0400 Subject: [PATCH 06/12] Publicize --- NewHorizons/Handlers/SubtitlesHandler.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/NewHorizons/Handlers/SubtitlesHandler.cs b/NewHorizons/Handlers/SubtitlesHandler.cs index 26cdf081..480d6911 100644 --- a/NewHorizons/Handlers/SubtitlesHandler.cs +++ b/NewHorizons/Handlers/SubtitlesHandler.cs @@ -11,21 +11,21 @@ namespace NewHorizons.Handlers public static int SUBTITLE_HEIGHT = 97; public static int SUBTITLE_WIDTH = 669; // nice - Graphic graphic; - Image image; + public Graphic graphic; + public Image image; public float fadeSpeed = 0.005f; - float fade = 1; - bool fadingAway = true; + public float fade = 1; + public bool fadingAway = true; - static List possibleSubtitles = new List(); - static bool eoteSubtitleHasBeenInserted = false; - int subtitleIndex; + public static List possibleSubtitles = new List(); + public static bool eoteSubtitleHasBeenInserted = false; + public int subtitleIndex; - System.Random randomizer; + public System.Random randomizer; - static readonly int PAUSE_TIMER_MAX = 50; - int pauseTimer = PAUSE_TIMER_MAX; + public static readonly int PAUSE_TIMER_MAX = 50; + public int pauseTimer = PAUSE_TIMER_MAX; public void Start() { From 8e8cf2bd92302857cbe316e0f4d4340322238de6 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Sun, 22 May 2022 19:56:00 -0400 Subject: [PATCH 07/12] Fix ArgumentOutOfRangeException --- NewHorizons/Handlers/SubtitlesHandler.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Handlers/SubtitlesHandler.cs b/NewHorizons/Handlers/SubtitlesHandler.cs index 480d6911..bd9efb1d 100644 --- a/NewHorizons/Handlers/SubtitlesHandler.cs +++ b/NewHorizons/Handlers/SubtitlesHandler.cs @@ -63,7 +63,9 @@ namespace NewHorizons.Handlers } public void Update() - { + { + if (possibleSubtitles.Count == 0) return; + if (image.sprite == null) image.sprite = possibleSubtitles[0]; // don't fade transition subtitles if there's only one subtitle From 60af9f9d65069529b2d6c9f4eed1c009311c83e3 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Sun, 22 May 2022 19:16:36 -0400 Subject: [PATCH 08/12] Fix Epic Games EOTE Bug --- NewHorizons/Handlers/SubtitlesHandler.cs | 35 ++++++++++++++++-------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/NewHorizons/Handlers/SubtitlesHandler.cs b/NewHorizons/Handlers/SubtitlesHandler.cs index bd9efb1d..adf59545 100644 --- a/NewHorizons/Handlers/SubtitlesHandler.cs +++ b/NewHorizons/Handlers/SubtitlesHandler.cs @@ -19,13 +19,26 @@ namespace NewHorizons.Handlers public bool fadingAway = true; public static List possibleSubtitles = new List(); - public static bool eoteSubtitleHasBeenInserted = false; + public static bool eoteSubtitleHasBeenInserted = false; + public static Sprite eoteSprite; public int subtitleIndex; public System.Random randomizer; public static readonly int PAUSE_TIMER_MAX = 50; - public int pauseTimer = PAUSE_TIMER_MAX; + public int pauseTimer = PAUSE_TIMER_MAX; + + public static void CheckForEOTE() + { + if (!eoteSubtitleHasBeenInserted) + { + if (Main.HasDLC) + { + if (eoteSprite != null) possibleSubtitles.Insert(0, eoteSprite); // ensure that the Echoes of the Eye subtitle always appears first + eoteSubtitleHasBeenInserted = true; + } + } + } public void Start() { @@ -36,15 +49,13 @@ namespace NewHorizons.Handlers image = GetComponent(); graphic.enabled = true; - image.enabled = true; - - if (!Main.HasDLC) image.sprite = null; // Just in case. I don't know how not having the dlc changes the subtitle game object - - if (!eoteSubtitleHasBeenInserted) - { - if (image.sprite != null) possibleSubtitles.Insert(0, image.sprite); // ensure that the Echoes of the Eye subtitle always appears first - eoteSubtitleHasBeenInserted = true; - } + image.enabled = true; + + eoteSprite = image.sprite; + + CheckForEOTE(); + + image.sprite = null; // Just in case. I don't know how not having the dlc changes the subtitle game object } public static void AddSubtitle(IModBehaviour mod, string filepath) @@ -64,6 +75,8 @@ namespace NewHorizons.Handlers public void Update() { + CheckForEOTE(); + if (possibleSubtitles.Count == 0) return; if (image.sprite == null) image.sprite = possibleSubtitles[0]; From 6e84bde604014ff46a53705a5097c4a47a3c2c4c Mon Sep 17 00:00:00 2001 From: Noah <34462599+MegaPiggy@users.noreply.github.com> Date: Wed, 25 May 2022 20:02:53 -0400 Subject: [PATCH 09/12] Update StarModule.cs --- NewHorizons/External/Modules/VariableSize/StarModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NewHorizons/External/Modules/VariableSize/StarModule.cs b/NewHorizons/External/Modules/VariableSize/StarModule.cs index 7b5f1e77..d722be68 100644 --- a/NewHorizons/External/Modules/VariableSize/StarModule.cs +++ b/NewHorizons/External/Modules/VariableSize/StarModule.cs @@ -21,7 +21,7 @@ namespace NewHorizons.External.Modules.VariableSize /// /// Should we add a star controller to this body? If you want clouds to work on a binary brown dwarf system, set this to false. /// - [DefaultValue(true)] public bool hasStarController { get; set; } = true; + [DefaultValue(true)] public bool hasStarController = true; /// /// The default sun has its own atmosphere that is different from regular planets. If you want that, set this to @@ -56,4 +56,4 @@ namespace NewHorizons.External.Modules.VariableSize /// public MColor tint; } -} \ No newline at end of file +} From 68fb856bb97f4cffb207aee112863f549d9ecd98 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Wed, 25 May 2022 20:05:40 -0400 Subject: [PATCH 10/12] Add missing comma --- NewHorizons/Schemas/body_schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 1900a1c9..82f35c52 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -1708,7 +1708,7 @@ "type": "boolean", "description": "Should we add a star controller to this body? If you want clouds to work on a binary brown dwarf system, set this to false.", "default": true - } + }, "hasAtmosphere": { "type": "boolean", "description": "The default sun has its own atmosphere that is different from regular planets. If you want that, set this to\n`true`.", From 2237f4b5d003b48a55bdb9e83e0e7ad8d3b01e2c Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Wed, 25 May 2022 23:23:39 -0400 Subject: [PATCH 11/12] Update AudioUtilities.cs --- NewHorizons/Utility/AudioUtilities.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/NewHorizons/Utility/AudioUtilities.cs b/NewHorizons/Utility/AudioUtilities.cs index 66684c22..45b68261 100644 --- a/NewHorizons/Utility/AudioUtilities.cs +++ b/NewHorizons/Utility/AudioUtilities.cs @@ -50,11 +50,10 @@ namespace NewHorizons.Utility audioType = UnityEngine.AudioType.OGGVORBIS; break; case ("mp3"): - Logger.LogWarning($".mp3 files take up a lot of memory! Please use .wav or .ogg instead."); audioType = UnityEngine.AudioType.MPEG; break; default: - Logger.LogError($"Invalid audio file extension ({extension}) must be .wav or .ogg"); + Logger.LogError($"Invalid audio file extension ({extension}) must be .wav or .ogg or .mp3"); return null; } From 194b42313b7d798b38405b9d917d6056b051ebfa Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Sun, 22 May 2022 19:16:55 -0400 Subject: [PATCH 12/12] Cloak Sphere Volume --- NewHorizons/Builder/Body/CloakBuilder.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/NewHorizons/Builder/Body/CloakBuilder.cs b/NewHorizons/Builder/Body/CloakBuilder.cs index 54edf7d0..4debb50a 100644 --- a/NewHorizons/Builder/Body/CloakBuilder.cs +++ b/NewHorizons/Builder/Body/CloakBuilder.cs @@ -24,6 +24,7 @@ namespace NewHorizons.Builder.Body cloakFieldController._referenceFrameVolume = OWRB._attachedRFVolume; cloakFieldController._exclusionSector = null; + cloakFieldController._cloakSphereVolume = (sector?.transform ?? planetGO.transform).GetComponentInChildren(); var cloakSectorController = newCloak.AddComponent(); cloakSectorController.Init(newCloak.GetComponent(), planetGO);