mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Lighting + Cloud refactor
This commit is contained in:
parent
4d06292d5c
commit
23f3005d46
@ -10,7 +10,7 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
atmoGO.SetActive(false);
|
||||
atmoGO.transform.parent = sector?.transform ?? planetGO.transform;
|
||||
|
||||
if (atmosphereModule.HasAtmosphere)
|
||||
if (atmosphereModule.UseAtmosphereShader)
|
||||
{
|
||||
GameObject atmo = GameObject.Instantiate(GameObject.Find("TimberHearth_Body/Atmosphere_TH/AtmoSphere"));
|
||||
atmo.transform.parent = atmoGO.transform;
|
||||
@ -18,7 +18,7 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
atmo.transform.localScale = Vector3.one * atmosphereModule.Size * 1.2f;
|
||||
foreach (var meshRenderer in atmo.GetComponentsInChildren<MeshRenderer>())
|
||||
{
|
||||
meshRenderer.material.SetFloat("_InnerRadius", atmosphereModule.Cloud != null ? atmosphereModule.Size : surfaceSize);
|
||||
meshRenderer.material.SetFloat("_InnerRadius", atmosphereModule.Clouds != null ? atmosphereModule.Size : surfaceSize);
|
||||
meshRenderer.material.SetFloat("_OuterRadius", atmosphereModule.Size * 1.2f);
|
||||
if (atmosphereModule.AtmosphereTint != null)
|
||||
meshRenderer.material.SetColor("_SkyColor", atmosphereModule.AtmosphereTint.ToColor());
|
||||
|
||||
@ -10,9 +10,11 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
{
|
||||
private static Shader _sphereShader = null;
|
||||
private static Material[] _gdCloudMaterials;
|
||||
private static GameObject _lightningPrefab;
|
||||
|
||||
public static void Make(GameObject planetGO, Sector sector, AtmosphereModule atmo, IModBehaviour mod)
|
||||
{
|
||||
Color cloudTint = atmo.CloudTint == null ? Color.white : (Color)atmo.CloudTint.ToColor32();
|
||||
if (_lightningPrefab == null) _lightningPrefab = GameObject.Find("GiantsDeep_Body/Sector_GD/Clouds_GD/LightningGenerator_GD");
|
||||
|
||||
GameObject cloudsMainGO = new GameObject("Clouds");
|
||||
cloudsMainGO.SetActive(false);
|
||||
@ -23,16 +25,16 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
GameObject cloudsBottomGO = new GameObject("BottomClouds");
|
||||
cloudsBottomGO.SetActive(false);
|
||||
cloudsBottomGO.transform.parent = cloudsMainGO.transform;
|
||||
cloudsBottomGO.transform.localScale = Vector3.one * (atmo.Size * 0.9f);
|
||||
cloudsBottomGO.transform.localScale = Vector3.one * atmo.Clouds.InnerCloudRadius;
|
||||
|
||||
TessellatedSphereRenderer bottomTSR = cloudsBottomGO.AddComponent<TessellatedSphereRenderer>();
|
||||
bottomTSR.tessellationMeshGroup = GameObject.Find("CloudsBottomLayer_QM").GetComponent<TessellatedSphereRenderer>().tessellationMeshGroup;
|
||||
var bottomTSRMaterials = GameObject.Find("CloudsBottomLayer_QM").GetComponent<TessellatedSphereRenderer>().sharedMaterials;
|
||||
|
||||
// If they set a colour apply it to all the materials else keep the default QM one
|
||||
if (atmo.CloudTint != null)
|
||||
if (atmo.Clouds.Tint != null)
|
||||
{
|
||||
var bottomColor = cloudTint;
|
||||
var bottomColor = atmo.Clouds.Tint.ToColor();
|
||||
|
||||
var bottomTSRTempArray = new Material[2];
|
||||
|
||||
@ -74,15 +76,15 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
fluidCLFV._density = 1.2f;
|
||||
|
||||
var fluidType = FluidVolume.Type.CLOUD;
|
||||
if (!string.IsNullOrEmpty(atmo.CloudFluidType))
|
||||
if (!string.IsNullOrEmpty(atmo.Clouds.FluidType))
|
||||
{
|
||||
try
|
||||
{
|
||||
fluidType = (FluidVolume.Type)Enum.Parse(typeof(FluidVolume.Type), atmo.CloudFluidType.ToUpper());
|
||||
fluidType = (FluidVolume.Type)Enum.Parse(typeof(FluidVolume.Type), atmo.Clouds.FluidType.ToUpper());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError($"Couldn't parse fluid volume type [{atmo.CloudFluidType}]: {ex.Message}, {ex.StackTrace}");
|
||||
Logger.LogError($"Couldn't parse fluid volume type [{atmo.Clouds.FluidType}]: {ex.Message}, {ex.StackTrace}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,7 +95,32 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
// Fix the rotations once the rest is done
|
||||
cloudsMainGO.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(0, 0, 0));
|
||||
// For the base shader it has to be rotated idk
|
||||
if (atmo.UseBasicCloudShader) cloudsMainGO.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(90, 0, 0));
|
||||
if (atmo.Clouds.UseBasicCloudShader) cloudsMainGO.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(90, 0, 0));
|
||||
|
||||
// Lightning
|
||||
if (atmo.Clouds.HasLightning)
|
||||
{
|
||||
var lightning = _lightningPrefab.InstantiateInactive();
|
||||
lightning.transform.parent = cloudsMainGO.transform;
|
||||
lightning.transform.localPosition = Vector3.zero;
|
||||
|
||||
var lightningGenerator = lightning.GetComponent<CloudLightningGenerator>();
|
||||
lightningGenerator._altitude = (atmo.Clouds.OuterCloudRadius + atmo.Clouds.InnerCloudRadius) / 2f;
|
||||
lightningGenerator._audioSector = sector;
|
||||
if (atmo.Clouds.LightningGradient != null)
|
||||
{
|
||||
var gradient = new GradientColorKey[atmo.Clouds.LightningGradient.Length];
|
||||
|
||||
for(int i = 0; i < atmo.Clouds.LightningGradient.Length; i++)
|
||||
{
|
||||
var pair = atmo.Clouds.LightningGradient[i];
|
||||
gradient[i] = new GradientColorKey(pair.Tint.ToColor(), pair.Time);
|
||||
}
|
||||
|
||||
lightningGenerator._lightColor.colorKeys = gradient;
|
||||
}
|
||||
lightning.SetActive(true);
|
||||
}
|
||||
|
||||
cloudsMainGO.transform.position = planetGO.transform.TransformPoint(Vector3.zero);
|
||||
cloudsBottomGO.transform.position = planetGO.transform.TransformPoint(Vector3.zero);
|
||||
@ -106,18 +133,18 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
|
||||
public static GameObject MakeTopClouds(GameObject rootObject, AtmosphereModule atmo, IModBehaviour mod)
|
||||
{
|
||||
Color cloudTint = atmo.CloudTint == null ? Color.white : (Color)atmo.CloudTint.ToColor32();
|
||||
Color cloudTint = atmo.Clouds.Tint == null ? Color.white : atmo.Clouds.Tint.ToColor();
|
||||
|
||||
Texture2D image, cap, ramp;
|
||||
|
||||
try
|
||||
{
|
||||
image = ImageUtilities.GetTexture(mod, atmo.Cloud);
|
||||
image = ImageUtilities.GetTexture(mod, atmo.Clouds.TexturePath);
|
||||
|
||||
if (atmo.CloudCap == null) cap = ImageUtilities.ClearTexture(128, 128);
|
||||
else cap = ImageUtilities.GetTexture(mod, atmo.CloudCap);
|
||||
if (atmo.CloudRamp == null) ramp = ImageUtilities.CanvasScaled(image, 1, image.height);
|
||||
else ramp = ImageUtilities.GetTexture(mod, atmo.CloudRamp);
|
||||
if (atmo.Clouds.CapPath == null) cap = ImageUtilities.ClearTexture(128, 128);
|
||||
else cap = ImageUtilities.GetTexture(mod, atmo.Clouds.CapPath);
|
||||
if (atmo.Clouds.RampPath == null) ramp = ImageUtilities.CanvasScaled(image, 1, image.height);
|
||||
else ramp = ImageUtilities.GetTexture(mod, atmo.Clouds.RampPath);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -128,7 +155,7 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
GameObject cloudsTopGO = new GameObject("TopClouds");
|
||||
cloudsTopGO.SetActive(false);
|
||||
cloudsTopGO.transform.parent = rootObject.transform;
|
||||
cloudsTopGO.transform.localScale = Vector3.one * atmo.Size;
|
||||
cloudsTopGO.transform.localScale = Vector3.one * atmo.Clouds.OuterCloudRadius;
|
||||
|
||||
MeshFilter topMF = cloudsTopGO.AddComponent<MeshFilter>();
|
||||
topMF.mesh = GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh;
|
||||
@ -139,19 +166,19 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
if (_gdCloudMaterials == null) _gdCloudMaterials = GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshRenderer>().sharedMaterials;
|
||||
var tempArray = new Material[2];
|
||||
|
||||
if (atmo.UseBasicCloudShader)
|
||||
if (atmo.Clouds.UseBasicCloudShader)
|
||||
{
|
||||
var material = new Material(_sphereShader);
|
||||
if (!atmo.ShadowsOnClouds) material.renderQueue = 2550;
|
||||
material.name = atmo.ShadowsOnClouds ? "BasicShadowCloud" : "BasicCloud";
|
||||
if (atmo.Clouds.Unlit) material.renderQueue = 2550;
|
||||
material.name = atmo.Clouds.Unlit ? "BasicCloud" : "BasicShadowCloud";
|
||||
|
||||
tempArray[0] = material;
|
||||
}
|
||||
else
|
||||
{
|
||||
var material = new Material(_gdCloudMaterials[0]);
|
||||
if (!atmo.ShadowsOnClouds) material.renderQueue = 2550;
|
||||
material.name = atmo.ShadowsOnClouds ? "AdvancedShadowCloud" : "AdvancedCloud";
|
||||
if (atmo.Clouds.Unlit) material.renderQueue = 2550;
|
||||
material.name = atmo.Clouds.Unlit ? "AdvancedCloud" : "AdvancedShadowCloud";
|
||||
tempArray[0] = material;
|
||||
}
|
||||
|
||||
@ -169,14 +196,14 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
material.SetTexture("_CapTex", cap);
|
||||
}
|
||||
|
||||
if (!atmo.ShadowsOnClouds)
|
||||
if (atmo.Clouds.Unlit)
|
||||
{
|
||||
cloudsTopGO.layer = LayerMask.NameToLayer("IgnoreSun");
|
||||
}
|
||||
|
||||
RotateTransform topRT = cloudsTopGO.AddComponent<RotateTransform>();
|
||||
// Idk why but the axis is weird
|
||||
topRT._localAxis = atmo.UseBasicCloudShader ? Vector3.forward : Vector3.up;
|
||||
topRT._localAxis = atmo.Clouds.UseBasicCloudShader ? Vector3.forward : Vector3.up;
|
||||
topRT._degreesPerSecond = 10;
|
||||
topRT._randomizeRotationRate = false;
|
||||
|
||||
|
||||
@ -40,9 +40,9 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
ER._material = gdRuleset._material;
|
||||
|
||||
var cloudMaterial = new Material(gdRuleset._cloudMaterial);
|
||||
if (config.Atmosphere?.CloudTint != null)
|
||||
if (config.Atmosphere?.Clouds?.Tint != null)
|
||||
{
|
||||
cloudMaterial.SetColor("_FogColor", config.Atmosphere.CloudTint.ToColor32());
|
||||
cloudMaterial.SetColor("_FogColor", config.Atmosphere.Clouds.Tint.ToColor32());
|
||||
}
|
||||
ER._cloudMaterial = cloudMaterial;
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ namespace NewHorizons.Builder.Body
|
||||
GeometryBuilder.Make(newProxy, null, body.Config.Base.GroundSize);
|
||||
if (realSize < body.Config.Base.GroundSize) realSize = body.Config.Base.GroundSize;
|
||||
}
|
||||
if (body.Config.Atmosphere?.Cloud != null)
|
||||
if (body.Config.Atmosphere?.Clouds != null)
|
||||
{
|
||||
CloudsBuilder.MakeTopClouds(newProxy, body.Config.Atmosphere, body.Mod);
|
||||
if (realSize < body.Config.Atmosphere.Size) realSize = body.Config.Atmosphere.Size;
|
||||
|
||||
@ -59,7 +59,7 @@ namespace NewHorizons.Builder.Orbital
|
||||
var color = Color.white;
|
||||
if (config.Orbit.Tint != null) color = config.Orbit.Tint.ToColor32();
|
||||
else if (config.Star != null) color = config.Star.Tint.ToColor32();
|
||||
else if (config.Atmosphere != null && config.Atmosphere.CloudTint != null) color = config.Atmosphere.CloudTint.ToColor32();
|
||||
else if (config.Atmosphere?.Clouds?.Tint != null) color = config.Atmosphere.Clouds.Tint.ToColor32();
|
||||
else if (config.Singularity != null) color = new Color(1f, 0.5f, 1f);
|
||||
else if (config.Water != null) color = new Color(0.5f, 0.5f, 1f);
|
||||
else if (config.Lava != null) color = new Color(1f, 0.5f, 0.5f);
|
||||
|
||||
@ -69,7 +69,7 @@ namespace NewHorizons.Builder.Props
|
||||
{
|
||||
try
|
||||
{
|
||||
TornadoBuilder.Make(go, sector, tornadoInfo, config.Atmosphere?.Cloud != null);
|
||||
TornadoBuilder.Make(go, sector, tornadoInfo, config.Atmosphere?.Clouds != null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@ -518,7 +518,7 @@ namespace NewHorizons.Builder.ShipLog
|
||||
if (starColor != null) return starColor.ToColor();
|
||||
|
||||
var atmoColor = body.Config.Atmosphere?.AtmosphereTint;
|
||||
if (body.Config.Atmosphere?.Cloud != null && atmoColor != null) return atmoColor.ToColor();
|
||||
if (body.Config.Atmosphere?.Clouds != null && atmoColor != null) return atmoColor.ToColor();
|
||||
|
||||
if (body.Config?.HeightMap?.TextureMap != null)
|
||||
{
|
||||
|
||||
41
NewHorizons/External/Configs/PlanetConfig.cs
vendored
41
NewHorizons/External/Configs/PlanetConfig.cs
vendored
@ -1,5 +1,7 @@
|
||||
using NewHorizons.External.Modules;
|
||||
using NewHorizons.External.Modules.VariableSize;
|
||||
using NewHorizons.Utility;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NewHorizons.External.Configs
|
||||
{
|
||||
@ -44,13 +46,15 @@ namespace NewHorizons.External.Configs
|
||||
if (ShipLog == null) ShipLog = new ShipLogModule();
|
||||
}
|
||||
|
||||
public void Validate()
|
||||
public void MigrateAndValidate()
|
||||
{
|
||||
// Validate
|
||||
if (Base.CenterOfSolarSystem) Orbit.IsStatic = true;
|
||||
if (Atmosphere?.Clouds?.LightningGradient != null) Atmosphere.Clouds.HasLightning = true;
|
||||
|
||||
// Backwards compatability
|
||||
// Should be the only place that obsolete things are referenced
|
||||
#pragma warning disable 612, 618
|
||||
#pragma warning disable 612, 618
|
||||
if (Base.WaterSize != 0)
|
||||
{
|
||||
Water = new WaterModule();
|
||||
@ -85,7 +89,38 @@ namespace NewHorizons.External.Configs
|
||||
{
|
||||
Base.AmbientLight = 0.5f;
|
||||
}
|
||||
#pragma warning restore 612, 618
|
||||
|
||||
if (Atmosphere != null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Atmosphere.Cloud))
|
||||
{
|
||||
Atmosphere.Clouds = new AtmosphereModule.CloudInfo()
|
||||
{
|
||||
OuterCloudRadius = Atmosphere.Size,
|
||||
InnerCloudRadius = Atmosphere.Size * 0.9f,
|
||||
Tint = Atmosphere.CloudTint,
|
||||
TexturePath = Atmosphere.Cloud,
|
||||
CapPath = Atmosphere.CloudCap,
|
||||
RampPath = Atmosphere.CloudRamp,
|
||||
FluidType = Atmosphere.CloudFluidType,
|
||||
UseBasicCloudShader = Atmosphere.UseBasicCloudShader,
|
||||
Unlit = !Atmosphere.ShadowsOnClouds,
|
||||
};
|
||||
}
|
||||
|
||||
// Validate
|
||||
if (Atmosphere.Clouds?.LightningGradient != null)
|
||||
{
|
||||
Atmosphere.Clouds.HasLightning = true;
|
||||
}
|
||||
|
||||
// Former is obsolete, latter is to validate
|
||||
if (Atmosphere.HasAtmosphere || Atmosphere.AtmosphereTint != null)
|
||||
{
|
||||
Atmosphere.UseAtmosphereShader = true;
|
||||
}
|
||||
}
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
41
NewHorizons/External/Modules/AtmosphereModule.cs
vendored
41
NewHorizons/External/Modules/AtmosphereModule.cs
vendored
@ -1,24 +1,32 @@
|
||||
using NewHorizons.Utility;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NewHorizons.External.Modules
|
||||
{
|
||||
public class AtmosphereModule
|
||||
{
|
||||
public float Size { get; set; }
|
||||
public MColor CloudTint { get; set; }
|
||||
public string Cloud { get; set; }
|
||||
public string CloudCap { get; set; }
|
||||
public string CloudRamp { get; set; }
|
||||
public string CloudFluidType { get; set; }
|
||||
public bool UseBasicCloudShader { get; set; }
|
||||
public bool ShadowsOnClouds { get; set; } = true;
|
||||
public MColor AtmosphereTint { get; set; }
|
||||
public MColor FogTint { get; set; }
|
||||
public float FogDensity { get; set; }
|
||||
public float FogSize { get; set; }
|
||||
public bool HasRain { get; set; }
|
||||
public bool HasSnow { get; set; }
|
||||
public bool HasOxygen { get; set; }
|
||||
public bool HasAtmosphere { get; set; }
|
||||
public MColor AtmosphereTint { get; set; }
|
||||
public bool UseAtmosphereShader { get; set; }
|
||||
public CloudInfo Clouds { get; set; }
|
||||
|
||||
|
||||
#region Obsolete
|
||||
[System.Obsolete("CloudTint is deprecated, please use CloudInfo instead")] public MColor CloudTint { get; set; }
|
||||
[System.Obsolete("CloudTint is deprecated, please use CloudInfo instead")] public string Cloud { get; set; }
|
||||
[System.Obsolete("CloudCap is deprecated, please use CloudInfo instead")] public string CloudCap { get; set; }
|
||||
[System.Obsolete("CloudRamp is deprecated, please use CloudInfo instead")] public string CloudRamp { get; set; }
|
||||
[System.Obsolete("CloudFluidType is deprecated, please use CloudInfo instead")] public string CloudFluidType { get; set; }
|
||||
[System.Obsolete("UseBasicCloudShader is deprecated, please use CloudInfo instead")] public bool UseBasicCloudShader { get; set; }
|
||||
[System.Obsolete("ShadowsOnClouds is deprecated, please use CloudInfo instead")] public bool ShadowsOnClouds { get; set; } = true;
|
||||
[System.Obsolete("HasAtmosphere is deprecated, please use UseAtmosphereShader instead")] public bool HasAtmosphere { get; set; }
|
||||
#endregion Obsolete
|
||||
|
||||
public class AirInfo
|
||||
{
|
||||
@ -27,5 +35,20 @@ namespace NewHorizons.External.Modules
|
||||
public bool IsRaining { get; set; }
|
||||
public bool IsSnowing { get; set; }
|
||||
}
|
||||
|
||||
public class CloudInfo
|
||||
{
|
||||
public float OuterCloudRadius { get; set; }
|
||||
public float InnerCloudRadius { get; set; }
|
||||
public MColor Tint { get; set; }
|
||||
public string TexturePath { get; set; }
|
||||
public string CapPath { get; set; }
|
||||
public string RampPath { get; set; }
|
||||
public string FluidType { get; set; }
|
||||
public bool UseBasicCloudShader { get; set; }
|
||||
public bool Unlit { get; set; }
|
||||
public bool HasLightning { get; set; }
|
||||
public MGradient[] LightningGradient { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -447,7 +447,7 @@ namespace NewHorizons.Handlers
|
||||
|
||||
AirBuilder.Make(go, sector, airInfo);
|
||||
|
||||
if (!string.IsNullOrEmpty(body.Config.Atmosphere.Cloud))
|
||||
if (!string.IsNullOrEmpty(body.Config.Atmosphere?.Clouds?.TexturePath))
|
||||
{
|
||||
CloudsBuilder.Make(go, sector, body.Config.Atmosphere, body.Mod);
|
||||
SunOverrideBuilder.Make(go, sector, body.Config.Atmosphere, surfaceSize);
|
||||
|
||||
@ -15,7 +15,7 @@ namespace NewHorizons.Handlers
|
||||
{
|
||||
//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?.Cloud != null) && b.Config.Star == null && b.Config.CanShowOnTitle).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;
|
||||
|
||||
@ -74,12 +74,12 @@ namespace NewHorizons.Handlers
|
||||
heightMap.MaxHeight = size;
|
||||
heightMap.MinHeight = body.Config.HeightMap.MinHeight * size / body.Config.HeightMap.MaxHeight;
|
||||
}
|
||||
if (body.Config.Atmosphere != null && body.Config.Atmosphere.Cloud != null)
|
||||
if (body.Config.Atmosphere?.Clouds?.TexturePath != null)
|
||||
{
|
||||
// Hacky but whatever I just want a sphere
|
||||
size = Mathf.Clamp(body.Config.Atmosphere.Size / 10, minSize, maxSize);
|
||||
heightMap.MaxHeight = heightMap.MinHeight = size + 1;
|
||||
heightMap.TextureMap = body.Config.Atmosphere.Cloud;
|
||||
heightMap.TextureMap = body.Config.Atmosphere.Clouds.TexturePath;
|
||||
}
|
||||
|
||||
HeightMapBuilder.Make(titleScreenGO, null, heightMap, body.Mod);
|
||||
|
||||
@ -375,7 +375,7 @@ namespace NewHorizons
|
||||
try
|
||||
{
|
||||
var config = mod.ModHelper.Storage.Load<PlanetConfig>(relativeDirectory);
|
||||
config.Validate();
|
||||
config.MigrateAndValidate();
|
||||
|
||||
Logger.Log($"Loaded {config.Name}");
|
||||
|
||||
@ -397,7 +397,7 @@ namespace NewHorizons
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError($"Couldn't load {relativeDirectory}: {e.Message}, is your Json formatted correctly?");
|
||||
Logger.LogError($"Couldn't load {relativeDirectory}: {e.Message} {e.StackTrace}, is your Json formatted correctly?");
|
||||
}
|
||||
|
||||
return body;
|
||||
|
||||
@ -60,21 +60,37 @@
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"R": {
|
||||
"r": {
|
||||
"$ref": "#/$defs/colorPart"
|
||||
},
|
||||
"G": {
|
||||
"g": {
|
||||
"$ref": "#/$defs/colorPart"
|
||||
},
|
||||
"B": {
|
||||
"b": {
|
||||
"$ref": "#/$defs/colorPart"
|
||||
},
|
||||
"A": {
|
||||
"a": {
|
||||
"$ref": "#/$defs/colorPart",
|
||||
"default": 255
|
||||
}
|
||||
}
|
||||
},
|
||||
"gradient": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"time": {
|
||||
"type": "number",
|
||||
"default": 0
|
||||
},
|
||||
"tint": {
|
||||
"$ref": "#/$defs/color"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"angle": {
|
||||
"type": "number",
|
||||
"default": 0,
|
||||
@ -288,44 +304,6 @@
|
||||
"default": 0,
|
||||
"description": "Scale height of the atmosphere"
|
||||
},
|
||||
"cloudTint": {
|
||||
"$ref": "#/$defs/color",
|
||||
"description": "Colour of the cloud layer. Only relevant if \"cloud\" has a value"
|
||||
},
|
||||
"cloud": {
|
||||
"type": "string",
|
||||
"description": "Relative filepath to the cloud texture, if the planet has clouds."
|
||||
},
|
||||
"cloudCap": {
|
||||
"type": "string",
|
||||
"description": "Relative filepath to the cloud cap texture, if the planet has clouds."
|
||||
},
|
||||
"cloudRamp": {
|
||||
"type": "string",
|
||||
"description": "Relative filepath to the cloud ramp texture, if the planet has clouds. If you don't put anything here it will be auto-generated."
|
||||
},
|
||||
"cloudFluidType": {
|
||||
"type": "string",
|
||||
"default": "CLOUD",
|
||||
"description": "Fluid type for sounds/effects when colliding with this cloud.",
|
||||
"enum": [
|
||||
"NONE",
|
||||
"WATER",
|
||||
"CLOUD",
|
||||
"SAND",
|
||||
"PLASMA"
|
||||
]
|
||||
},
|
||||
"useBasicCloudShader": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Set to `false` in order to use Giant's deep shader. Set to `true` to just apply the cloud texture as is."
|
||||
},
|
||||
"shadowsOnClouds": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "If the top layer should have shadows. Set to false if you're making a brown dwarf."
|
||||
},
|
||||
"fogTint": {
|
||||
"$ref": "#/$defs/color",
|
||||
"description": "Colour of fog on the planet, if you put fog."
|
||||
@ -354,7 +332,7 @@
|
||||
"default": false,
|
||||
"description": "Lets you survive on the planet without a suit."
|
||||
},
|
||||
"hasAtmosphere": {
|
||||
"useAtmosphereShader": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Whether we use an atmospheric shader on the planet. Doesn't affect clouds, fog, rain, snow, oxygen, etc. Purely visual."
|
||||
@ -362,6 +340,67 @@
|
||||
"atmosphereTint": {
|
||||
"$ref": "#/$defs/color",
|
||||
"description": "Colour of atmospheric shader on the planet."
|
||||
},
|
||||
"clouds": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"outerCloudRadius": {
|
||||
"type": "number",
|
||||
"description": "Radius from the center to the outer layer of the clouds."
|
||||
},
|
||||
"innerCloudRadius": {
|
||||
"type": "number",
|
||||
"description": "Radius from the center to the inner layer of the clouds."
|
||||
},
|
||||
"tint": {
|
||||
"$ref": "#/$defs/color",
|
||||
"description": "Colour of the inner cloud layer."
|
||||
},
|
||||
"texturePath": {
|
||||
"type": "string",
|
||||
"description": "Relative filepath to the cloud texture, if the planet has clouds."
|
||||
},
|
||||
"capPath": {
|
||||
"type": "string",
|
||||
"description": "Relative filepath to the cloud cap texture, if the planet has clouds."
|
||||
},
|
||||
"rampPath": {
|
||||
"type": "string",
|
||||
"description": "Relative filepath to the cloud ramp texture, if the planet has clouds. If you don't put anything here it will be auto-generated."
|
||||
},
|
||||
"fluidType": {
|
||||
"type": "string",
|
||||
"default": "CLOUD",
|
||||
"description": "Fluid type for sounds/effects when colliding with this cloud.",
|
||||
"enum": [
|
||||
"NONE",
|
||||
"WATER",
|
||||
"CLOUD",
|
||||
"SAND",
|
||||
"PLASMA"
|
||||
]
|
||||
},
|
||||
"useBasicCloudShader": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Set to `false` in order to use Giant's deep shader. Set to `true` to just apply the cloud texture as is."
|
||||
},
|
||||
"unlit": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "If the top layer shouldn't have shadows. Set to true if you're making a brown dwarf for example."
|
||||
},
|
||||
"hasLightning": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Add lightning to this planet like on Giant's Deep."
|
||||
},
|
||||
"lightningGradient": {
|
||||
"$ref": "#/$defs/gradient",
|
||||
"description": "Colour gradient of the lightning, time is in seconds."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
20
NewHorizons/Utility/MGradient.cs
Normal file
20
NewHorizons/Utility/MGradient.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NewHorizons.Utility
|
||||
{
|
||||
public class MGradient
|
||||
{
|
||||
public MGradient(float time, MColor tint)
|
||||
{
|
||||
Time = time;
|
||||
Tint = tint;
|
||||
}
|
||||
|
||||
public float Time { get; }
|
||||
public MColor Tint { get; }
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user