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); diff --git a/NewHorizons/Builder/Body/StarBuilder.cs b/NewHorizons/Builder/Body/StarBuilder.cs index 6e7dbe58..e51341ef 100644 --- a/NewHorizons/Builder/Body/StarBuilder.cs +++ b/NewHorizons/Builder/Body/StarBuilder.cs @@ -79,11 +79,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()); @@ -106,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; @@ -204,8 +203,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/Components/SizeControllers/StarEvolutionController.cs b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs index 4468b948..c862f7fc 100644 --- a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs +++ b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs @@ -51,7 +51,7 @@ namespace NewHorizons.Components.SizeControllers private float maxScale; private static readonly int ColorRamp = Shader.PropertyToID("_ColorRamp"); - void Awake() + void Start() { var sun = GameObject.FindObjectOfType(); _collapseStartSurfaceMaterial = new Material(sun._collapseStartSurfaceMaterial); @@ -59,11 +59,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) { diff --git a/NewHorizons/External/Modules/VariableSize/StarModule.cs b/NewHorizons/External/Modules/VariableSize/StarModule.cs index e3056c44..d722be68 100644 --- a/NewHorizons/External/Modules/VariableSize/StarModule.cs +++ b/NewHorizons/External/Modules/VariableSize/StarModule.cs @@ -17,6 +17,11 @@ namespace NewHorizons.External.Modules.VariableSize /// Should this star explode after 22 minutes? /// [DefaultValue(true)] public bool goSupernova = true; + + /// + /// 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 = true; /// /// The default sun has its own atmosphere that is different from regular planets. If you want that, set this to @@ -51,4 +56,4 @@ namespace NewHorizons.External.Modules.VariableSize /// public MColor tint; } -} \ No newline at end of file +} 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/Handlers/SubtitlesHandler.cs b/NewHorizons/Handlers/SubtitlesHandler.cs index 6e302802..b267e453 100644 --- a/NewHorizons/Handlers/SubtitlesHandler.cs +++ b/NewHorizons/Handlers/SubtitlesHandler.cs @@ -12,21 +12,34 @@ 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 static Sprite eoteSprite; + 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 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() { @@ -37,15 +50,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) @@ -66,7 +77,11 @@ namespace NewHorizons.Handlers } public void Update() - { + { + CheckForEOTE(); + + if (possibleSubtitles.Count == 0) return; + if (image.sprite == null) image.sprite = possibleSubtitles[0]; // don't fade transition subtitles if there's only one subtitle diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 3d307363..82f35c52 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -1434,6 +1434,7 @@ "description": "The color to apply to highlighted entries with this curiosity.", "$ref": "#/definitions/MColor" }, + "id": { "type": "string", "description": "The ID of the curiosity to apply the color to." @@ -1703,6 +1704,11 @@ "description": "Should this star explode after 22 minutes?", "default": true }, + "hasStarController": { + "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`.", diff --git a/NewHorizons/Utility/AudioUtilities.cs b/NewHorizons/Utility/AudioUtilities.cs index 129cbdc4..45b68261 100644 --- a/NewHorizons/Utility/AudioUtilities.cs +++ b/NewHorizons/Utility/AudioUtilities.cs @@ -49,25 +49,53 @@ namespace NewHorizons.Utility case ("ogg"): audioType = UnityEngine.AudioType.OGGVORBIS; break; + case ("mp3"): + 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; } - 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); + } } } } diff --git a/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs b/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs index fbebff18..592cdc11 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;