From 685842843efafa938be72cdad8074ab7f4e64b74 Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 18 Aug 2023 13:47:17 -0400 Subject: [PATCH 1/9] Fix neutron stars appearing inside other stars --- NewHorizons/Builder/Body/StellarRemnantBuilder.cs | 2 +- NewHorizons/manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NewHorizons/Builder/Body/StellarRemnantBuilder.cs b/NewHorizons/Builder/Body/StellarRemnantBuilder.cs index 0d30dae2..8cfd7520 100644 --- a/NewHorizons/Builder/Body/StellarRemnantBuilder.cs +++ b/NewHorizons/Builder/Body/StellarRemnantBuilder.cs @@ -120,7 +120,7 @@ namespace NewHorizons.Builder.Body flares.gameObject.transform.localScale = new Vector3(0.85f, 0.85f, 0.85f); // Add singularity - var singularityRenderer = SingularityBuilder.MakeSingularityGraphics(planetGO, true, neutronStarSize, neutronStarSize * 2.5f); + var singularityRenderer = SingularityBuilder.MakeSingularityGraphics(neutronStar, true, neutronStarSize, neutronStarSize * 2.5f); singularityRenderer.GetComponent().material.color = new Color(0.5f, 2f, 2f, 1f); return neutronStar; diff --git a/NewHorizons/manifest.json b/NewHorizons/manifest.json index b4f2e7ed..762b1c52 100644 --- a/NewHorizons/manifest.json +++ b/NewHorizons/manifest.json @@ -4,7 +4,7 @@ "author": "xen, Bwc9876, clay, MegaPiggy, John, Trifid, Hawkbar, Book", "name": "New Horizons", "uniqueName": "xen.NewHorizons", - "version": "1.14.5", + "version": "1.14.6", "owmlVersion": "2.9.3", "dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ], "conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_CommonResources" ], From 95a7a79bae85b2465e5978d3bdbdfe4410700dda Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 20 Aug 2023 11:44:33 -0400 Subject: [PATCH 2/9] Possibly fix first loop immortality --- NewHorizons/Main.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 2906f9be..6aad270b 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -547,7 +547,8 @@ namespace NewHorizons } // Wait for player to be awake and also for frames to pass - Delay.RunWhenOrInNUpdates(() => OnSystemReady(DidWarpFromShip, DidWarpFromVessel), () => _playerAwake && PlayerSpawned, 30); + var justLinkedToStatue = PlayerData.KnowsLaunchCodes() && PlayerData._currentGameSave.loopCount == 1; + Delay.RunWhenOrInNUpdates(() => OnSystemReady(DidWarpFromShip, DidWarpFromVessel), () => (_playerAwake && PlayerSpawned) || justLinkedToStatue, 30); } else { From 621ab4e33ac24ae6de9ff5a7f8bedf43f1a74dc7 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 22 Aug 2023 19:11:56 -0400 Subject: [PATCH 3/9] Log error if default system override is invalid #702 --- NewHorizons/Main.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 2906f9be..0f53d14e 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -906,6 +906,11 @@ namespace NewHorizons } else { + if (!string.IsNullOrEmpty(_defaultSystemOverride)) + { + NHLogger.LogError($"The given default system override {_defaultSystemOverride} is invalid - no system exists with that name"); + } + _currentStarSystem = _defaultStarSystem; IsWarpingFromShip = false; } From 37032ca222c5654d3a6ade675d4b3c4efb805b8d Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 22 Aug 2023 19:15:01 -0400 Subject: [PATCH 4/9] Add option to disable proxy generation #700 --- NewHorizons/External/Modules/BaseModule.cs | 6 ++++++ NewHorizons/Handlers/PlanetCreationHandler.cs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/NewHorizons/External/Modules/BaseModule.cs b/NewHorizons/External/Modules/BaseModule.cs index 9d72301c..1e1c28d1 100644 --- a/NewHorizons/External/Modules/BaseModule.cs +++ b/NewHorizons/External/Modules/BaseModule.cs @@ -79,6 +79,12 @@ namespace NewHorizons.External.Modules /// public bool pushable; + /// + /// Set this to true to have no proxy be generated for this planet. + /// This is a small representation of the planet that appears when it is outside of the regular Unity camera range. + /// + public bool hideProxy; + #region Obsolete [Obsolete("IsSatellite is deprecated, please use ShowMinimap instead")] diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index 2b014cbf..d15c97a9 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -493,7 +493,7 @@ namespace NewHorizons.Handlers var remnant = otherBodies.Where(x => x.Config.isStellarRemnant && x.Config.name == body.Config.name).FirstOrDefault(); // TODO: add proxies for quantum states //var quantumStates = otherBodies.Where(x => x.Config.isQuantumState && x.Config.name == body.Config.name).ToArray(); - if (!(body.Config.Cloak != null && body.Config.Cloak.radius != 0f)) + if (!(body.Config.Cloak != null && body.Config.Cloak.radius != 0f) && !body.Config.Base.hideProxy) { Delay.FireOnNextUpdate(() => { From 1a6cbd1d781809fa597510272322b5673f0c7eb7 Mon Sep 17 00:00:00 2001 From: Ben C Date: Tue, 22 Aug 2023 23:18:24 +0000 Subject: [PATCH 5/9] Updated 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 faf9e1e9..48c96350 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -577,6 +577,10 @@ "pushable": { "type": "boolean", "description": "Apply physics to this planet when you bump into it. Will have a spherical collider the size of surfaceSize. \nFor custom colliders they have to all be convex and you can leave surface size as 0.\nThis is meant for stuff like satellites which are relatively simple and can be de-orbited.\nIf you are using an orbit line but a tracking line, it will be removed when the planet is bumped in to." + }, + "hideProxy": { + "type": "boolean", + "description": "Set this to true to have no proxy be generated for this planet. \nThis is a small representation of the planet that appears when it is outside of the regular Unity camera range." } } }, From 5908cc1fe6db39c658f63fbc2e11e4fb52ecefa1 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 22 Aug 2023 19:20:27 -0400 Subject: [PATCH 6/9] Give DayNightAudioVolume track setting, make them loop --- .../Builder/Volumes/DayNightAudioVolumeBuilder.cs | 2 ++ .../Components/Volumes/NHDayNightAudioVolume.cs | 12 ++++++++++++ .../Volumes/VolumeInfos/DayNightAudioVolumeInfo.cs | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/NewHorizons/Builder/Volumes/DayNightAudioVolumeBuilder.cs b/NewHorizons/Builder/Volumes/DayNightAudioVolumeBuilder.cs index 738f30f6..b2ed1ce1 100644 --- a/NewHorizons/Builder/Volumes/DayNightAudioVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/DayNightAudioVolumeBuilder.cs @@ -1,6 +1,7 @@ using NewHorizons.Builder.Props; using NewHorizons.Components.Volumes; using NewHorizons.External.Modules.Volumes.VolumeInfos; +using NewHorizons.Utility; using NewHorizons.Utility.OuterWilds; using OWML.Common; using UnityEngine; @@ -21,6 +22,7 @@ namespace NewHorizons.Builder.Volumes audioVolume.nightAudio = info.nightAudio; audioVolume.modBehaviour = mod; audioVolume.volume = info.volume; + audioVolume.SetTrack(info.track.ConvertToOW()); var shape = go.AddComponent(); shape.radius = info.radius; diff --git a/NewHorizons/Components/Volumes/NHDayNightAudioVolume.cs b/NewHorizons/Components/Volumes/NHDayNightAudioVolume.cs index 709c31d5..77f8febb 100644 --- a/NewHorizons/Components/Volumes/NHDayNightAudioVolume.cs +++ b/NewHorizons/Components/Volumes/NHDayNightAudioVolume.cs @@ -16,6 +16,7 @@ namespace NewHorizons.Components.Volumes private OWAudioSource _daySource; private OWAudioSource _nightSource; + private OWAudioMixer.TrackName _track; private Transform _planetTransform; private Transform _sunTransform; @@ -63,6 +64,8 @@ namespace NewHorizons.Components.Volumes _daySource.spread = 180f; _daySource.dopplerLevel = 0f; _daySource.SetMaxVolume(volume); + _daySource.SetTrack(_track); + _daySource.loop = true; AudioUtilities.SetAudioClip(_daySource, dayAudio, modBehaviour); } @@ -77,6 +80,8 @@ namespace NewHorizons.Components.Volumes _nightSource.spread = 180f; _nightSource.dopplerLevel = 0f; _nightSource.SetMaxVolume(volume); + _nightSource.SetTrack(_track); + _nightSource.loop = true; AudioUtilities.SetAudioClip(_nightSource, nightAudio, modBehaviour); } } @@ -138,5 +143,12 @@ namespace NewHorizons.Components.Volumes { return Vector3.Angle(_planetTransform.position - Locator.GetPlayerTransform().position, Locator.GetPlayerTransform().position - _sunTransform.position) < dayWindow * 0.5f; } + + public void SetTrack(OWAudioMixer.TrackName track) + { + _track = track; + _nightSource?.SetTrack(track); + _daySource?.SetTrack(track); + } } } diff --git a/NewHorizons/External/Modules/Volumes/VolumeInfos/DayNightAudioVolumeInfo.cs b/NewHorizons/External/Modules/Volumes/VolumeInfos/DayNightAudioVolumeInfo.cs index 25f71870..1e6717ff 100644 --- a/NewHorizons/External/Modules/Volumes/VolumeInfos/DayNightAudioVolumeInfo.cs +++ b/NewHorizons/External/Modules/Volumes/VolumeInfos/DayNightAudioVolumeInfo.cs @@ -1,3 +1,4 @@ +using NewHorizons.External.SerializableEnums; using Newtonsoft.Json; using System.ComponentModel; using System.ComponentModel.DataAnnotations; @@ -35,5 +36,11 @@ namespace NewHorizons.External.Modules.Volumes.VolumeInfos [Range(0f, 1f)] [DefaultValue(1f)] public float volume = 1f; + + /// + /// The audio track of this audio volume. + /// Most of the time you'll use environment (the default) for sound effects and music for music. + /// + [DefaultValue("environment")] public NHAudioMixerTrackName track = NHAudioMixerTrackName.Environment; } } From 4bb77c8832e94f27b5c6d1d8ca01b24722b2cb63 Mon Sep 17 00:00:00 2001 From: Ben C Date: Tue, 22 Aug 2023 23:25:07 +0000 Subject: [PATCH 7/9] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 48c96350..ddab910d 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -3880,6 +3880,11 @@ "default": 1.0, "maximum": 1.0, "minimum": 0.0 + }, + "track": { + "description": "The audio track of this audio volume.\nMost of the time you'll use environment (the default) for sound effects and music for music. ", + "default": "environment", + "$ref": "#/definitions/NHAudioMixerTrackName" } } }, From 9c6dcefc01196c1cb22b5c3e86654a5a2392feb7 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 22 Aug 2023 19:57:08 -0400 Subject: [PATCH 8/9] Fix water/sand/lava title screen sizing, make sizes relative #678 --- NewHorizons/Handlers/TitleSceneHandler.cs | 209 +++++++++++++--------- 1 file changed, 121 insertions(+), 88 deletions(-) diff --git a/NewHorizons/Handlers/TitleSceneHandler.cs b/NewHorizons/Handlers/TitleSceneHandler.cs index e7337c12..de7aa0fc 100644 --- a/NewHorizons/Handlers/TitleSceneHandler.cs +++ b/NewHorizons/Handlers/TitleSceneHandler.cs @@ -27,8 +27,8 @@ namespace NewHorizons.Handlers public static void DisplayBodyOnTitleScreen(List bodies) { - //Try loading one planet why not - //var eligible = BodyDict.Values.ToList().SelectMany(x => x).ToList().Where(b => (b.Config.HeightMap != null || b.Config.Atmosphere?.Cloud != null) && b.Config.Star == null).ToArray(); + // Try loading one planet why not + // var eligible = BodyDict.Values.ToList().SelectMany(x => x).ToList().Where(b => (b.Config.HeightMap != null || b.Config.Atmosphere?.Cloud != null) && b.Config.Star == null).ToArray(); var eligible = bodies.Where(b => (b.Config.HeightMap != null || b.Config.Atmosphere?.clouds != null) && b.Config.Star == null && b.Config.canShowOnTitle).ToArray(); var eligibleCount = eligible.Count(); if (eligibleCount == 0) return; @@ -38,26 +38,29 @@ namespace NewHorizons.Handlers NHLogger.LogVerbose($"Displaying {selectionCount} bodies on the title screen"); - GameObject body1, body2, body3; + var planetSizes = new List<(GameObject planet, float size)>(); + + var bodyInfo = LoadTitleScreenBody(eligible[indices[0]]); + bodyInfo.planet.transform.localRotation = Quaternion.Euler(15, 0, 0); + planetSizes.Add(bodyInfo); - body1 = LoadTitleScreenBody(eligible[indices[0]]); - body1.transform.localRotation = Quaternion.Euler(15, 0, 0); if (selectionCount > 1) { - body1.transform.localScale = Vector3.one * (body1.transform.localScale.x) * 0.3f; - body1.transform.localPosition = new Vector3(0, -15, 0); - body1.transform.localRotation = Quaternion.Euler(10f, 0f, 0f); - body2 = LoadTitleScreenBody(eligible[indices[1]]); - body2.transform.localScale = Vector3.one * (body2.transform.localScale.x) * 0.3f; - body2.transform.localPosition = new Vector3(7, 30, 0); - body2.transform.localRotation = Quaternion.Euler(10f, 0f, 0f); + bodyInfo.planet.transform.localPosition = new Vector3(0, -15, 0); + bodyInfo.planet.transform.localRotation = Quaternion.Euler(10f, 0f, 0f); + + var bodyInfo2 = LoadTitleScreenBody(eligible[indices[1]]); + bodyInfo2.planet.transform.localPosition = new Vector3(7, 30, 0); + bodyInfo2.planet.transform.localRotation = Quaternion.Euler(10f, 0f, 0f); + planetSizes.Add(bodyInfo2); } + if (selectionCount > 2) { - body3 = LoadTitleScreenBody(eligible[indices[2]]); - body3.transform.localScale = Vector3.one * (body3.transform.localScale.x) * 0.3f; - body3.transform.localPosition = new Vector3(-5, 10, 0); - body3.transform.localRotation = Quaternion.Euler(10f, 0f, 0f); + var bodyInfo3 = LoadTitleScreenBody(eligible[indices[2]]); + bodyInfo3.planet.transform.localPosition = new Vector3(-5, 10, 0); + bodyInfo3.planet.transform.localRotation = Quaternion.Euler(10f, 0f, 0f); + planetSizes.Add(bodyInfo3); } SearchUtilities.Find("Scene/Background/PlanetPivot/Prefab_HEA_Campfire").SetActive(false); @@ -72,87 +75,72 @@ namespace NewHorizons.Handlers light.color = Color.white; light.range = float.PositiveInfinity; light.intensity = 0.8f; + + // Resize planets relative to each other + // If there are multiple planets shrink them down to 30% of the size + var maxSize = planetSizes.Select(x => x.size).Max(); + var multiplePlanets = planetSizes.Count > 1; + foreach (var (planet, size) in planetSizes) + { + planet.transform.localScale *= (size / maxSize) * (multiplePlanets ? 0.3f : 1f); + } } - private static GameObject LoadTitleScreenBody(NewHorizonsBody body) + private static (GameObject planet, float size) LoadTitleScreenBody(NewHorizonsBody body) { NHLogger.LogVerbose($"Displaying {body.Config.name} on the title screen"); var titleScreenGO = new GameObject(body.Config.name + "_TitleScreen"); - var maxSize = -1f; + var maxRadius = -1f; if (body.Config.HeightMap != null) { HeightMapBuilder.Make(titleScreenGO, null, body.Config.HeightMap, body.Mod, 30); - maxSize = Mathf.Max(maxSize, body.Config.HeightMap.maxHeight, body.Config.HeightMap.minHeight); + maxRadius = Mathf.Max(maxRadius, body.Config.HeightMap.maxHeight, body.Config.HeightMap.minHeight); } + if (body.Config.Atmosphere?.clouds?.texturePath != null && body.Config.Atmosphere?.clouds?.cloudsPrefab != CloudPrefabType.Transparent) { - // Hacky but whatever I just want a sphere + // Hacky but whatever I just want a textured sphere var cloudTextureMap = new HeightMapModule(); cloudTextureMap.maxHeight = cloudTextureMap.minHeight = body.Config.Atmosphere.size; cloudTextureMap.textureMap = body.Config.Atmosphere.clouds.texturePath; HeightMapBuilder.Make(titleScreenGO, null, cloudTextureMap, body.Mod, 30); - maxSize = Mathf.Max(maxSize, cloudTextureMap.maxHeight); + + maxRadius = Mathf.Max(maxRadius, cloudTextureMap.maxHeight); } - else + + if (body.Config.Base.groundSize > 0f) { - if (body.Config.Water != null) + MakeSphere(titleScreenGO, body.Config.Base.groundSize * 2f); + maxRadius = Mathf.Max(maxRadius, body.Config.Base.groundSize); + } + + if (body.Config.Water != null) + { + var waterRadius = MakeWater(body, titleScreenGO); + maxRadius = Mathf.Max(maxRadius, waterRadius); + } + + if (body.Config.Lava != null) + { + var lavaRadius = MakeLava(body, titleScreenGO); + maxRadius = Mathf.Max(maxRadius, lavaRadius); + } + + if (body.Config.Sand != null) + { + var sandRadius = MakeSand(body, titleScreenGO); + maxRadius = Mathf.Max(maxRadius, sandRadius); + } + + if (body.Config.Rings != null && body.Config.Rings.Length > 0) + { + foreach (var ring in body.Config.Rings) { - var waterGO = GameObject.CreatePrimitive(PrimitiveType.Sphere); - var size = 2f * body.Config.Water.size * (body.Config.Water.curve?.FirstOrDefault()?.value ?? 1f); + RingBuilder.Make(titleScreenGO, null, ring, body.Mod); - waterGO.transform.localScale = Vector3.one * size; - - var mr = waterGO.GetComponent(); - var colour = body.Config.Water.tint?.ToColor() ?? Color.blue; - mr.material.color = new Color(colour.r, colour.g, colour.b, 0.9f); - - // Make it transparent! - mr.material.SetOverrideTag("RenderType", "Transparent"); - mr.material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); - mr.material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); - mr.material.SetInt("_ZWrite", 0); - mr.material.DisableKeyword("_ALPHATEST_ON"); - mr.material.DisableKeyword("_ALPHABLEND_ON"); - mr.material.EnableKeyword("_ALPHAPREMULTIPLY_ON"); - mr.material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent; - - waterGO.transform.parent = titleScreenGO.transform; - waterGO.transform.localPosition = Vector3.zero; - - maxSize = Mathf.Max(maxSize, size); - } - if (body.Config.Lava != null) - { - var lavaGO = GameObject.CreatePrimitive(PrimitiveType.Sphere); - var size = 2f * body.Config.Lava.size * (body.Config.Lava.curve?.FirstOrDefault()?.value ?? 1f); - - lavaGO.transform.localScale = Vector3.one * size; - - var mr = lavaGO.GetComponent(); - mr.material.color = body.Config.Lava.tint?.ToColor() ?? Color.red; - mr.material.SetColor("_EmissionColor", mr.material.color * 2f); - - lavaGO.transform.parent = titleScreenGO.transform; - lavaGO.transform.localPosition = Vector3.zero; - - maxSize = Mathf.Max(maxSize, size); - } - if (body.Config.Sand != null) - { - var sandGO = GameObject.CreatePrimitive(PrimitiveType.Sphere); - var size = 2f * body.Config.Sand.size * (body.Config.Sand.curve?.FirstOrDefault()?.value ?? 1f); - - sandGO.transform.localScale = Vector3.one * size; - var mr = sandGO.GetComponent(); - mr.material.color = body.Config.Sand.tint?.ToColor() ?? Color.yellow; - mr.material.SetFloat("_Glossiness", 0); - - sandGO.transform.parent = titleScreenGO.transform; - sandGO.transform.localPosition = Vector3.zero; - - maxSize = Mathf.Max(maxSize, size); + maxRadius = Mathf.Max(maxRadius, ring.outerRadius); } } @@ -164,21 +152,66 @@ namespace NewHorizons.Handlers } pivot.name = "Pivot"; - if (body.Config.Rings != null && body.Config.Rings.Length > 0) - { - foreach (var ring in body.Config.Rings) - { - RingBuilder.Make(titleScreenGO, null, ring, body.Mod); - - maxSize = Mathf.Max(maxSize, ring.outerRadius); - } - } - titleScreenGO.transform.parent = pivot.transform; titleScreenGO.transform.localPosition = Vector3.zero; - titleScreenGO.transform.localScale = Vector3.one * 30f / maxSize; + titleScreenGO.transform.localScale = Vector3.one * 30f / maxRadius; - return titleScreenGO; + return (titleScreenGO, maxRadius); + } + + // Returns radius + private static float MakeWater(NewHorizonsBody body, GameObject root) + { + var diameter = 2f * body.Config.Water.size * (body.Config.Water.curve?.FirstOrDefault()?.value ?? 1f); + + var mr = MakeSphere(root, diameter); + var colour = body.Config.Water.tint?.ToColor() ?? Color.blue; + mr.material.color = new Color(colour.r, colour.g, colour.b, 0.9f); + + // Make it transparent! + mr.material.SetOverrideTag("RenderType", "Transparent"); + mr.material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); + mr.material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); + mr.material.SetInt("_ZWrite", 0); + mr.material.DisableKeyword("_ALPHATEST_ON"); + mr.material.DisableKeyword("_ALPHABLEND_ON"); + mr.material.EnableKeyword("_ALPHAPREMULTIPLY_ON"); + mr.material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent; + + return diameter / 2f; + } + + private static float MakeLava(NewHorizonsBody body, GameObject root) + { + var diameter = 2f * body.Config.Lava.size * (body.Config.Lava.curve?.FirstOrDefault()?.value ?? 1f); + + var mr = MakeSphere(root, diameter); + mr.material.color = body.Config.Lava.tint?.ToColor() ?? Color.red; + mr.material.SetColor("_EmissionColor", mr.material.color * 2f); + + return diameter / 2f; + } + + private static float MakeSand(NewHorizonsBody body, GameObject root) + { + var diameter = 2f * body.Config.Sand.size * (body.Config.Sand.curve?.FirstOrDefault()?.value ?? 1f); + + var mr = MakeSphere(root, diameter); + mr.material.color = body.Config.Sand.tint?.ToColor() ?? Color.yellow; + mr.material.SetFloat("_Glossiness", 0); + + return diameter / 2f; + } + + private static MeshRenderer MakeSphere(GameObject root, float diameter) + { + var sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); + var meshRenderer = sphere.GetComponent(); + sphere.transform.parent = root.transform; + sphere.transform.localPosition = Vector3.zero; + sphere.transform.localScale = Vector3.one * diameter; + + return meshRenderer; } } } From 6880b5be200c030d661cf7561104ca553a264c56 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 22 Aug 2023 20:10:40 -0400 Subject: [PATCH 9/9] Adjust the relative sizes --- NewHorizons/Handlers/TitleSceneHandler.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Handlers/TitleSceneHandler.cs b/NewHorizons/Handlers/TitleSceneHandler.cs index de7aa0fc..c0c3924c 100644 --- a/NewHorizons/Handlers/TitleSceneHandler.cs +++ b/NewHorizons/Handlers/TitleSceneHandler.cs @@ -79,10 +79,19 @@ namespace NewHorizons.Handlers // Resize planets relative to each other // If there are multiple planets shrink them down to 30% of the size var maxSize = planetSizes.Select(x => x.size).Max(); + var minSize = planetSizes.Select(x => x.size).Min(); var multiplePlanets = planetSizes.Count > 1; foreach (var (planet, size) in planetSizes) { - planet.transform.localScale *= (size / maxSize) * (multiplePlanets ? 0.3f : 1f); + var adjustedSize = size / maxSize; + // If some planets would be too small we'll do a funny thing + if (minSize / maxSize < 0.3f) + { + var t = Mathf.InverseLerp(minSize, maxSize, size); + adjustedSize = Mathf.Lerp(0.3f, 1f, t * t); + } + + planet.transform.localScale *= adjustedSize * (multiplePlanets ? 0.3f : 1f); } }