diff --git a/NewHorizons/Builder/Atmosphere/AirBuilder.cs b/NewHorizons/Builder/Atmosphere/AirBuilder.cs index 2ec48cb4..f9c3c617 100644 --- a/NewHorizons/Builder/Atmosphere/AirBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/AirBuilder.cs @@ -1,10 +1,11 @@ +using NewHorizons.External.Configs; using NewHorizons.External.Modules; using UnityEngine; namespace NewHorizons.Builder.Atmosphere { public static class AirBuilder { - public static void Make(GameObject planetGO, Sector sector, AtmosphereModule.AirInfo info) + public static void Make(GameObject planetGO, Sector sector, PlanetConfig config) { GameObject airGO = new GameObject("Air"); airGO.SetActive(false); @@ -13,7 +14,7 @@ namespace NewHorizons.Builder.Atmosphere SphereCollider sc = airGO.AddComponent(); sc.isTrigger = true; - sc.radius = info.scale; + sc.radius = config.Atmosphere.size; SimpleFluidVolume sfv = airGO.AddComponent(); sfv._layer = 5; @@ -26,15 +27,19 @@ namespace NewHorizons.Builder.Atmosphere ShockLayerRuleset shockLayerRuleset = planetGO.GetComponentInChildren().gameObject.AddComponent(); shockLayerRuleset._type = ShockLayerRuleset.ShockType.Atmospheric; shockLayerRuleset._radialCenter = airGO.transform; - shockLayerRuleset._innerRadius = 0; - shockLayerRuleset._outerRadius = info.scale; - if (info.hasOxygen) + var bottom = config.Base.surfaceSize; + var top = config.Atmosphere.size; + + shockLayerRuleset._innerRadius = (bottom + top) / 2f; + shockLayerRuleset._outerRadius = top; + + if (config.Atmosphere.hasOxygen) { airGO.AddComponent(); } - if (info.isRaining) + if (config.Atmosphere.hasRain) { var vref = airGO.AddComponent(); vref._rainDirection = VisorRainEffectVolume.RainDirection.Radial; diff --git a/NewHorizons/Builder/Atmosphere/EffectsBuilder.cs b/NewHorizons/Builder/Atmosphere/EffectsBuilder.cs index 1ff3df9e..0271e8ed 100644 --- a/NewHorizons/Builder/Atmosphere/EffectsBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/EffectsBuilder.cs @@ -1,11 +1,12 @@ -using NewHorizons.External.Modules; +using NewHorizons.External.Configs; +using NewHorizons.External.Modules; using NewHorizons.Utility; using UnityEngine; namespace NewHorizons.Builder.Atmosphere { public static class EffectsBuilder { - public static void Make(GameObject planetGO, Sector sector, AtmosphereModule.AirInfo info, float surfaceSize) + public static void Make(GameObject planetGO, Sector sector, PlanetConfig config, float surfaceSize) { GameObject effectsGO = new GameObject("Effects"); effectsGO.SetActive(false); @@ -19,7 +20,7 @@ namespace NewHorizons.Builder.Atmosphere SCG._dynamicCullingBounds = false; SCG._waitForStreaming = false; - if (info.isRaining) + if (config.Atmosphere.hasRain) { var rainGO = GameObject.Instantiate(SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Effects_GDInterior/Effects_GD_Rain"), effectsGO.transform); rainGO.transform.position = planetGO.transform.position; @@ -29,7 +30,7 @@ namespace NewHorizons.Builder.Atmosphere { new Keyframe(surfaceSize - 0.5f, 0), new Keyframe(surfaceSize, 10f), - new Keyframe(info.scale, 0f) + new Keyframe(config.Atmosphere.size, 0f) }); rainGO.GetComponent()._activeInSector = sector; @@ -37,7 +38,7 @@ namespace NewHorizons.Builder.Atmosphere rainGO.SetActive(true); } - if (info.isSnowing) + if (config.Atmosphere.hasSnow) { var snowGO = new GameObject("SnowEffects"); snowGO.transform.parent = effectsGO.transform; @@ -53,7 +54,7 @@ namespace NewHorizons.Builder.Atmosphere { new Keyframe(surfaceSize - 0.5f, 0), new Keyframe(surfaceSize, 10f), - new Keyframe(info.scale, 0f) + new Keyframe(config.Atmosphere.size, 0f) }); snowEmitter.GetComponent()._activeInSector = sector; diff --git a/NewHorizons/External/Modules/AtmosphereModule.cs b/NewHorizons/External/Modules/AtmosphereModule.cs index c22a4c14..786475f5 100644 --- a/NewHorizons/External/Modules/AtmosphereModule.cs +++ b/NewHorizons/External/Modules/AtmosphereModule.cs @@ -86,15 +86,6 @@ namespace NewHorizons.External.Modules /// public bool useAtmosphereShader; - // not an actual config thing, rip - public class AirInfo - { - public bool hasOxygen; - public bool isRaining; - public bool isSnowing; - public float scale; - } - [JsonObject] public class CloudInfo { diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index f6e23438..25e1e2e8 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -532,17 +532,9 @@ namespace NewHorizons.Handlers if (body.Config.Atmosphere != null) { - var airInfo = new AtmosphereModule.AirInfo() - { - hasOxygen = body.Config.Atmosphere.hasOxygen, - isRaining = body.Config.Atmosphere.hasRain, - isSnowing = body.Config.Atmosphere.hasSnow, - scale = body.Config.Atmosphere.size - }; - var surfaceSize = body.Config.Base.surfaceSize; - AirBuilder.Make(go, sector, airInfo); + AirBuilder.Make(go, sector, body.Config); if (!string.IsNullOrEmpty(body.Config.Atmosphere?.clouds?.texturePath)) { @@ -551,7 +543,7 @@ namespace NewHorizons.Handlers } if (body.Config.Atmosphere.hasRain || body.Config.Atmosphere.hasSnow) - EffectsBuilder.Make(go, sector, airInfo, surfaceSize); + EffectsBuilder.Make(go, sector, body.Config, surfaceSize); if (body.Config.Atmosphere.fogSize != 0) FogBuilder.Make(go, sector, body.Config.Atmosphere);