Remove air info, resize ShockLayerRuleset

This commit is contained in:
Nick 2022-07-14 23:08:59 -04:00
parent bd48fa21a5
commit f34fea66a4
4 changed files with 20 additions and 31 deletions

View File

@ -1,10 +1,11 @@
using NewHorizons.External.Configs;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Builder.Atmosphere namespace NewHorizons.Builder.Atmosphere
{ {
public static class AirBuilder 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"); GameObject airGO = new GameObject("Air");
airGO.SetActive(false); airGO.SetActive(false);
@ -13,7 +14,7 @@ namespace NewHorizons.Builder.Atmosphere
SphereCollider sc = airGO.AddComponent<SphereCollider>(); SphereCollider sc = airGO.AddComponent<SphereCollider>();
sc.isTrigger = true; sc.isTrigger = true;
sc.radius = info.scale; sc.radius = config.Atmosphere.size;
SimpleFluidVolume sfv = airGO.AddComponent<SimpleFluidVolume>(); SimpleFluidVolume sfv = airGO.AddComponent<SimpleFluidVolume>();
sfv._layer = 5; sfv._layer = 5;
@ -26,15 +27,19 @@ namespace NewHorizons.Builder.Atmosphere
ShockLayerRuleset shockLayerRuleset = planetGO.GetComponentInChildren<PlanetoidRuleset>().gameObject.AddComponent<ShockLayerRuleset>(); ShockLayerRuleset shockLayerRuleset = planetGO.GetComponentInChildren<PlanetoidRuleset>().gameObject.AddComponent<ShockLayerRuleset>();
shockLayerRuleset._type = ShockLayerRuleset.ShockType.Atmospheric; shockLayerRuleset._type = ShockLayerRuleset.ShockType.Atmospheric;
shockLayerRuleset._radialCenter = airGO.transform; 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<OxygenVolume>(); airGO.AddComponent<OxygenVolume>();
} }
if (info.isRaining) if (config.Atmosphere.hasRain)
{ {
var vref = airGO.AddComponent<VisorRainEffectVolume>(); var vref = airGO.AddComponent<VisorRainEffectVolume>();
vref._rainDirection = VisorRainEffectVolume.RainDirection.Radial; vref._rainDirection = VisorRainEffectVolume.RainDirection.Radial;

View File

@ -1,11 +1,12 @@
using NewHorizons.External.Modules; using NewHorizons.External.Configs;
using NewHorizons.External.Modules;
using NewHorizons.Utility; using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Builder.Atmosphere namespace NewHorizons.Builder.Atmosphere
{ {
public static class EffectsBuilder 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"); GameObject effectsGO = new GameObject("Effects");
effectsGO.SetActive(false); effectsGO.SetActive(false);
@ -19,7 +20,7 @@ namespace NewHorizons.Builder.Atmosphere
SCG._dynamicCullingBounds = false; SCG._dynamicCullingBounds = false;
SCG._waitForStreaming = 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); 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; rainGO.transform.position = planetGO.transform.position;
@ -29,7 +30,7 @@ namespace NewHorizons.Builder.Atmosphere
{ {
new Keyframe(surfaceSize - 0.5f, 0), new Keyframe(surfaceSize - 0.5f, 0),
new Keyframe(surfaceSize, 10f), new Keyframe(surfaceSize, 10f),
new Keyframe(info.scale, 0f) new Keyframe(config.Atmosphere.size, 0f)
}); });
rainGO.GetComponent<PlanetaryVectionController>()._activeInSector = sector; rainGO.GetComponent<PlanetaryVectionController>()._activeInSector = sector;
@ -37,7 +38,7 @@ namespace NewHorizons.Builder.Atmosphere
rainGO.SetActive(true); rainGO.SetActive(true);
} }
if (info.isSnowing) if (config.Atmosphere.hasSnow)
{ {
var snowGO = new GameObject("SnowEffects"); var snowGO = new GameObject("SnowEffects");
snowGO.transform.parent = effectsGO.transform; snowGO.transform.parent = effectsGO.transform;
@ -53,7 +54,7 @@ namespace NewHorizons.Builder.Atmosphere
{ {
new Keyframe(surfaceSize - 0.5f, 0), new Keyframe(surfaceSize - 0.5f, 0),
new Keyframe(surfaceSize, 10f), new Keyframe(surfaceSize, 10f),
new Keyframe(info.scale, 0f) new Keyframe(config.Atmosphere.size, 0f)
}); });
snowEmitter.GetComponent<PlanetaryVectionController>()._activeInSector = sector; snowEmitter.GetComponent<PlanetaryVectionController>()._activeInSector = sector;

View File

@ -86,15 +86,6 @@ namespace NewHorizons.External.Modules
/// </summary> /// </summary>
public bool useAtmosphereShader; 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] [JsonObject]
public class CloudInfo public class CloudInfo
{ {

View File

@ -532,17 +532,9 @@ namespace NewHorizons.Handlers
if (body.Config.Atmosphere != null) 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; 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)) if (!string.IsNullOrEmpty(body.Config.Atmosphere?.clouds?.texturePath))
{ {
@ -551,7 +543,7 @@ namespace NewHorizons.Handlers
} }
if (body.Config.Atmosphere.hasRain || body.Config.Atmosphere.hasSnow) 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) if (body.Config.Atmosphere.fogSize != 0)
FogBuilder.Make(go, sector, body.Config.Atmosphere); FogBuilder.Make(go, sector, body.Config.Atmosphere);